# The Phase API

## Contents

# The Phase API#

## Options#

Option | Default | Acceptable Values | Acceptable Types | Description |
---|---|---|---|---|

assembled_jac_type | csc | ['csc', 'dense'] | N/A | Linear solver(s) in this group or implicit component, if using an assembled jacobian, will use this type. |

ode_class | N/A | N/A | N/A | System defining the ODE |

ode_init_kwargs | {} | N/A | ['dict'] | Keyword arguments provided when initializing the ODE System |

transcription | **Required** | N/A | ['TranscriptionBase'] | Transcription technique of the optimal control problem. |

The transcription is an instance of one of the transcriptions available in Dymos.

## set_time_options#

- Phase.set_time_options(
units=unspecified,fix_initial=unspecified,fix_duration=unspecified,input_initial=unspecified,input_duration=unspecified,initial_val=unspecified,initial_bounds=unspecified,initial_scaler=unspecified,initial_adder=unspecified,initial_ref0=unspecified,initial_ref=unspecified,duration_val=unspecified,duration_bounds=unspecified,duration_scaler=unspecified,duration_adder=unspecified,duration_ref0=unspecified,duration_ref=unspecified,targets=unspecified,time_phase_targets=unspecified,t_initial_targets=unspecified,t_duration_targets=unspecified)[source]Sets options for time in the phase.

Only those options which are specified in the arguments will be updated.

- Parameters

unitsstrThe default units for time variables in the phase. Default is ‘s’.

fix_initialboolIf True, the initial time of the phase is not treated as a design variable for the optimization problem.

fix_durationboolIf True, the duration of the phase is not treated as a design variable for the optimization problem.

input_initialboolIf True, the user is expected to link phase.t_initial to an external output source. Providing input_initial=True makes all initial time optimization settings irrelevant.

input_durationboolIf True, the user is expected to link phase.t_duration to an external output source. Providing input_duration=True makes all time duration optimization settings irrelevant.

initial_valfloatDefault value of the time at the start of the phase.

initial_boundsiterable of (float, float)The bounds (lower, upper) for time at the start of the phase.

initial_scalerfloatScalar for the initial value of time.

initial_adderfloatAdder for the initial value of time.

initial_ref0floatZero-reference for the initial value of time.

initial_reffloatUnit-reference for the initial value of time.

duration_valfloatDefault value for the time duration of the phase.

duration_boundsiterable of (float, float)The bounds (lower, upper) for the time duration of the phase.

duration_scalerfloatScaler for phase time duration.

duration_adderfloatAdder for phase time duration.

duration_ref0floatZero-reference for phase time duration.

duration_reffloatUnit-reference for phase time duration.

targetsiterable of strTargets in the ODE for the value of current time.

time_phase_targetsiterable of strTargets in the ODE for the value of current phase elapsed time.

t_initial_targetsiterable of strTargets in the ODE for the value of phase initial time.

t_duration_targetsiterable of strTargets in the ODE for the value of phase time duration.

## add_state#

- Phase.add_state(
name,units=unspecified,shape=unspecified,rate_source=unspecified,targets=unspecified,val=unspecified,fix_initial=unspecified,fix_final=unspecified,lower=unspecified,upper=unspecified,scaler=unspecified,adder=unspecified,ref0=unspecified,ref=unspecified,defect_scaler=unspecified,defect_ref=unspecified,solve_segments=unspecified,connected_initial=unspecified)[source]Add a state variable to be integrated by the phase.

- Parameters

namestrName of the state variable in the RHS.

unitsstr or NoneUnits in which the state variable is defined. Internally components may use different units for the state variable, but the IndepVarComp which provides its value will provide it in these units, and collocation defects will use these units. If units is not specified here then the unit will be determined from the rate_source.

shapetuple of intThe shape of the state variable. For instance, a 3D cartesian position vector would have a shape of (3,). This only needs to be specified if the rate_source target points to a control or state whose shape isn’t known in time.

rate_sourcestrThe path to the ODE output which provides the rate of this state variable.

