Declarations
Language overview · Install this source revision
model Name { ... } contains declarations and simultaneous relations. Semicolons
end declarations; // introduces a comment and /// attaches documentation. Names are case-sensitive.
model Current(parameter voltage: kg * m ^ 2 / (s ^ 3 * A) = 12, parameter resistance: kg * m ^ 2 / (s ^ 3 * A ^ 2) = 4) { variable current: A; relation ohm { voltage - resistance * current = 0; }}| Declaration | Meaning in this example |
|---|---|
parameter voltage: dimension = 12; |
A fixed mathematical input of 12 coherent SI units; voltage here is measured in volts. |
variable current: A; |
An unknown current, not a Python variable or a command to compute it immediately. |
relation ohm { ... } |
An equation constraining those values; declaration order is not execution order. |
An algebraic variable needs no declaration initial value. An evolving scalar
uses state x: 1; initial { x = 1; } to declare its role and initial equation; see
Equations and state. 1 denotes a dimensionless
type. Do not interpret an omitted initial value as a promise of zero initialization.
Spatial declarations
Section titled “Spatial declarations”A spatial unknown also names its exact support. In the
complete elastic-body example,
variable displacement: vector<m, 2> on body; means a vector
displacement on body, in metres. The enclosing domain body = box(...) supplies
the two-dimensional support. The compiler supplies the admitted continuum
Representation; source declarations do not select a mesh or finite-element space.
Scalar and vector declarations are not interchangeable. Component support and Field requirements bind existing occurrences; see Composition.
Example source · declaration parser · Next: Quantities and units