[Top] [Contents] [Index] [ ? ]

MTT: Model Transformation Tools

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:

1. Introduction  
2. User interface  
3. Creating Models  
4. Simulation  
5. Sensitivity models  
6. Representations  
7. Extending MTT  
8. Documentation  
9. Languages  
10. Language tools  
11. Administration  
Glossary  
Index  
-- The Detailed Node Listing ---
Introduction
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  
Components
1.6.1 Ports  
1.6.2 Constitutive relationship  
1.6.3 Symbolic parameters  
1.6.4 Numeric parameters  
User interface
2.1 Menu-driven interface  
2.2 Command line interface  
2.3 Options  
2.4 Utilities  
Utilities
2.4.1 Help  
2.4.2 Copy  
2.4.3 Clean  
2.4.4 Version control  
Help
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>  
Creating Models
3.1 Quick start  
3.2 Creating simple models  
3.3 Creating complex models  
Creating complex models
3.3.1 Top level  
Simulation
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  
Steady-state solutions
4.1.1 Steady-state solutions (odess)  
4.1.2 Steady-state solutions (ss)  
Simulation parameters
4.2.1 Euler integration  
4.2.2 Implicit integration  
4.2.3 Runge Kutta IV integration  
4.2.4 Hybrd algebraic solver  
Simulation code
4.6.1 Dynamically linked functions  
Simulation output
4.7.1 Viewing results with gnuplot  
4.7.2 Exporting results to SciGraphica  
Representations
6.1 Representation summary  
6.2 Defining representations  
6.3 Verbal description (desc)  
6.4 Acausal bond graph (abg)  
6.5 Stripped acausal bond graph (sabg)  
6.6 Labels (lbl)  
6.7 Structure (struc)  
6.8 Constitutive relationship (cr)  
6.9 Parameters  
6.10 Causal bond graph (cbg)  
6.11 Elementary system equations (ese)  
6.12 Differential-Algebraic Equations (dae)  
6.13 Constrained-state Equations (cse)  
6.14 Ordinary Differential Equations  
6.15 Descriptor matrices (dm)  
6.16 Report (rep)  
Acausal bond graph (abg)
6.4.1 Language fig (abg.fig)  
6.4.2 Language m (rbg.m)  
6.4.3 Language m (abg.m)  
6.4.4 Language tex (abg.tex)  
Language fig (abg.fig)
6.4.1.1 Icon library  
6.4.1.2 Bonds  
6.4.1.3 Strokes  
6.4.1.4 Components  
6.4.1.5 Simple components  
6.4.1.6 SS components  
6.4.1.7 Simple components - implementation  
6.4.1.8 Compound components  
6.4.1.9 Named SS components  
6.4.1.10 Coerced bond direction  
6.4.1.11 Port labels  
6.4.1.12 Vector port labels  
6.4.1.13 Port label defaults  
6.4.1.14 Vector Components  
6.4.1.15 Artwork  
6.4.1.16 Valid Names  
Simple components
6.4.1.6 SS components  
6.4.1.7 Simple components - implementation  
Compound components
6.4.1.9 Named SS components  
Language m (rbg.m)
6.4.2.1 Transformation abg2rbg_fig2m  
Language m (abg.m)
6.4.3.1 Arrow-orientated causality  
6.4.3.2 Component-orientated causality  
6.4.3.3 Transformation rbg2abg_m  
Stripped acausal bond graph (sabg)
6.5.1 Language fig (sabg.fig)  
6.5.2 Stripped acausal bond graph (view)  
Labels (lbl)
6.6.1 SS component labels  
6.6.2 Other component labels  
6.6.3 Component names  
6.6.4 Component constitutive relationship  
6.6.5 Component arguments  
6.6.6 Parameter declarations  
6.6.7 Units declarations  
6.6.8 Interface Control Definition  
6.6.9 Aliases  
6.6.10 Parameter passing  
6.6.11 Old-style labels (lbl)  
6.6.12 Language tex (desc.tex)  
Other component labels
6.6.3 Component names  
6.6.4 Component constitutive relationship  
6.6.5 Component arguments  
6.6.9 Aliases  
6.6.10 Parameter passing  
6.6.11 Old-style labels (lbl)  
Aliases
6.6.9.1 Port aliases  
6.6.9.2 Parameter aliases  
6.6.9.3 CR aliases  
6.6.9.4 Component aliases  
Old-style labels (lbl)
6.6.11.1 SS component labels (old-style)  
6.6.11.2 Other component labels (old-style)  
6.6.11.3 Parameter passing (old-style)  
Parameter passing (old-style)
6.6.12 Language tex (desc.tex)  
Structure (struc)
6.7.1 Language txt (struc.txt)  
6.7.2 Language tex (struc.tex)  
6.7.3 Language tex (view)  
Constitutive relationship (cr)
6.8.1 Predefined constitutive relationships  
6.8.2 DIY constitutive relationships  
6.8.3 Unresolved constitutive relationships  
6.8.4 Unresolved constitutive relationships - Octave  
6.8.5 Unresolved constitutive relationships - c++  
Predefined constitutive relationships
6.8.1.1 lin  
6.8.1.2 exotherm  
Parameters
6.9.1 Symbolic parameters (subs.r)  
6.9.2 Symbolic parameters for simplification (simp.r)  
6.9.3 Numeric parameters (numpar)  
Numeric parameters (numpar)
6.9.3.1 Text form (numpar.txt)  
Causal bond graph (cbg)
6.10.1 Language fig (cbg.fig)  
6.10.2 Language m (cbg.m)  
Language m (cbg.m)
6.10.2.1 Transformation abg2cbg_m  
Elementary system equations (ese)
6.11.0.1 Transformation cbg2ese_m2r  
Differential-Algebraic Equations (dae)
6.12.1 Language reduce (dae.r)  
6.12.2 Language m (dae.m)  
Language reduce (dae.r)
6.12.1.1 Transformation ese2dae_r  
Language m (dae.m)
6.12.2.1 Transformation dae_r2m  
Constrained-state Equations (cse)
6.13.1 Language reduce (cse.r)  
6.13.2 Language m (view)  
Language reduce (cse.r)
6.13.1.1 Transformation dae2cse_r  
Ordinary Differential Equations
6.14.1 Language reduce (ode.r)  
6.14.2 Language m (ode.m)  
6.14.3 Language m (view)  
Language reduce (ode.r)
6.14.1.1 Transformation cse2ode_r  
Language m (ode.m)
6.14.2.1 Transformation ode_r2m  
Descriptor matrices (dm)
6.15.1 Language reduce (dm.r)  
6.15.2 Language m (dm.m)  
Report (rep)
6.16.1 Language text (rep.txt)  
6.16.2 Language view  
Extending MTT
7.1 Makefiles  
7.2 New (DIY) representations  
7.3 Component library  
New (DIY) representations
7.2.1 Makefile  
7.2.2 Shell-script  
7.2.3 Documentation  
Documentation
8.1 Manual  
8.2 On-line documentation  
On-line documentation
8.2.1 Brief on-line documentation  
8.2.2 Detailed on-line documentation  
Languages
9.1 Fig  r
9.2 m  
9.3 Reduce  
9.4 c  
Language tools
10.1 Views  
10.2 Xfig  
10.3 Text editors  
10.4 Octave  
10.5 LaTeX  
Octave
10.4.1 Octave control system toolbox (OCST)  
10.4.2 Creating GNU Octave .oct files  
10.4.3 Creating Matlab .mex files  
10.4.4 Embedding MTT models in Simulink  
Administration
11.1 Software components  
11.2 REDUCE setup  
11.3 Octave setup  
11.4 Paths  
11.5 File structure  
A.1 GNU Free Documentation License  
A.2 GNU GENERAL PUBLIC LICENSE  
Octave setup
11.3.1 .octaverc  
11.3.2 .oct file dependencies  
Paths
11.4.1 $MTTPATH  
11.4.2 $MTT_COMPONENTS  
11.4.3 $MTT_CRS  
11.4.4 $MTT_EXAMPLES  
11.4.5 $OCTAVE_PATH  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1. Introduction

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] [ ? ]