targetsstr or Sequence of strThe path to the targets of the state variable in the ODE system. If given this will override the value given by the @declare_state decorator on the ODE. In the future, if left _unspecified (the default), the phase variable will try to connect to an ODE input of the same name. Set targets to None to prevent this.

valndarrayThe default value of the state at the state discretization nodes of the phase.

fix_initialbool(False)If True, omit the first value of the state from the design variables (prevent the optimizer from changing it).

fix_finalbool(False)If True, omit the final value of the state from the design variables (prevent the optimizer from changing it).

lowerfloat or ndarray or None (None)The lower bound of the state at the nodes of the phase.

upperfloat or ndarray or None (None)The upper bound of the state at the nodes of the phase.

scalerfloat or ndarray or None (None)The scaler of the state value at the nodes of the phase.

adderfloat or ndarray or None (None)The adder of the state value at the nodes of the phase.

ref0float or ndarray or None (None)The zero-reference value of the state at the nodes of the phase.

reffloat or ndarray or None (None)The unit-reference value of the state at the nodes of the phase.

defect_scalerfloat or ndarrayThe scaler of the state defect at the collocation nodes of the phase.

defect_reffloat or ndarrayThe unit-reference value of the state defect at the collocation nodes of the phase. If provided, this value overrides defect_scaler.

solve_segmentsbool(False)If True, a solver will be used to converge the collocation defects within a segment. Note that the state continuity defects between segements will still be handled by the optimizer.

connected_initialboolIf True, then the initial value for this state comes from an externally connected source.

## set_state_options#

- Phase.set_state_options(
name,units=unspecified,shape=unspecified,rate_source=unspecified,targets=unspecified,val=unspecified,fix_initial=unspecified,fix_final=unspecified,lower=unspecified,upper=unspecified,scaler=unspecified,adder=unspecified,ref0=unspecified,ref=unspecified,defect_scaler=unspecified,defect_ref=unspecified,solve_segments=unspecified,connected_initial=unspecified)[source]Set options that apply the EOM state variable of the given name.

- Parameters

namestrName of the state variable in the RHS.

unitsstr or NoneUnits in which the state variable is defined. Internally components may use different units for the state variable, but the IndepVarComp which provides its value will provide it in these units, and collocation defects will use these units. If units is not specified here then the unit will be determined from the rate_source.

shapetuple of intThe shape of the state variable. For instance, a 3D cartesian position vector would have a shape of (3,). This only needs to be specified if the rate_source target points to a control or state whose shape isn’t known in time.

rate_sourcestrThe path to the ODE output which provides the rate of this state variable.

targetsstr or Sequence of strThe path to the targets of the state variable in the ODE system. If given this will override the value given by the @declare_state decorator on the ODE. In the future, if left _unspecified (the default), the phase variable will try to connect to an ODE input of the same name. Set targets to None to prevent this.

valndarrayThe default value of the state at the state discretization nodes of the phase.

fix_initialbool(False)If True, omit the first value of the state from the design variables (prevent the optimizer from changing it).

fix_finalbool(False)If True, omit the final value of the state from the design variables (prevent the optimizer from changing it).

lowerfloat or ndarray or None (None)The lower bound of the state at the nodes of the phase.

upperfloat or ndarray or None (None)The upper bound of the state at the nodes of the phase.

scalerfloat or ndarray or None (None)The scaler of the state value at the nodes of the phase.

adderfloat or ndarray or None (None)The adder of the state value at the nodes of the phase.

ref0float or ndarray or None (None)The zero-reference value of the state at the nodes of the phase.

reffloat or ndarray or None (None)The unit-reference value of the state at the nodes of the phase.

defect_scalerfloat or ndarrayThe scaler of the state defect at the collocation nodes of the phase.

defect_reffloat or ndarrayThe unit-reference value of the state defect at the collocation nodes of the phase. If provided, this value overrides defect_scaler.

solve_segmentsbool(False)If True, a solver will be used to converge the collocation defects within a segment. Note that the state continuity defects between segements will still be handled by the optimizer.

