# ODE Solver (Formula) (G Dataflow)

Solves ordinary differential equations that you define with formulas.  ## ODE

Formula strings and variable strings that implement the right-hand side of an ordinary differential equation x' = f(x,t). ### f(x,t)

Right-hand side of ordinary differential equations. The formula can contain any number of valid variables. ### x name

Names of variables. ### time name

Name of the time at which the ODE solver steps or evaluates the state. ## initial values

Vector of the initial values of the variables.

The components of initial values correspond to the components of x. ## simulation parameters

Set of parameters to configure the numerical solution of the differential equations. ### initial time

Start time for solving the differential equations. ### final time

End time for solving the differential equations. final time must be greater than initial time. ### continuous solver

Type of solver this node uses to solve the differential equations.

Name Value Description
Runge-Kutta 1 (Euler) 0 A fixed step-size, single-step solver of first order. This solver applies to ODEs only.
Runge-Kutta 2 1 A fixed step-size, single-step solver of second order. This solver applies to ODEs only.
Runge-Kutta 3 2 A fixed step-size, single-step solver of third order. This solver applies to ODEs only.
Runge-Kutta 4 3 A fixed step-size, single-step solver of fourth order. This solver applies to ODEs only.
Runge-Kutta 23 (Variable) 4 A variable step-size solver that starts with a third order method and embeds a set of Bogacki-Shampine coefficients for a second order method. This solver applies to ODEs only.
Runge-Kutta 45 (Variable) 5 A variable step-size solver that starts with a fifth order method and embeds a set of Dormand-Prince coefficients for a fourth order method. This solver applies to ODEs only.
BDF (Variable) 6 A variable step-size, variable order (orders 1 through 5) implementation of the multi-step backwards differentiation formula (BDF). This method is suitable for moderately stiff problems.
Adams-Moulton (Variable) 7 A variable step-size, multi-step variable order (orders 1 through 12) implementation of the Adams-Moulton predictor-corrector pair in predict-evaluate-correct-evaluate (PECE) mode. This solver provides efficient and accurate solutions for non-stiff ODEs.
Rosenbrock (Variable) 8 A variable step-size, single-step explicit solver that uses a second order method with third order error estimates. This solver applies to ODEs only.
Discrete States Only 9 Fixed step-size, single-step algorithm for simulations that contain no continuous functions and therefore no differential equations. This solver applies to ODEs only.
SDIRK4 (Variable) 10 A variable step-size solver of the fourth order. This solver is a singly diagonal implicit Runge-Kutta method (SDIRK). This solver applies to ODEs only.
Radau 5 (Variable) 11 A variable step-size Radau solver of the fifth order.
Radau 9 (Variable) 12 A variable step-size Radau solver of the ninth order.
Radau 13 (Variable) 13 A variable step-size Radau solver of the thirteenth order.
Radau [Variable Order] (Variable) 14 A variable step-size Radau solver of variable order.
Gear's Method (Variable) 15 A variable step-size, variable order solver that implements a multi-step BDF. This solver is efficient for stiff problems and suitable for DAEs with implicit linear and nonlinear algebraic constraints. ### time step

Interval, in seconds, between the times at which this node evaluates the model and updates the model output. The node uses this input only if you select a fixed step-size solver. ### initial time step

Step size for the first time step that the solver uses to solve the differential equations. The node uses this input only if you select a variable step-size solver. ### minimum time step

Smallest time step size that the solver can use to solve the differential equations. The node uses this input only if you select a variable step-size solver. ### maximum time step

Largest time step size that the solver can use to solve the differential equations. The node uses this input only if you select a variable step-size solver. ### absolute tolerance

Absolute tolerance the solver uses to control the local error for each variable.

You must specify a scalar tolerance which applies to all variables. absolute tolerance cannot be negative. The corresponding absolute tolerance and relative tolerance cannot both be zeroes. ### relative tolerance

Relative tolerance the solver uses to control the local error for each variable state.

You must specify a scalar tolerance which applies to all variables. relative tolerance cannot be negative. The corresponding absolute tolerance and relative tolerance cannot both be zeroes. ### discrete time step

Base time step, in seconds, to use for discrete functions.

This input is used only for the ODE solver.

If you select a fixed step-size solver, discrete time step must be an integer multiple of time step. Otherwise, a run-time error occurs when you attempt to run the simulation. ## error in

Error conditions that occur before this node runs.

The node responds to this input according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error  If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Default: No error ## times

Points of time at which the differential equation solver evaluates the state.

If you select a fixed step-size solver, the values in times are evenly spaced. ## x

Values of the variables over time.

Each row of x contains the values evaluated at a particular time and each column contains a history of a particular value over time. ## error out

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error  If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

## Controlling the Local Error

The solver calculates the local error by the following equation: |x| * relative tolerance + absolute tolerance.

This node uses this error to adjust the step size. If the error is too large, the solver rejects the current step and reduces the step size for another try. If the error is too small, the solver accepts the current step and increases the step size for next try. The relative tolerance has greater impact on the local error when x is relatively large. The absolute tolerance has greater impact on the local error when x is relatively small.

Where This Node Can Run:

Desktop OS: Windows

FPGA: Not supported

Web Server: Not supported in VIs that run in a web application