system.py¶
Define the base System class.

class
openmdao.core.system.
System
(num_par_fd=1, **kwargs)[source]¶ Bases:
object
Base class for all systems in OpenMDAO.
Never instantiated; subclassed by <Group> or <Component>. All subclasses have their attributes defined here.
 In attribute names:
abs / abs_name : absolute, unpromoted variable name, seen from root (unique). rel / rel_name : relative, unpromoted variable name, seen from current system (unique). prom / prom_name : relative, promoted variable name, seen from current system (nonunique). idx : global variable index among variables on all procs (I/O indices separate). my_idx : index among variables in this system, on this processor (I/O indices separate). io : indicates explicitly that input and output variables are combined in the same dict.
Attributes
name
(str) Name of the system, must be different from siblings.
pathname
(str) Global name of the system, including the path.
comm
(MPI.Comm or <FakeComm>) MPI communicator object.
options
(OptionsDictionary) options dictionary
recording_options
(OptionsDictionary) Recording options dictionary
under_complex_step
(bool) When True, this system is undergoing complex step.
force_alloc_complex
(bool) When True, the vectors have been allocated for checking with complex step.
iter_count
(int) Int that holds the number of times this system has iterated in a recording run.
cite
(str) Listing of relevant citations that should be referenced when publishing work that uses this class.
supports_multivecs
(bool) If True, this system overrides compute_multi_jacvec_product (if an ExplicitComponent), or solve_multi_linear/apply_multi_linear (if an ImplicitComponent).
matrix_free
(Bool) This is set to True if the component overrides the appropriate function with a userdefined matrix vector product with the Jacobian or any of its subsystems do.

__init__
(self, num_par_fd=1, **kwargs)[source]¶ Initialize all attributes.
 Parameters
 num_par_fdint
If FD is active, number of concurrent FD solves.
 **kwargsdict of keyword arguments
Keyword arguments that will be mapped into the System options.

add_constraint
(self, name, lower=None, upper=None, equals=None, ref=None, ref0=None, adder=None, scaler=None, indices=None, linear=False, parallel_deriv_color=None, vectorize_derivs=False, cache_linear_solution=False)[source]¶ Add a constraint variable to this system.
 Parameters
 namestring
Name of the response variable in the system.
 lowerfloat or ndarray, optional
Lower boundary for the variable
 upperfloat or ndarray, optional
Upper boundary for the variable
 equalsfloat or ndarray, optional
Equality constraint value for the variable
 reffloat or ndarray, optional
Value of response variable that scales to 1.0 in the driver.
 ref0float or ndarray, optional
Value of response variable that scales to 0.0 in the driver.
 adderfloat or ndarray, optional
Value to add to the model value to get the scaled value. Adder is first in precedence.
 scalerfloat or ndarray, optional
value to multiply the model value to get the scaled value. Scaler is second in precedence.
 indicessequence of int, optional
If variable is an array, these indicate which entries are of interest for this particular response. These may be positive or negative integers.
 linearbool
Set to True if constraint is linear. Default is False.
 parallel_deriv_colorstring
If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.
 vectorize_derivsbool
If True, vectorize derivative calculations.
 cache_linear_solutionbool
If True, store the linear solution vectors for this variable so they can be used to start the next linear solution with an initial guess equal to the solution from the previous linear solve.
Notes
The response can be scaled using ref and ref0. The argument
ref0
represents the physical value when the scaled value is 0. The argumentref
represents the physical value when the scaled value is 1.

add_design_var
(self, name, lower=None, upper=None, ref=None, ref0=None, indices=None, adder=None, scaler=None, parallel_deriv_color=None, vectorize_derivs=False, cache_linear_solution=False)[source]¶ Add a design variable to this system.
 Parameters
 namestring
Name of the design variable in the system.
 lowerfloat or ndarray, optional
Lower boundary for the param
 upperupper or ndarray, optional
Upper boundary for the param
 reffloat or ndarray, optional
Value of design var that scales to 1.0 in the driver.
 ref0float or ndarray, optional
Value of design var that scales to 0.0 in the driver.
 indicesiter of int, optional
If a param is an array, these indicate which entries are of interest for this particular design variable. These may be positive or negative integers.
 adderfloat or ndarray, optional