connected_initialboolIf True, then the initial value for this state comes from an externally connected source.

## add_control#

- Phase.add_control(
name,units=unspecified,desc=unspecified,opt=unspecified,fix_initial=unspecified,fix_final=unspecified,targets=unspecified,rate_targets=unspecified,rate2_targets=unspecified,val=unspecified,shape=unspecified,lower=unspecified,upper=unspecified,scaler=unspecified,adder=unspecified,ref0=unspecified,ref=unspecified,continuity=unspecified,continuity_scaler=unspecified,rate_continuity=unspecified,rate_continuity_scaler=unspecified,rate2_continuity=unspecified,rate2_continuity_scaler=unspecified)[source]Adds a dynamic control variable to be tied to a parameter in the ODE.

- Parameters

namestrThe name assigned to the control variable. If the ODE has been decorated with parameters, this should be the name of a control in the system.

unitsstr or NoneThe units with which the control parameter in this phase will be defined. It must be compatible with the units of the targets to which the control is connected.

descstrA description of the control variable.

optboolIf True, the control value will be a design variable for the optimization problem. If False, allow the control to be connected externally.

fix_initialboolIf True, the initial value of this control is fixed and not a design variable. This option is invalid if opt=False.

fix_finalboolIf True, the final value of this control is fixed and not a design variable. This option is invalid if opt=False.

targetsSequence of str or NoneTargets in the ODE to which this control is connected. In the future, if left _unspecified (the default), the phase control will try to connect to an ODE input of the same name. Set targets to None to prevent this.

rate_targetsSequence of str or NoneThe targets in the ODE to which the control rate is connected.

rate2_targetsSequence of str or NoneThe parameter in the ODE to which the control 2nd derivative is connected.

valfloatThe default value of the control variable at the control input nodes.

shapeSequence of intThe shape of the control variable at each point in time. Only needed for controls that don’t have a target in the ode.

lowerSequence of Number or NoneThe lower bound of the control variable at the nodes. This option is invalid if opt=False.

upperSequence or Number or NoneThe upper bound of the control variable at the nodes. This option is invalid if opt=False.

scalerfloat or NoneThe scaler of the control variable at the nodes. This option is invalid if opt=False.

adderfloat or NoneThe adder of the control variable at the nodes. This option is invalid if opt=False.

ref0float or NoneThe zero-reference value of the control variable at the nodes. This option is invalid if opt=False.

reffloat or NoneThe unit-reference value of the control variable at the nodes. This option is invalid if opt=False.

continuityboolEnforce continuity of control values at segment boundaries. This option is invalid if opt=False.

continuity_scalerboolScaler of the continuity constraint. This option is invalid if opt=False. This option is only relevant in the Radau pseudospectral transcription where the continuity constraint is nonlinear. For Gauss-Lobatto the continuity constraint is linear.

rate_continuityboolEnforce continuity of control first derivatives (in dimensionless time) at segment boundaries. This option is invalid if opt=False.

rate_continuity_scalerfloatScaler of the rate continuity constraint at segment boundaries. This option is invalid if opt=False.

rate2_continuityboolEnforce continuity of control second derivatives at segment boundaries. This option is invalid if opt=False.

rate2_continuity_scalerfloatScaler of the dimensionless rate continuity constraint at segment boundaries. This option is invalid if opt=False.

Notes

rate and rate2 continuity are not enforced for input controls.

## set_control_options#

- Phase.set_control_options(
name,units=unspecified,desc=unspecified,opt=unspecified,fix_initial=unspecified,fix_final=unspecified,targets=unspecified,rate_targets=unspecified,rate2_targets=unspecified,val=unspecified,shape=unspecified,lower=unspecified,upper=unspecified,scaler=unspecified,adder=unspecified,ref0=unspecified,ref=unspecified,continuity=unspecified,continuity_scaler=unspecified,rate_continuity=unspecified,rate_continuity_scaler=unspecified,rate2_continuity=unspecified,rate2_continuity_scaler=unspecified)[source]Set options on an existing dynamic control variable in the phase.

