Copyright (C) 1996,1997,1998,1999,2000 Peter J. Gawthrop
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.
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 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.
General information about MTT is available at URL
http://www.mech.gla.ac.uk/~peterg/software/MTThere.
MTT is a set of Model Transformation Tools based on bond graphs. 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:
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 MTT - a set of Model Transformation Tools each of which implements a single transformation between system representations.
System representations have two attributes.
Transformations in 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.
Physical systems have many representations. These include
Each of these representations is related to other representations by an appropriate transformation (see section 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:
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 (see section What is a transformation?.
In this context, the following considerations are relevant.
I happen to believe that Bond graphs (see section What is a bond graph?) provide the most convenient and powerful basis for the core representation.
Each system representation (see section What is a representation? is related to other representations by an appropriate transformation as follows:
Thus modeling is seen as a sequence of transformations between representations.
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:
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 (see section Components) connected by bonds (see section Bonds) which define the relationship between variables (see section Variables).
In bond graph terminology there are four sorts of variables:
Examples of effort variables are
Examples of flow variables are
Examples of integrated flow variables are
Bonds connect components (see section Components) together. Each bond carries two variables:
Each bond has three notations associated with it:
The half-arrow indicates two things:
The causal stroke indicates two things:
The causal half-stoke indicates one thing:
Components provide the building blocks of a dynamic system when connected by bonds (see section Bonds). Components have the following attributes:
ports
constitutive relationships
Components have one or more ports. Each port carries two variables, and effort and a flow variable (see section Variables). Any pair of ports can be connected by a bond (see section 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 MTT using named SS components. (see section Named SS components).
The direction of the named SS components. (see section Named SS components) is coerced (see section 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.
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 (see section Symbolic parameters) which may be replaced, for the purposes of numerical analysis by numeric parameters (see section Numeric parameters).
The constitutive relationship of a system component (see section 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, MTT allows replacement of symbolic parameters by numeric parameters (see section Numeric parameters) when appropriate.
Numerical parameters are needed to give specific values to symbolic parameters (see section Symbolic parameters) for the purposes of numeric analysis; for example: simulation, graph plotting or use within a numerical package such as Octave (see section Octave).
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.
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).
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. MTT implements a simple pragmatic approach to the modelling and simulation of such systems via two new Bond Graph components:
ISW
I component
CSW
C component
There are two user interfaces to MTT: a command line interface (see section Command line interface) and a menu-driven interface (see section Menu-driven interface).
The Menu-driven interface for MTT is invoked as:
xmtt
This will bring up a menu which should be self explanatory :-). Various messages will be echoed in the window from whence xMTT was invoked.
The command line interface for MTT is of the form:
mtt [options] <system_name> <representation> <language>
[options]
<system_name>
<representation>
<language>
for example
mtt rc rep view
creates a view of the report describing system rc and
mtt rc sm m
creates an m file (suitlable for Octave or Matlab) containing state matrices describing the system rc.
MTT has a number of optional switches to control its operation. These are invoked immediately after `mtt' on the command line; for example:
mtt -o -s -c syst cbg view
invokes the -o, -s, and -c options.
The available options are:
-q
-A
-D
-I
-abg
-c
-d <dir>
-dc
-dc
-i <implicit|euler>
-o
-oct
-opt
-p
-partition
-r
-s
-ss
-stdin
-sub <subsystem>
-t
-u
-v
-viewlevel <N>
--version
--versions
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:
mtt help
mtt copy <system>
mtt rename <old_name> <new_name>
mtt <system> clean
mtt clean
mtt system representation vc
mtt system vc
These are described in more detail in the following sections.
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:
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>
The command
mtt help representations
lists all of the representations (see section Representations) available in MTT. These may change as the version number of MTT increases.
The command
mtt help representations <match_string>
lists those representation which contain the string match_string.
This string can be any regular expression (see standard Linux
documentation under awk).
For example
mtt help representations descriptor
gives all representations containing the word descriptor.
The command
mtt help components
lists all of the components (see section Components) available in MTT. These may change as the version number of MTT increases.
The command
mtt help components <match_string>
lists those component which contain the string match_string.
This string can be any regular expression (see standard Linux
documentation under awk).
For example
mtt help components source
gives all components containing the word component.
This command provides a good way to get started in MTT. having found an interesting example, copy it to your working directory using
mtt copy <example_name>
(see section Copy)
mtt help examples
lists all of the examples available in MTT. This list will change as more examples are added.
The command
mtt help examples <match_string>
lists those component which contain the string match_string.
This string can be any regular expression (see standard Linux
documentation under awk).
For example
mtt help examples pharmokinetic
gives all examples containing the word pharmokinetic.
The command
mtt help crs
lists all of the constitutive relationships (see section Constitutive relationship) available in MTT. These may change as the version number of MTT increases.
The command
mtt help crs <match_string>
lists those constitutive relationships which contain the string match_string.
This string can be any regular expression (see standard Linux
documentation under awk).
For example
mtt help crs sin
gives all crs containing the word sin.
The command
mtt help <name>
gives a detailed description of the entity called name.
MTT provides a way of copying examples to your working directory:
mtt copy <example_name>
Use the command
mtt help examples
(see section help examples) to find something of interest.
Note that components and constitutive relationships are automatically copied when required.
MTT generates a lot of representations in a number of languages. Some of these you will edit yourself; others can always be recreated by 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:
mtt system clean
mtt clean
The first removes all files that can be regenerated with 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 (see section Defining representations).
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.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 MTT) are the Defining representations (see section Defining representations).
All of the files, with the exception of system_abg.fig,
are initially created by MTT and contain the RCS header for
version control.
The 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 MTT version commands are as follows:
mtt system representation vc
mtt system vc
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'.
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 MTT aspects of creating a model. For convenience, this is divided into creating simple models and creating complex models.
It is probably worth a quick skim though 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.
mtt copy rc
Move to it.
cd rc
View the acausal bond graph (the system is called "rc").
mtt rc abg view
View the causal bond graph of the system.
mtt rc cbg view
View the corresponding ordinary differential equations (ode).
mtt rc ode view
View the system (output) step response
mtt rc sro view
An alternative (but more general) way of achieving the same result is
mtt -c rc odeso view
View the system transfer function
mtt rc tf view
View the log modulus frequency response of the system.
mtt rc lmfr view
View the log modulus frequency response of the system for 100 logarithmically spaced frequencies in the range 0.1 to 10 radians per second.
mtt rc lmfr view 'W=logspace(-1,1,100);'
MTT has a report generation ((see section Report (rep)) facility which can generate a hypertext description of the system.
mtt rc rep hview
The report contents are specified by the rep representation (see section Report (rep)), in this case the corresponding file is:
% %% 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 -c rc odeso ps mtt rc rep txt
A non-hypertext version can be viewed using:
mtt rc rep view
Now have a go at modifying the bond graph.
mtt rc abg fig
This brings up the bond graph in Xfig (see section Xfig). Try creating a system with two rs and 2 cs.
More examples can be found using
mtt help examples
Details of an example can be found using
mtt help <example_name>
and copied using
mtt copy <example_name>
Lots of examples are available.
mtt help examples
lists them and
mtt copy <name>
gets you an example. A number of examples are to be found here.
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 (see section Creating complex models) need to be built up hierarchically.
The recommended sequence of steps to create a simple model is:
mtt syst abg fig
SS components.
(see section SS components).
Save the bond graph.
mtt syst cbg view
mtt syst dae view
mtt syst sm view
mtt syst tf view
mtt syst sro view
mtt syst odeso viewMTT 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.
Complex models -- in distinction to simple models (see section 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 (see section Ports); within each component, ports are represented by named SS components (see section Named SS components); outwith each component, ports are unambiguously identified by labels (see section Port labels) and vector labels (see section 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 (see section Creating simple models) is then followed using the top level system (see section Top level); MTT then recursively operates on the lower level systems.
The report representation (see section Report (rep)) provides a convenient way of viewing a complex system.
An example of such a system can be created as follows:
mtt copy twolink mtt twolink rep hviewThe result is here.
The top level of a complex model contains subsystems but is not, itself, contained by other systems. It has the following special features:
One purpose of modelling is to simulate the modeled dynamic system. Although this is just another transformation (see section What is a transformation?) and therefore is covered in the appropriate chapter (see section 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). MTT provides a number of alternative routes to simulation based on the following representations (see section Representations):
cse
ode
in each case these equations may be linear or nonlinear.
Special cases of numerical simulation, appropriate to linear systems, are:
ir
iro
sr
sro
There are a number of languages (see section Languages) which can be used to describe these representations for the purposes of numerical simulation:
m
octave a high-level interactive language for numerical
computation.
c
gcc a c compiler.
There are a number solution algorithms available:
However, all combinations of representation, language and solution method are not supported by MTT at the moment. Given a system `system', some recommended commands are:
mtt system iro view
mtt system sro view
mtt -c system odeso view
mtt -c -i euler system odeso view
Simulation parameters are described in the system_simpar.txt file (see section Simulation parameters).
The steady-state solution of a system can also be "simulated"(see section Steady-state solutions (odess)).
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 (see section Simulation parameters) is used to provide the time scales.
Simulation parameters are set in the system_simpar.txt file. At the moment this sets the following variables:
Euler integration approximates the solution of the Ordinary Differential Equation
dx/dt = f(x,u)
by
x := x + f(x,u)*DDT
where
DDT = DT/STEPFACTOR
If the system is linear, stability is ensured if the integer STEPFACTOR is chosen to be greater than the real number
(maximum eigenvalue of -A)*DT/2
where A is the nxn matrix appearing in
f(x,u) = Ax + Bu
If the system is non linear, the linearised system matrix A should act as a guide to the choice of STEPFACTOR.
Implicit integration approximates the solution of the Ordinary Differential Equation
dx/dt = f(x,u)
by
(I-A*DT)x := (I-A*DT)x + f(x,u)DT
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:
E(x) dx/dt = f(x,u)
where E(x) is a state-dependent matrix. The approximate solution is then given by:
(E(x)-A*DT)x := (E(x)-A*DT)x + f(x,u)DT
which reduces to the ordinary differential equation case when E(x)=I.
The _smx representation includes the E matrix.
The initial state of a simulation of is set in the state
representation with the language txt.
As usual, MTT defaults this for you. There are two possibilities
The view (see section 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
odes
odeso
Particular output variables can be selected by adding a fourth argument in one of 2 forms
'name1;name2;..;namen'
'name1:name2'
An example of plotting a single variable against time is:
mtt -o -c -ss OttoCycle odeso ps 'OttoCycle_cycle_V'
An example of plotting one variable against another is:
mtt -o -c -ss OttoCycle odeso ps 'OttoCycle_cycle_V:OttoCycle_cycle_P'
The sensitivity model of a system is a set of equations giving the sensitivity of the system outputs with respect to system parameters. 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.
mtt copy rc cd rc mtt -s src ode view mtt -s src odeso view
The sensitivity system src is automatically created from the system rc using the predefined sR and sC components together with vector junctions (see section 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:
scse
sm
scsm
As discussed in section What is a representation?, a system has many representations. The purpose of MTT is to provide an easy way to generate such representation by applying the appropriate sequence of transformations. The representations supported by MTT are summarised in section 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 defining representations are listed in section Defining representations.
Each representation is implemented in one or more languages depending on its use. These languages are discussed in section Languages and are associated with appropriate tools for modifying or viewing the representations.
Some of the the representations available in MTT are (in alphabetical order):
abg
cbg
cr
cse
csm
dae
daes
daeso
def
desc
dm
ese
fr
input
ir
iro
lbl
lmfr
lpfr
nifr
numpar
nyfr
obs
ode
odes
odes
odeso
odess
odesso
rbg
rep
rfe
sabg
simp
sm
smx
sms
smss
sr
sro
ss
sspar
struc
sub
sub
sympar
tf
A complete list can be found via the help representations command
(see section help representations).
Many of these representations have more than one language (see section Representations) associated with them.
Some of these representations define the system (see section 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 MTT and may then be subsequently edited (see section Text editors) viewed or operated on by the appropriate tools (see section Language tools).
system_abg.fig
system_lbl.txt
system_desc.tex
system_simp.r
system_subs.r
system_simpar.txt
system_numpar.txt
system_input.txt
system_sspar.r
Systems can be documented in LaTeX using the _desc.tex file. This file is included in the report (see section Report (rep)) if the abg tex option is included in the rep.txt file. As usual, MTT provides a default text file to be edited by the user (see section Text editors).
The acausal bond graph is the main input to 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:
mtt sys abg fig
To create the acausal bond graph of system `sys' in language m type:
mtt sys abg m
To view the acausal bond graph of system `sys' type:
mtt sys abg view
A bond graph is made up of:
bonds
strokes
components
artwork
An icon library of bonds, components and other symbols is available within xfig (see section Icon library).
A number of predefined iconic symbols are available within xfig.
Click onto the library icon Click onto the library pull-down menu and select BondGraph Select iconic symbols from the presented list
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:
Causal strokes are represented by single-segment polylines. There are two sorts of strokes:
MTT is reasonably forgiving; but a neat diagram will be less ambiguous to you as well as to MTT.
Causality is indicated as follows:
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:
type
R
type:label
R:r
type*n
MySystem*25
type:label*n
MySystem:MyLabel*25
The following simple components are defined in MTT.
R
C
I
SS
TF
GY
AE
AF
CSW
ISW
$$
SS components provide input and output variables for a system;
Named SS components (see section Named SS components) provide this for
subsystems.
Each simple component, with name NAME, is defined by two m files:
NAME_cause.m
NAME_eqn.m
Only the experienced user would normally define simple components - Compound components (see section Compound components) are recommended for DIY components.
Compound components are systems described by bond graphs and implemented by MTT. They have special SS components, Named SS components (see section Named SS components), to indicate connections to the encapsulating system.
Like any other system, they are described by a graphical Bond Graph description (see section Language fig (abg.fig)), and a label file (see section Labels (lbl)).
By convention, all of the files describing a component live in a directory with the same name as the component.
Named SS components provide the link from the system which defines
compound component to the system which uses a compound
component see section Compound components.
A named SS components is of the form
SS:[name];
Where `name' is a name consisting of alphanumeric characters and underscore; for example:
SS:[Mechanical_1]
Each such named SS provides one of the ports (see section Ports). The direction of the named SS components. (see section Named SS components) is coerced (see section 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 (see section Top level) and is treated as an ordinary SS component with the given direction and with the attributes specified in the label file (see section Labels (lbl)).
Named SS components (see section Named SS components) provide the mechanism for declaring the ports (see section Ports) of a component. The corresponding bond has a direction. However, under some circumstances, it may be useful to reverse this direction. MTT provides a coercion mechanism for this: the the direction of the bond attached to the named SS component (see section Named SS components) is replaced by the direction of the bond attached to the component port.
Most multi-port components have ports
see section Ports)which display different
behaviors; the exception to this is the junction (0 and 1)
components. For this reason, 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
[name], where `name' is a name consisting of alphanumeric
characters and underscore; for example:
[Mechanical_1]
This provides a label for corresponding to the component to which the nearest bond-end is attached.
The following rules must be be obeyed:
Port labels may be grouped into vector port labels (see section Vector port labels). Components with compatible (ie containing the same number of ports) vector ports may be connected by a single bond (see section 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 explicit causal strokes (see section Strokes)
Port labels (see section Port labels) may be grouped into vector port
labels of the form [name1,name2,name3].
[Mechanical_1,Electrical,Hydraulic_5]
Whether impicitly or explicity, all ports of components (with the exception of 0 and 1 junctions) must have lables (see section Port labels). However, these can be omitted from the bond graph in the following circumstances and default labels are supplied by MTT.
These defaults may, in turn be aliases (see section Aliases) for port labels (see section Port labels) or vector port labels (see section Vector port labels). Combining the default and alias mechanism is a powerful tool for creating uncluttered, yet complex, bond graph models.
Vectors of components can be created in four cases:
0 junctions,
1 junctions,
SS components and
SS port components.
In each case, the presence of a vector component is indicated by a single port label (see section Port labels) containing numerals from 1 to the order of the vector. Thus a vector of 3 component is indicated by a port label of the form [1,2,3].
Within the corresponding label file (see section 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 (see section Port aliases)
%ALIAS in Electrical_1,Electrical_2,Electrical_3
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 (see section 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.
For compatibility with earlier versions of MTT, the following objects are ignored even at level 0. However, their use is strongly discouraged.
", ', ! etc.
The stripped abg file (sabg) (see section Stripped acausal bond graph (sabg)) shows only those parts of the diagram recognised by MTT and is therefore useful for distinguishing artwork.
A valid name is a text string containing alphanumeric characters. It must NOT contain underscore `_', hyphen `-', `:' or `*'.
The raw bond graph of system `sys' is represented as an m file with heading:
function [rbonds, rstrokes,rcomponents,rports,n_ports] = sys_rbg
This representation is a half-way house between the fig (see section Language fig (abg.fig)) and m (see section Language m (abg.m)) representations. It contains the geometric information from the fig file in a form digestible by Octave (see section Octave).
The five outputs of this function are:
rbonds is a matrix with
rstrokes is a matrix with (see section Strokes)
rcomponents is a matrix with (see section Components)
rports is a matrix with (see section Port labels)
n_ports is the number of ports associated with the system -- i.e. the number of Named SS components (see section Named SS components).
This transformation takes the acausal bond graph as a fig file (see section Language fig (abg.fig)) and transforms it into a raw bond graph in m-file format (see section Language m (rbg.m)).
This transformation is implemented in GNU awk (gawk). It scans both the fig file (see section Language fig (abg.fig)) and the label file (see section Labels (lbl)) and generates the rbg (see section 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.
The acausal bond graph of system `sys' is represented as an m file with heading:
function [bonds,components,n_ports] = sys_abg
The three outputs of this function are:
bonds is a matrix with
components is a matrix with
n_ports is the number of ports associated with the system -- i.e. the number of Named SS components (see section Named SS components).
The arrow-orientated causality convention assigns -1, 0 or 1 to both the effort and flow (see section Variables) sides of a bond to represent the causal stroke (see section Strokes) as follows:
0
1
-1
see section Component-orientated causality.
The component-orientated causality convention assigns -1, 0 or 1 to both the effort and flow (see section Variables) sides of a bond to represent the causal stroke (see section Strokes) as follows:
0
1
-1
see section Arrow-orientated causality.
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.
For the purpose of producing a report (see section Report (rep)), MTT generates a LaTeX (see section LaTeX) file describing the bond graph and its subsystems. Additional information may be supplied using the description representation (see section Description (desc)).
The stripped acausal bond graph is the acausal bond graph representation (see section Acausal bond graph (abg)) without the artwork (see section Artwork). It is useful to check for mistakes by showing precisely what is recognised by MTT.
The stripped acausal bond graph can be generated as a fig (see section Fig) file using
mtt syst sabg fig
This representation has the standard text view (see section Views).
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)
Each lable contains three fields (in the following order) separated by white space and on one line:
Not each component see section Components needs a label, only those which are explicitly labeled on the Bond Graph see section Acausal bond graph (abg). MTT checks whether all components labelled on the bond graph have labels and vice versa.
If no lbl file exists, MTT will create a valid one for you. If wish to create one to edit yourself, type
mtt system_name lbl txt
An example lbl file (for the RC system is):
%% 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
The old-style lbl files (see section Old-style labels (lbl)) are NO LONGER supported -- you are encouraged to convert them ASAP.
In addition to the label there are two information fields, see section 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
info_field_1
info_field_2
Each of these two fields contains one of the following attributes:
internal
a number
a symbol
unknown
zero
Some examples are:
%% 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
In addition to the label there are two information fields, see section Labels (lbl). They correspond to the constitutive relationship (see see section Constitutive relationship and arguments of the component as follows
info_field_1
info_field_2
Some examples are:
%Armature resistance r_a lin effort,r_a %Gearbox ratio n lin effort,n
MTT supports parameter-passing to (see section Parameter passing) subsystems.
The component name field must contain a valid name (see section Valid Names corresponding to the name (the bit after the :) of each named component (see section Components) on the bond graph (see section Acausal bond graph (abg)).
The constitutive relationship field contains the name of a constitutive relationship for the component. There are three sorts of constitutive relationship recognised by MTT:
It is sometimes useful to use variables (in addition to those implied by the Component arguments see section Component arguments) to compute values in, for example the numpar file. These can be declared in the label file; for examples , the two variables var1 and var 2 can be declared as:
#VAR var1 #VAR var2
Aliases provide a convenient mechanism for relabelling words appearing in the label file (see section Labels (lbl)). There are three contexts in which the alias mechanism is used:
All three mechanisms use the same form of statement within the label file
%ALIAS short_label real_label
MTT distinguishes between the three forms as follows:
Aliases provide a way of refering to (see section Port labels) or vector port labels (see section Vector port labels) on the bond graph using a short-hand notation. With in a component label file (see section Labels (lbl)) statements of the following forms can occur
%ALIAS short_label real_label
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
%ALIAS short_label_1 real_label %ALIAS short_label_2 real_label %ALIAS short_label_3 real_label
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
%ALIAS short_label_1|short_label_2|short_label_3 real_label
The alias feature is particularly powerful in conjunction with vector port labels (see section Vector port labels) and the port label default (see section Port label defaults) mechanisms. For example, a component with 5 ports appearing in the lbl file as:
[Hydraulic_in] external external
[Hydraulic_out] external external
[Power_Shaft] external external
[Thermal_in] external external
[Thermal_out] external external
together with the following statements in the label file:
%ALIAS in Thermal_in,Hyydraulic_in %ALIAS out Thermal_out,Hydraulic_out %ALIAS shaft|power Power_Shaft
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.
Parameter aliases are of the form
%ALIAS $n actual parameter
where n is an integer (unique within the label file). For example
%ALIAS $1 c_v %ALIAS $2 density,ideal_gas,r %ALIAS $3 alpha %ALIAS $4 flow,k_p
Assigns four symbolic parameters to the corresponding strings These four
parameters ($1--$4) can then be used for parameter
passing(see section Parameter passing).
Component aliases are of the form
%ALIAS Component_name Component_location
An example appears in the following label file fragment
... %ALIAS wPipe CompressibleFlow/wPipe %ALIAS Poly CompressibleFlow/Poly ....
The two components `wPipe' and `Poly' are both to be found within the library `Compressible flow' and the respective subdirectories. This follows the MTT convention that compound components (see section Compound components) live within a directory of the same name.
MTT supports parameter-passing to subsystems within label files
(see section Labels (lbl)). Within a subsystem, explicit constitutive
relationships and parameters (or groups thereof) can be replaced by
postitional parameters such as $1, $2 etc. Although this
can be done directly, it is recommended that this is done via the alias
mechanism (see section Parameter aliases).
In a subsystem
$i, is replaced by the ith field of a colon ; separated
field in the calling label file. This field may include commas ,
and the four arithmetic operators +, -, * and
/.
For example, consider the following example label file fragment (associated with a component called Pump:
...
%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
The 4 parameters $1, $2, $3, and $4 can be
passed from a higher level component as in the following label file
fragment:
% 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
Thus in component `comp':
$1 is replaced by c_v
$2 is replaced by rho,ideal_gas
$3 is replaced by alpha
$4 is replaced by effort,k_c
whereas in component `turb' the first three parameters are the same but
$4 is replaced by effort,k_t
Old syle labels (mtt version 2.x) are supported by mtt version 3.x. However, you are advised to use the new form (see section Labels (lbl)).
Each line of the _label.txt file is of one of three forms:
label field_1 field_2
Only the first is noticed by 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:
Named SS component, see section Named SS components never have labels.
In addition to the label there are two information fields, see section Labels (lbl). They correspond to the effort and flow of the components as follows
info_field_1
info_field_2
Each of these two fields contains one of the following attributes:
internal
a number
a symbol
unknown
zero
Some examples are:
%Label field1 field2 ss1 external external ss2 0 external
In addition to the label there are two information fields, see section Labels (lbl). They correspond to the constitutive relationship (see see section Constitutive relationship and arguments of the component as follows
info_field_1
info_field_2
Some examples are:
%Armature resistance r_a lin effort,r_a %Gearbox ratio n lin effort,n
MTT supports parameter-passing to (see section Parameter passing (old-style)) subsystems.
MTT supports parameter-passing to (see section Parameter passing (old-style))
subsystems within label files (see section Labels (lbl)). Within a subsystem,
explicit constitutive relationships and parameters (or groups thereof)
can be replaced by
$1, $2, etc.
In a subsystem
$i, is replaced by the ith field of a colon ; separated
field in the calling label file. This field may include commas ,.
For example subsystem ROD contains the following lines in the label file:
%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
This can be used in a higher-level lbl (see section Labels (lbl)) file as:
%SUMMARY Pendulum example from Section 10.3 of "Metamodelling" %Rod parameters rod none l;l;j;m
The bond graph 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 (see section Language tex (abg.tex)) of the acausal bond graph representation (see section Acausal bond graph (abg)).
This file may contain any LaTeX compatible commands. Any mathematics should conform to the AMSmath package.
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.
This text tile contains a description of the system structure (see section Structure (struc) with 5 tab-separated columns containing the following information:
type
system name
repetition
An example of such a file (corresponding to rc) (see section Quick start) is:
input 1 e1 rc 1 output 1 e2 rc 1 state 1 c rc 1
This LaTeX (see section LaTeX) file contains a description of the system structure
(see section Structure (struc) in longtable format. It is a useful
item to include in a report(see section Report (rep)).
This representation has the standard text view (see section Views).
The constitutive relationship (see section Constitutive relationship) of a simple component (see section Simple components is defined in the symbolic algebra language Reduce (see section Reduce). The constitutive relationship of a compound components (see section Compound components) is implied by the constitutive relationships of its constituent components.
Some common cr's are predefined by MTT; these are:
lin
exotherm
The constitutive relationship lin is predefined for the following
components.
R
TF
GY
MTF
MGY
FMR
Lin takes two arguments in the form causality,gain
causality
gain
For example the arguments
flow,r
given to an R component corresponds to
e = rf
if if the input causality is flow or
f = e/r
if if the input causality is effort.
You can write your own constitutive relationships using Reduce (see section Reduce). This requires some understanding as to how MTT represent the elementary system equations (see section Elementary system equations (ese)). Looking at the predefined constitutive relationships is a good way to get started (see section File structure).
In general, lbl (see section Labels (lbl)) files contain symbolic parameters. MTT provides three ways of substituting for these parameters:
This file contains reduce statements to symbolically change the expressions describing the system. For example, a useful set of trig substitutions is:
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));
This file contains reduce statements to symbolically change the expressions describing the system. Unlike the subs.r file (see section Symbolic parameters (subs.r)) it does not affect all system transformations; only those converting to LaTeX form.
When computing time and frequency responses; or when evaluating functions in Octave (see section Octave); symbolic parameters need numerical instantiations.
The numpar representation provides the relevant numerical information. It comes in a number of languages:
txt
m
octave a high-level interactive language for numerical
computation -- translated by mtt from the txt version.
c
gcc a c compiler -- translated by mtt from the txt version.
This is the textual form of the numerical parameters representation (see section Numeric parameters (numpar)). Lines are either
assignment statements
comments
commented assignment statements
An example file is:
# Numerical parameter file (rc_numpar.txt) # Generated by MTT at Mon Jun 16 15:10:17 BST 1997 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # %% Version control history # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # %% $Id: mtt.texi,v 1.61 2000/09/14 17:13:06 peterg Exp $ # %% $Log: mtt.texi,v $ # %% 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)
As usual, MTT provides a default text file to be edited by the user (see section Text editors).
The causal bond graph is the causally complete version of the Acausal bond graph (see section Acausal bond graph (abg)).
To create the causal bond graph of system `sys' in language fig type:
mtt sys cbg fig
To create the causal bond graph of system `sys' in language m type:
mtt sys cbg m
To view the causal bond graph of system `sys' type:
mtt sys cbg view
The fig file is created by MTT. It is identical to the corresponding acausal representation (see section Language fig (abg.fig)) except that
The causal bond graph of system `sys' is represented as an m file with heading:
function [cbonds,status] = sys_cbg
The two outputs of this function are:
cbonds is a matrix with
status is a matrix with
A successful model would therefore have all zeros in the status matrix.
This transformation takes the acausal bond graph as an m file (see section Language m (abg.m)) and transforms it into a causal bond graph in m-file format (see section 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.
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 (see section Reduce) language.
Because these are based on a causally complete system, these assignment statements are directly soluble by substitution.
Unlike early versions of MTT, MTT does 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.
cr(arguments,out_causality,outport,
input_1, causality_1, port_1,
....
input_i, causality_i, port_i,
....
input_n, causality_n, port_n
);
where the symbols have the following meaning
arguments
out_causality
outport
input_i
causality_i
port_i
An example for a resistor with linear constitutive relationship is:
rc_1_bond4_flow := lin(flow,r,flow,1,
rc_1_bond4_effort,effort,1
);
This transformation takes the causal bond graph as an m file (see section Language m (cbg.m)) and transforms it into elementary system equations in Reduce (see section 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 `sys_def.r'.
The system differential algebraic equations describe the system dynamics together together with any algebraic constraints.
They are generated in language lang for system
sys by:
mtt sys dae lang
Valid languages are:
r
m
view
There are five sets of variables describing the system:
x
z
u
ui
y
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:
The system DAEs (see section Differential-Algebraic Equations (dae)) are represented in the reduce (see section Reduce) language as arrays containing the algebraic expressions for the right hand sides of each set of equations. The arrays are:
MTTx
MTTz
MTTu
mttv
MTTy
This transformation (see section What is a transformation?) uses Reduce (see section Reduce) to combine the elementary system equations (see section Elementary system equations (ese)) with the constitutive relationships (see section Constitutive relationship) and simplify the result.
The system DAEs (see section Differential-Algebraic Equations (dae)) are represented in the m (see section m) language as two m-functions of the form:
function resid = sys_dae(dx,x,t) function y = sys_dae(dx,x,t)
Where x is the dae 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.
This transformation (see section What is a transformation?) uses Reduce (see section Reduce) to rewrite the elementary system equations (see section Elementary system equations (ese)) in m-file format (see section m) . Numerical parameters are declared as global.
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:
E(x) dx/dt = f(x,u) y = g(x,u)
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 lang for system
sys by:
mtt sys cse lang
Valid languages are:
r
m
view
There are three sets of variables describing the system:
x
u
y
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:
The system CSEs (see section Constrained-state Equations (cse)) are represented in the reduce (see section Reduce) language as arrays containing the algebraic expressions for the right hand sides of each set of equations. The arrays are:
MTTx
MTTu
MTTy
together with the array containing the elements of the E matrix.
This transformation (see section What is a transformation?) Reduce (see section Reduce) to find various Jacobians which are combined to find the E matrix and the constrained-state equations (see section Constrained-state Equations (cse)).
This representation has the standard text view (see section Views).
The system ordinary differential equations describe the system dynamics.
They are generated in language lang for system
sys by:
mtt sys ode lang
Valid languages are:
r
m
view
There are three sets of variables describing the system:
x
u
y
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:
The system ODEs (see section Ordinary Differential Equations) are represented in the reduce (see section Reduce) language as arrays containing the algebraic expressions for the right hand sides of each set of equations. The arrays are:
MTTx
MTTu
MTTy
This transformation (see section What is a transformation?) uses Reduce (see section Reduce) to invert the E matrix of the constrained-state equations (see section Constrained-state Equations (cse)) and simplify the result.
The system ODEs (see section Ordinary Differential Equations) are represented in the m (see section m) language as two m-functions of the form:
function dx = sys_ODE(x,t) function y = sys_ODE(dx,x,t)
Where x is the ODE 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.
This transformation (see section What is a transformation?) uses Reduce (see section Reduce) to rewrite the ordinary differential equations (see section Ordinary Differential Equations) in m-file format (see section m) . Numerical parameters are declared as global.
This representation has the standard text view (see section Views).
The system descriptor matrices A, B, C, D and E describe the linearised system dynamics in the form
E dx/dt = Ax + Bu y = Cx + Du
They are generated in language lang for system
sys by:
mtt sys dm lang
Valid languages are:
r
m
view
The system descriptor matrices (see section Descriptor matrices (dm)) are represented in the reduce (see section Reduce) language as arrays containing the four matrices. The arrays are:
MTTA
MTTB
MTTA
MTTD
MTTE
The system descriptor matrices (see section Descriptor matrices (dm)) are represented in the m (see section m) language as an m-function of the form:
function [A,B,C,D,E] = sys_dm
System numeric parameters (see section Numeric parameters) are passed via global variables defined in the _numpar.m file. Thus the system descriptor matrices are typically generated in Octave (see section Octave) as follows:
sys_numpar [A,B,C,D,E] = sys_dm
Parameters can be changed from their default values by entering
their values directly into Octave (see section Octave) and then invoking
sys_dm; for example
sys_numpar par_1 = 25 par_2 = par_1 + 3 [A,B,C,D,E] = sys_dm
MTT has a report-generator feature. The user specifies the report contents in a text file (see section Language text (rep.txt)) using an appropriate text editor (see section Text editors).
For example, the report can be viewed by typing
mtt system rep view
The user specifies the report contents in a text file (see section Language text (rep.txt)) using an appropriate text editor (see section Text editors). The text file contains lines which are either comments (indicated by %) or valid MTT commands. The report will then contain appropriate sections. The following languages are supported by the report generator:
m
octave a high-level interactive language for numerical
computation.
r
reduce a high-level interactive language for symbolic
computation.
tex
latex a text processor.
ps
ghostview another document viewer.
c
gcc a c compiler.
For 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
The acausal bond graph (abg) (see section Acausal bond graph (abg)) with the tex language is handled in a special way: the acausal Bond Graph in fig format (see section Language fig (abg.fig)), the label file (see section Labels (lbl)) the description file (see section Description (desc)), together with corresponding subsystems are included in the report. It is recommended that the first (non-comment line) in the file should be:
mtt <system> abg tex
where <system> is the name of the (top-level) system.
As usual, MTT provides a default text file to be edited by the user (see section 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.
This representation has the standard text view (see section Views).
MTT has a number of built-in mechanisms for the user to extend its capabilities. As MTT is based on `Make' it is unsurprising that these involve the creation of `make files'.
If a file called `Makefile' exists in the current directory, 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 MTT unaware. Such a function can be created using the makefile. An example `Makefile' is
# 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
All of the files in the line stating `all:' are created when MTT is executed (if they don't already exist).
It may be convenient to create new representations for MTT; in particular, it is nice to be able to include the result of some numerical or symbolic computations within an MTT report (see section Report (rep)).
To create a new representation `myrep' in a language `mylang', create a file with the name
myrep_rep.make
This file must contain text in `make' syntax. It is executed by MTT and the two arguments `SYS' (the system name) and `LANG' (the language) are passed to it by MTT. Note that MTT cannot know of any prerequisites, but these can be explicitly included in the makefile (which may include execution of MTT itself.
The following example declares the new representation `nppp' which is created with the Octave script sys_nppp.m where `sys' is the system name. This needs a number of files (for exaample `sys_ode2odes.out') which are themselves created by MTT.
# -*-makefile-*-
# Makefile for representation nppp
# File nppp_rep.make
#Copyright (C) 2000 by Peter J. Gawthrop
all: $(SYS)_nppp.$(LANG)
$(SYS)_nppp.view: $(SYS)_nppp.ps
echo Viewing $(SYS)_nppp.ps; ghostview $(SYS)_nppp.ps&
$(SYS)_nppp.ps: $(SYS)_ode2odes.out s$(SYS)_ode2odes.out \
$(SYS)_sim.m s$(SYS)_sim.m \
$(SYS)_state.m $(SYS)_sympar.m $(SYS)_numpar.m \
s$(SYS)_state.m s$(SYS)_sympar.m s$(SYS)_numpar.m \
$(SYS)_sm.m $(SYS)_def.m s$(SYS)_def.m
octave $(SYS)_nppp.m
$(SYS)_ode2odes.out:
mtt -q -c -stdin $(SYS) ode2odes out
s$(SYS)_ode2odes.out:
mtt -q -c -stdin -s s$(SYS) ode2odes out
$(SYS)_sim.m:
mtt -q -c $(SYS) sim m
s$(SYS)_sim.m:
mtt -q -c -s s$(SYS) sim m
$(SYS)_state.m:
mtt -q $(SYS) state m
$(SYS)_sympar.m :
mtt -q $(SYS) sympar m
$(SYS)_numpar.m:
mtt -q $(SYS) numpar m
s$(SYS)_state.m:
mtt -q -s s$(SYS) state m
s$(SYS)_sympar.m :
mtt -q -s s$(SYS) sympar m
s$(SYS)_numpar.m:
mtt -q -s s$(SYS) numpar m
$(SYS)_sm.m:
mtt -q $(SYS) sm m
$(SYS)_def.m:
mtt -q $(SYS) def m
s$(SYS)_def.m:
mtt -q -s s$(SYS) def m
Future extensions of MTT will use such representations stored in $MTT_REP.
These are a number of languages used by MTT to implement the various representations. Each has associated Language tools (see section Language tools) to manipulate and/or view the representation.
fig
Fig a graphical description language.
m
octave a high-level interactive language for numerical
computation.
r
reduce a high-level interactive language for symbolic
computation.
tex
latex a text processor.
dvi
xdvi a document viewer.
ps
ghostview another document viewer.
gdat
gnuplot a data viewer.
c
gcc a c compiler.
These tools are automatically invoked as appropriate by MTT; but for more advanced use, these tools can be used directly on files (with the appropriate suffix) generated by MTT.
Please see xfig documentation.
Please see Octave documentation Octave documentation. Matlab documentation.
Please see the reduce documentation.
Please see the gcc documentation.
A number of representations (see section Representations) have a language representation which is particularly useful for viewing by the user. These views are invoked, where appropriate by the command:
mtt sys rep view
where sys is the system name and rep a corresponding representation.
All representations live in text files and thus may be edited using your favourite text editor; however, the Fig (see section Fig) representation is pretty meaningless in this form and so you should use Xfig (see section 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 MTT out of an emacs shell window and keep the rest of the files in emacs buffers.
Octave is a numerical matrix-based language See section `Octave' in Octave. It is similar to Matlab in many ways. In most cases, m-files generated by MTT can be understood by both Matlab and Octave (and no doubt other Matlab lookalikes).
MTT provides the octave function mtt. The octave
command
help mtt
gives the following information:
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
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.
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>
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:
step(rc); bode(rc);
MTT provides an interface to the Octave control system toolbox
(OCST) using the mfile mtt2sys. the octave command
help mtt2sys
gives the following information.
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
Thus for example, if octave is in the directory containing the system rc:
rc = mtt2sys("rc");
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:
step(rc); bode(rc);
LaTeX is a powerful text processor which MTT uses to provide visual output.
MTT is built from a set of readily-available software tools. These are:
The General purpose tools are (these will all be available with a standard Linux distribution):
sh
gmake
gawk
sed
grep
comm
xfig
fig2dev
ghostview
xdvi
dvips
latex
latex2html
perl
gnuplot
gnuscape
gcc
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:
REDUCE documentation. ZIB documentation.ZIB ( http://www.zib.de )
Octave is available at various web sites including:
The `.octaverc' file should contain the following lines:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Startup file for Octave for use with MTT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% implicit_str_to_num_ok = 1; empty_list_elements_ok = 1;
There are a number of paths that must be set correctely for MTT
to work. These are normally set up by sourcing the file mttrc that
lives in the MTT home directory.
The environment variable $MTTPATH points to the mtt home directory.
This is usually /usr/local/lib/mtt.
The environment variable $MTT_COMPONENTS is a colon-separated path pointing to directories containing components and subsystems. By default
MTT_COMPONENTS=$MTTPATH/lib/comp
but you may wish to add your own component libraries:
MTT_COMPONENTS=my_library_path:$MTT_COMPONENTS
The environment variable $MTT_CRS is a colon-separated path pointing to directories containing constitutive relationships. By default
MTT_CRS=$MTTPATH/lib/cr
but you may wish to add your own component libraries:
MTT_CRS=my_cr_path:$MTT_CRS
The environment variable $MTT_EXAMPLES is a colon-separated path pointing to directories containing EXAMPLES and subsystems. By default
MTT_EXAMPLES=$MTTPATH/lib/examples
but you may wish to add your own component libraries:
MTT_EXAMPLES=my_examples_path:$MTT_EXAMPLES
The $OCTAVE_PATH path must include the relevant paths for mtt to
work properly. In particular, it must include:
$MTTPATH/trans/m $MTTPATH/lib/comp/simple $MTTPATH/lib/comp/compound
The recommended installation of MTT uses the following
directory structure with corresponding contents. Normally, each of the
listed directories is a subdirectory of `/usr/local'. The directory
mtt is pointed to by $MTTPATH (see section $MTTPATH).
m-files associated with the transformations.
awk scripts associated with the transformations.
m-files defining the simple components.
m-files defining the compound components.
Jump to: ' - a - b - c - d - e - f - g - i - l - m - n - o - p - r - s - t
Jump to: < - a - b - c - d - e - f - h - i - l - m - n - o - p - q - r - s - t - u - v - x
This document was generated on 15 September 2000 using texi2html 1.56k.