Value to add to the model value to get the scaled value. Adder is first in precedence.
 scalerfloat or ndarray, optional
value to multiply the model value to get the scaled value. Scaler is second in precedence.
 parallel_deriv_colorstring
If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.
 vectorize_derivsbool
If True, vectorize derivative calculations.
 cache_linear_solutionbool
If True, store the linear solution vectors for this variable so they can be used to start the next linear solution with an initial guess equal to the solution from the previous linear solve.
Notes
The response can be scaled using ref and ref0. The argument
ref0
represents the physical value when the scaled value is 0. The argumentref
represents the physical value when the scaled value is 1.

add_objective
(self, name, ref=None, ref0=None, index=None, adder=None, scaler=None, parallel_deriv_color=None, vectorize_derivs=False, cache_linear_solution=False)[source]¶ Add a response variable to this system.
 Parameters
 namestring
Name of the response variable in the system.
 reffloat or ndarray, optional
Value of response variable that scales to 1.0 in the driver.
 ref0float or ndarray, optional
Value of response variable that scales to 0.0 in the driver.
 indexint, optional
If variable is an array, this indicates which entry is of interest for this particular response. This may be a positive or negative integer.
 adderfloat or ndarray, optional
Value to add to the model value to get the scaled value. Adder is first in precedence.
 scalerfloat or ndarray, optional
value to multiply the model value to get the scaled value. Scaler is second in precedence.
 parallel_deriv_colorstring
If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.
 vectorize_derivsbool
If True, vectorize derivative calculations.
 cache_linear_solutionbool
If True, store the linear solution vectors for this variable so they can be used to start the next linear solution with an initial guess equal to the solution from the previous linear solve.
Notes
The objective can be scaled using scaler and adder, where
\[x_{scaled} = scaler(x + adder)\]or through the use of ref/ref0, which map to scaler and adder through the equations:
\[ \begin{align}\begin{aligned}0 = scaler(ref_0 + adder)\\1 = scaler(ref + adder)\end{aligned}\end{align} \]which results in:
\[ \begin{align}\begin{aligned}adder = ref_0\\scaler = \frac{1}{ref + adder}\end{aligned}\end{align} \]

add_recorder
(self, recorder, recurse=False)[source]¶ Add a recorder to the driver.
 Parameters
 recorder<CaseRecorder>
A recorder instance.
 recurseboolean
Flag indicating if the recorder should be added to all the subsystems.

add_response
(self, name, type_, lower=None, upper=None, equals=None, ref=None, ref0=None, indices=None, index=None, adder=None, scaler=None, linear=False, parallel_deriv_color=None, vectorize_derivs=False, cache_linear_solution=False)[source]¶ Add a response variable to this system.
The response can be scaled using ref and ref0. The argument
ref0
represents the physical value when the scaled value is 0. The argumentref
represents the physical value when the scaled value is 1. Parameters
 namestring
Name of the response variable in the system.
 type_string
The type of response. Supported values are ‘con’ and ‘obj’
 lowerfloat or ndarray, optional
Lower boundary for the variable
 upperupper or ndarray, optional
Upper boundary for the variable
 equalsequals or ndarray, optional
Equality constraint value for the variable
 reffloat or ndarray, optional
Value of response variable that scales to 1.0 in the driver.
 ref0upper or ndarray, optional
Value of response variable that scales to 0.0 in the driver.
 indicessequence of int, optional
If variable is an array, these indicate which entries are of interest for this particular response.
 indexint, optional
If variable is an array, this indicates which entry is of interest for this particular response.
 adderfloat or ndarray, optional
Value to add to the model value to get the scaled value. Adder is first in precedence.
 scalerfloat or ndarray, optional
value to multiply the model value to get the scaled value. Scaler is second in precedence.
 linearbool
Set to True if constraint is linear. Default is False.
 parallel_deriv_colorstring
If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.
 vectorize_derivsbool
If True, vectorize derivative calculations.
 cache_linear_solutionbool
If True, store the linear solution vectors for this variable so they can be used to start the next linear solution with an initial guess equal to the solution from the previous linear solve.

check_config
(self, logger)[source]¶ Perform optional error checks.
 Parameters
 loggerobject