- Parameters

namestrThe name assigned to the control variable. If the ODE has been decorated with parameters, this should be the name of a control in the system.

unitsstr or NoneThe units with which the control parameter in this phase will be defined. It must be compatible with the units of the targets to which the control is connected.

descstrA description of the control variable.

optboolIf True, the control value will be a design variable for the optimization problem. If False, allow the control to be connected externally.

fix_initialboolIf True, the initial value of this control is fixed and not a design variable. This option is invalid if opt=False.

fix_finalboolIf True, the final value of this control is fixed and not a design variable. This option is invalid if opt=False.

targetsSequence of str or NoneTargets in the ODE to which this control is connected. In the future, if left _unspecified (the default), the phase control will try to connect to an ODE input of the same name. Set targets to None to prevent this.

rate_targetsSequence of str or NoneThe targets in the ODE to which the control rate is connected.

rate2_targetsSequence of str or NoneThe parameter in the ODE to which the control 2nd derivative is connected.

valfloatThe default value of the control variable at the control input nodes.

shapeSequence of intThe shape of the control variable at each point in time. Only needed for controls that don’t have a target in the ode.

lowerSequence of Number or NoneThe lower bound of the control variable at the nodes. This option is invalid if opt=False.

upperSequence or Number or NoneThe upper bound of the control variable at the nodes. This option is invalid if opt=False.

scalerfloat or NoneThe scaler of the control variable at the nodes. This option is invalid if opt=False.

adderfloat or NoneThe adder of the control variable at the nodes. This option is invalid if opt=False.

ref0float or NoneThe zero-reference value of the control variable at the nodes. This option is invalid if opt=False.

reffloat or NoneThe unit-reference value of the control variable at the nodes. This option is invalid if opt=False.

continuityboolEnforce continuity of control values at segment boundaries. This option is invalid if opt=False.

continuity_scalerboolScaler of the continuity constraint. This option is invalid if opt=False. This option is only relevant in the Radau pseudospectral transcription where the continuity constraint is nonlinear. For Gauss-Lobatto the continuity constraint is linear.

rate_continuityboolEnforce continuity of control first derivatives (in dimensionless time) at segment boundaries. This option is invalid if opt=False.

rate_continuity_scalerfloatScaler of the rate continuity constraint at segment boundaries. This option is invalid if opt=False.

rate2_continuityboolEnforce continuity of control second derivatives at segment boundaries. This option is invalid if opt=False.

rate2_continuity_scalerfloatScaler of the dimensionless rate continuity constraint at segment boundaries. This option is invalid if opt=False.

Notes

rate and rate2 continuity are not enforced for input controls.

## add_polynomial_control#

- Phase.add_polynomial_control(
name,order,desc=unspecified,val=unspecified,units=unspecified,opt=unspecified,fix_initial=unspecified,fix_final=unspecified,lower=unspecified,upper=unspecified,scaler=unspecified,adder=unspecified,ref0=unspecified,ref=unspecified,targets=unspecified,rate_targets=unspecified,rate2_targets=unspecified,shape=unspecified)[source]Adds an polynomial control variable to be tied to a parameter in the ODE.

Polynomial controls are defined by values at the Legendre-Gauss-Lobatto nodes of a single polynomial, defined on [-1, 1] in phase tau space.

For a polynomial control of a given order, the number of nodes used to define the polynomial is (order + 1).

- Parameters

namestrName of the controllable parameter in the ODE.

orderintThe order of the interpolating polynomial used to represent the control value in phase tau space.

descstrA description of the polynomial control.

valfloat or ndarrayDefault value of the control at all nodes. If val scalar and the control is dynamic it will be broadcast.

unitsstr or None or 0Units in which the control variable is defined. If 0, use the units declared for the parameter in the ODE.

optboolIf True (default) the value(s) of this control will be design variables in the optimization problem, in the path ‘phase_name.indep_controls.controls:control_name’. If False, the values of this control will exist as input controls:{name}.

