ODEFunction

class ozone.ode_function.ODEFunction(**kwargs)

Base class for required user-defined ode function.

Define an ODE of the form y’ = f(t, x, y).

Methods

initialize(**kwargs)

Optional method that calls declare_time, declare_state, and/or declare_dynamic_parameter.

Parameters:

kwargs : dict

Keyword arguments passed in during instantiation.

set_system(system_class, system_init_kwargs=None)

Set the OpenMDAO System that computes the ODE function.

Parameters:

system_class : System

OpenMDAO Group or Component class defining our ODE.

system_init_kwargs : dict or None

Dictionary of kwargs that should be passed in when instantiating system_class.

declare_time(targets=None, units=None)

Specify the targets and units of time or the time-like variable.

Parameters:

targets : string_types or Iterable or None

Targets for the time or time-like variable within the ODE, or None if no models are explicitly time-dependent. Default is None.

units : str or None

Units for the integration variable within the ODE. Default is None.

declare_state(name, rate_source, targets=None, shape=None, units=None)

Add an ODE state variable.

Parameters:

name : str

The name of the state variable as seen by the driver. This variable will exist as an interface to the ODE.

rate_source : str

The path to the variable within the ODE which represents the derivative of the state variable w.r.t. the variable of integration.

targets : string_types or Iterable or None

Paths to inputs in the ODE to which the incoming value of the state variable needs to be connected.

shape : int or tuple or None

The shape of the variable to potentially be provided as a control.

units : str or None

Units of the variable.

declare_parameter(name, targets, shape=None, units=None, dynamic=True)

Declare an input to the ODE.

Parameters:

name : str

The name of the parameter.

targets : string_types or Iterable or None

Paths to inputs in the ODE to which the incoming value of the parameter needs to be connected.

shape : int or tuple or None

Shape of the parameter.

units : str or None

Units of the parameter.

dynamic : bool

If True, the parameter has a different value at each time step (dynamic parameter); otherwise, the parameter has the same value at all time steps (static parameter). A dynamic parameter should have shape (num_nodes, ...) where ... is defined by the shape argument.

get_test_parameters()

Optional method to provide default parameters; used for testing.

Returns:

dict

Dictionary of initial conditions keyed by state name.

float

Integration start time.

float

Integration end time.

get_exact_solution(initial_conditions, t0, t)

Optional method to compute the exact solution at time t given initial conditions at t0.

Parameters:

initial_conditions : dict

Dictionary of initial conditions keyed by state name.

t0 : float

Integration start time.

t : float

Time at which the exact solution is desired.