1.1 What is a representation?

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] [ ? ]

1.2 What is a transformation?

Each system representation (see section 1.1 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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.3 What is a bond graph?

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] [ ? ]

1.4 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


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.5 Bonds

Bonds connect components (see section 1.6 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:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.6 Components

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
provide the connections to other components (see section 1.6.1 Ports)
constitutive relationships
define how the port-variables are related (see section 1.6.2 Constitutive relationship)

1.6.1 Ports  
1.6.2 Constitutive relationship  
1.6.3 Symbolic parameters  
1.6.4 Numeric parameters  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.6.1 Ports

Components have one or more ports. Each port carries two variables, and effort and a flow variable (see section 1.4 Variables). Any pair of ports can be connected by a bond (see section 1.5 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 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] [ ? ]

1.6.2 Constitutive relationship

The constitutive relationship of a component defines how the port variables are related. This relationship may be linear or non-linear. This typically contains symbolic parameters (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] [ ? ]

1.6.3 Symbolic parameters

The constitutive relationship of a system component (see section 1.6 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 1.6.4 Numeric parameters) when appropriate.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.6.4 Numeric parameters

Numerical parameters are needed to give specific values to symbolic parameters (see section 1.6.3 Symbolic parameters) for the purposes of numeric analysis; for example: simulation, graph plotting or use within a numerical package such as Octave (see section 10.4 Octave).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.7 Algebraic loops

Following Chapter 3 of the book, algebraic loops appear as under-causal components in the bond graph. It is up to the modeler to indicate how these loops are to be resolved by adding appropriate SS elements.

In particular if zero junction is undercausal an SS:loop component (with effort output indicated by a causal stroke) with the following label file entry:

 
  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] [ ? ]