fix_initialboolIf True, the given initial value of the polynomial control is not a design variable and will not be changed during the optimization.

fix_finalboolIf True, the given final value of the polynomial control is not a design variable and will not be changed during the optimization.

lowerfloat or ndarrayThe lower bound of the control at the nodes of the phase.

upperfloat or ndarrayThe upper bound of the control at the nodes of the phase.

scalerfloat or ndarrayThe scaler of the control value at the nodes of the phase.

adderfloat or ndarrayThe adder of the control value at the nodes of the phase.

ref0float or ndarrayThe zero-reference value of the control at the nodes of the phase.

reffloat or ndarrayThe unit-reference value of the control at the nodes of the phase.

targetsSequence of str or NoneTargets in the ODE to which this polynomial control is connected.

rate_targetsNone or strThe name of the parameter in the ODE to which the first time-derivative of the control value is connected.

rate2_targetsNone or strThe name of the parameter in the ODE to which the second time-derivative of the control value is connected.

shapeSequence of intThe shape of the control variable at each point in time.

## set_polynomial_control_options#

- Phase.set_polynomial_control_options(
name,order,desc=unspecified,val=unspecified,units=unspecified,opt=unspecified,fix_initial=unspecified,fix_final=unspecified,lower=unspecified,upper=unspecified,scaler=unspecified,adder=unspecified,ref0=unspecified,ref=unspecified,targets=unspecified,rate_targets=unspecified,rate2_targets=unspecified,shape=unspecified)[source]Set options on an existing polynomial control variable in the phase.

- Parameters

namestrName of the controllable parameter in the ODE.

orderintThe order of the interpolating polynomial used to represent the control value in phase tau space.

descstrA description of the polynomial control.

valfloat or ndarrayDefault value of the control at all nodes. If val scalar and the control is dynamic it will be broadcast.

unitsstr or None or 0Units in which the control variable is defined. If 0, use the units declared for the parameter in the ODE.

optboolIf True (default) the value(s) of this control will be design variables in the optimization problem, in the path ‘phase_name.indep_controls.controls:control_name’. If False, the values of this control will exist as input controls:{name}.

fix_initialboolIf True, the given initial value of the polynomial control is not a design variable and will not be changed during the optimization.

fix_finalboolIf True, the given final value of the polynomial control is not a design variable and will not be changed during the optimization.

lowerfloat or ndarrayThe lower bound of the control at the nodes of the phase.

upperfloat or ndarrayThe upper bound of the control at the nodes of the phase.

scalerfloat or ndarrayThe scaler of the control value at the nodes of the phase.

adderfloat or ndarrayThe adder of the control value at the nodes of the phase.

ref0float or ndarrayThe zero-reference value of the control at the nodes of the phase.

reffloat or ndarrayThe unit-reference value of the control at the nodes of the phase.

targetsSequence of str or NoneTargets in the ODE to which this polynomial control is connected.

rate_targetsNone or strThe name of the parameter in the ODE to which the first time-derivative of the control value is connected.

rate2_targetsNone or strThe name of the parameter in the ODE to which the second time-derivative of the control value is connected.

shapeSequence of intThe shape of the control variable at each point in time.

## add_parameter#

- Phase.add_parameter(
name,val=unspecified,units=unspecified,opt=False,desc=unspecified,lower=unspecified,upper=unspecified,scaler=unspecified,adder=unspecified,ref0=unspecified,ref=unspecified,targets=unspecified,shape=unspecified,dynamic=unspecified,static_target=unspecified,include_timeseries=unspecified)[source]Add a parameter (static control variable) to the phase.

- Parameters

namestrName of the parameter.

valfloat or ndarrayDefault value of the parameter at all nodes.

unitsstr or None or 0Units in which the parameter is defined. If 0, use the units declared for the parameter in the ODE.