The object that manages logging output.

get_constraints
(self, recurse=True)[source]¶ Get the Constraint settings from this system.
Retrieve the constraint settings for the current system as a dict, keyed by variable name.
 Parameters
 recursebool, optional
If True, recurse through the subsystems and return the path of all constraints relative to the this system.
 Returns
 dict
The constraints defined in the current system.

get_design_vars
(self, recurse=True, get_sizes=True)[source]¶ Get the DesignVariable settings from this system.
Retrieve all design variable settings from the system and, if recurse is True, all of its subsystems.
 Parameters
 recursebool
If True, recurse through the subsystems and return the path of all design vars relative to the this system.
 get_sizesbool, optional
If True, compute the size of each response.
 Returns
 dict
The design variables defined in the current system and, if recurse=True, its subsystems.

get_linear_vectors
(self, vec_name='linear')[source]¶ Return the linear inputs, outputs, and residuals vectors.
 Parameters
 vec_namestr
Name of the linear righthandside vector. The default is ‘linear’.
 Returns
 (inputs, outputs, residuals)tuple of <Vector> instances
Yields the inputs, outputs, and residuals linear vectors for vec_name.

get_nonlinear_vectors
(self)[source]¶ Return the inputs, outputs, and residuals vectors.
 Returns
 (inputs, outputs, residuals)tuple of <Vector> instances
Yields the inputs, outputs, and residuals nonlinear vectors.

get_objectives
(self, recurse=True)[source]¶ Get the Objective settings from this system.
Retrieve all objectives settings from the system as a dict, keyed by variable name.
 Parameters
 recursebool, optional
If True, recurse through the subsystems and return the path of all objective relative to the this system.
 Returns
 dict
The objectives defined in the current system.

get_responses
(self, recurse=True, get_sizes=True)[source]¶ Get the response variable settings from this system.
Retrieve all response variable settings from the system as a dict, keyed by variable name.
 Parameters
 recursebool, optional
If True, recurse through the subsystems and return the path of all responses relative to the this system.
 get_sizesbool, optional
If True, compute the size of each response.
 Returns
 dict
The responses defined in the current system and, if recurse=True, its subsystems.

is_active
(self)[source]¶ Determine if the system is active on this rank.
 Returns
 bool
If running under MPI, returns True if this System has a valid communicator. Always returns True if not running under MPI.

linear_solver
¶ Get the linear solver for this system.

list_inputs
(self, values=True, prom_name=False, units=False, shape=False, hierarchical=True, print_arrays=False, out_stream=<object object at 0x7facfacd8440>)[source]¶ Return and optionally log a list of input names and other optional information.
If the model is parallel, only the local variables are returned to the process. Also optionally logs the information to a user defined output stream. If the model is parallel, the rank 0 process logs information about all variables across all processes.
 Parameters
 valuesbool, optional
When True, display/return input values. Default is True.
 prom_namebool, optional
When True, display/return the promoted name of the variable. Default is False.
 unitsbool, optional
When True, display/return units. Default is False.
 shapebool, optional
When True, display/return the shape of the value. Default is False.
 hierarchicalbool, optional
When True, human readable output shows variables in hierarchical format.
 print_arraysbool, optional
When False, in the columnar display, just display norm of any ndarrays with size > 1. The norm is surrounded by vertical bars to indicate that it is a norm. When True, also display full values of the ndarray below the row. Format is affected by the values set with numpy.set_printoptions Default is False.
 out_streamfilelike object
Where to send human readable output. Default is sys.stdout. Set to None to suppress.
 Returns
 list
list of input names and other optional information about those inputs

list_outputs
(self, explicit=True, implicit=True, values=True, prom_name=False, residuals=False, residuals_tol=None, units=False, shape=False, bounds=False, scaling=False, hierarchical=True, print_arrays=False, out_stream=<object object at 0x7facfacd8440>)[source]¶ Return and optionally log a list of output names and other optional information.
If the model is parallel, only the local variables are returned to the process. Also optionally logs the information to a user defined output stream. If the model is parallel, the rank 0 process logs information about all variables across all processes.
 Parameters
 explicitbool, optional
include outputs from explicit components. Default is True.
 implicitbool, optional
