General Commands > About General Commands > model.ode()

model.ode()
Create global equations (ODEs and DAEs).
Syntax
model.ode().create(<tag>);
model.ode(<tag>).state(<statelist>);
model.ode(<tag>).state(<pos>,<state>);
model.ode(<tag>).ode(<state>,<equation>);
model.ode(<tag>).descr(<state>,<descr>);
model.ode(<tag>).weak(<wlist>);
model.ode(<tag>).weak(<pos>,<wexpr>);
model.ode(<tag>).discrete(<boolean>);
model.ode(<tag>).valueType(prop);
 
model.ode(<tag>).state();
model.ode(<tag>).ode(<state>);
model.ode(<tag>).descr(<state>);
model.ode(<tag>).weak();
model.ode(<tag>).discrete();
model.ode(<tag>).valueType();
Description
model.ode(<tag>) returns a global equation (or an ODE or a DAE) with tag <tag>.
model.ode().create(<tag>) creates an global equation with tag <tag>.
model.ode(<tag>).state(<statelist>) sets the states of the global equation tagged <tag> according to the list <statelist>.
model.ode(<tag>).state(<pos>,<state>) edits the state at position <pos> in the state vector for the global equation <tag>.
model.ode(<tag>).ode(<state>,<equation>) sets the equation for the state <state>. If the state variable has not previously been added using model.ode(<tag>).state(<statelist>) then <state> is appended to the list of state variables.
model.ode(<tag>).descr(<state>,<descr>) sets the description for the state <state>.
model.ode(<tag>).weak(<wlist>) set weak equations. <wlist> is a list of weak expressions.
model.ode(<tag>).weak(<pos>,<wexpr>) sets the weak expression at position <pos> in the list of weak expressions.
model.ode(<tag>).state() returns the state variables as a string array.
model.ode(<tag>).ode(<state>) returns the global equation for the state variable <state> as a string.
model.ode(<tag>).descr(<state>) returns the description of the state variable <state> as a string.
model.ode(<tag>).weak() returns the weak equations as a string vector of weak expressions.
model.ode(<tag>).discrete(true) specifies that the global equation contains event states.
model.ode(<tag>).valueType(prop) specifies value type as real or complex when splitting of complex variables in real and imaginary parts has been turned on.
model.ode(<tag>).valueType() returns the value type.
Example
Define a global equations with the variables u and w, the ODEs ut+1 = 0 and vt+1 = 0, where the subscript t indicates the derivative with respect to time. Also define a weak expression test(uv.
Code for use with Java
Model model = ModelUtil.create("Model");
model.ode().create("ode1");
model.ode("ode1").ode("u","ut+1");
model.ode("ode1").ode("v","vt-1");
model.ode("ode1").weak(new String[]{"test(u)*v"});
Code for use with MATLAB
model = ModelUtil.create('Model');
model.ode.create('ode1');
model.ode('ode1').ode('u','ut+1');
model.ode('ode1').ode('v','vt-1');
model.ode('ode1').weak({'test(u)*v'});
See Also
model.init(), model.solverEvent()