optboolIf True, the value(s) of this parameter will be design variables in the optimization problem, in the path ‘phase_name.indep_controls.controls:control_name’. If False (default), the this parameter will still be owned by an IndepVarComp in the phase, but it will not be a design variable in the optimization.

descstrA description of the parameter.

lowerfloat or ndarrayThe lower bound of the parameter value.

upperfloat or ndarrayThe upper bound of the parameter value.

scalerfloat or ndarrayThe scaler of the parameter value for the optimizer.

adderfloat or ndarrayThe adder of the parameter value for the optimizer.

ref0float or ndarrayThe zero-reference value of the parameter for the optimizer.

reffloat or ndarrayThe unit-reference value of the parameter for the optimizer.

targetsSequence of str or NoneTargets in the ODE to which this parameter is connected. In the future, if left _unspecified (the default), the phase parameter will try to connect to an ODE input of the same name. Set targets to None to prevent this.

shapeSequence of intThe shape of the parameter.

dynamicboolTrue if the targets in the ODE may be dynamic (if the inputs are sized to the number of nodes) else False.

static_targetbool or _unspecifiedTrue if the targets in the ODE are not shaped with num_nodes as the first dimension (meaning they cannot have a unique value at each node). Otherwise False.

include_timeseriesboolTrue if the static parameters should be included in output timeseries, else False.

## set_parameter_options#

- Phase.set_parameter_options(
name,val=unspecified,units=unspecified,opt=False,desc=unspecified,lower=unspecified,upper=unspecified,scaler=unspecified,adder=unspecified,ref0=unspecified,ref=unspecified,targets=unspecified,shape=unspecified,dynamic=unspecified,static_target=unspecified,include_timeseries=unspecified)[source]Set options for an existing parameter (static control variable) in the phase.

- Parameters

namestrName of the parameter.

valfloat or ndarrayDefault value of the parameter at all nodes.

unitsstr or None or 0Units in which the parameter is defined. If 0, use the units declared for the parameter in the ODE.

optboolIf True the value(s) of this parameter will be design variables in the optimization problem, in the path ‘phase_name.indep_controls.controls:control_name’. If False (default), the this parameter will still be owned by an IndepVarComp in the phase, but it will not be a design variable in the optimization.

descstrA description of the parameter.

lowerfloat or ndarrayThe lower bound of the parameter value.

upperfloat or ndarrayThe upper bound of the parameter value.

scalerfloat or ndarrayThe scaler of the parameter value for the optimizer.

adderfloat or ndarrayThe adder of the parameter value for the optimizer.

ref0float or ndarrayThe zero-reference value of the parameter for the optimizer.

reffloat or ndarrayThe unit-reference value of the parameter for the optimizer.

targetsSequence of str or NoneTargets in the ODE to which this parameter is connected. In the future, if left _unspecified (the default), the phase parameter will try to connect to an ODE input of the same name. Set targets to None to prevent this.

shapeSequence of intThe shape of the parameter.

dynamicboolTrue if the targets in the ODE may be dynamic (if the inputs are sized to the number of nodes) else False. This option is deprecated.

static_targetbool or _unspecifiedTrue if the targets in the ODE are not shaped with num_nodes as the first dimension (meaning they cannot have a unique value at each node). Otherwise False.

include_timeseriesboolTrue if the static parameters should be included in output timeseries, else False.

## add_timeseries#

- Phase.add_timeseries(
name,transcription,subset='all')[source]Adds a new timeseries output upon which outputs can be provided.

- Parameters

namestrA name for the timeseries output path.

transcriptionstrA transcription object which provides a grid upon which the outputs of the timeseries are provided.

subsetstrThe name of the node subset in the given transcription at which outputs are to be provided.

## add_timeseries_output#

- Phase.add_timeseries_output(
name,output_name=None,units=unspecified,shape=unspecified,timeseries='timeseries')[source]Add a variable to the timeseries outputs of the phase.

- Parameters

namestr, or list of strThe name(s) of the variable to be used as a timeseries output. Must be one of ‘time’, ‘time_phase’, one of the states, controls, control rates, or parameters, in the phase, the path to an output variable in the ODE, or a glob pattern matching some outputs in the ODE.

