| [Top] | [Contents] | [Index] | [ ? ] |
It implements two features not discussed in that book:
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
| 1.1 What is a representation? | ||
| 1.2 What is a transformation? | ||
| 1.3 What is a bond graph? | ||
| 1.4 Variables | ||
| 1.5 Bonds | ||
| 1.6 Components | ||
| 1.7 Algebraic loops | ||
| 1.8 Switched systems |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Physical systems have many representations. These include
Each of these representations is related to other representations by an appropriate transformation (see section 1.2 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 1.2 What is a transformation?.
In this context, the following considerations are relevant.
I happen to believe that Bond graphs (see section 1.3 What is a bond graph?) provide the most convenient and powerful basis for the core representation.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Each system representation (see section 1.1 What is a representation? is related to other representations by an appropriate transformation as follows:
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 1.6 Components) connected by bonds (see section 1.5 Bonds) which define the relationship between variables (see section 1.4 Variables).
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Examples of effort variables are
Examples of flow variables are
Examples of integrated flow variables are
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The half-arrow indicates two things:
The causal stroke indicates two things:
The causal half-stoke indicates one thing:
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Components provide the building blocks of a dynamic system when connected by bonds (see section 6.4.1.2 Bonds). Components have the following attributes:
ports
constitutive relationships
| 1.6.1 Ports | ||
| 1.6.2 Constitutive relationship | ||
| 1.6.3 Symbolic parameters | ||
| 1.6.4 Numeric parameters |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Ports are implemented in MTT using named SS components. (see section 6.4.1.9 Named SS components).
The direction of the named SS components. (see section 6.4.1.9 Named SS components) is coerced (see section 6.4.1.10 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.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 1.6.3 Symbolic parameters) which may be replaced, for the purposes of numerical analysis by numeric parameters (see section 1.6.4 Numeric parameters).
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
However, MTT allows replacement of symbolic parameters by numeric parameters (see section 1.6.4 Numeric parameters) when appropriate.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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:
loop SS unknown,zero |
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).
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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
These switches are user controlled through the logic representation (see section 4.4 Simulation logic).
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| 2.1 Menu-driven interface | ||
| 2.2 Command line interface | ||
| 2.3 Options | ||
| 2.4 Utilities |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
xmtt |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
mtt [options] <system_name> <representation> <language> |
[options]
<system_name>
<representation>
<language>
mtt rc rep view |
mtt rc sm m |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 -ss -cc syst cbg view |
-o, -ss, and -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:
alias mtt='mtt -o -ss -cc' |
mtt syst cbg view |
The available options are:
-q
-A
-ae
-D
-I
-abg
-c
-cc
-d
-dc
-dc
-i
-o
-oct
-opt
-p
-partition
-r
-s
-ss
-stdin
-sub
-t
-u
-v
-viewlevel
--version
--versions
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
mtt help
mtt copy <system>
mtt rename <old_name> <new_name>
mtt <system> clean
mtt clean
mtt system representation vc
mtt system vc
| 2.4.1 Help | ||
| 2.4.2 Copy | ||
| 2.4.3 Clean | ||
| 2.4.4 Version control |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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>
|
| 2.4.1.1 help representations | ||
| 2.4.1.2 help components | ||
| 2.4.1.3 help examples | ||
| 2.4.1.4 help crs | ||
| 2.4.1.5 help <name> |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The command
mtt help representations |
The command
mtt help representations <match_string> |
match_string.
This string can be any regular expression (see standard Linux
documentation under awk).
For example
mtt help representations descriptor |
descriptor.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The command
mtt help components |
The command
mtt help components <match_string> |
match_string.
This string can be any regular expression (see standard Linux
documentation under awk).
For example
mtt help components source |
component.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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> |
mtt help examples |
The command
mtt help examples <match_string> |
match_string.
This string can be any regular expression (see standard Linux
documentation under awk).
For example
mtt help examples pharmokinetic |
pharmokinetic.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The command
mtt help crs |
The command
mtt help crs <match_string> |
match_string.
This string can be any regular expression (see standard Linux
documentation under awk).
For example
mtt help crs sin |
sin.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The command
mtt help <name> |
name.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
MTT provides a way of copying examples to your working directory:
mtt copy <example_name> |
Use the command
mtt help examples |
Note that components and constitutive relationships are automatically copied when required.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
mtt system clean
mtt clean
The files which remain after such a clean are the Defining representations (see section 6.2 Defining representations).
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 6.2 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'.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
| 3.1 Quick start | ||
| 3.2 Creating simple models | ||
| 3.3 Creating complex models |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 |
cd rc |
mtt rc abg view |
mtt rc cbg view |
mtt rc ode view |
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 |
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 6.16 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 6.16 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 |
mtt rc rep view |
Now have a go at modifying the bond graph.
mtt rc abg fig |
More examples can be found using
mtt help examples |
mtt help <example_name> |
mtt copy <example_name> |
Lots of examples are available.
mtt help examples |
mtt copy <name> |
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>.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 3.3 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 6.4.1.6 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 view |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Complex models -- in distinction to simple models (see section 3.2 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 1.6.1 Ports); within each component, ports are represented by named SS components (see section 6.4.1.9 Named SS components); outwith each component, ports are unambiguously identified by labels (see section 6.4.1.11 Port labels) and vector labels (see section 6.4.1.12 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 3.2 Creating simple models) is then followed using the top level system (see section 3.3.1 Top level); MTT then recursively operates on the lower level systems.
The report representation (see section 6.16 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 hview |
The result is <A HREF="./examples/twolink/twolink_rep/twolink_rep.html"> here</A>.
| 3.3.1 Top level |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 6. Representations):
cse
ode
Special cases of numerical simulation, appropriate to linear systems, are:
ir
iro
sr
sro
There are a number of languages (see section 9. 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.
cc
g++ a C++ front-end to gcc.
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 4.2 Simulation parameters).
The steady-state solution of a system can also be "simulated"(see section 4.1 Steady-state solutions).
| 4.1 Steady-state solutions | ||
| 4.2 Simulation parameters | ||
| 4.3 Simulation input | ||
| 4.4 Simulation logic | ||
| 4.5 Simulation initial state | ||
| 4.6 Simulation code | ||
| 4.7 Simulation output |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| 4.1.1 Steady-state solutions (odess) | ||
| 4.1.2 Steady-state solutions (ss) |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 4.2 Simulation parameters) is used to provide the time scales.
For example
mtt copy rc cd rc mtt rc odess view |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
mtt system ss view |
For example
mtt copy |