<odeSystem>
<odeSystem> computes a numerical solution to a system of ordinary differential equations. The following are required attributes: variables and initialConditions. The opening <odeSystem> tag defines a block in which to enter one or more <rightHandSide> children, representing the successive RHS’s of the equations defining the system.
Attributes and Properties
Attributes for <odeSystem>
Number display (5)
avoidScientificNotationboolean. Default value: false. Whether to render numbers in full decimal form rather than scientific notation.
displayDecimalsinteger. Default value: 2. Number of decimal places to display when rendering this number.
displayDigitsinteger. Default value: 3. Number of significant digits to display when rendering this number.
displaySmallAsZeronumber. Default value: 1e-14. Threshold below which numbers are displayed as zero.
padZerosboolean. Default value: false. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Other (10)
chunkSizenumber. Default value: 10. Step-size chunk used when numerically integrating the system.
hideInitialConditionboolean. Default value: false. Whether to hide the initial condition from the rendered output.
independentVariable_variableName. Default value: . The independent variable of the ODE system.
initialConditions[ mathList ]. The initial values of each dependent variable, in order.
initialIndependentVariableValuemath. Default value: . The value of the independent variable at which the initial conditions are specified.
maxIterationsnumber. Default value: 1000. Maximum number of iterations the integrator may perform.
numberboolean. Default value: false. Whether to display equation numbers next to each equation.
renderModetext. Default value: align. How to format the rendered system of equations (e.g. "align").
tolerancenumber. Default value: 0.000001. Numerical tolerance used by the integrator.
variables[ _variableNameList ]. The dependent variables of the system, in the same order as the right-hand sides.
Common to all components (9)
copyreference. Create an independent copy of another component by reference. Enter a references a $name.
disabledboolean. Default value: false. Whether this component is disabled and cannot be interacted with.
extendreference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.
fixedboolean. Default value: false. Whether this component's value is fixed and cannot be modified.
fixLocationboolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
hideboolean. Default value: false. Whether to hide this component from the rendered output.
isResponseboolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.
nametext. The name used to reference this component from elsewhere in the document.
styleNumberinteger. Default value: 1. The style number used to select this component's visual styling from the available style definitions.
Properties for <odeSystem name="o">
Number display (5)
$o.avoidScientificNotationboolean. Whether to render numbers in full decimal form rather than scientific notation.
$o.displayDecimalsinteger. Number of decimal places to display when rendering this number.
$o.displayDigitsinteger. Number of significant digits to display when rendering this number.
$o.displaySmallAsZeronumber. Threshold below which numbers are displayed as zero.
$o.padZerosboolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Other (26)
$o.backgroundColortext. Human-readable name for this component's background color, derived from the active style and theme.
$o.chunkSizenumber. Step-size chunk used when numerically integrating the system.
$o.disabledboolean. Whether this component is disabled and cannot be interacted with.
$o.equationTagtext. The displayed equation number tag (when equation numbering is enabled).
$o.fixedboolean. Whether this component's value is fixed and cannot be modified.
$o.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$o.hideInitialConditionboolean. Whether to hide the initial condition from the rendered output.
$o.independentVariable_variableName. The independent variable of the ODE system.
$o.initialConditionmath. The initial value of the first dependent variable at the initial independent-variable value.
$o.initialConditions[ math ]. The initial values of each dependent variable at the initial independent variable value.
$o.initialIndependentVariableValuemath. The value of the independent variable at which the initial conditions are specified.
$o.latexlatex. The full ODE system rendered as a LaTeX string.
$o.maxIterationsnumber. Maximum number of iterations the integrator may perform.
$o.numberboolean. Whether to display equation numbers next to each equation.
$o.numericalSolutionfunction. Numerical solution function for the first dependent variable, as a function of the independent variable.
$o.numericalSolutions[ function ]. Numerical solution functions for each dependent variable, as functions of the independent variable.
$o.renderModetext. How to format the rendered system of equations (e.g. "align").
$o.rhsmath. The right-hand-side expression of the first ODE in the system.
$o.rhss[ math ]. The right-hand-side expressions of each ODE in the system.
$o.righthandsidemath. The right-hand-side expression of the first ODE in the system.
$o.righthandsides[ math ]. The right-hand-side expressions of each ODE in the system.
$o.textColortext. Human-readable name for this component's text color, derived from the active style and theme.
$o.textStyleDescriptiontext. Human-readable description of this component's text styling (color and any background color).
$o.tolerancenumber. Numerical tolerance used by the integrator.
$o.variables[ _variableName ]. The dependent variables of the system, in order matching the right-hand sides.
Common to all components (4)
$o.doenetMLtext. The DoenetML source code that produced this component.
$o.hideboolean. Whether to hide this component from the rendered output.
$o.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$o.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: Single ODE system with user-input
The required attributes as well as the <rightHandSide> child of the <odeSystem> component for a single differential equation are retrieved from user input. A <function> is then defined by accessing the numericalSolution property of the named <odeSystem> component. The solution can be graphed and evaluated in this manner using typical function evaluation techniques (i.e. by using either the $$functionName(input) evaluation reference or the <evaluate> component.)
Example: A spring-mass ODE system problem with validation
A linear spring-mass system is modeled as a <odeSystem> with two <rightHandSide> children.
The problem is customizable via math inputs embedded in the problem statement. Note that, given the numerical
nature of the solution process for the <odeSystem> component, an error allowance must be provided
in the <answer> component using the allowedErrorInNumbers attribute.
Example: A simple pendulum ODE System
This example illustrates the use of <odeSystem> for a second-order nonlinear differential equation arising
from the motion of a simple pendulum without damping
where is the angle of the pendulum, is the acceleration due to gravity, and is the length of the pendulum.
Making the substitution results in a first-order system of two equations,
The right-hand side of these two equations are entered into the <odeSystem> component as <rightHandSide> children.
The order of the children should match the order of the independent variables listed in the variables attribute
of the <odeSystem> component definition. In this example, we have variables="theta omega", so the right-hand
side equation for is listed as the first child, and the right-hand side for is
listed as the second child.
Example: Animated simple pendulum - simulation
Refer to the previous example for the setup of the <odeSystem> component for this problem. In this example, the time parameter defined by the <number> t is animated with the <animateFromSequence/> component, which in turn animates . The simulated pendulum illustrates the angle.
Example: Animated simple pendulum - phase plane
Refer to the example titled “A simple pendulum ODE system” for the setup of the <odeSystem> component for this problem. In this example, the time parameter defined by the <number> t is animated with the <animateFromSequence/> component, which in turn animates and . The nullcline of the phase plane is then graphed as a parametric <curve> with the horizontal coordinate given by the numerical solution for and the vertical coordinate given by the numerical solution for .
Example: Animated simple pendulum - angle v. time
A point moving along the function corresponding to the pendulum’s motion from the previous example is rendered on a <graph> by animating the time parameter defined by the <number> t.
Example: independentVariable
The default independent variable is . To employ a different independent variable, use the independentVariable attribute.
Example: initialIndependentVariableValue
The default initial value for the independent variable is . To employ a different initial value, use the initialIndependentVariableValue attribute.
Example: chunkSize
The solution to an ODE is calculated numerically in batches of the size given by the chunkSize attribute, which defaults to . Each chunk is an interval where the independent variable changes by chunkSize. For each chunk, the numerical algorithm will use as many iterations as needed (up to the maximum number of iterations determined by the maxIterations attribute) to a achieve an error tolerance determined by the tolerance attribute. If this tolerance is not achieved, the evaluation of numerical solutions returns NaN. The algorithm may be able to integrate to larger values of the independent variable by increasing maxIterations or decreasing chunkSize (or by increasing tolerance).
Example: tolerance
The tolerance attribute may be adjusted to obtain convergence of solutions if the default tolerance of is inadequate. (For example, try evaluating in the example above.) The tolerance is the acceptable relative local error for the solution.
If solutions do not converge for the specified combination of solution parameters, including the tolerance attribute, the evaluation of numerical solutions returns NaN.
Example: maxIterations
The maxIterations attribute may be adjusted to obtain convergence of solutions if the default number of iterations () is inadequate for the desired tolerance. (For example, try evaluating in the example above.)
If solutions do not converge for the specified combination of solution parameters, including the maxIterations attribute, the evaluation of numerical solutions returns NaN.
The maxIterations attribute is the maximum number of iterations the solution algorithm will attempt to achieve the prescribed tolerance for each batch of the size given by chunkSize. For this reason, one can also decrease chunkSize to help achieve the required tolerance.
Example: hideInitialCondition
Use the hideInitialCondition attribute to suppress rendering of the required initial condition specification below the differential equations.
Example: initialConditions
The initialConditions attribute is required for the <odeSystem> component. Initial conditions for each dependent variable should be listed in the attribute in the same order that the associated equations appear as <rightHandSide> children in the <odeSystem> block.
Example: variables
The variables attribute is required for the <odeSystem> component. Each dependent variable should be listed in the variables attribute in the same order that the associated equations appear as <rightHandSide> children in the <odeSystem> block.
Example: Attributes as properties
The attributes listed in the example above are also available as properties.
Example: rhss
The rhss property stores/renders the right-hand side children of the <odeSystem> in an array.
Example: latex
The latex property stores/renders the LaTeX of the <odeSystem>.
Example: numericalSolutions
The numericalSolutions property is an array of functions corresponding
to numerical solutions for each dependent variable in the system. To access the
computed solutions of the system, use function evaluation with $odeSystemName.numericalSolutions[i] for
the function, or define new functions referencing the numericalSolution[i] property with the extend attribute.