output_namestr or None or list or dictThe name of the variable as listed in the phase timeseries outputs. By default this is the last element in name when split by dots. The user may override the constraint name if splitting the path causes name collisions.

unitsstr or None or _unspecifiedThe units to express the timeseries output. If None, use the units associated with the target. If provided, must be compatible with the target units. If a list of names is provided, units can be a matching list or dictionary.

shapetuple or _unspecifiedThe shape of the timeseries output variable. This must be provided (if not scalar) since Dymos doesn’t necessarily know the shape of ODE outputs until setup time.

timeseriesstr or NoneThe name of the timeseries to which the output is being added.

## add_boundary_constraint#

- Phase.add_boundary_constraint(
name,loc,constraint_name=None,units=None,shape=None,indices=None,lower=None,upper=None,equals=None,scaler=None,adder=None,ref=None,ref0=None,linear=False,flat_indices=False)[source]Add a boundary constraint to a variable in the phase.

- Parameters

namestrName of the variable to constrain. If name is not a state, control, or ‘time’, then this is assumed to be the path of the variable to be constrained in the ODE.

locstrThe location of the boundary constraint (‘initial’ or ‘final’).

constraint_namestr or NoneThe name of the variable as provided to the boundary constraint comp. By default this is the last element in name when split by dots. The user may override the constraint name if splitting the path causes name collisions.

unitsstr or NoneThe units in which the boundary constraint is to be applied. If None, use the units associated with the constrained output. If provided, must be compatible with the variables units.

shapetuple, list, ndarray, or NoneThe shape of the variable being boundary-constrained. This can be inferred automatically for time, states, controls, and parameters, but is required if the constrained variable is an output of the ODE system.

indicestuple, list, ndarray, slice, or NoneThe indices of the output variable to be boundary constrained at either the initial or final time in the phase. When the variable is multi-dimensional, this should be a list of lists, one for each dimension, containing the indices to be constrained. Note the behavior of indices changes depending on the value of the flat_indices option.

lowerfloat or ndarray, optionalLower boundary for the variable.

upperfloat or ndarray, optionalUpper boundary for the variable.

equalsfloat or ndarray, optionalEquality constraint value for the variable.

scalerfloat or ndarray, optionalValue to multiply the model value to get the scaled value. Scaler is second in precedence.

adderfloat or ndarray, optionalValue to add to the model value to get the scaled value. Adder is first in precedence.

reffloat or ndarray, optionalValue of response variable that scales to 1.0 in the driver.

ref0float or ndarray, optionalValue of response variable that scales to 0.0 in the driver.

linearboolSet to True if constraint is linear. Setting this to True when the constraint is not a linear function of the design variables will result in a failure of the optimization.

flat_indicesboolIf True, treat indices as flattened C-ordered indices of elements to constrain. Otherwise, indices should be a tuple or list giving the elements to constrain at each point in time.

## add_path_constraint#

- Phase.add_path_constraint(
name,constraint_name=None,units=None,shape=None,indices=None,lower=None,upper=None,equals=None,scaler=None,adder=None,ref=None,ref0=None,linear=False,flat_indices=False)[source]Add a path constraint to a variable in the phase.

- Parameters

namestrName of the response variable in the system.

constraint_namestr or NoneThe name of the variable as provided to the boundary constraint comp. By default this is the last element in name when split by dots. The user may override the constraint name if splitting the path causes name collisions.

unitsstr or NoneThe units in which the boundary constraint is to be applied. If None, use the units associated with the constrained output. If provided, must be compatible with the variables units.

shapetuple, list, ndarray, or NoneThe shape of the variable being boundary-constrained. This can be inferred automatically for time, states, controls, and parameters, but is required if the constrained variable is an output of the ODE system.

indicestuple, list, ndarray, or NoneThe indices of the output variable to be constrained at each point in time in the phase. When the variable is multi-dimensional, this should be a list of lists, one for each dimension, containing the indices to be constrained. Note the behavior of indices changes depending on the value of the flat_indices option.