include outputs from implicit components. Default is True.
 valuesbool, optional
When True, display/return output values. Default is True.
 prom_namebool, optional
When True, display/return the promoted name of the variable. Default is False.
 residualsbool, optional
When True, display/return residual values. Default is False.
 residuals_tolfloat, optional
If set, limits the output of list_outputs to only variables where the norm of the resids array is greater than the given ‘residuals_tol’. Default is None.
 unitsbool, optional
When True, display/return units. Default is False.
 shapebool, optional
When True, display/return the shape of the value. Default is False.
 boundsbool, optional
When True, display/return bounds (lower and upper). Default is False.
 scalingbool, optional
When True, display/return scaling (ref, ref0, and res_ref). Default is False.
 hierarchicalbool, optional
When True, human readable output shows variables in hierarchical format.
 print_arraysbool, optional
When False, in the columnar display, just display norm of any ndarrays with size > 1. The norm is surrounded by vertical bars to indicate that it is a norm. When True, also display full values of the ndarray below the row. Format is affected by the values set with numpy.set_printoptions Default is False.
 out_streamfilelike
Where to send human readable output. Default is sys.stdout. Set to None to suppress.
 Returns
 list
list of output names and other optional information about those outputs

ln_solver
¶ Get the linear solver for this system.

metadata
¶ Get the options for this System.

nl_solver
¶ Get the nonlinear solver for this system.

nonlinear_solver
¶ Get the nonlinear solver for this system.

reconfigure
(self)[source]¶ Perform reconfiguration.
 Returns
 bool
If True, reconfiguration is to be performed.

resetup
(self, setup_mode='full')[source]¶ Public wrapper for _setup that reconfigures after an initial setup has been performed.
 Parameters
 setup_modestr
Must be one of ‘full’, ‘reconf’, or ‘update’.

run_apply_linear
(self, vec_names, mode, scope_out=None, scope_in=None)[source]¶ Compute jacvec product.
This calls _apply_linear, but with the model assumed to be in an unscaled state.
 Parameters
 vec_names[str, …]
list of names of the righthandside vectors.
 modestr
‘fwd’ or ‘rev’.
 scope_outset or None
Set of absolute output names in the scope of this matvec product. If None, all are in the scope.
 scope_inset or None
Set of absolute input names in the scope of this matvec product. If None, all are in the scope.

run_apply_nonlinear
(self)[source]¶ Compute residuals.
This calls _apply_nonlinear, but with the model assumed to be in an unscaled state.

run_linearize
(self, sub_do_ln=True)[source]¶ Compute jacobian / factorization.
This calls _linearize, but with the model assumed to be in an unscaled state.
 Parameters
 sub_do_lnboolean
Flag indicating if the children should call linearize on their linear solvers.

run_solve_linear
(self, vec_names, mode)[source]¶ Apply inverse jac product.
This calls _solve_linear, but with the model assumed to be in an unscaled state.
 Parameters
 vec_names[str, …]
list of names of the righthandside vectors.
 modestr
‘fwd’ or ‘rev’.

run_solve_nonlinear
(self)[source]¶ Compute outputs.
This calls _solve_nonlinear, but with the model assumed to be in an unscaled state.

set_initial_values
(self)[source]¶ Set all input and output variables to their declared initial values.

system_iter
(self, include_self=False, recurse=True, typ=None)[source]¶ Yield a generator of local subsystems of this system.
 Parameters
 include_selfbool
If True, include this system in the iteration.
 recursebool
If True, iterate over the whole tree under this system.
 typtype
If not None, only yield Systems that match that are instances of the given type.

openmdao.core.system.
get_relevant_vars
(connections, desvars, responses, mode)[source]¶ Find all relevant vars between desvars and responses.
Both vars are assumed to be outputs (either design vars or responses).
 Parameters
 connectionsdict
Mapping of targets to their sources.
 desvarslist of str
Names of design variables.
 responseslist of str
Names of response variables.
 modestr
Direction of derivatives, either ‘fwd’ or ‘rev’.
 Returns
 dict
Dict of ({‘outputs’: dep_outputs, ‘inputs’: dep_inputs, dep_systems) keyed by design vars and responses.