1.8 Switched systems

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
a switched I component
CSW
a switched C component

These switches are user controlled through the logic representation (see section 4.4 Simulation logic).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2. User interface

There are two user interfaces to MTT: a command line interface (see section 2.2 Command line interface) and a menu-driven interface (see section 2.1 Menu-driven interface).

2.1 Menu-driven interface  
2.2 Command line interface  
2.3 Options  
2.4 Utilities  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.1 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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.2 Command line interface

The command line interface for MTT is of the form:
 
mtt [options] <system_name> <representation> <language>
[options]
the (optional) option switches (see section 2.3 Options)
<system_name>
the name of the system being transformed
<representation>
the mnemonic for the system representation (see section 6.1 Representation summary)
<language>
the mnemonic for language for the representation (see section 9. Languages)
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.
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.3 Options

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
invokes the -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'
Means that the previous example can be executed using
 
mtt syst cbg view

The available options are:

-q
quiet mode -- suppress MTT banner
-A
solve algebraic equations symbolically
-ae
<hybrd> solve algebraic equations numerically (this option requires -cc or -oct)
-D
debug -- leave log files etc
-I
prints more information
-abg
start at abg.m representation
-c
c-code generation
-cc
C++ code generation
-d
<dir> use directory <dir>
-dc
Maximise derivative (not integral) causality
-dc
Maximise derivative (not integral) causality
-i
<implicit|euler|rk4> Use implicit, euler or Runge Kutta IVintegration
-o
ode is same as dae
-oct
use oct files in place of m files where appropriate
-opt
optimise code generation
-p
print environment variables
-partition
partition hierachical system
-r
reset time stamp on representation
-s
try to generate sensitivity BG (experimental)
-ss
use steady-state info to initialise simulations
-stdin
read input data from standard input for simulations
-sub
<subsystem> operate on this subsystem
-t
tidy mode (default)
-u
untidy mode (leaves files in current dir)
-v
verbose mode (multiple uses increase the verbosity)
-viewlevel
<N> View N levels of hierachy
--version
print version and exit
--versions
print version of mtt and components and exit


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.4 Utilities

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
Lists the help/browser commands
mtt copy <system>
Copies the system (ie directory and enclosed files) to the current working directory.
mtt rename <old_name> <new_name>
Renames all of the defining representations (see section 6.2 Defining representations) and textually changes each file appropriately.
mtt <system> clean
Remove all files generated by MTT associated with system `system'.
mtt clean
Remove all files generated by MTT associated with all systems within the current directory.
mtt system representation vc
Apply version control to representation `representation' of system `system'.
mtt system vc
Apply version control to all representations (under version control) system `system'.
These are described in more detail in the following sections.

2.4.1 Help  
2.4.2 Copy  
2.4.3 Clean  
2.4.4 Version control  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.4.1 Help

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>

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] [ ? ]

2.4.1.1 help representations

The command

 
mtt help representations
lists all of the representations (see section 6. 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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.4.1.2 help components

The command

 
mtt help components
lists all of the components (see section 1.6 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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.4.1.3 help examples

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 2.4.2 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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.4.1.4 help crs

The command

 
mtt help crs
lists all of the constitutive relationships (see section 1.6.2 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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.4.1.5 help <name>

The command

 
mtt help <name>
gives a detailed description of the entity called name.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.4.2 Copy

MTT provides a way of copying examples to your working directory:

 
mtt copy <example_name>

Use the command

 
mtt help examples
(see section 2.4.1.3 help examples) to find something of interest.

Note that components and constitutive relationships are automatically copied when required.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.4.3 Clean

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:
  1. mtt system clean
  2. 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 6.2 Defining representations).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.4.4 Version control

When you are working on a modeling project, it is easy to forget what changes you made to a system and why you made them. Sometimes, you may regret some changes and wish to revert to an earlier version: even if you use .old files this may be difficult to achieve safely.

These are very similar problems to those faced by software developers and can be solved in the same way: using version control.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
Apply version control to representation `representation' of system `system'.
mtt system vc
Apply version control to all representations (under version control) system `system'.

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] [ ? ]

3. Creating Models

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] [ ? ]

3.1 Quick start

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 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
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 10.2 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 <A HREF="http://www.mech.gla.ac.uk/~peterg/software/MTT/examples/Examples/Examples.html"> here</A>.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2 Creating simple models

For then purposes of this section, simple models are those which are built up from bond graphs involving predefined components. In contrast, more complex systems (see section 3.3 Creating complex models) need to be built up hierarchically.

The recommended sequence of steps to create a simple model is:

  1. Decide on a name for the system; let us call it `syst' for the purposes of this discussion.
  2. Invoke the Bond Graph editor to draw the acausal Bond Graph.
     
      mtt syst abg fig
    
  3. Draw the Bond Graph (see section 6.4.1 Language fig (abg.fig)), including the bonds (see section 1.5 Bonds), the components (see section 1.6 Components) and any artwork (see section 6.4.1.15 Artwork) to make the Bond Graph more readable. The graphical editor xfig is (see section 10.2 Xfig) is self-explanatory. The icon library is helpful here (see see section 6.4.1.1 Icon library).
  4. Add causal strokes (see section 6.4.1.3 Strokes) where needed to define causality. As a general rule, use the minimum number of strokes needed to define the problem; this will often be only on the SS components. (see section 6.4.1.6 SS components). Save the bond graph.
  5. View the corresponding causal bond graph.
     
      mtt syst cbg view
    
    1. At this stage, MTT will warn you that the labeled components do not appear in the label file - this can safely be ignored.
    2. MTT will indicate the percentage of components which are causally complete -- ideally this will be 100\%. Components which are not causally complete will be listed.
    3. A view of the causal bond graph will be created. The added causal strokes are indicated in blue, undercausal components in green and overcausal components in red.
    4. If the bond graph is causally complete, proceed to the next step, otherwise think hard and return to the first step.

  6. At this stage, no constitutive relationships have been defined. Nevertheless, MTT will proceed in a semi-qualitative fashion by assuming that all constitutive relationships are unity (and therefore linear). It may be useful at this stage to view various derived representations to check the overall model properties before proceeding further. For example:
    1. View the system Differential-algebraic equations
       
      mtt syst dae view
      
    2. View the system state matrices
       
      mtt syst sm view
      
    3. View the system transfer function
       
      mtt syst tf view
      
    4. View the system step response
       
      mtt syst sro view
      

  7. As well as creating the causal bond graph, MTT has also generated templates for other text files (see section 6.2 Defining representations) used to further specify the system. These can now be edited using your favorite text editor (see section 10.3 Text editors).

  8. MTT will now generate the representations (see section 6.1 Representation summary)that you desire. For example the system can be simulated by
     
    mtt syst odeso view
    
    MTT will complain if a component is named in the bond graph but not in the label file and vice versa. This mainly to catch typing errors.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.3 Creating complex models

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] [ ? ]