lowerfloat or ndarray, optionalLower boundary for the variable.

upperfloat or ndarray, optionalUpper boundary for the variable.

equalsfloat or ndarray, optionalEquality constraint value for the variable.

scalerfloat or ndarray, optionalValue to multiply the model value to get the scaled value. Scaler is second in precedence.

adderfloat or ndarray, optionalValue to add to the model value to get the scaled value. Adder is first in precedence.

reffloat or ndarray, optionalValue of response variable that scales to 1.0 in the driver.

ref0float or ndarray, optionalValue of response variable that scales to 0.0 in the driver.

linearboolSet to True if constraint is linear. If set to True and the constrained output is not a linear function of the design variables, the optimization will fail.

flat_indicesboolIf True, treat indices as flattened C-ordered indices of elements to constrain at each given point in time. Otherwise, indices should be a tuple or list giving the elements to constrain at each point in time.

## simulate#

- Phase.simulate(
times_per_seg=10,method=unspecified,atol=unspecified,rtol=unspecified,first_step=unspecified,max_step=unspecified,record_file=None)[source]Simulate the Phase using scipy.integrate.solve_ivp.

- Parameters

times_per_segint or NoneNumber of equally spaced times per segment at which output is requested. If None, output will be provided at all Nodes.

methodstrThe scipy.integrate.solve_ivp integration method.

atolfloatAbsolute convergence tolerance for scipy.integrate.solve_ivp.

rtolfloatRelative convergence tolerance for scipy.integrate.solve_ivp.

first_stepfloatInitial step size for the integration.

max_stepfloatMaximum step size for the integration.

record_filestr or NoneIf a string, the file to which the result of the simulation will be saved. If None, no record of the simulation will be saved.

- Returns

- problem
An OpenMDAO Problem in which the simulation is implemented. This Problem interface can be interrogated to obtain timeseries outputs in the same manner as other Phases to obtain results at the requested times.

## set_refine_options#

- Phase.set_refine_options(
refine=unspecified,tol=unspecified,min_order=unspecified,max_order=unspecified,smoothness_factor=unspecified)[source]Set the specified option(s) for grid refinement in the phase.

- Parameters

refineboolIf True, this Phase will undergo refinement during the grid refinement procedure.

tolfloatThe error tolerance used by all grid-refinement algorithms.

min_orderintThe minimum allowable transcription order for segments in the phase. Used in hp and ph refinement methods.

max_orderintThe maximum allowable transcription order for segments in the phase. Used in hp and ph refinement methods.

smoothness_factorfloatThe maximum allowable ratio of state second derivatives. If exceeded the segment must be split. Used in hp refinement method.

## interp#

- Phase.interp(
name=None,ys=None,xs=None,nodes=None,kind='linear',axis=0)[source]Interpolate values onto the given subset of nodes in the phase.

If specified, name will be used to determine the kind of variable being interpolated.

- Parameters

namestr or NoneIf nodes is None, then use the name argument to determine which kind of variable is being interpolated. If it is a state, assume nodes is ‘state_input’. If it is related to a control, assume nodes is ‘control_input’. If it is a polynomial control, assume the nodes are the input nodes for that polynomial control. Any other type of variable will result in an error.

ysndarray or Sequence or NoneArray of control/state/parameter values.

xsndarray or Sequence or NoneArray of integration variable values.

nodesstr or NoneThe name of the node subset or None (default).

kindstrSpecifies the kind of interpolation, as per the scipy.interpolate package. One of (‘linear’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’ where ‘zero’, ‘slinear’, ‘quadratic’ and ‘cubic’ refer to a spline interpolation of zeroth, first, second or third order) or as an integer specifying the order of the spline interpolator to use. Default is ‘linear’.

axisintSpecifies the axis along which interpolation should be performed. Default is the first axis (0).

- Returns

- np.array
The values of y interpolated at nodes of the specified type.