Dynamic modelling: Difference between revisions

From ASCEND
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{solvers}}{{stub}}
{{solvers}}{{stub}}
Dynamic modelling in ASCEND is where you solve a system of [http://en.wikipedia.org/wiki/Ordinary_differential_equations ordinary differential equations (ODEs)] or [http://en.wikipedia.org/wiki/Differential_algebraic_equation differential/algebraic equations] for the time-varying values of variables in the model over a certain interval, given the initial conditions of the model. We also refer to this as ''integration''. Dynamic modelling can be done within the ASCEND language providing the relationship between variables and their derivatives can be established.
Dynamic modelling in ASCEND is where you solve a system of [http://en.wikipedia.org/wiki/Ordinary_differential_equations ordinary differential equations (ODEs)] or [http://en.wikipedia.org/wiki/Differential_algebraic_equation differential/algebraic equations] for the time-varying values of variables in the model over a certain interval, given the initial conditions of the model. We also refer to this as ''integration''. Dynamic modelling can be done within the ASCEND language providing the relationship between variables and their derivatives can be established.


The current method for specifying derivatives is by including the <tt>ivpsystem.a4l</tt> library:
The current method for specifying derivatives is by including the <tt>ivpsystem.a4l</tt> library:
Line 20: Line 19:


which must be run before sending your model to either [[IDA]] or [[LSODE]] (or a future [[Solvers|solver]]...) for integration.
which must be run before sending your model to either [[IDA]] or [[LSODE]] (or a future [[Solvers|solver]]...) for integration.


== New syntax ==
== New syntax ==


[[Dante Stroe]] recently added support for [[LINK semantics]] that allows this fairly painful syntax to be improved. Based on the LINK structure the following syntax can now be used to define derivative chains, for example:
[[Dante Stroe]] recently added support for [[LINK semantics]] that allows this fairly painful syntax to be improved. Based on the LINK structure the following syntax can now be used to define derivative chains, for example:


<source lang="a4c">INDEPENDENT t;
<source lang="a4c">INDEPENDENT t;
Line 31: Line 28:


This syntax can be used in either the declarative part of the model, either in the Methods section.
This syntax can be used in either the declarative part of the model, either in the Methods section.


* The '''INDEPENDENT''' keyword adds an independent variable to the solver. While it is possible to store multiple independent variables in the solver data structures, the user is currently limited to only one independent variable, since there is no implementation of partial derivatives. (Implementation-wise, a LINK entry with the 'indepenendent' key and the independent variable itself is created)
* The '''INDEPENDENT''' keyword adds an independent variable to the solver. While it is possible to store multiple independent variables in the solver data structures, the user is currently limited to only one independent variable, since there is no implementation of partial derivatives. (Implementation-wise, a LINK entry with the 'indepenendent' key and the independent variable itself is created)
Line 38: Line 34:


The following models using the aforementioned syntax have been added:
The following models using the aforementioned syntax have been added:


* [http://ascendcode.cheme.cmu.edu/viewvc.cgi/code/branches/dante/models/test/ida/singlederiv_wLINK.a4c <font color="orange">dante</font>:models/test/ida/singlederiv_wLINK.a4c]
* [http://ascendcode.cheme.cmu.edu/viewvc.cgi/code/branches/dante/models/test/ida/singlederiv_wLINK.a4c <font color="orange">dante</font>:models/test/ida/singlederiv_wLINK.a4c]
Line 47: Line 42:


See also
See also
* [[External Integrators]] in the development section.
* [[External Integrators]] in the development section.
* [[Initial-value modelling]].
* [[Initial-value modelling]].
* [[Improved DAE syntax]]
* [[Improved DAE syntax]]


[[Category:Solvers]]
[[Category:Stubs]]
[[Category:Documentation]]
[[Category:Documentation]]
[[Category:Syntax]]
[[Category:Syntax]]

Revision as of 09:45, 2 August 2010

NLA
QRSlv
CMSlv
IPSlv
NLP
CONOPT
IPOPT
TRON
MINOS
Opt
NGSlv
DAE/ODE
IDA
LSODE
DOPRI5
RADAU5
LA
Linsolqr
Linsol
LP
MakeMPS
Logic
LRSlv

Dynamic modelling in ASCEND is where you solve a system of ordinary differential equations (ODEs) or differential/algebraic equations for the time-varying values of variables in the model over a certain interval, given the initial conditions of the model. We also refer to this as integration. Dynamic modelling can be done within the ASCEND language providing the relationship between variables and their derivatives can be established.

The current method for specifying derivatives is by including the ivpsystem.a4l library:

REQUIRE &quot;ivpsystem.a4l&quot;;

at the start of your model, then creating a special method

METHOD ode_init;
    dx_dt.ode_id := 1;
    x.ode_id := 1; (* ie these variables are related with ID '1' *)

    dx_dt.ode_type := 2; (* ie 'this is a derivative variable' *)
    x.ode_type := 1; (* ie 'this is a differential variable *)

    t.ode_type:= -1; (* 'tag' the independent variable *)
END ode_init;

which must be run before sending your model to either IDA or LSODE (or a future solver...) for integration.

New syntax

Dante Stroe recently added support for LINK semantics that allows this fairly painful syntax to be improved. Based on the LINK structure the following syntax can now be used to define derivative chains, for example:

INDEPENDENT t;
DER(dx_dt,x)

This syntax can be used in either the declarative part of the model, either in the Methods section.

  • The INDEPENDENT keyword adds an independent variable to the solver. While it is possible to store multiple independent variables in the solver data structures, the user is currently limited to only one independent variable, since there is no implementation of partial derivatives. (Implementation-wise, a LINK entry with the 'indepenendent' key and the independent variable itself is created)
  • The DER keyword is used to declare the derivative chains in terms of the declared independent variable. The parameters of DER are the differential variables in decreasing order (ode_type in the previous syntax). The derivative chains declared in DER can be arbitrarily long, however the solver does not handle more than 2nd order derivatives. (Implementation-wise, a LINK entry with the 'ode' key and the differential variable is created)

The following models using the aforementioned syntax have been added:

See also