3.3.1 Top level

The top level of a complex model contains subsystems but is not, itself, contained by other systems. It has the following special features:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4. Simulation

One purpose of modelling is to simulate the modeled dynamic system. Although this is just another transformation (see section 1.2 What is a transformation?) and therefore is covered in the appropriate chapter (see section 6. 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 6. Representations):

cse
constrained-state differential equation form
ode
ordinary differential (or state-space) equations
in each case these equations may be linear or nonlinear.

Special cases of numerical simulation, appropriate to linear systems, are:

ir
impulse response - state
iro
impulse response - output
sr
impulse response - state
sro
impulse response - output

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
creates the impulse response of a linear system via the system_sm.m representation using explicit solution via the matrix exponential.
mtt system sro view
creates the step response of a linear system via the system_sm.m representation using explicit solution via the matrix exponential.
mtt -c system odeso view
creates the response of a nonlinear system via the system_ode.c representation using implicit integration.
mtt -c -i euler system odeso view
creates the response of a nonlinear system via the system_ode.c representation using euler integration.

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 Steady-state solutions

4.1.1 Steady-state solutions (odess)  
4.1.2 Steady-state solutions (ss)  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1.1 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 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] [ ? ]

4.1.2 Steady-state solutions (ss)

A rudimentary form of steady-state solution exists in mtt. The steady states and inouts are supplied by the user in the file system_simpar.r and the corresponding output and sate derivative computed by MTT using
 
mtt system ss view

For example

 
mtt copy