sellar.py

Test objects for the sellar two discipline problem.

From Sellar’s analytic problem.

Sellar, R. S., Batill, S. M., and Renaud, J. E., “Response Surface Based, Concurrent Subspace Optimization for Multidisciplinary System Design,” Proceedings References 79 of the 34th AIAA Aerospace Sciences Meeting and Exhibit, Reno, NV, January 1996.

class openmdao.test_suite.components.sellar.SellarDerivatives(**kwargs)[source]

Bases: openmdao.core.group.Group

Group containing the Sellar MDA. This version uses the disciplines with derivatives.

__init__(self, **kwargs)

Set the solvers to nonlinear and linear block Gauss–Seidel by default.

Parameters
**kwargsdict

dict of arguments available here and in all descendants of this Group.

add(self, name, subsys, promotes=None)

Add a subsystem (deprecated version of <Group.add_subsystem>).

Parameters
namestr

Name of the subsystem being added

subsysSystem

An instantiated, but not-yet-set up system object.

promotesiter of str, optional

A list of variable names specifying which subsystem variables to ‘promote’ up to this group. This is for backwards compatibility with older versions of OpenMDAO.

Returns
System

The System that was passed in.

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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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)

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)

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 argument ref 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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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.

add_subsystem(self, name, subsys, promotes=None, promotes_inputs=None, promotes_outputs=None, min_procs=1, max_procs=None, proc_weight=1.0)

Add a subsystem.

Parameters
namestr

Name of the subsystem being added

subsys<System>

An instantiated, but not-yet-set up system object.

promotesiter of (str or tuple), optional

A list of variable names specifying which subsystem variables to ‘promote’ up to this group. If an entry is a tuple of the form (old_name, new_name), this will rename the variable in the parent group.

promotes_inputsiter of (str or tuple), optional

A list of input variable names specifying which subsystem input variables to ‘promote’ up to this group. If an entry is a tuple of the form (old_name, new_name), this will rename the variable in the parent group.

promotes_outputsiter of (str or tuple), optional

A list of output variable names specifying which subsystem output variables to ‘promote’ up to this group. If an entry is a tuple of the form (old_name, new_name), this will rename the variable in the parent group.

min_procsint

Minimum number of MPI processes usable by the subsystem. Defaults to 1.

max_procsint or None

Maximum number of MPI processes usable by the subsystem. A value of None (the default) indicates there is no maximum limit.

proc_weightfloat

Weight given to the subsystem when allocating available MPI processes to all subsystems. Default is 1.0.

Returns
<System>

the subsystem that was passed in. This is returned to enable users to instantiate and add a subsystem at the same time, and get the reference back.

approx_totals(self, method='fd', step=None, form=None, step_calc=None)

Approximate derivatives for a Group using the specified approximation method.

Parameters
methodstr

The type of approximation that should be used. Valid options include: ‘fd’: Finite Difference, ‘cs’: Complex Step

stepfloat

Step size for approximation. Defaults to None, in which case, the approximation method provides its default value.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Defaults to None, in which case, the approximation method provides its default value.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Defaults to None, in which case, the approximation method provides its default value.

check_config(self, logger)

Perform optional error checks.

Parameters
loggerobject

The object that manages logging output.

cleanup(self)

Clean up resources prior to exit.

compute_sys_graph(self, comps_only=False)

Compute a dependency graph for subsystems in this group.

Variable connection information is stored in each edge of the system graph.

Parameters
comps_onlybool (False)

If True, return a graph of all components within this group or any of its descendants. No sub-groups will be included. Otherwise, a graph containing only direct children (both Components and Groups) of this group will be returned.

Returns
DiGraph

A directed graph containing names of subsystems and their connections.

configure(self)

Configure this group to assign children settings.

This method may optionally be overidden by your Group’s method.

You may only use this method to change settings on your children subsystems. This includes setting solvers in cases where you want to override the defaults.

You can assume that the full hierarchy below your level has been instantiated and has already called its own configure methods.

Available attributes:

name pathname comm options system hieararchy with attribute access

connect(self, src_name, tgt_name, src_indices=None, flat_src_indices=None)

Connect source src_name to target tgt_name in this namespace.

Parameters
src_namestr

name of the source variable to connect

tgt_namestr or [str, … ] or (str, …)

name of the target variable(s) to connect

src_indicesint or list of ints or tuple of ints or int ndarray or Iterable or None

The global indices of the source variable to transfer data from. The shapes of the target and src_indices must match, and form of the entries within is determined by the value of ‘flat_src_indices’.

flat_src_indicesbool

If True, each entry of src_indices is assumed to be an index into the flattened source. Otherwise it must be a tuple or list of size equal to the number of dimensions of the source.

declare_coloring(self, wrt=('*', ), method='fd', form=None, step=None, per_instance=False, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, show_summary=True, show_sparsity=False)

Set options for deriv coloring of a set of wrt vars matching the given pattern(s).

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain input names, output names, or glob patterns.

methodstr

Method used to compute derivative: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference. Leave undeclared to keep unchanged from previous or default value.

per_instancebool

If True, a separate coloring will be generated for each instance of a given class. Otherwise, only one coloring for a given class will be generated and all instances of that class will use it.

num_full_jacsint

Number of times to repeat partial jacobian computation when computing sparsity.

tolfloat

Tolerance used to determine if an array entry is nonzero during sparsity determination.

ordersint

Number of orders above and below the tolerance to check during the tolerance sweep.

perturb_sizefloat

Size of input/output perturbation during generation of sparsity.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

If True, display sparsity with coloring info after generating coloring.

get_approx_coloring_fname(self)

Return the full pathname to a coloring file.

Parameters
systemSystem

The System having its coloring saved or loaded.

Returns
str

Full pathname of the coloring file.

get_constraints(self, recurse=True)

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)

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 design variable.

Returns
dict

The design variables defined in the current system and, if recurse=True, its subsystems.

get_linear_vectors(self, vec_name='linear')

Return the linear inputs, outputs, and residuals vectors.

Parameters
vec_namestr

Name of the linear right-hand-side 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)

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)

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)

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.

guess_nonlinear(self, inputs, outputs, residuals, discrete_inputs=None, discrete_outputs=None)

Provide initial guess for states.

Override this method to set the initial guess for states.

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

outputsVector

unscaled, dimensional output variables read via outputs[key]

residualsVector

unscaled, dimensional residuals written to via residuals[key]

discrete_inputsdict or None

If not None, dict containing discrete input values.

discrete_outputsdict or None

If not None, dict containing discrete output values.

initialize(self)[source]

Perform any one-time initialization run at instantiation.

is_active(self)

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.

property 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only inputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only outputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like

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

property ln_solver

Get the linear solver for this system.

property metadata

Get the options for this System.

property msginfo

Our instance pathname, if available, or our class name. For use in error messages.

Returns
str

Either our instance pathname or class name.

property nl_solver

Get the nonlinear solver for this system.

property nonlinear_solver

Get the nonlinear solver for this system.

reconfigure(self)

Perform reconfiguration.

Returns
bool

If True, reconfiguration is to be performed.

record_iteration(self)

Record an iteration of the current System.

resetup(self, setup_mode='full')

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)

Compute jac-vec 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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

scope_outset or None

Set of absolute output names in the scope of this mat-vec product. If None, all are in the scope.

scope_inset or None

Set of absolute input names in the scope of this mat-vec product. If None, all are in the scope.

run_apply_nonlinear(self)

Compute residuals.

This calls _apply_nonlinear, but with the model assumed to be in an unscaled state.

run_linearize(self, sub_do_ln=True)

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)

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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear(self)

Compute outputs.

This calls _solve_nonlinear, but with the model assumed to be in an unscaled state.

set_initial_values(self)

Set all input and output variables to their declared initial values.

set_order(self, new_order)

Specify a new execution order for this system.

Parameters
new_orderlist of str

List of system names in desired new execution order.

setup(self)[source]

Build this group.

This method should be overidden by your Group’s method. The reason for using this method to add subsystem is to save memory and setup time when using your Group while running under MPI. This avoids the creation of systems that will not be used in the current process.

You may call ‘add_subsystem’ to add systems to this group. You may also issue connections, and set the linear and nonlinear solvers for this group level. You cannot safely change anything on children systems; use the ‘configure’ method instead.

Available attributes:

name pathname comm options

system_iter(self, include_self=False, recurse=True, typ=None)

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.

use_fixed_coloring(self, coloring=<object object at 0x7f338004ca50>, recurse=True)

Use a precomputed coloring for this System.

Parameters
coloringstr

A coloring filename. If no arg is passed, filename will be determined automatically.

recursebool

If True, set fixed coloring in all subsystems that declare a coloring. Ignored if a specific coloring is passed in.

class openmdao.test_suite.components.sellar.SellarDerivativesConnected(**kwargs)[source]

Bases: openmdao.core.group.Group

Group containing the Sellar MDA. This version uses the disciplines with derivatives.

__init__(self, **kwargs)

Set the solvers to nonlinear and linear block Gauss–Seidel by default.

Parameters
**kwargsdict

dict of arguments available here and in all descendants of this Group.

add(self, name, subsys, promotes=None)

Add a subsystem (deprecated version of <Group.add_subsystem>).

Parameters
namestr

Name of the subsystem being added

subsysSystem

An instantiated, but not-yet-set up system object.

promotesiter of str, optional

A list of variable names specifying which subsystem variables to ‘promote’ up to this group. This is for backwards compatibility with older versions of OpenMDAO.

Returns
System

The System that was passed in.

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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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)

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)

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 argument ref 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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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.

add_subsystem(self, name, subsys, promotes=None, promotes_inputs=None, promotes_outputs=None, min_procs=1, max_procs=None, proc_weight=1.0)

Add a subsystem.

Parameters
namestr

Name of the subsystem being added

subsys<System>

An instantiated, but not-yet-set up system object.

promotesiter of (str or tuple), optional

A list of variable names specifying which subsystem variables to ‘promote’ up to this group. If an entry is a tuple of the form (old_name, new_name), this will rename the variable in the parent group.

promotes_inputsiter of (str or tuple), optional

A list of input variable names specifying which subsystem input variables to ‘promote’ up to this group. If an entry is a tuple of the form (old_name, new_name), this will rename the variable in the parent group.

promotes_outputsiter of (str or tuple), optional

A list of output variable names specifying which subsystem output variables to ‘promote’ up to this group. If an entry is a tuple of the form (old_name, new_name), this will rename the variable in the parent group.

min_procsint

Minimum number of MPI processes usable by the subsystem. Defaults to 1.

max_procsint or None

Maximum number of MPI processes usable by the subsystem. A value of None (the default) indicates there is no maximum limit.

proc_weightfloat

Weight given to the subsystem when allocating available MPI processes to all subsystems. Default is 1.0.

Returns
<System>

the subsystem that was passed in. This is returned to enable users to instantiate and add a subsystem at the same time, and get the reference back.

approx_totals(self, method='fd', step=None, form=None, step_calc=None)

Approximate derivatives for a Group using the specified approximation method.

Parameters
methodstr

The type of approximation that should be used. Valid options include: ‘fd’: Finite Difference, ‘cs’: Complex Step

stepfloat

Step size for approximation. Defaults to None, in which case, the approximation method provides its default value.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Defaults to None, in which case, the approximation method provides its default value.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Defaults to None, in which case, the approximation method provides its default value.

check_config(self, logger)

Perform optional error checks.

Parameters
loggerobject

The object that manages logging output.

cleanup(self)

Clean up resources prior to exit.

compute_sys_graph(self, comps_only=False)

Compute a dependency graph for subsystems in this group.

Variable connection information is stored in each edge of the system graph.

Parameters
comps_onlybool (False)

If True, return a graph of all components within this group or any of its descendants. No sub-groups will be included. Otherwise, a graph containing only direct children (both Components and Groups) of this group will be returned.

Returns
DiGraph

A directed graph containing names of subsystems and their connections.

configure(self)

Configure this group to assign children settings.

This method may optionally be overidden by your Group’s method.

You may only use this method to change settings on your children subsystems. This includes setting solvers in cases where you want to override the defaults.

You can assume that the full hierarchy below your level has been instantiated and has already called its own configure methods.

Available attributes:

name pathname comm options system hieararchy with attribute access

connect(self, src_name, tgt_name, src_indices=None, flat_src_indices=None)

Connect source src_name to target tgt_name in this namespace.

Parameters
src_namestr

name of the source variable to connect

tgt_namestr or [str, … ] or (str, …)

name of the target variable(s) to connect

src_indicesint or list of ints or tuple of ints or int ndarray or Iterable or None

The global indices of the source variable to transfer data from. The shapes of the target and src_indices must match, and form of the entries within is determined by the value of ‘flat_src_indices’.

flat_src_indicesbool

If True, each entry of src_indices is assumed to be an index into the flattened source. Otherwise it must be a tuple or list of size equal to the number of dimensions of the source.

declare_coloring(self, wrt=('*', ), method='fd', form=None, step=None, per_instance=False, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, show_summary=True, show_sparsity=False)

Set options for deriv coloring of a set of wrt vars matching the given pattern(s).

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain input names, output names, or glob patterns.

methodstr

Method used to compute derivative: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference. Leave undeclared to keep unchanged from previous or default value.

per_instancebool

If True, a separate coloring will be generated for each instance of a given class. Otherwise, only one coloring for a given class will be generated and all instances of that class will use it.

num_full_jacsint

Number of times to repeat partial jacobian computation when computing sparsity.

tolfloat

Tolerance used to determine if an array entry is nonzero during sparsity determination.

ordersint

Number of orders above and below the tolerance to check during the tolerance sweep.

perturb_sizefloat

Size of input/output perturbation during generation of sparsity.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

If True, display sparsity with coloring info after generating coloring.

get_approx_coloring_fname(self)

Return the full pathname to a coloring file.

Parameters
systemSystem

The System having its coloring saved or loaded.

Returns
str

Full pathname of the coloring file.

get_constraints(self, recurse=True)

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)

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 design variable.

Returns
dict

The design variables defined in the current system and, if recurse=True, its subsystems.

get_linear_vectors(self, vec_name='linear')

Return the linear inputs, outputs, and residuals vectors.

Parameters
vec_namestr

Name of the linear right-hand-side 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)

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)

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)

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.

guess_nonlinear(self, inputs, outputs, residuals, discrete_inputs=None, discrete_outputs=None)

Provide initial guess for states.

Override this method to set the initial guess for states.

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

outputsVector

unscaled, dimensional output variables read via outputs[key]

residualsVector

unscaled, dimensional residuals written to via residuals[key]

discrete_inputsdict or None

If not None, dict containing discrete input values.

discrete_outputsdict or None

If not None, dict containing discrete output values.

initialize(self)

Perform any one-time initialization run at instantiation.

is_active(self)

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.

property 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only inputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only outputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like

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

property ln_solver

Get the linear solver for this system.

property metadata

Get the options for this System.

property msginfo

Our instance pathname, if available, or our class name. For use in error messages.

Returns
str

Either our instance pathname or class name.

property nl_solver

Get the nonlinear solver for this system.

property nonlinear_solver

Get the nonlinear solver for this system.

reconfigure(self)

Perform reconfiguration.

Returns
bool

If True, reconfiguration is to be performed.

record_iteration(self)

Record an iteration of the current System.

resetup(self, setup_mode='full')

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)

Compute jac-vec 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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

scope_outset or None

Set of absolute output names in the scope of this mat-vec product. If None, all are in the scope.

scope_inset or None

Set of absolute input names in the scope of this mat-vec product. If None, all are in the scope.

run_apply_nonlinear(self)

Compute residuals.

This calls _apply_nonlinear, but with the model assumed to be in an unscaled state.

run_linearize(self, sub_do_ln=True)

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)

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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear(self)

Compute outputs.

This calls _solve_nonlinear, but with the model assumed to be in an unscaled state.

set_initial_values(self)

Set all input and output variables to their declared initial values.

set_order(self, new_order)

Specify a new execution order for this system.

Parameters
new_orderlist of str

List of system names in desired new execution order.

setup(self)[source]

Build this group.

This method should be overidden by your Group’s method. The reason for using this method to add subsystem is to save memory and setup time when using your Group while running under MPI. This avoids the creation of systems that will not be used in the current process.

You may call ‘add_subsystem’ to add systems to this group. You may also issue connections, and set the linear and nonlinear solvers for this group level. You cannot safely change anything on children systems; use the ‘configure’ method instead.

Available attributes:

name pathname comm options

system_iter(self, include_self=False, recurse=True, typ=None)

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.

use_fixed_coloring(self, coloring=<object object at 0x7f338004ca50>, recurse=True)

Use a precomputed coloring for this System.

Parameters
coloringstr

A coloring filename. If no arg is passed, filename will be determined automatically.

recursebool

If True, set fixed coloring in all subsystems that declare a coloring. Ignored if a specific coloring is passed in.

class openmdao.test_suite.components.sellar.SellarDerivativesGrouped(**kwargs)[source]

Bases: openmdao.core.group.Group

Group containing the Sellar MDA. This version uses the disciplines with derivatives.

__init__(self, **kwargs)

Set the solvers to nonlinear and linear block Gauss–Seidel by default.

Parameters
**kwargsdict

dict of arguments available here and in all descendants of this Group.

add(self, name, subsys, promotes=None)

Add a subsystem (deprecated version of <Group.add_subsystem>).

Parameters
namestr

Name of the subsystem being added

subsysSystem

An instantiated, but not-yet-set up system object.

promotesiter of str, optional

A list of variable names specifying which subsystem variables to ‘promote’ up to this group. This is for backwards compatibility with older versions of OpenMDAO.

Returns
System

The System that was passed in.

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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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)

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)

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 argument ref 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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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.

add_subsystem(self, name, subsys, promotes=None, promotes_inputs=None, promotes_outputs=None, min_procs=1, max_procs=None, proc_weight=1.0)

Add a subsystem.

Parameters
namestr

Name of the subsystem being added

subsys<System>

An instantiated, but not-yet-set up system object.

promotesiter of (str or tuple), optional

A list of variable names specifying which subsystem variables to ‘promote’ up to this group. If an entry is a tuple of the form (old_name, new_name), this will rename the variable in the parent group.

promotes_inputsiter of (str or tuple), optional

A list of input variable names specifying which subsystem input variables to ‘promote’ up to this group. If an entry is a tuple of the form (old_name, new_name), this will rename the variable in the parent group.

promotes_outputsiter of (str or tuple), optional

A list of output variable names specifying which subsystem output variables to ‘promote’ up to this group. If an entry is a tuple of the form (old_name, new_name), this will rename the variable in the parent group.

min_procsint

Minimum number of MPI processes usable by the subsystem. Defaults to 1.

max_procsint or None

Maximum number of MPI processes usable by the subsystem. A value of None (the default) indicates there is no maximum limit.

proc_weightfloat

Weight given to the subsystem when allocating available MPI processes to all subsystems. Default is 1.0.

Returns
<System>

the subsystem that was passed in. This is returned to enable users to instantiate and add a subsystem at the same time, and get the reference back.

approx_totals(self, method='fd', step=None, form=None, step_calc=None)

Approximate derivatives for a Group using the specified approximation method.

Parameters
methodstr

The type of approximation that should be used. Valid options include: ‘fd’: Finite Difference, ‘cs’: Complex Step

stepfloat

Step size for approximation. Defaults to None, in which case, the approximation method provides its default value.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Defaults to None, in which case, the approximation method provides its default value.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Defaults to None, in which case, the approximation method provides its default value.

check_config(self, logger)

Perform optional error checks.

Parameters
loggerobject

The object that manages logging output.

cleanup(self)

Clean up resources prior to exit.

compute_sys_graph(self, comps_only=False)

Compute a dependency graph for subsystems in this group.

Variable connection information is stored in each edge of the system graph.

Parameters
comps_onlybool (False)

If True, return a graph of all components within this group or any of its descendants. No sub-groups will be included. Otherwise, a graph containing only direct children (both Components and Groups) of this group will be returned.

Returns
DiGraph

A directed graph containing names of subsystems and their connections.

configure(self)[source]

Configure this group to assign children settings.

This method may optionally be overidden by your Group’s method.

You may only use this method to change settings on your children subsystems. This includes setting solvers in cases where you want to override the defaults.

You can assume that the full hierarchy below your level has been instantiated and has already called its own configure methods.

Available attributes:

name pathname comm options system hieararchy with attribute access

connect(self, src_name, tgt_name, src_indices=None, flat_src_indices=None)

Connect source src_name to target tgt_name in this namespace.

Parameters
src_namestr

name of the source variable to connect

tgt_namestr or [str, … ] or (str, …)

name of the target variable(s) to connect

src_indicesint or list of ints or tuple of ints or int ndarray or Iterable or None

The global indices of the source variable to transfer data from. The shapes of the target and src_indices must match, and form of the entries within is determined by the value of ‘flat_src_indices’.

flat_src_indicesbool

If True, each entry of src_indices is assumed to be an index into the flattened source. Otherwise it must be a tuple or list of size equal to the number of dimensions of the source.

declare_coloring(self, wrt=('*', ), method='fd', form=None, step=None, per_instance=False, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, show_summary=True, show_sparsity=False)

Set options for deriv coloring of a set of wrt vars matching the given pattern(s).

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain input names, output names, or glob patterns.

methodstr

Method used to compute derivative: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference. Leave undeclared to keep unchanged from previous or default value.

per_instancebool

If True, a separate coloring will be generated for each instance of a given class. Otherwise, only one coloring for a given class will be generated and all instances of that class will use it.

num_full_jacsint

Number of times to repeat partial jacobian computation when computing sparsity.

tolfloat

Tolerance used to determine if an array entry is nonzero during sparsity determination.

ordersint

Number of orders above and below the tolerance to check during the tolerance sweep.

perturb_sizefloat

Size of input/output perturbation during generation of sparsity.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

If True, display sparsity with coloring info after generating coloring.

get_approx_coloring_fname(self)

Return the full pathname to a coloring file.

Parameters
systemSystem

The System having its coloring saved or loaded.

Returns
str

Full pathname of the coloring file.

get_constraints(self, recurse=True)

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)

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 design variable.

Returns
dict

The design variables defined in the current system and, if recurse=True, its subsystems.

get_linear_vectors(self, vec_name='linear')

Return the linear inputs, outputs, and residuals vectors.

Parameters
vec_namestr

Name of the linear right-hand-side 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)

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)

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)

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.

guess_nonlinear(self, inputs, outputs, residuals, discrete_inputs=None, discrete_outputs=None)

Provide initial guess for states.

Override this method to set the initial guess for states.

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

outputsVector

unscaled, dimensional output variables read via outputs[key]

residualsVector

unscaled, dimensional residuals written to via residuals[key]

discrete_inputsdict or None

If not None, dict containing discrete input values.

discrete_outputsdict or None

If not None, dict containing discrete output values.

initialize(self)[source]

Perform any one-time initialization run at instantiation.

is_active(self)

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.

property 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only inputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only outputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like

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

property ln_solver

Get the linear solver for this system.

property metadata

Get the options for this System.

property msginfo

Our instance pathname, if available, or our class name. For use in error messages.

Returns
str

Either our instance pathname or class name.

property nl_solver

Get the nonlinear solver for this system.

property nonlinear_solver

Get the nonlinear solver for this system.

reconfigure(self)

Perform reconfiguration.

Returns
bool

If True, reconfiguration is to be performed.

record_iteration(self)

Record an iteration of the current System.

resetup(self, setup_mode='full')

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)

Compute jac-vec 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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

scope_outset or None

Set of absolute output names in the scope of this mat-vec product. If None, all are in the scope.

scope_inset or None

Set of absolute input names in the scope of this mat-vec product. If None, all are in the scope.

run_apply_nonlinear(self)

Compute residuals.

This calls _apply_nonlinear, but with the model assumed to be in an unscaled state.

run_linearize(self, sub_do_ln=True)

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)

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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear(self)

Compute outputs.

This calls _solve_nonlinear, but with the model assumed to be in an unscaled state.

set_initial_values(self)

Set all input and output variables to their declared initial values.

set_order(self, new_order)

Specify a new execution order for this system.

Parameters
new_orderlist of str

List of system names in desired new execution order.

setup(self)[source]

Build this group.

This method should be overidden by your Group’s method. The reason for using this method to add subsystem is to save memory and setup time when using your Group while running under MPI. This avoids the creation of systems that will not be used in the current process.

You may call ‘add_subsystem’ to add systems to this group. You may also issue connections, and set the linear and nonlinear solvers for this group level. You cannot safely change anything on children systems; use the ‘configure’ method instead.

Available attributes:

name pathname comm options

system_iter(self, include_self=False, recurse=True, typ=None)

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.

use_fixed_coloring(self, coloring=<object object at 0x7f338004ca50>, recurse=True)

Use a precomputed coloring for this System.

Parameters
coloringstr

A coloring filename. If no arg is passed, filename will be determined automatically.

recursebool

If True, set fixed coloring in all subsystems that declare a coloring. Ignored if a specific coloring is passed in.

class openmdao.test_suite.components.sellar.SellarDis1(units=None, scaling=None)[source]

Bases: openmdao.core.explicitcomponent.ExplicitComponent

Component containing Discipline 1 – no derivatives version.

__init__(self, units=None, scaling=None)[source]

Store some bound methods so we can detect runtime overrides.

Parameters
**kwargsdict of keyword arguments

Keyword arguments that will be mapped into the Component 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref represents the physical value when the scaled value is 1.

add_discrete_input(self, name, val, desc='', tags=None)

Add a discrete input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_discrete_output(self, name, val, desc='', tags=None)

Add an output variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable.

tagsstr or list of strs or set of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_input(self, name, val=1.0, shape=None, src_indices=None, flat_src_indices=None, units=None, desc='', tags=None)

Add an input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray or Iterable

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if src_indices not provided and val is not an array. Default is None.

src_indicesint or list of ints or tuple of ints or int ndarray or Iterable or None

The global indices of the source variable to transfer data from. A value of None implies this input depends on all entries of source. Default is None. The shapes of the target and src_indices must match, and form of the entries within is determined by the value of ‘flat_src_indices’.

flat_src_indicesbool

If True, each entry of src_indices is assumed to be an index into the flattened source. Otherwise each entry must be a tuple or list of size equal to the number of dimensions of the source.

unitsstr or None

Units in which this input variable will be provided to the component during execution. Default is None, which means it is unitless.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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_output(self, name, val=1.0, shape=None, units=None, res_units=None, desc='', lower=None, upper=None, ref=1.0, ref0=0.0, res_ref=None, tags=None)

Add an output variable to the component.

For ExplicitComponent, res_ref defaults to the value in res unless otherwise specified.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if val is not an array. Default is None.

unitsstr or None

Units in which the output variables will be provided to the component during execution. Default is None, which means it has no units.

res_unitsstr or None

Units in which the residuals of this output will be given to the user when requested. Default is None, which means it has no units.

descstr

description of the variable.

lowerfloat or list or tuple or ndarray or None

lower bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no lower bound. Default is None.

upperfloat or list or tuple or ndarray or None

upper bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no upper bound. Default is None.

reffloat

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 1. Default is 1.

ref0float

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 0. Default is 0.

res_reffloat

Scaling parameter. The value in the user-defined res_units of this output’s residual when the scaled value is 1. Default is None, which means residual scaling matches output scaling.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs and also when listing results from case recorders.

Returns
dict

metadata for added variable

add_recorder(self, recorder, recurse=False)

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)

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 argument ref 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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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)

Perform optional error checks.

Parameters
loggerobject

The object that manages logging output.

cleanup(self)

Clean up resources prior to exit.

compute(self, inputs, outputs)[source]

Evaluates the equation y1 = z1**2 + z2 + x1 - 0.2*y2

compute_jacvec_product(self, inputs, d_inputs, d_outputs, mode, discrete_inputs=None)

Compute jac-vector product. The model is assumed to be in an unscaled state.

If mode is:

‘fwd’: d_inputs |-> d_outputs

‘rev’: d_outputs |-> d_inputs

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

d_inputsVector

see inputs; product must be computed only if var_name in d_inputs

d_outputsVector

see outputs; product must be computed only if var_name in d_outputs

modestr

either ‘fwd’ or ‘rev’

discrete_inputsdict or None

If not None, dict containing discrete input values.

compute_partials(self, inputs, partials, discrete_inputs=None)

Compute sub-jacobian parts. The model is assumed to be in an unscaled state.

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

partialsJacobian

sub-jac components written to partials[output_name, input_name]

discrete_inputsdict or None

If not None, dict containing discrete input values.

declare_coloring(self, wrt=('*', ), method='fd', form=None, step=None, per_instance=False, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, show_summary=True, show_sparsity=False)

Set options for deriv coloring of a set of wrt vars matching the given pattern(s).

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain input names, output names, or glob patterns.

methodstr

Method used to compute derivative: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference. Leave undeclared to keep unchanged from previous or default value.

per_instancebool

If True, a separate coloring will be generated for each instance of a given class. Otherwise, only one coloring for a given class will be generated and all instances of that class will use it.

num_full_jacsint

Number of times to repeat partial jacobian computation when computing sparsity.

tolfloat

Tolerance used to determine if an array entry is nonzero during sparsity determination.

ordersint

Number of orders above and below the tolerance to check during the tolerance sweep.

perturb_sizefloat

Size of input/output perturbation during generation of sparsity.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

If True, display sparsity with coloring info after generating coloring.

declare_partials(self, of, wrt, dependent=True, rows=None, cols=None, val=None, method='exact', step=None, form=None, step_calc=None)

Declare information about this component’s subjacobians.

Parameters
ofstr or list of str

The name of the residual(s) that derivatives are being computed for. May also contain a glob pattern.

wrtstr or list of str

The name of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.

dependentbool(True)

If False, specifies no dependence between the output(s) and the input(s). This is only necessary in the case of a sparse global jacobian, because if ‘dependent=False’ is not specified and declare_partials is not called for a given pair, then a dense matrix of zeros will be allocated in the sparse global jacobian for that pair. In the case of a dense global jacobian it doesn’t matter because the space for a dense subjac will always be allocated for every pair.

rowsndarray of int or None

Row indices for each nonzero entry. For sparse subjacobians only.

colsndarray of int or None

Column indices for each nonzero entry. For sparse subjacobians only.

valfloat or ndarray of float or scipy.sparse

Value of subjacobian. If rows and cols are not None, this will contain the values found at each (row, col) location in the subjac.

methodstr

The type of approximation that should be used. Valid options include: ‘fd’: Finite Difference, ‘cs’: Complex Step, ‘exact’: use the component defined analytic derivatives. Default is ‘exact’.

stepfloat

Step size for approximation. Defaults to None, in which case the approximation method provides its default value.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Defaults to None, in which case the approximation method provides its default value.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Defaults to None, in which case the approximation method provides its default value.

Returns
dict

Metadata dict for the specified partial(s).

property distributed

Provide ‘distributed’ property for backwards compatibility.

Returns
bool

reference to the ‘distributed’ option.

get_approx_coloring_fname(self)

Return the full pathname to a coloring file.

Parameters
systemSystem

The System having its coloring saved or loaded.

Returns
str

Full pathname of the coloring file.

get_constraints(self, recurse=True)

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)

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 design variable.

Returns
dict

The design variables defined in the current system and, if recurse=True, its subsystems.

get_linear_vectors(self, vec_name='linear')

Return the linear inputs, outputs, and residuals vectors.

Parameters
vec_namestr

Name of the linear right-hand-side 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)

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)

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)

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.

initialize(self)

Perform any one-time initialization run at instantiation.

is_active(self)

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.

property 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only inputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only outputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like

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

property ln_solver

Get the linear solver for this system.

property metadata

Get the options for this System.

property msginfo

Our instance pathname, if available, or our class name. For use in error messages.

Returns
str

Either our instance pathname or class name.

property nl_solver

Get the nonlinear solver for this system.

property nonlinear_solver

Get the nonlinear solver for this system.

reconfigure(self)

Perform reconfiguration.

Returns
bool

If True, reconfiguration is to be performed.

record_iteration(self)

Record an iteration of the current System.

resetup(self, setup_mode='full')

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)

Compute jac-vec 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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

scope_outset or None

Set of absolute output names in the scope of this mat-vec product. If None, all are in the scope.

scope_inset or None

Set of absolute input names in the scope of this mat-vec product. If None, all are in the scope.

run_apply_nonlinear(self)

Compute residuals.

This calls _apply_nonlinear, but with the model assumed to be in an unscaled state.

run_linearize(self, sub_do_ln=True)

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)

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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear(self)

Compute outputs.

This calls _solve_nonlinear, but with the model assumed to be in an unscaled state.

set_check_partial_options(self, wrt, method='fd', form=None, step=None, step_calc=None, directional=False)

Set options that will be used for checking partial derivatives.

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.

methodstr

Method for check: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form for check, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference check. Leave undeclared to keep unchanged from previous or default value.

step_calcstr

Type of step calculation for check, can be “abs” for absolute (default) or “rel” for relative. Leave undeclared to keep unchanged from previous or default value.

directionalbool

Set to True to perform a single directional derivative for each vector variable in the pattern named in wrt.

set_initial_values(self)

Set all input and output variables to their declared initial values.

setup(self)[source]

Declare inputs and outputs.

Available attributes:

name pathname comm options

system_iter(self, include_self=False, recurse=True, typ=None)

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.

use_fixed_coloring(self, coloring=<object object at 0x7f338004ca50>, recurse=True)

Use a precomputed coloring for this System.

Parameters
coloringstr

A coloring filename. If no arg is passed, filename will be determined automatically.

recursebool

If True, set fixed coloring in all subsystems that declare a coloring. Ignored if a specific coloring is passed in.

class openmdao.test_suite.components.sellar.SellarDis1CS(units=None, scaling=None)[source]

Bases: openmdao.test_suite.components.sellar.SellarDis1

Component containing Discipline 1 – complex step version.

__init__(self, units=None, scaling=None)

Store some bound methods so we can detect runtime overrides.

Parameters
**kwargsdict of keyword arguments

Keyword arguments that will be mapped into the Component 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref represents the physical value when the scaled value is 1.

add_discrete_input(self, name, val, desc='', tags=None)

Add a discrete input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_discrete_output(self, name, val, desc='', tags=None)

Add an output variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable.

tagsstr or list of strs or set of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_input(self, name, val=1.0, shape=None, src_indices=None, flat_src_indices=None, units=None, desc='', tags=None)

Add an input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray or Iterable

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if src_indices not provided and val is not an array. Default is None.

src_indicesint or list of ints or tuple of ints or int ndarray or Iterable or None

The global indices of the source variable to transfer data from. A value of None implies this input depends on all entries of source. Default is None. The shapes of the target and src_indices must match, and form of the entries within is determined by the value of ‘flat_src_indices’.

flat_src_indicesbool

If True, each entry of src_indices is assumed to be an index into the flattened source. Otherwise each entry must be a tuple or list of size equal to the number of dimensions of the source.

unitsstr or None

Units in which this input variable will be provided to the component during execution. Default is None, which means it is unitless.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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_output(self, name, val=1.0, shape=None, units=None, res_units=None, desc='', lower=None, upper=None, ref=1.0, ref0=0.0, res_ref=None, tags=None)

Add an output variable to the component.

For ExplicitComponent, res_ref defaults to the value in res unless otherwise specified.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if val is not an array. Default is None.

unitsstr or None

Units in which the output variables will be provided to the component during execution. Default is None, which means it has no units.

res_unitsstr or None

Units in which the residuals of this output will be given to the user when requested. Default is None, which means it has no units.

descstr

description of the variable.

lowerfloat or list or tuple or ndarray or None

lower bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no lower bound. Default is None.

upperfloat or list or tuple or ndarray or None

upper bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no upper bound. Default is None.

reffloat

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 1. Default is 1.

ref0float

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 0. Default is 0.

res_reffloat

Scaling parameter. The value in the user-defined res_units of this output’s residual when the scaled value is 1. Default is None, which means residual scaling matches output scaling.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs and also when listing results from case recorders.

Returns
dict

metadata for added variable

add_recorder(self, recorder, recurse=False)

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)

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 argument ref 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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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)

Perform optional error checks.

Parameters
loggerobject

The object that manages logging output.

cleanup(self)

Clean up resources prior to exit.

compute(self, inputs, outputs)

Evaluates the equation y1 = z1**2 + z2 + x1 - 0.2*y2

compute_jacvec_product(self, inputs, d_inputs, d_outputs, mode, discrete_inputs=None)

Compute jac-vector product. The model is assumed to be in an unscaled state.

If mode is:

‘fwd’: d_inputs |-> d_outputs

‘rev’: d_outputs |-> d_inputs

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

d_inputsVector

see inputs; product must be computed only if var_name in d_inputs

d_outputsVector

see outputs; product must be computed only if var_name in d_outputs

modestr

either ‘fwd’ or ‘rev’

discrete_inputsdict or None

If not None, dict containing discrete input values.

compute_partials(self, inputs, partials, discrete_inputs=None)

Compute sub-jacobian parts. The model is assumed to be in an unscaled state.

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

partialsJacobian

sub-jac components written to partials[output_name, input_name]

discrete_inputsdict or None

If not None, dict containing discrete input values.

declare_coloring(self, wrt=('*', ), method='fd', form=None, step=None, per_instance=False, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, show_summary=True, show_sparsity=False)

Set options for deriv coloring of a set of wrt vars matching the given pattern(s).

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain input names, output names, or glob patterns.

methodstr

Method used to compute derivative: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference. Leave undeclared to keep unchanged from previous or default value.

per_instancebool

If True, a separate coloring will be generated for each instance of a given class. Otherwise, only one coloring for a given class will be generated and all instances of that class will use it.

num_full_jacsint

Number of times to repeat partial jacobian computation when computing sparsity.

tolfloat

Tolerance used to determine if an array entry is nonzero during sparsity determination.

ordersint

Number of orders above and below the tolerance to check during the tolerance sweep.

perturb_sizefloat

Size of input/output perturbation during generation of sparsity.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

If True, display sparsity with coloring info after generating coloring.

declare_partials(self, of, wrt, dependent=True, rows=None, cols=None, val=None, method='exact', step=None, form=None, step_calc=None)

Declare information about this component’s subjacobians.

Parameters
ofstr or list of str

The name of the residual(s) that derivatives are being computed for. May also contain a glob pattern.

wrtstr or list of str

The name of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.

dependentbool(True)

If False, specifies no dependence between the output(s) and the input(s). This is only necessary in the case of a sparse global jacobian, because if ‘dependent=False’ is not specified and declare_partials is not called for a given pair, then a dense matrix of zeros will be allocated in the sparse global jacobian for that pair. In the case of a dense global jacobian it doesn’t matter because the space for a dense subjac will always be allocated for every pair.

rowsndarray of int or None

Row indices for each nonzero entry. For sparse subjacobians only.

colsndarray of int or None

Column indices for each nonzero entry. For sparse subjacobians only.

valfloat or ndarray of float or scipy.sparse

Value of subjacobian. If rows and cols are not None, this will contain the values found at each (row, col) location in the subjac.

methodstr

The type of approximation that should be used. Valid options include: ‘fd’: Finite Difference, ‘cs’: Complex Step, ‘exact’: use the component defined analytic derivatives. Default is ‘exact’.

stepfloat

Step size for approximation. Defaults to None, in which case the approximation method provides its default value.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Defaults to None, in which case the approximation method provides its default value.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Defaults to None, in which case the approximation method provides its default value.

Returns
dict

Metadata dict for the specified partial(s).

property distributed

Provide ‘distributed’ property for backwards compatibility.

Returns
bool

reference to the ‘distributed’ option.

get_approx_coloring_fname(self)

Return the full pathname to a coloring file.

Parameters
systemSystem

The System having its coloring saved or loaded.

Returns
str

Full pathname of the coloring file.

get_constraints(self, recurse=True)

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)

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 design variable.

Returns
dict

The design variables defined in the current system and, if recurse=True, its subsystems.

get_linear_vectors(self, vec_name='linear')

Return the linear inputs, outputs, and residuals vectors.

Parameters
vec_namestr

Name of the linear right-hand-side 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)

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)

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)

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.

initialize(self)

Perform any one-time initialization run at instantiation.

is_active(self)

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.

property 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only inputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only outputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like

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

property ln_solver

Get the linear solver for this system.

property metadata

Get the options for this System.

property msginfo

Our instance pathname, if available, or our class name. For use in error messages.

Returns
str

Either our instance pathname or class name.

property nl_solver

Get the nonlinear solver for this system.

property nonlinear_solver

Get the nonlinear solver for this system.

reconfigure(self)

Perform reconfiguration.

Returns
bool

If True, reconfiguration is to be performed.

record_iteration(self)

Record an iteration of the current System.

resetup(self, setup_mode='full')

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)

Compute jac-vec 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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

scope_outset or None

Set of absolute output names in the scope of this mat-vec product. If None, all are in the scope.

scope_inset or None

Set of absolute input names in the scope of this mat-vec product. If None, all are in the scope.

run_apply_nonlinear(self)

Compute residuals.

This calls _apply_nonlinear, but with the model assumed to be in an unscaled state.

run_linearize(self, sub_do_ln=True)

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)

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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear(self)

Compute outputs.

This calls _solve_nonlinear, but with the model assumed to be in an unscaled state.

set_check_partial_options(self, wrt, method='fd', form=None, step=None, step_calc=None, directional=False)

Set options that will be used for checking partial derivatives.

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.

methodstr

Method for check: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form for check, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference check. Leave undeclared to keep unchanged from previous or default value.

step_calcstr

Type of step calculation for check, can be “abs” for absolute (default) or “rel” for relative. Leave undeclared to keep unchanged from previous or default value.

directionalbool

Set to True to perform a single directional derivative for each vector variable in the pattern named in wrt.

set_initial_values(self)

Set all input and output variables to their declared initial values.

setup(self)

Declare inputs and outputs.

Available attributes:

name pathname comm options

system_iter(self, include_self=False, recurse=True, typ=None)

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.

use_fixed_coloring(self, coloring=<object object at 0x7f338004ca50>, recurse=True)

Use a precomputed coloring for this System.

Parameters
coloringstr

A coloring filename. If no arg is passed, filename will be determined automatically.

recursebool

If True, set fixed coloring in all subsystems that declare a coloring. Ignored if a specific coloring is passed in.

class openmdao.test_suite.components.sellar.SellarDis1withDerivatives(units=None, scaling=None)[source]

Bases: openmdao.test_suite.components.sellar.SellarDis1

Component containing Discipline 1 – derivatives version.

__init__(self, units=None, scaling=None)

Store some bound methods so we can detect runtime overrides.

Parameters
**kwargsdict of keyword arguments

Keyword arguments that will be mapped into the Component 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref represents the physical value when the scaled value is 1.

add_discrete_input(self, name, val, desc='', tags=None)

Add a discrete input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_discrete_output(self, name, val, desc='', tags=None)

Add an output variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable.

tagsstr or list of strs or set of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_input(self, name, val=1.0, shape=None, src_indices=None, flat_src_indices=None, units=None, desc='', tags=None)

Add an input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray or Iterable

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if src_indices not provided and val is not an array. Default is None.

src_indicesint or list of ints or tuple of ints or int ndarray or Iterable or None

The global indices of the source variable to transfer data from. A value of None implies this input depends on all entries of source. Default is None. The shapes of the target and src_indices must match, and form of the entries within is determined by the value of ‘flat_src_indices’.

flat_src_indicesbool

If True, each entry of src_indices is assumed to be an index into the flattened source. Otherwise each entry must be a tuple or list of size equal to the number of dimensions of the source.

unitsstr or None

Units in which this input variable will be provided to the component during execution. Default is None, which means it is unitless.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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_output(self, name, val=1.0, shape=None, units=None, res_units=None, desc='', lower=None, upper=None, ref=1.0, ref0=0.0, res_ref=None, tags=None)

Add an output variable to the component.

For ExplicitComponent, res_ref defaults to the value in res unless otherwise specified.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if val is not an array. Default is None.

unitsstr or None

Units in which the output variables will be provided to the component during execution. Default is None, which means it has no units.

res_unitsstr or None

Units in which the residuals of this output will be given to the user when requested. Default is None, which means it has no units.

descstr

description of the variable.

lowerfloat or list or tuple or ndarray or None

lower bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no lower bound. Default is None.

upperfloat or list or tuple or ndarray or None

upper bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no upper bound. Default is None.

reffloat

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 1. Default is 1.

ref0float

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 0. Default is 0.

res_reffloat

Scaling parameter. The value in the user-defined res_units of this output’s residual when the scaled value is 1. Default is None, which means residual scaling matches output scaling.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs and also when listing results from case recorders.

Returns
dict

metadata for added variable

add_recorder(self, recorder, recurse=False)

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)

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 argument ref 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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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)

Perform optional error checks.

Parameters
loggerobject

The object that manages logging output.

cleanup(self)

Clean up resources prior to exit.

compute(self, inputs, outputs)

Evaluates the equation y1 = z1**2 + z2 + x1 - 0.2*y2

compute_jacvec_product(self, inputs, d_inputs, d_outputs, mode, discrete_inputs=None)

Compute jac-vector product. The model is assumed to be in an unscaled state.

If mode is:

‘fwd’: d_inputs |-> d_outputs

‘rev’: d_outputs |-> d_inputs

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

d_inputsVector

see inputs; product must be computed only if var_name in d_inputs

d_outputsVector

see outputs; product must be computed only if var_name in d_outputs

modestr

either ‘fwd’ or ‘rev’

discrete_inputsdict or None

If not None, dict containing discrete input values.

compute_partials(self, inputs, partials)[source]

Jacobian for Sellar discipline 1.

declare_coloring(self, wrt=('*', ), method='fd', form=None, step=None, per_instance=False, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, show_summary=True, show_sparsity=False)

Set options for deriv coloring of a set of wrt vars matching the given pattern(s).

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain input names, output names, or glob patterns.

methodstr

Method used to compute derivative: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference. Leave undeclared to keep unchanged from previous or default value.

per_instancebool

If True, a separate coloring will be generated for each instance of a given class. Otherwise, only one coloring for a given class will be generated and all instances of that class will use it.

num_full_jacsint

Number of times to repeat partial jacobian computation when computing sparsity.

tolfloat

Tolerance used to determine if an array entry is nonzero during sparsity determination.

ordersint

Number of orders above and below the tolerance to check during the tolerance sweep.

perturb_sizefloat

Size of input/output perturbation during generation of sparsity.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

If True, display sparsity with coloring info after generating coloring.

declare_partials(self, of, wrt, dependent=True, rows=None, cols=None, val=None, method='exact', step=None, form=None, step_calc=None)

Declare information about this component’s subjacobians.

Parameters
ofstr or list of str

The name of the residual(s) that derivatives are being computed for. May also contain a glob pattern.

wrtstr or list of str

The name of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.

dependentbool(True)

If False, specifies no dependence between the output(s) and the input(s). This is only necessary in the case of a sparse global jacobian, because if ‘dependent=False’ is not specified and declare_partials is not called for a given pair, then a dense matrix of zeros will be allocated in the sparse global jacobian for that pair. In the case of a dense global jacobian it doesn’t matter because the space for a dense subjac will always be allocated for every pair.

rowsndarray of int or None

Row indices for each nonzero entry. For sparse subjacobians only.

colsndarray of int or None

Column indices for each nonzero entry. For sparse subjacobians only.

valfloat or ndarray of float or scipy.sparse

Value of subjacobian. If rows and cols are not None, this will contain the values found at each (row, col) location in the subjac.

methodstr

The type of approximation that should be used. Valid options include: ‘fd’: Finite Difference, ‘cs’: Complex Step, ‘exact’: use the component defined analytic derivatives. Default is ‘exact’.

stepfloat

Step size for approximation. Defaults to None, in which case the approximation method provides its default value.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Defaults to None, in which case the approximation method provides its default value.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Defaults to None, in which case the approximation method provides its default value.

Returns
dict

Metadata dict for the specified partial(s).

property distributed

Provide ‘distributed’ property for backwards compatibility.

Returns
bool

reference to the ‘distributed’ option.

get_approx_coloring_fname(self)

Return the full pathname to a coloring file.

Parameters
systemSystem

The System having its coloring saved or loaded.

Returns
str

Full pathname of the coloring file.

get_constraints(self, recurse=True)

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)

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 design variable.

Returns
dict

The design variables defined in the current system and, if recurse=True, its subsystems.

get_linear_vectors(self, vec_name='linear')

Return the linear inputs, outputs, and residuals vectors.

Parameters
vec_namestr

Name of the linear right-hand-side 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)

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)

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)

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.

initialize(self)

Perform any one-time initialization run at instantiation.

is_active(self)

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.

property 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only inputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only outputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like

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

property ln_solver

Get the linear solver for this system.

property metadata

Get the options for this System.

property msginfo

Our instance pathname, if available, or our class name. For use in error messages.

Returns
str

Either our instance pathname or class name.

property nl_solver

Get the nonlinear solver for this system.

property nonlinear_solver

Get the nonlinear solver for this system.

reconfigure(self)

Perform reconfiguration.

Returns
bool

If True, reconfiguration is to be performed.

record_iteration(self)

Record an iteration of the current System.

resetup(self, setup_mode='full')

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)

Compute jac-vec 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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

scope_outset or None

Set of absolute output names in the scope of this mat-vec product. If None, all are in the scope.

scope_inset or None

Set of absolute input names in the scope of this mat-vec product. If None, all are in the scope.

run_apply_nonlinear(self)

Compute residuals.

This calls _apply_nonlinear, but with the model assumed to be in an unscaled state.

run_linearize(self, sub_do_ln=True)

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)

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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear(self)

Compute outputs.

This calls _solve_nonlinear, but with the model assumed to be in an unscaled state.

set_check_partial_options(self, wrt, method='fd', form=None, step=None, step_calc=None, directional=False)

Set options that will be used for checking partial derivatives.

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.

methodstr

Method for check: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form for check, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference check. Leave undeclared to keep unchanged from previous or default value.

step_calcstr

Type of step calculation for check, can be “abs” for absolute (default) or “rel” for relative. Leave undeclared to keep unchanged from previous or default value.

directionalbool

Set to True to perform a single directional derivative for each vector variable in the pattern named in wrt.

set_initial_values(self)

Set all input and output variables to their declared initial values.

setup(self)

Declare inputs and outputs.

Available attributes:

name pathname comm options

system_iter(self, include_self=False, recurse=True, typ=None)

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.

use_fixed_coloring(self, coloring=<object object at 0x7f338004ca50>, recurse=True)

Use a precomputed coloring for this System.

Parameters
coloringstr

A coloring filename. If no arg is passed, filename will be determined automatically.

recursebool

If True, set fixed coloring in all subsystems that declare a coloring. Ignored if a specific coloring is passed in.

class openmdao.test_suite.components.sellar.SellarDis2(units=None, scaling=None)[source]

Bases: openmdao.core.explicitcomponent.ExplicitComponent

Component containing Discipline 2 – no derivatives version.

__init__(self, units=None, scaling=None)[source]

Store some bound methods so we can detect runtime overrides.

Parameters
**kwargsdict of keyword arguments

Keyword arguments that will be mapped into the Component 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref represents the physical value when the scaled value is 1.

add_discrete_input(self, name, val, desc='', tags=None)

Add a discrete input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_discrete_output(self, name, val, desc='', tags=None)

Add an output variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable.

tagsstr or list of strs or set of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_input(self, name, val=1.0, shape=None, src_indices=None, flat_src_indices=None, units=None, desc='', tags=None)

Add an input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray or Iterable

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if src_indices not provided and val is not an array. Default is None.

src_indicesint or list of ints or tuple of ints or int ndarray or Iterable or None

The global indices of the source variable to transfer data from. A value of None implies this input depends on all entries of source. Default is None. The shapes of the target and src_indices must match, and form of the entries within is determined by the value of ‘flat_src_indices’.

flat_src_indicesbool

If True, each entry of src_indices is assumed to be an index into the flattened source. Otherwise each entry must be a tuple or list of size equal to the number of dimensions of the source.

unitsstr or None

Units in which this input variable will be provided to the component during execution. Default is None, which means it is unitless.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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_output(self, name, val=1.0, shape=None, units=None, res_units=None, desc='', lower=None, upper=None, ref=1.0, ref0=0.0, res_ref=None, tags=None)

Add an output variable to the component.

For ExplicitComponent, res_ref defaults to the value in res unless otherwise specified.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if val is not an array. Default is None.

unitsstr or None

Units in which the output variables will be provided to the component during execution. Default is None, which means it has no units.

res_unitsstr or None

Units in which the residuals of this output will be given to the user when requested. Default is None, which means it has no units.

descstr

description of the variable.

lowerfloat or list or tuple or ndarray or None

lower bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no lower bound. Default is None.

upperfloat or list or tuple or ndarray or None

upper bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no upper bound. Default is None.

reffloat

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 1. Default is 1.

ref0float

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 0. Default is 0.

res_reffloat

Scaling parameter. The value in the user-defined res_units of this output’s residual when the scaled value is 1. Default is None, which means residual scaling matches output scaling.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs and also when listing results from case recorders.

Returns
dict

metadata for added variable

add_recorder(self, recorder, recurse=False)

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)

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 argument ref 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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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)

Perform optional error checks.

Parameters
loggerobject

The object that manages logging output.

cleanup(self)

Clean up resources prior to exit.

compute(self, inputs, outputs)[source]

Evaluates the equation y2 = y1**(.5) + z1 + z2

compute_jacvec_product(self, inputs, d_inputs, d_outputs, mode, discrete_inputs=None)

Compute jac-vector product. The model is assumed to be in an unscaled state.

If mode is:

‘fwd’: d_inputs |-> d_outputs

‘rev’: d_outputs |-> d_inputs

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

d_inputsVector

see inputs; product must be computed only if var_name in d_inputs

d_outputsVector

see outputs; product must be computed only if var_name in d_outputs

modestr

either ‘fwd’ or ‘rev’

discrete_inputsdict or None

If not None, dict containing discrete input values.

compute_partials(self, inputs, partials, discrete_inputs=None)

Compute sub-jacobian parts. The model is assumed to be in an unscaled state.

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

partialsJacobian

sub-jac components written to partials[output_name, input_name]

discrete_inputsdict or None

If not None, dict containing discrete input values.

declare_coloring(self, wrt=('*', ), method='fd', form=None, step=None, per_instance=False, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, show_summary=True, show_sparsity=False)

Set options for deriv coloring of a set of wrt vars matching the given pattern(s).

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain input names, output names, or glob patterns.

methodstr

Method used to compute derivative: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference. Leave undeclared to keep unchanged from previous or default value.

per_instancebool

If True, a separate coloring will be generated for each instance of a given class. Otherwise, only one coloring for a given class will be generated and all instances of that class will use it.

num_full_jacsint

Number of times to repeat partial jacobian computation when computing sparsity.

tolfloat

Tolerance used to determine if an array entry is nonzero during sparsity determination.

ordersint

Number of orders above and below the tolerance to check during the tolerance sweep.

perturb_sizefloat

Size of input/output perturbation during generation of sparsity.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

If True, display sparsity with coloring info after generating coloring.

declare_partials(self, of, wrt, dependent=True, rows=None, cols=None, val=None, method='exact', step=None, form=None, step_calc=None)

Declare information about this component’s subjacobians.

Parameters
ofstr or list of str

The name of the residual(s) that derivatives are being computed for. May also contain a glob pattern.

wrtstr or list of str

The name of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.

dependentbool(True)

If False, specifies no dependence between the output(s) and the input(s). This is only necessary in the case of a sparse global jacobian, because if ‘dependent=False’ is not specified and declare_partials is not called for a given pair, then a dense matrix of zeros will be allocated in the sparse global jacobian for that pair. In the case of a dense global jacobian it doesn’t matter because the space for a dense subjac will always be allocated for every pair.

rowsndarray of int or None

Row indices for each nonzero entry. For sparse subjacobians only.

colsndarray of int or None

Column indices for each nonzero entry. For sparse subjacobians only.

valfloat or ndarray of float or scipy.sparse

Value of subjacobian. If rows and cols are not None, this will contain the values found at each (row, col) location in the subjac.

methodstr

The type of approximation that should be used. Valid options include: ‘fd’: Finite Difference, ‘cs’: Complex Step, ‘exact’: use the component defined analytic derivatives. Default is ‘exact’.

stepfloat

Step size for approximation. Defaults to None, in which case the approximation method provides its default value.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Defaults to None, in which case the approximation method provides its default value.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Defaults to None, in which case the approximation method provides its default value.

Returns
dict

Metadata dict for the specified partial(s).

property distributed

Provide ‘distributed’ property for backwards compatibility.

Returns
bool

reference to the ‘distributed’ option.

get_approx_coloring_fname(self)

Return the full pathname to a coloring file.

Parameters
systemSystem

The System having its coloring saved or loaded.

Returns
str

Full pathname of the coloring file.

get_constraints(self, recurse=True)

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)

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 design variable.

Returns
dict

The design variables defined in the current system and, if recurse=True, its subsystems.

get_linear_vectors(self, vec_name='linear')

Return the linear inputs, outputs, and residuals vectors.

Parameters
vec_namestr

Name of the linear right-hand-side 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)

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)

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)

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.

initialize(self)

Perform any one-time initialization run at instantiation.

is_active(self)

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.

property 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only inputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only outputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like

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

property ln_solver

Get the linear solver for this system.

property metadata

Get the options for this System.

property msginfo

Our instance pathname, if available, or our class name. For use in error messages.

Returns
str

Either our instance pathname or class name.

property nl_solver

Get the nonlinear solver for this system.

property nonlinear_solver

Get the nonlinear solver for this system.

reconfigure(self)

Perform reconfiguration.

Returns
bool

If True, reconfiguration is to be performed.

record_iteration(self)

Record an iteration of the current System.

resetup(self, setup_mode='full')

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)

Compute jac-vec 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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

scope_outset or None

Set of absolute output names in the scope of this mat-vec product. If None, all are in the scope.

scope_inset or None

Set of absolute input names in the scope of this mat-vec product. If None, all are in the scope.

run_apply_nonlinear(self)

Compute residuals.

This calls _apply_nonlinear, but with the model assumed to be in an unscaled state.

run_linearize(self, sub_do_ln=True)

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)

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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear(self)

Compute outputs.

This calls _solve_nonlinear, but with the model assumed to be in an unscaled state.

set_check_partial_options(self, wrt, method='fd', form=None, step=None, step_calc=None, directional=False)

Set options that will be used for checking partial derivatives.

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.

methodstr

Method for check: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form for check, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference check. Leave undeclared to keep unchanged from previous or default value.

step_calcstr

Type of step calculation for check, can be “abs” for absolute (default) or “rel” for relative. Leave undeclared to keep unchanged from previous or default value.

directionalbool

Set to True to perform a single directional derivative for each vector variable in the pattern named in wrt.

set_initial_values(self)

Set all input and output variables to their declared initial values.

setup(self)[source]

Declare inputs and outputs.

Available attributes:

name pathname comm options

system_iter(self, include_self=False, recurse=True, typ=None)

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.

use_fixed_coloring(self, coloring=<object object at 0x7f338004ca50>, recurse=True)

Use a precomputed coloring for this System.

Parameters
coloringstr

A coloring filename. If no arg is passed, filename will be determined automatically.

recursebool

If True, set fixed coloring in all subsystems that declare a coloring. Ignored if a specific coloring is passed in.

class openmdao.test_suite.components.sellar.SellarDis2CS(units=None, scaling=None)[source]

Bases: openmdao.test_suite.components.sellar.SellarDis2

Component containing Discipline 2 – complex step version.

__init__(self, units=None, scaling=None)

Store some bound methods so we can detect runtime overrides.

Parameters
**kwargsdict of keyword arguments

Keyword arguments that will be mapped into the Component 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref represents the physical value when the scaled value is 1.

add_discrete_input(self, name, val, desc='', tags=None)

Add a discrete input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_discrete_output(self, name, val, desc='', tags=None)

Add an output variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable.

tagsstr or list of strs or set of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_input(self, name, val=1.0, shape=None, src_indices=None, flat_src_indices=None, units=None, desc='', tags=None)

Add an input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray or Iterable

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if src_indices not provided and val is not an array. Default is None.

src_indicesint or list of ints or tuple of ints or int ndarray or Iterable or None

The global indices of the source variable to transfer data from. A value of None implies this input depends on all entries of source. Default is None. The shapes of the target and src_indices must match, and form of the entries within is determined by the value of ‘flat_src_indices’.

flat_src_indicesbool

If True, each entry of src_indices is assumed to be an index into the flattened source. Otherwise each entry must be a tuple or list of size equal to the number of dimensions of the source.

unitsstr or None

Units in which this input variable will be provided to the component during execution. Default is None, which means it is unitless.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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_output(self, name, val=1.0, shape=None, units=None, res_units=None, desc='', lower=None, upper=None, ref=1.0, ref0=0.0, res_ref=None, tags=None)

Add an output variable to the component.

For ExplicitComponent, res_ref defaults to the value in res unless otherwise specified.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if val is not an array. Default is None.

unitsstr or None

Units in which the output variables will be provided to the component during execution. Default is None, which means it has no units.

res_unitsstr or None

Units in which the residuals of this output will be given to the user when requested. Default is None, which means it has no units.

descstr

description of the variable.

lowerfloat or list or tuple or ndarray or None

lower bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no lower bound. Default is None.

upperfloat or list or tuple or ndarray or None

upper bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no upper bound. Default is None.

reffloat

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 1. Default is 1.

ref0float

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 0. Default is 0.

res_reffloat

Scaling parameter. The value in the user-defined res_units of this output’s residual when the scaled value is 1. Default is None, which means residual scaling matches output scaling.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs and also when listing results from case recorders.

Returns
dict

metadata for added variable

add_recorder(self, recorder, recurse=False)

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)

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 argument ref 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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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)

Perform optional error checks.

Parameters
loggerobject

The object that manages logging output.

cleanup(self)

Clean up resources prior to exit.

compute(self, inputs, outputs)

Evaluates the equation y2 = y1**(.5) + z1 + z2

compute_jacvec_product(self, inputs, d_inputs, d_outputs, mode, discrete_inputs=None)

Compute jac-vector product. The model is assumed to be in an unscaled state.

If mode is:

‘fwd’: d_inputs |-> d_outputs

‘rev’: d_outputs |-> d_inputs

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

d_inputsVector

see inputs; product must be computed only if var_name in d_inputs

d_outputsVector

see outputs; product must be computed only if var_name in d_outputs

modestr

either ‘fwd’ or ‘rev’

discrete_inputsdict or None

If not None, dict containing discrete input values.

compute_partials(self, inputs, partials, discrete_inputs=None)

Compute sub-jacobian parts. The model is assumed to be in an unscaled state.

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

partialsJacobian

sub-jac components written to partials[output_name, input_name]

discrete_inputsdict or None

If not None, dict containing discrete input values.

declare_coloring(self, wrt=('*', ), method='fd', form=None, step=None, per_instance=False, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, show_summary=True, show_sparsity=False)

Set options for deriv coloring of a set of wrt vars matching the given pattern(s).

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain input names, output names, or glob patterns.

methodstr

Method used to compute derivative: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference. Leave undeclared to keep unchanged from previous or default value.

per_instancebool

If True, a separate coloring will be generated for each instance of a given class. Otherwise, only one coloring for a given class will be generated and all instances of that class will use it.

num_full_jacsint

Number of times to repeat partial jacobian computation when computing sparsity.

tolfloat

Tolerance used to determine if an array entry is nonzero during sparsity determination.

ordersint

Number of orders above and below the tolerance to check during the tolerance sweep.

perturb_sizefloat

Size of input/output perturbation during generation of sparsity.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

If True, display sparsity with coloring info after generating coloring.

declare_partials(self, of, wrt, dependent=True, rows=None, cols=None, val=None, method='exact', step=None, form=None, step_calc=None)

Declare information about this component’s subjacobians.

Parameters
ofstr or list of str

The name of the residual(s) that derivatives are being computed for. May also contain a glob pattern.

wrtstr or list of str

The name of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.

dependentbool(True)

If False, specifies no dependence between the output(s) and the input(s). This is only necessary in the case of a sparse global jacobian, because if ‘dependent=False’ is not specified and declare_partials is not called for a given pair, then a dense matrix of zeros will be allocated in the sparse global jacobian for that pair. In the case of a dense global jacobian it doesn’t matter because the space for a dense subjac will always be allocated for every pair.

rowsndarray of int or None

Row indices for each nonzero entry. For sparse subjacobians only.

colsndarray of int or None

Column indices for each nonzero entry. For sparse subjacobians only.

valfloat or ndarray of float or scipy.sparse

Value of subjacobian. If rows and cols are not None, this will contain the values found at each (row, col) location in the subjac.

methodstr

The type of approximation that should be used. Valid options include: ‘fd’: Finite Difference, ‘cs’: Complex Step, ‘exact’: use the component defined analytic derivatives. Default is ‘exact’.

stepfloat

Step size for approximation. Defaults to None, in which case the approximation method provides its default value.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Defaults to None, in which case the approximation method provides its default value.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Defaults to None, in which case the approximation method provides its default value.

Returns
dict

Metadata dict for the specified partial(s).

property distributed

Provide ‘distributed’ property for backwards compatibility.

Returns
bool

reference to the ‘distributed’ option.

get_approx_coloring_fname(self)

Return the full pathname to a coloring file.

Parameters
systemSystem

The System having its coloring saved or loaded.

Returns
str

Full pathname of the coloring file.

get_constraints(self, recurse=True)

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)

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 design variable.

Returns
dict

The design variables defined in the current system and, if recurse=True, its subsystems.

get_linear_vectors(self, vec_name='linear')

Return the linear inputs, outputs, and residuals vectors.

Parameters
vec_namestr

Name of the linear right-hand-side 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)

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)

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)

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.

initialize(self)

Perform any one-time initialization run at instantiation.

is_active(self)

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.

property 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only inputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only outputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like

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

property ln_solver

Get the linear solver for this system.

property metadata

Get the options for this System.

property msginfo

Our instance pathname, if available, or our class name. For use in error messages.

Returns
str

Either our instance pathname or class name.

property nl_solver

Get the nonlinear solver for this system.

property nonlinear_solver

Get the nonlinear solver for this system.

reconfigure(self)

Perform reconfiguration.

Returns
bool

If True, reconfiguration is to be performed.

record_iteration(self)

Record an iteration of the current System.

resetup(self, setup_mode='full')

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)

Compute jac-vec 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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

scope_outset or None

Set of absolute output names in the scope of this mat-vec product. If None, all are in the scope.

scope_inset or None

Set of absolute input names in the scope of this mat-vec product. If None, all are in the scope.

run_apply_nonlinear(self)

Compute residuals.

This calls _apply_nonlinear, but with the model assumed to be in an unscaled state.

run_linearize(self, sub_do_ln=True)

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)

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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear(self)

Compute outputs.

This calls _solve_nonlinear, but with the model assumed to be in an unscaled state.

set_check_partial_options(self, wrt, method='fd', form=None, step=None, step_calc=None, directional=False)

Set options that will be used for checking partial derivatives.

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.

methodstr

Method for check: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form for check, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference check. Leave undeclared to keep unchanged from previous or default value.

step_calcstr

Type of step calculation for check, can be “abs” for absolute (default) or “rel” for relative. Leave undeclared to keep unchanged from previous or default value.

directionalbool

Set to True to perform a single directional derivative for each vector variable in the pattern named in wrt.

set_initial_values(self)

Set all input and output variables to their declared initial values.

setup(self)

Declare inputs and outputs.

Available attributes:

name pathname comm options

system_iter(self, include_self=False, recurse=True, typ=None)

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.

use_fixed_coloring(self, coloring=<object object at 0x7f338004ca50>, recurse=True)

Use a precomputed coloring for this System.

Parameters
coloringstr

A coloring filename. If no arg is passed, filename will be determined automatically.

recursebool

If True, set fixed coloring in all subsystems that declare a coloring. Ignored if a specific coloring is passed in.

class openmdao.test_suite.components.sellar.SellarDis2withDerivatives(units=None, scaling=None)[source]

Bases: openmdao.test_suite.components.sellar.SellarDis2

Component containing Discipline 2 – derivatives version.

__init__(self, units=None, scaling=None)

Store some bound methods so we can detect runtime overrides.

Parameters
**kwargsdict of keyword arguments

Keyword arguments that will be mapped into the Component 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref represents the physical value when the scaled value is 1.

add_discrete_input(self, name, val, desc='', tags=None)

Add a discrete input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_discrete_output(self, name, val, desc='', tags=None)

Add an output variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable.

tagsstr or list of strs or set of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_input(self, name, val=1.0, shape=None, src_indices=None, flat_src_indices=None, units=None, desc='', tags=None)

Add an input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray or Iterable

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if src_indices not provided and val is not an array. Default is None.

src_indicesint or list of ints or tuple of ints or int ndarray or Iterable or None

The global indices of the source variable to transfer data from. A value of None implies this input depends on all entries of source. Default is None. The shapes of the target and src_indices must match, and form of the entries within is determined by the value of ‘flat_src_indices’.

flat_src_indicesbool

If True, each entry of src_indices is assumed to be an index into the flattened source. Otherwise each entry must be a tuple or list of size equal to the number of dimensions of the source.

unitsstr or None

Units in which this input variable will be provided to the component during execution. Default is None, which means it is unitless.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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_output(self, name, val=1.0, shape=None, units=None, res_units=None, desc='', lower=None, upper=None, ref=1.0, ref0=0.0, res_ref=None, tags=None)

Add an output variable to the component.

For ExplicitComponent, res_ref defaults to the value in res unless otherwise specified.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if val is not an array. Default is None.

unitsstr or None

Units in which the output variables will be provided to the component during execution. Default is None, which means it has no units.

res_unitsstr or None

Units in which the residuals of this output will be given to the user when requested. Default is None, which means it has no units.

descstr

description of the variable.

lowerfloat or list or tuple or ndarray or None

lower bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no lower bound. Default is None.

upperfloat or list or tuple or ndarray or None

upper bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no upper bound. Default is None.

reffloat

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 1. Default is 1.

ref0float

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 0. Default is 0.

res_reffloat

Scaling parameter. The value in the user-defined res_units of this output’s residual when the scaled value is 1. Default is None, which means residual scaling matches output scaling.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs and also when listing results from case recorders.

Returns
dict

metadata for added variable

add_recorder(self, recorder, recurse=False)

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)

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 argument ref 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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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)

Perform optional error checks.

Parameters
loggerobject

The object that manages logging output.

cleanup(self)

Clean up resources prior to exit.

compute(self, inputs, outputs)

Evaluates the equation y2 = y1**(.5) + z1 + z2

compute_jacvec_product(self, inputs, d_inputs, d_outputs, mode, discrete_inputs=None)

Compute jac-vector product. The model is assumed to be in an unscaled state.

If mode is:

‘fwd’: d_inputs |-> d_outputs

‘rev’: d_outputs |-> d_inputs

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

d_inputsVector

see inputs; product must be computed only if var_name in d_inputs

d_outputsVector

see outputs; product must be computed only if var_name in d_outputs

modestr

either ‘fwd’ or ‘rev’

discrete_inputsdict or None

If not None, dict containing discrete input values.

compute_partials(self, inputs, J)[source]

Jacobian for Sellar discipline 2.

declare_coloring(self, wrt=('*', ), method='fd', form=None, step=None, per_instance=False, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, show_summary=True, show_sparsity=False)

Set options for deriv coloring of a set of wrt vars matching the given pattern(s).

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain input names, output names, or glob patterns.

methodstr

Method used to compute derivative: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference. Leave undeclared to keep unchanged from previous or default value.

per_instancebool

If True, a separate coloring will be generated for each instance of a given class. Otherwise, only one coloring for a given class will be generated and all instances of that class will use it.

num_full_jacsint

Number of times to repeat partial jacobian computation when computing sparsity.

tolfloat

Tolerance used to determine if an array entry is nonzero during sparsity determination.

ordersint

Number of orders above and below the tolerance to check during the tolerance sweep.

perturb_sizefloat

Size of input/output perturbation during generation of sparsity.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

If True, display sparsity with coloring info after generating coloring.

declare_partials(self, of, wrt, dependent=True, rows=None, cols=None, val=None, method='exact', step=None, form=None, step_calc=None)

Declare information about this component’s subjacobians.

Parameters
ofstr or list of str

The name of the residual(s) that derivatives are being computed for. May also contain a glob pattern.

wrtstr or list of str

The name of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.

dependentbool(True)

If False, specifies no dependence between the output(s) and the input(s). This is only necessary in the case of a sparse global jacobian, because if ‘dependent=False’ is not specified and declare_partials is not called for a given pair, then a dense matrix of zeros will be allocated in the sparse global jacobian for that pair. In the case of a dense global jacobian it doesn’t matter because the space for a dense subjac will always be allocated for every pair.

rowsndarray of int or None

Row indices for each nonzero entry. For sparse subjacobians only.

colsndarray of int or None

Column indices for each nonzero entry. For sparse subjacobians only.

valfloat or ndarray of float or scipy.sparse

Value of subjacobian. If rows and cols are not None, this will contain the values found at each (row, col) location in the subjac.

methodstr

The type of approximation that should be used. Valid options include: ‘fd’: Finite Difference, ‘cs’: Complex Step, ‘exact’: use the component defined analytic derivatives. Default is ‘exact’.

stepfloat

Step size for approximation. Defaults to None, in which case the approximation method provides its default value.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Defaults to None, in which case the approximation method provides its default value.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Defaults to None, in which case the approximation method provides its default value.

Returns
dict

Metadata dict for the specified partial(s).

property distributed

Provide ‘distributed’ property for backwards compatibility.

Returns
bool

reference to the ‘distributed’ option.

get_approx_coloring_fname(self)

Return the full pathname to a coloring file.

Parameters
systemSystem

The System having its coloring saved or loaded.

Returns
str

Full pathname of the coloring file.

get_constraints(self, recurse=True)

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)

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 design variable.

Returns
dict

The design variables defined in the current system and, if recurse=True, its subsystems.

get_linear_vectors(self, vec_name='linear')

Return the linear inputs, outputs, and residuals vectors.

Parameters
vec_namestr

Name of the linear right-hand-side 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)

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)

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)

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.

initialize(self)

Perform any one-time initialization run at instantiation.

is_active(self)

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.

property 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only inputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only outputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like

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

property ln_solver

Get the linear solver for this system.

property metadata

Get the options for this System.

property msginfo

Our instance pathname, if available, or our class name. For use in error messages.

Returns
str

Either our instance pathname or class name.

property nl_solver

Get the nonlinear solver for this system.

property nonlinear_solver

Get the nonlinear solver for this system.

reconfigure(self)

Perform reconfiguration.

Returns
bool

If True, reconfiguration is to be performed.

record_iteration(self)

Record an iteration of the current System.

resetup(self, setup_mode='full')

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)

Compute jac-vec 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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

scope_outset or None

Set of absolute output names in the scope of this mat-vec product. If None, all are in the scope.

scope_inset or None

Set of absolute input names in the scope of this mat-vec product. If None, all are in the scope.

run_apply_nonlinear(self)

Compute residuals.

This calls _apply_nonlinear, but with the model assumed to be in an unscaled state.

run_linearize(self, sub_do_ln=True)

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)

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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear(self)

Compute outputs.

This calls _solve_nonlinear, but with the model assumed to be in an unscaled state.

set_check_partial_options(self, wrt, method='fd', form=None, step=None, step_calc=None, directional=False)

Set options that will be used for checking partial derivatives.

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.

methodstr

Method for check: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form for check, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference check. Leave undeclared to keep unchanged from previous or default value.

step_calcstr

Type of step calculation for check, can be “abs” for absolute (default) or “rel” for relative. Leave undeclared to keep unchanged from previous or default value.

directionalbool

Set to True to perform a single directional derivative for each vector variable in the pattern named in wrt.

set_initial_values(self)

Set all input and output variables to their declared initial values.

setup(self)

Declare inputs and outputs.

Available attributes:

name pathname comm options

system_iter(self, include_self=False, recurse=True, typ=None)

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.

use_fixed_coloring(self, coloring=<object object at 0x7f338004ca50>, recurse=True)

Use a precomputed coloring for this System.

Parameters
coloringstr

A coloring filename. If no arg is passed, filename will be determined automatically.

recursebool

If True, set fixed coloring in all subsystems that declare a coloring. Ignored if a specific coloring is passed in.

class openmdao.test_suite.components.sellar.SellarImplicitDis1(units=None, scaling=None)[source]

Bases: openmdao.core.implicitcomponent.ImplicitComponent

Component containing Discipline 1 – no derivatives version.

__init__(self, units=None, scaling=None)[source]

Store some bound methods so we can detect runtime overrides.

Parameters
**kwargsdict of keyword arguments

Keyword arguments that will be mapped into the Component 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref represents the physical value when the scaled value is 1.

add_discrete_input(self, name, val, desc='', tags=None)

Add a discrete input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_discrete_output(self, name, val, desc='', tags=None)

Add an output variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable.

tagsstr or list of strs or set of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_input(self, name, val=1.0, shape=None, src_indices=None, flat_src_indices=None, units=None, desc='', tags=None)

Add an input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray or Iterable

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if src_indices not provided and val is not an array. Default is None.

src_indicesint or list of ints or tuple of ints or int ndarray or Iterable or None

The global indices of the source variable to transfer data from. A value of None implies this input depends on all entries of source. Default is None. The shapes of the target and src_indices must match, and form of the entries within is determined by the value of ‘flat_src_indices’.

flat_src_indicesbool

If True, each entry of src_indices is assumed to be an index into the flattened source. Otherwise each entry must be a tuple or list of size equal to the number of dimensions of the source.

unitsstr or None

Units in which this input variable will be provided to the component during execution. Default is None, which means it is unitless.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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_output(self, name, val=1.0, shape=None, units=None, res_units=None, desc='', lower=None, upper=None, ref=1.0, ref0=0.0, res_ref=1.0, tags=None)

Add an output variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if val is not an array. Default is None.

unitsstr or None

Units in which the output variables will be provided to the component during execution. Default is None, which means it has no units.

res_unitsstr or None

Units in which the residuals of this output will be given to the user when requested. Default is None, which means it has no units.

descstr

description of the variable.

lowerfloat or list or tuple or ndarray or Iterable or None

lower bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no lower bound. Default is None.

upperfloat or list or tuple or ndarray or or Iterable None

upper bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no upper bound. Default is None.

reffloat or ndarray

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 1. Default is 1.

ref0float or ndarray

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 0. Default is 0.

res_reffloat or ndarray

Scaling parameter. The value in the user-defined res_units of this output’s residual when the scaled value is 1. Default is 1.

tagsstr or list of strs or set of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_recorder(self, recorder, recurse=False)

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)

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 argument ref 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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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.

apply_linear(self, inputs, outputs, d_inputs, d_outputs, d_residuals, mode)

Compute jac-vector product. The model is assumed to be in an unscaled state.

If mode is:

‘fwd’: (d_inputs, d_outputs) |-> d_residuals

‘rev’: d_residuals |-> (d_inputs, d_outputs)

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

outputsVector

unscaled, dimensional output variables read via outputs[key]

d_inputsVector

see inputs; product must be computed only if var_name in d_inputs

d_outputsVector

see outputs; product must be computed only if var_name in d_outputs

d_residualsVector

see outputs

modestr

either ‘fwd’ or ‘rev’

apply_nonlinear(self, inputs, outputs, resids)[source]

Evaluates the equation y1 = z1**2 + z2 + x1 - 0.2*y2

check_config(self, logger)

Perform optional error checks.

Parameters
loggerobject

The object that manages logging output.

cleanup(self)

Clean up resources prior to exit.

declare_coloring(self, wrt=('*', ), method='fd', form=None, step=None, per_instance=False, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, show_summary=True, show_sparsity=False)

Set options for deriv coloring of a set of wrt vars matching the given pattern(s).

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain input names, output names, or glob patterns.

methodstr

Method used to compute derivative: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference. Leave undeclared to keep unchanged from previous or default value.

per_instancebool

If True, a separate coloring will be generated for each instance of a given class. Otherwise, only one coloring for a given class will be generated and all instances of that class will use it.

num_full_jacsint

Number of times to repeat partial jacobian computation when computing sparsity.

tolfloat

Tolerance used to determine if an array entry is nonzero during sparsity determination.

ordersint

Number of orders above and below the tolerance to check during the tolerance sweep.

perturb_sizefloat

Size of input/output perturbation during generation of sparsity.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

If True, display sparsity with coloring info after generating coloring.

declare_partials(self, of, wrt, dependent=True, rows=None, cols=None, val=None, method='exact', step=None, form=None, step_calc=None)

Declare information about this component’s subjacobians.

Parameters
ofstr or list of str

The name of the residual(s) that derivatives are being computed for. May also contain a glob pattern.

wrtstr or list of str

The name of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.

dependentbool(True)

If False, specifies no dependence between the output(s) and the input(s). This is only necessary in the case of a sparse global jacobian, because if ‘dependent=False’ is not specified and declare_partials is not called for a given pair, then a dense matrix of zeros will be allocated in the sparse global jacobian for that pair. In the case of a dense global jacobian it doesn’t matter because the space for a dense subjac will always be allocated for every pair.

rowsndarray of int or None

Row indices for each nonzero entry. For sparse subjacobians only.

colsndarray of int or None

Column indices for each nonzero entry. For sparse subjacobians only.

valfloat or ndarray of float or scipy.sparse

Value of subjacobian. If rows and cols are not None, this will contain the values found at each (row, col) location in the subjac.

methodstr

The type of approximation that should be used. Valid options include: ‘fd’: Finite Difference, ‘cs’: Complex Step, ‘exact’: use the component defined analytic derivatives. Default is ‘exact’.

stepfloat

Step size for approximation. Defaults to None, in which case the approximation method provides its default value.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Defaults to None, in which case the approximation method provides its default value.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Defaults to None, in which case the approximation method provides its default value.

Returns
dict

Metadata dict for the specified partial(s).

property distributed

Provide ‘distributed’ property for backwards compatibility.

Returns
bool

reference to the ‘distributed’ option.

get_approx_coloring_fname(self)

Return the full pathname to a coloring file.

Parameters
systemSystem

The System having its coloring saved or loaded.

Returns
str

Full pathname of the coloring file.

get_constraints(self, recurse=True)

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)

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 design variable.

Returns
dict

The design variables defined in the current system and, if recurse=True, its subsystems.

get_linear_vectors(self, vec_name='linear')

Return the linear inputs, outputs, and residuals vectors.

Parameters
vec_namestr

Name of the linear right-hand-side 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)

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)

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)

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.

guess_nonlinear(self, inputs, outputs, residuals, discrete_inputs=None, discrete_outputs=None)

Provide initial guess for states.

Override this method to set the initial guess for states.

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

outputsVector

unscaled, dimensional output variables read via outputs[key]

residualsVector

unscaled, dimensional residuals written to via residuals[key]

discrete_inputsdict or None

If not None, dict containing discrete input values.

discrete_outputsdict or None

If not None, dict containing discrete output values.

initialize(self)

Perform any one-time initialization run at instantiation.

is_active(self)

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.

property linear_solver

Get the linear solver for this system.

linearize(self, inputs, outputs, J)[source]

Jacobian for Sellar discipline 1.

list_inputs(self, values=True, prom_name=False, units=False, shape=False, hierarchical=True, print_arrays=False, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only inputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only outputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like

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

property ln_solver

Get the linear solver for this system.

property metadata

Get the options for this System.

property msginfo

Our instance pathname, if available, or our class name. For use in error messages.

Returns
str

Either our instance pathname or class name.

property nl_solver

Get the nonlinear solver for this system.

property nonlinear_solver

Get the nonlinear solver for this system.

reconfigure(self)

Perform reconfiguration.

Returns
bool

If True, reconfiguration is to be performed.

record_iteration(self)

Record an iteration of the current System.

resetup(self, setup_mode='full')

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)

Compute jac-vec 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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

scope_outset or None

Set of absolute output names in the scope of this mat-vec product. If None, all are in the scope.

scope_inset or None

Set of absolute input names in the scope of this mat-vec product. If None, all are in the scope.

run_apply_nonlinear(self)

Compute residuals.

This calls _apply_nonlinear, but with the model assumed to be in an unscaled state.

run_linearize(self, sub_do_ln=True)

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)

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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear(self)

Compute outputs.

This calls _solve_nonlinear, but with the model assumed to be in an unscaled state.

set_check_partial_options(self, wrt, method='fd', form=None, step=None, step_calc=None, directional=False)

Set options that will be used for checking partial derivatives.

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.

methodstr

Method for check: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form for check, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference check. Leave undeclared to keep unchanged from previous or default value.

step_calcstr

Type of step calculation for check, can be “abs” for absolute (default) or “rel” for relative. Leave undeclared to keep unchanged from previous or default value.

directionalbool

Set to True to perform a single directional derivative for each vector variable in the pattern named in wrt.

set_initial_values(self)

Set all input and output variables to their declared initial values.

setup(self)[source]

Declare inputs and outputs.

Available attributes:

name pathname comm options

solve_linear(self, d_outputs, d_residuals, mode)

Apply inverse jac product. The model is assumed to be in an unscaled state.

If mode is:

‘fwd’: d_residuals |-> d_outputs

‘rev’: d_outputs |-> d_residuals

Note: this is not the linear solution for the implicit component. We use identity so that simple implicit components can function in a preconditioner under linear gauss-seidel. To correctly solve this component, you should slot a solver in linear_solver or override this method.

Parameters
d_outputsVector

unscaled, dimensional quantities read via d_outputs[key]

d_residualsVector

unscaled, dimensional quantities read via d_residuals[key]

modestr

either ‘fwd’ or ‘rev’

solve_nonlinear(self, inputs, outputs)

Compute outputs given inputs. The model is assumed to be in an unscaled state.

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

outputsVector

unscaled, dimensional output variables read via outputs[key]

system_iter(self, include_self=False, recurse=True, typ=None)

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.

use_fixed_coloring(self, coloring=<object object at 0x7f338004ca50>, recurse=True)

Use a precomputed coloring for this System.

Parameters
coloringstr

A coloring filename. If no arg is passed, filename will be determined automatically.

recursebool

If True, set fixed coloring in all subsystems that declare a coloring. Ignored if a specific coloring is passed in.

class openmdao.test_suite.components.sellar.SellarImplicitDis2(units=None, scaling=None)[source]

Bases: openmdao.core.implicitcomponent.ImplicitComponent

Component containing Discipline 2 – implicit version.

__init__(self, units=None, scaling=None)[source]

Store some bound methods so we can detect runtime overrides.

Parameters
**kwargsdict of keyword arguments

Keyword arguments that will be mapped into the Component 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref represents the physical value when the scaled value is 1.

add_discrete_input(self, name, val, desc='', tags=None)

Add a discrete input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_discrete_output(self, name, val, desc='', tags=None)

Add an output variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable.

tagsstr or list of strs or set of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_input(self, name, val=1.0, shape=None, src_indices=None, flat_src_indices=None, units=None, desc='', tags=None)

Add an input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray or Iterable

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if src_indices not provided and val is not an array. Default is None.

src_indicesint or list of ints or tuple of ints or int ndarray or Iterable or None

The global indices of the source variable to transfer data from. A value of None implies this input depends on all entries of source. Default is None. The shapes of the target and src_indices must match, and form of the entries within is determined by the value of ‘flat_src_indices’.

flat_src_indicesbool

If True, each entry of src_indices is assumed to be an index into the flattened source. Otherwise each entry must be a tuple or list of size equal to the number of dimensions of the source.

unitsstr or None

Units in which this input variable will be provided to the component during execution. Default is None, which means it is unitless.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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_output(self, name, val=1.0, shape=None, units=None, res_units=None, desc='', lower=None, upper=None, ref=1.0, ref0=0.0, res_ref=1.0, tags=None)

Add an output variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if val is not an array. Default is None.

unitsstr or None

Units in which the output variables will be provided to the component during execution. Default is None, which means it has no units.

res_unitsstr or None

Units in which the residuals of this output will be given to the user when requested. Default is None, which means it has no units.

descstr

description of the variable.

lowerfloat or list or tuple or ndarray or Iterable or None

lower bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no lower bound. Default is None.

upperfloat or list or tuple or ndarray or or Iterable None

upper bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no upper bound. Default is None.

reffloat or ndarray

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 1. Default is 1.

ref0float or ndarray

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 0. Default is 0.

res_reffloat or ndarray

Scaling parameter. The value in the user-defined res_units of this output’s residual when the scaled value is 1. Default is 1.

tagsstr or list of strs or set of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_recorder(self, recorder, recurse=False)

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)

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 argument ref 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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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.

apply_linear(self, inputs, outputs, d_inputs, d_outputs, d_residuals, mode)

Compute jac-vector product. The model is assumed to be in an unscaled state.

If mode is:

‘fwd’: (d_inputs, d_outputs) |-> d_residuals

‘rev’: d_residuals |-> (d_inputs, d_outputs)

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

outputsVector

unscaled, dimensional output variables read via outputs[key]

d_inputsVector

see inputs; product must be computed only if var_name in d_inputs

d_outputsVector

see outputs; product must be computed only if var_name in d_outputs

d_residualsVector

see outputs

modestr

either ‘fwd’ or ‘rev’

apply_nonlinear(self, inputs, outputs, resids)[source]

Evaluates the equation y2 = y1**(.5) + z1 + z2

check_config(self, logger)

Perform optional error checks.

Parameters
loggerobject

The object that manages logging output.

cleanup(self)

Clean up resources prior to exit.

declare_coloring(self, wrt=('*', ), method='fd', form=None, step=None, per_instance=False, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, show_summary=True, show_sparsity=False)

Set options for deriv coloring of a set of wrt vars matching the given pattern(s).

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain input names, output names, or glob patterns.

methodstr

Method used to compute derivative: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference. Leave undeclared to keep unchanged from previous or default value.

per_instancebool

If True, a separate coloring will be generated for each instance of a given class. Otherwise, only one coloring for a given class will be generated and all instances of that class will use it.

num_full_jacsint

Number of times to repeat partial jacobian computation when computing sparsity.

tolfloat

Tolerance used to determine if an array entry is nonzero during sparsity determination.

ordersint

Number of orders above and below the tolerance to check during the tolerance sweep.

perturb_sizefloat

Size of input/output perturbation during generation of sparsity.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

If True, display sparsity with coloring info after generating coloring.

declare_partials(self, of, wrt, dependent=True, rows=None, cols=None, val=None, method='exact', step=None, form=None, step_calc=None)

Declare information about this component’s subjacobians.

Parameters
ofstr or list of str

The name of the residual(s) that derivatives are being computed for. May also contain a glob pattern.

wrtstr or list of str

The name of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.

dependentbool(True)

If False, specifies no dependence between the output(s) and the input(s). This is only necessary in the case of a sparse global jacobian, because if ‘dependent=False’ is not specified and declare_partials is not called for a given pair, then a dense matrix of zeros will be allocated in the sparse global jacobian for that pair. In the case of a dense global jacobian it doesn’t matter because the space for a dense subjac will always be allocated for every pair.

rowsndarray of int or None

Row indices for each nonzero entry. For sparse subjacobians only.

colsndarray of int or None

Column indices for each nonzero entry. For sparse subjacobians only.

valfloat or ndarray of float or scipy.sparse

Value of subjacobian. If rows and cols are not None, this will contain the values found at each (row, col) location in the subjac.

methodstr

The type of approximation that should be used. Valid options include: ‘fd’: Finite Difference, ‘cs’: Complex Step, ‘exact’: use the component defined analytic derivatives. Default is ‘exact’.

stepfloat

Step size for approximation. Defaults to None, in which case the approximation method provides its default value.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Defaults to None, in which case the approximation method provides its default value.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Defaults to None, in which case the approximation method provides its default value.

Returns
dict

Metadata dict for the specified partial(s).

property distributed

Provide ‘distributed’ property for backwards compatibility.

Returns
bool

reference to the ‘distributed’ option.

get_approx_coloring_fname(self)

Return the full pathname to a coloring file.

Parameters
systemSystem

The System having its coloring saved or loaded.

Returns
str

Full pathname of the coloring file.

get_constraints(self, recurse=True)

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)

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 design variable.

Returns
dict

The design variables defined in the current system and, if recurse=True, its subsystems.

get_linear_vectors(self, vec_name='linear')

Return the linear inputs, outputs, and residuals vectors.

Parameters
vec_namestr

Name of the linear right-hand-side 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)

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)

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)

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.

guess_nonlinear(self, inputs, outputs, residuals, discrete_inputs=None, discrete_outputs=None)

Provide initial guess for states.

Override this method to set the initial guess for states.

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

outputsVector

unscaled, dimensional output variables read via outputs[key]

residualsVector

unscaled, dimensional residuals written to via residuals[key]

discrete_inputsdict or None

If not None, dict containing discrete input values.

discrete_outputsdict or None

If not None, dict containing discrete output values.

initialize(self)

Perform any one-time initialization run at instantiation.

is_active(self)

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.

property linear_solver

Get the linear solver for this system.

linearize(self, inputs, outputs, J)[source]

Jacobian for Sellar discipline 2.

list_inputs(self, values=True, prom_name=False, units=False, shape=False, hierarchical=True, print_arrays=False, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only inputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only outputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like

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

property ln_solver

Get the linear solver for this system.

property metadata

Get the options for this System.

property msginfo

Our instance pathname, if available, or our class name. For use in error messages.

Returns
str

Either our instance pathname or class name.

property nl_solver

Get the nonlinear solver for this system.

property nonlinear_solver

Get the nonlinear solver for this system.

reconfigure(self)

Perform reconfiguration.

Returns
bool

If True, reconfiguration is to be performed.

record_iteration(self)

Record an iteration of the current System.

resetup(self, setup_mode='full')

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)

Compute jac-vec 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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

scope_outset or None

Set of absolute output names in the scope of this mat-vec product. If None, all are in the scope.

scope_inset or None

Set of absolute input names in the scope of this mat-vec product. If None, all are in the scope.

run_apply_nonlinear(self)

Compute residuals.

This calls _apply_nonlinear, but with the model assumed to be in an unscaled state.

run_linearize(self, sub_do_ln=True)

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)

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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear(self)

Compute outputs.

This calls _solve_nonlinear, but with the model assumed to be in an unscaled state.

set_check_partial_options(self, wrt, method='fd', form=None, step=None, step_calc=None, directional=False)

Set options that will be used for checking partial derivatives.

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.

methodstr

Method for check: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form for check, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference check. Leave undeclared to keep unchanged from previous or default value.

step_calcstr

Type of step calculation for check, can be “abs” for absolute (default) or “rel” for relative. Leave undeclared to keep unchanged from previous or default value.

directionalbool

Set to True to perform a single directional derivative for each vector variable in the pattern named in wrt.

set_initial_values(self)

Set all input and output variables to their declared initial values.

setup(self)[source]

Declare inputs and outputs.

Available attributes:

name pathname comm options

solve_linear(self, d_outputs, d_residuals, mode)

Apply inverse jac product. The model is assumed to be in an unscaled state.

If mode is:

‘fwd’: d_residuals |-> d_outputs

‘rev’: d_outputs |-> d_residuals

Note: this is not the linear solution for the implicit component. We use identity so that simple implicit components can function in a preconditioner under linear gauss-seidel. To correctly solve this component, you should slot a solver in linear_solver or override this method.

Parameters
d_outputsVector

unscaled, dimensional quantities read via d_outputs[key]

d_residualsVector

unscaled, dimensional quantities read via d_residuals[key]

modestr

either ‘fwd’ or ‘rev’

solve_nonlinear(self, inputs, outputs)

Compute outputs given inputs. The model is assumed to be in an unscaled state.

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

outputsVector

unscaled, dimensional output variables read via outputs[key]

system_iter(self, include_self=False, recurse=True, typ=None)

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.

use_fixed_coloring(self, coloring=<object object at 0x7f338004ca50>, recurse=True)

Use a precomputed coloring for this System.

Parameters
coloringstr

A coloring filename. If no arg is passed, filename will be determined automatically.

recursebool

If True, set fixed coloring in all subsystems that declare a coloring. Ignored if a specific coloring is passed in.

class openmdao.test_suite.components.sellar.SellarNoDerivatives(**kwargs)[source]

Bases: openmdao.core.group.Group

Group containing the Sellar MDA. This version uses the disciplines without derivatives.

__init__(self, **kwargs)

Set the solvers to nonlinear and linear block Gauss–Seidel by default.

Parameters
**kwargsdict

dict of arguments available here and in all descendants of this Group.

add(self, name, subsys, promotes=None)

Add a subsystem (deprecated version of <Group.add_subsystem>).

Parameters
namestr

Name of the subsystem being added

subsysSystem

An instantiated, but not-yet-set up system object.

promotesiter of str, optional

A list of variable names specifying which subsystem variables to ‘promote’ up to this group. This is for backwards compatibility with older versions of OpenMDAO.

Returns
System

The System that was passed in.

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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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)

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)

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 argument ref 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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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.

add_subsystem(self, name, subsys, promotes=None, promotes_inputs=None, promotes_outputs=None, min_procs=1, max_procs=None, proc_weight=1.0)

Add a subsystem.

Parameters
namestr

Name of the subsystem being added

subsys<System>

An instantiated, but not-yet-set up system object.

promotesiter of (str or tuple), optional

A list of variable names specifying which subsystem variables to ‘promote’ up to this group. If an entry is a tuple of the form (old_name, new_name), this will rename the variable in the parent group.

promotes_inputsiter of (str or tuple), optional

A list of input variable names specifying which subsystem input variables to ‘promote’ up to this group. If an entry is a tuple of the form (old_name, new_name), this will rename the variable in the parent group.

promotes_outputsiter of (str or tuple), optional

A list of output variable names specifying which subsystem output variables to ‘promote’ up to this group. If an entry is a tuple of the form (old_name, new_name), this will rename the variable in the parent group.

min_procsint

Minimum number of MPI processes usable by the subsystem. Defaults to 1.

max_procsint or None

Maximum number of MPI processes usable by the subsystem. A value of None (the default) indicates there is no maximum limit.

proc_weightfloat

Weight given to the subsystem when allocating available MPI processes to all subsystems. Default is 1.0.

Returns
<System>

the subsystem that was passed in. This is returned to enable users to instantiate and add a subsystem at the same time, and get the reference back.

approx_totals(self, method='fd', step=None, form=None, step_calc=None)

Approximate derivatives for a Group using the specified approximation method.

Parameters
methodstr

The type of approximation that should be used. Valid options include: ‘fd’: Finite Difference, ‘cs’: Complex Step

stepfloat

Step size for approximation. Defaults to None, in which case, the approximation method provides its default value.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Defaults to None, in which case, the approximation method provides its default value.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Defaults to None, in which case, the approximation method provides its default value.

check_config(self, logger)

Perform optional error checks.

Parameters
loggerobject

The object that manages logging output.

cleanup(self)

Clean up resources prior to exit.

compute_sys_graph(self, comps_only=False)

Compute a dependency graph for subsystems in this group.

Variable connection information is stored in each edge of the system graph.

Parameters
comps_onlybool (False)

If True, return a graph of all components within this group or any of its descendants. No sub-groups will be included. Otherwise, a graph containing only direct children (both Components and Groups) of this group will be returned.

Returns
DiGraph

A directed graph containing names of subsystems and their connections.

configure(self)[source]

Configure this group to assign children settings.

This method may optionally be overidden by your Group’s method.

You may only use this method to change settings on your children subsystems. This includes setting solvers in cases where you want to override the defaults.

You can assume that the full hierarchy below your level has been instantiated and has already called its own configure methods.

Available attributes:

name pathname comm options system hieararchy with attribute access

connect(self, src_name, tgt_name, src_indices=None, flat_src_indices=None)

Connect source src_name to target tgt_name in this namespace.

Parameters
src_namestr

name of the source variable to connect

tgt_namestr or [str, … ] or (str, …)

name of the target variable(s) to connect

src_indicesint or list of ints or tuple of ints or int ndarray or Iterable or None

The global indices of the source variable to transfer data from. The shapes of the target and src_indices must match, and form of the entries within is determined by the value of ‘flat_src_indices’.

flat_src_indicesbool

If True, each entry of src_indices is assumed to be an index into the flattened source. Otherwise it must be a tuple or list of size equal to the number of dimensions of the source.

declare_coloring(self, wrt=('*', ), method='fd', form=None, step=None, per_instance=False, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, show_summary=True, show_sparsity=False)

Set options for deriv coloring of a set of wrt vars matching the given pattern(s).

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain input names, output names, or glob patterns.

methodstr

Method used to compute derivative: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference. Leave undeclared to keep unchanged from previous or default value.

per_instancebool

If True, a separate coloring will be generated for each instance of a given class. Otherwise, only one coloring for a given class will be generated and all instances of that class will use it.

num_full_jacsint

Number of times to repeat partial jacobian computation when computing sparsity.

tolfloat

Tolerance used to determine if an array entry is nonzero during sparsity determination.

ordersint

Number of orders above and below the tolerance to check during the tolerance sweep.

perturb_sizefloat

Size of input/output perturbation during generation of sparsity.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

If True, display sparsity with coloring info after generating coloring.

get_approx_coloring_fname(self)

Return the full pathname to a coloring file.

Parameters
systemSystem

The System having its coloring saved or loaded.

Returns
str

Full pathname of the coloring file.

get_constraints(self, recurse=True)

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)

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 design variable.

Returns
dict

The design variables defined in the current system and, if recurse=True, its subsystems.

get_linear_vectors(self, vec_name='linear')

Return the linear inputs, outputs, and residuals vectors.

Parameters
vec_namestr

Name of the linear right-hand-side 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)

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)

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)

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.

guess_nonlinear(self, inputs, outputs, residuals, discrete_inputs=None, discrete_outputs=None)

Provide initial guess for states.

Override this method to set the initial guess for states.

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

outputsVector

unscaled, dimensional output variables read via outputs[key]

residualsVector

unscaled, dimensional residuals written to via residuals[key]

discrete_inputsdict or None

If not None, dict containing discrete input values.

discrete_outputsdict or None

If not None, dict containing discrete output values.

initialize(self)[source]

Perform any one-time initialization run at instantiation.

is_active(self)

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.

property 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only inputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only outputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like

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

property ln_solver

Get the linear solver for this system.

property metadata

Get the options for this System.

property msginfo

Our instance pathname, if available, or our class name. For use in error messages.

Returns
str

Either our instance pathname or class name.

property nl_solver

Get the nonlinear solver for this system.

property nonlinear_solver

Get the nonlinear solver for this system.

reconfigure(self)

Perform reconfiguration.

Returns
bool

If True, reconfiguration is to be performed.

record_iteration(self)

Record an iteration of the current System.

resetup(self, setup_mode='full')

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)

Compute jac-vec 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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

scope_outset or None

Set of absolute output names in the scope of this mat-vec product. If None, all are in the scope.

scope_inset or None

Set of absolute input names in the scope of this mat-vec product. If None, all are in the scope.

run_apply_nonlinear(self)

Compute residuals.

This calls _apply_nonlinear, but with the model assumed to be in an unscaled state.

run_linearize(self, sub_do_ln=True)

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)

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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear(self)

Compute outputs.

This calls _solve_nonlinear, but with the model assumed to be in an unscaled state.

set_initial_values(self)

Set all input and output variables to their declared initial values.

set_order(self, new_order)

Specify a new execution order for this system.

Parameters
new_orderlist of str

List of system names in desired new execution order.

setup(self)[source]

Build this group.

This method should be overidden by your Group’s method. The reason for using this method to add subsystem is to save memory and setup time when using your Group while running under MPI. This avoids the creation of systems that will not be used in the current process.

You may call ‘add_subsystem’ to add systems to this group. You may also issue connections, and set the linear and nonlinear solvers for this group level. You cannot safely change anything on children systems; use the ‘configure’ method instead.

Available attributes:

name pathname comm options

system_iter(self, include_self=False, recurse=True, typ=None)

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.

use_fixed_coloring(self, coloring=<object object at 0x7f338004ca50>, recurse=True)

Use a precomputed coloring for this System.

Parameters
coloringstr

A coloring filename. If no arg is passed, filename will be determined automatically.

recursebool

If True, set fixed coloring in all subsystems that declare a coloring. Ignored if a specific coloring is passed in.

class openmdao.test_suite.components.sellar.SellarProblem(model_class=<class 'openmdao.test_suite.components.sellar.SellarDerivatives'>, **kwargs)[source]

Bases: openmdao.core.problem.Problem

The Sellar problem with configurable model class.

__getitem__(self, name)

Get an output/input variable.

Parameters
namestr

Promoted or relative variable name in the root system’s namespace.

Returns
float or ndarray or any python object

the requested output/input variable.

__init__(self, model_class=<class 'openmdao.test_suite.components.sellar.SellarDerivatives'>, **kwargs)[source]

Initialize attributes.

Parameters
model<System> or None

The top-level <System>. If not specified, an empty <Group> will be created.

driver<Driver> or None

The driver for the problem. If not specified, a simple “Run Once” driver will be used.

commMPI.Comm or <FakeComm> or None

The global communicator.

root<System> or None

Deprecated kwarg for model.

**optionsnamed args

All remaining named args are converted to options.

__setitem__(self, name, value)

Set an output/input variable.

Parameters
namestr

Promoted or relative variable name in the root system’s namespace.

valuefloat or ndarray or any python object

value to set this variable to.

add_recorder(self, recorder)

Add a recorder to the problem.

Parameters
recorderCaseRecorder

A recorder instance.

check_config(self, logger=None, checks=None, out_file='openmdao_checks.out')

Perform optional error checks on a Problem.

Parameters
loggerobject

Logging object.

checkslist of str or None

List of specific checks to be performed.

out_filestr or None

If not None, output will be written to this file in addition to stdout.

check_partials(self, out_stream=<object object at 0x7f3378b13860>, includes=None, excludes=None, compact_print=False, abs_err_tol=1e-06, rel_err_tol=1e-06, method='fd', step=None, form='forward', step_calc='abs', force_dense=True, show_only_incorrect=False)

Check partial derivatives comprehensively for all components in your model.

Parameters
out_streamfile-like object

Where to send human readable output. By default it goes to stdout. Set to None to suppress.

includesNone or list_like

List of glob patterns for pathnames to include in the check. Default is None, which includes all components in the model.

excludesNone or list_like

List of glob patterns for pathnames to exclude from the check. Default is None, which excludes nothing.

compact_printbool

Set to True to just print the essentials, one line per unknown-param pair.

abs_err_tolfloat

Threshold value for absolute error. Errors about this value will have a ‘*’ displayed next to them in output, making them easy to search for. Default is 1.0E-6.

rel_err_tolfloat

Threshold value for relative error. Errors about this value will have a ‘*’ displayed next to them in output, making them easy to search for. Note at times there may be a significant relative error due to a minor absolute error. Default is 1.0E-6.

methodstr

Method, ‘fd’ for finite difference or ‘cs’ for complex step. Default is ‘fd’.

stepfloat

Step size for approximation. Default is None, which means 1e-6 for ‘fd’ and 1e-40 for ‘cs’.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Default ‘forward’.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Default is ‘abs’.

force_densebool

If True, analytic derivatives will be coerced into arrays. Default is True.

show_only_incorrectbool, optional

Set to True if output should print only the subjacs found to be incorrect.

Returns
dict of dicts of dicts
First key:

is the component name;

Second key:

is the (output, input) tuple of strings;

Third key:

is one of [‘rel error’, ‘abs error’, ‘magnitude’, ‘J_fd’, ‘J_fwd’, ‘J_rev’];

For ‘rel error’, ‘abs error’, ‘magnitude’ the value is: A tuple containing norms for

forward - fd, adjoint - fd, forward - adjoint.

For ‘J_fd’, ‘J_fwd’, ‘J_rev’ the value is: A numpy array representing the computed

Jacobian for the three different methods of computation.

check_totals(self, of=None, wrt=None, out_stream=<object object at 0x7f3378b13860>, compact_print=False, driver_scaling=False, abs_err_tol=1e-06, rel_err_tol=1e-06, method='fd', step=None, form=None, step_calc='abs')

Check total derivatives for the model vs. finite difference.

Parameters
oflist of variable name strings or None

Variables whose derivatives will be computed. Default is None, which uses the driver’s objectives and constraints.

wrtlist of variable name strings or None

Variables with respect to which the derivatives will be computed. Default is None, which uses the driver’s desvars.

out_streamfile-like object

Where to send human readable output. By default it goes to stdout. Set to None to suppress.

compact_printbool

Set to True to just print the essentials, one line per unknown-param pair.

driver_scalingbool

When True, return derivatives that are scaled according to either the adder and scaler or the ref and ref0 values that were specified when add_design_var, add_objective, and add_constraint were called on the model. Default is False, which is unscaled.

abs_err_tolfloat

Threshold value for absolute error. Errors about this value will have a ‘*’ displayed next to them in output, making them easy to search for. Default is 1.0E-6.

rel_err_tolfloat

Threshold value for relative error. Errors about this value will have a ‘*’ displayed next to them in output, making them easy to search for. Note at times there may be a significant relative error due to a minor absolute error. Default is 1.0E-6.

methodstr

Method, ‘fd’ for finite difference or ‘cs’ for complex step. Default is ‘fd’

stepfloat

Step size for approximation. Default is None, which means 1e-6 for ‘fd’ and 1e-40 for ‘cs’.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Default None, which defaults to ‘forward’ for FD.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Default is ‘abs’.

Returns
Dict of Dicts of Tuples of Floats
First key:

is the (output, input) tuple of strings;

Second key:

is one of [‘rel error’, ‘abs error’, ‘magnitude’, ‘fdstep’];

For ‘rel error’, ‘abs error’, ‘magnitude’ the value is: A tuple containing norms for

forward - fd, adjoint - fd, forward - adjoint.

cleanup(self)

Clean up resources prior to exit.

compute_totals(self, of=None, wrt=None, return_format='flat_dict', debug_print=False, driver_scaling=False)

Compute derivatives of desired quantities with respect to desired inputs.

Parameters
oflist of variable name strings or None

Variables whose derivatives will be computed. Default is None, which uses the driver’s objectives and constraints.

wrtlist of variable name strings or None

Variables with respect to which the derivatives will be computed. Default is None, which uses the driver’s desvars.

return_formatstring

Format to return the derivatives. Can be either ‘dict’ or ‘flat_dict’. Default is a ‘flat_dict’, which returns them in a dictionary whose keys are tuples of form (of, wrt).

debug_printbool

Set to True to print out some debug information during linear solve.

driver_scalingbool

When True, return derivatives that are scaled according to either the adder and scaler or the ref and ref0 values that were specified when add_design_var, add_objective, and add_constraint were called on the model. Default is False, which is unscaled.

Returns
derivsobject

Derivatives in form requested by ‘return_format’.

final_setup(self)

Perform final setup phase on problem in preparation for run.

This is the second phase of setup, and is done automatically at the start of run_driver and run_model. At the beginning of final_setup, we have a model hierarchy with defined variables, solvers, case_recorders, and derivative settings. During this phase, the vectors are created and populated, the drivers and solvers are initialized, and the recorders are started, and the rest of the framework is prepared for execution.

get_val(self, name, units=None, indices=None, get_remote=False)

Get an output/input variable.

Function is used if you want to specify display units.

Parameters
namestr

Promoted or relative variable name in the root system’s namespace.

unitsstr, optional

Units to convert to before upon return.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to return.

get_remotebool

If True, retrieve the value even if it is on a remote process. Note that if the variable is remote on ANY process, this function must be called on EVERY process in the Problem’s MPI communicator.

Returns
float or ndarray

The requested output/input variable.

is_local(self, name)

Return True if the named variable or system is local to the current process.

Parameters
namestr

Name of a variable or system.

Returns
bool

True if the named system or variable is local to this process.

list_problem_vars(self, show_promoted_name=True, print_arrays=False, desvar_opts=[], cons_opts=[], objs_opts=[])

Print all design variables and responses (objectives and constraints).

Parameters
show_promoted_namebool

If True, then show the promoted names of the variables.

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.

desvar_optslist of str

List of optional columns to be displayed in the desvars table. Allowed values are: [‘lower’, ‘upper’, ‘ref’, ‘ref0’, ‘indices’, ‘adder’, ‘scaler’, ‘parallel_deriv_color’, ‘vectorize_derivs’, ‘cache_linear_solution’]

cons_optslist of str

List of optional columns to be displayed in the cons table. Allowed values are: [‘lower’, ‘upper’, ‘equals’, ‘ref’, ‘ref0’, ‘indices’, ‘index’, ‘adder’, ‘scaler’, ‘linear’, ‘parallel_deriv_color’, ‘vectorize_derivs’, ‘cache_linear_solution’]

objs_optslist of str

List of optional columns to be displayed in the objs table. Allowed values are: [‘ref’, ‘ref0’, ‘indices’, ‘adder’, ‘scaler’, ‘parallel_deriv_color’, ‘vectorize_derivs’, ‘cache_linear_solution’]

load_case(self, case)

Pull all input and output variables from a case into the model.

Parameters
caseCase object

A Case from a CaseRecorder file.

record_iteration(self, case_name)

Record the variables at the Problem level.

Parameters
case_namestr

Name used to identify this Problem case.

property root

Provide ‘root’ property for backwards compatibility.

Returns
<Group>

reference to the ‘model’ property.

run(self)

Backward compatible call for run_driver.

Returns
boolean

Failure flag; True if failed to converge, False is successful.

run_driver(self, case_prefix=None, reset_iter_counts=True)

Run the driver on the model.

Parameters
case_prefixstr or None

Prefix to prepend to coordinates when recording.

reset_iter_countsbool

If True and model has been run previously, reset all iteration counters.

Returns
boolean

Failure flag; True if failed to converge, False is successful.

run_model(self, case_prefix=None, reset_iter_counts=True)

Run the model by calling the root system’s solve_nonlinear.

Parameters
case_prefixstr or None

Prefix to prepend to coordinates when recording.

reset_iter_countsbool

If True and model has been run previously, reset all iteration counters.

run_once(self)

Backward compatible call for run_model.

set_solver_print(self, level=2, depth=1e+99, type_='all')

Control printing for solvers and subsolvers in the model.

Parameters
levelint

iprint level. Set to 2 to print residuals each iteration; set to 1 to print just the iteration totals; set to 0 to disable all printing except for failures, and set to -1 to disable all printing including failures.

depthint

How deep to recurse. For example, you can set this to 0 if you only want to print the top level linear and nonlinear solver messages. Default prints everything.

type_str

Type of solver to set: ‘LN’ for linear, ‘NL’ for nonlinear, or ‘all’ for all.

set_val(self, name, value, units=None, indices=None)

Set an output/input variable.

Function is used if you want to set a value using a different unit.

Parameters
namestr

Promoted or relative variable name in the root system’s namespace.

valuefloat or ndarray or list

Value to set this variable to.

unitsstr, optional

Units that value is defined in.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to set to specified value.

setup(self, vector_class=None, check=False, logger=None, mode='auto', force_alloc_complex=False, distributed_vector_class=<class 'openmdao.vectors.petsc_vector.PETScVector'>, local_vector_class=<class 'openmdao.vectors.default_vector.DefaultVector'>, derivatives=True)

Set up the model hierarchy.

When setup is called, the model hierarchy is assembled, the processors are allocated (for MPI), and variables and connections are all assigned. This method traverses down the model hierarchy to call setup on each subsystem, and then traverses up the model hierarchy to call configure on each subsystem.

Parameters
vector_classtype

Reference to an actual <Vector> class; not an instance. This is deprecated. Use distributed_vector_class instead.

checkboolean

whether to run config check after setup is complete.

loggerobject

Object for logging config checks if check is True.

modestring

Derivatives calculation mode, ‘fwd’ for forward, and ‘rev’ for reverse (adjoint). Default is ‘auto’, which will pick ‘fwd’ or ‘rev’ based on the direction resulting in the smallest number of linear solves required to compute derivatives.

force_alloc_complexbool

Force allocation of imaginary part in nonlinear vectors. OpenMDAO can generally detect when you need to do this, but in some cases (e.g., complex step is used after a reconfiguration) you may need to set this to True.

distributed_vector_classtype

Reference to the <Vector> class or factory function used to instantiate vectors and associated transfers involved in interprocess communication.

local_vector_classtype

Reference to the <Vector> class or factory function used to instantiate vectors and associated transfers involved in intraprocess communication.

derivativesbool

If True, perform any memory allocations necessary for derivative computation.

Returns
self<Problem>

this enables the user to instantiate and setup in one line.

class openmdao.test_suite.components.sellar.SellarProblemWithArrays(model_class=<class 'openmdao.test_suite.components.sellar.SellarDerivatives'>, **kwargs)[source]

Bases: openmdao.core.problem.Problem

The Sellar problem with ndarray variable options

__getitem__(self, name)

Get an output/input variable.

Parameters
namestr

Promoted or relative variable name in the root system’s namespace.

Returns
float or ndarray or any python object

the requested output/input variable.

__init__(self, model_class=<class 'openmdao.test_suite.components.sellar.SellarDerivatives'>, **kwargs)[source]

Initialize attributes.

Parameters
model<System> or None

The top-level <System>. If not specified, an empty <Group> will be created.

driver<Driver> or None

The driver for the problem. If not specified, a simple “Run Once” driver will be used.

commMPI.Comm or <FakeComm> or None

The global communicator.

root<System> or None

Deprecated kwarg for model.

**optionsnamed args

All remaining named args are converted to options.

__setitem__(self, name, value)

Set an output/input variable.

Parameters
namestr

Promoted or relative variable name in the root system’s namespace.

valuefloat or ndarray or any python object

value to set this variable to.

add_recorder(self, recorder)

Add a recorder to the problem.

Parameters
recorderCaseRecorder

A recorder instance.

check_config(self, logger=None, checks=None, out_file='openmdao_checks.out')

Perform optional error checks on a Problem.

Parameters
loggerobject

Logging object.

checkslist of str or None

List of specific checks to be performed.

out_filestr or None

If not None, output will be written to this file in addition to stdout.

check_partials(self, out_stream=<object object at 0x7f3378b13860>, includes=None, excludes=None, compact_print=False, abs_err_tol=1e-06, rel_err_tol=1e-06, method='fd', step=None, form='forward', step_calc='abs', force_dense=True, show_only_incorrect=False)

Check partial derivatives comprehensively for all components in your model.

Parameters
out_streamfile-like object

Where to send human readable output. By default it goes to stdout. Set to None to suppress.

includesNone or list_like

List of glob patterns for pathnames to include in the check. Default is None, which includes all components in the model.

excludesNone or list_like

List of glob patterns for pathnames to exclude from the check. Default is None, which excludes nothing.

compact_printbool

Set to True to just print the essentials, one line per unknown-param pair.

abs_err_tolfloat

Threshold value for absolute error. Errors about this value will have a ‘*’ displayed next to them in output, making them easy to search for. Default is 1.0E-6.

rel_err_tolfloat

Threshold value for relative error. Errors about this value will have a ‘*’ displayed next to them in output, making them easy to search for. Note at times there may be a significant relative error due to a minor absolute error. Default is 1.0E-6.

methodstr

Method, ‘fd’ for finite difference or ‘cs’ for complex step. Default is ‘fd’.

stepfloat

Step size for approximation. Default is None, which means 1e-6 for ‘fd’ and 1e-40 for ‘cs’.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Default ‘forward’.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Default is ‘abs’.

force_densebool

If True, analytic derivatives will be coerced into arrays. Default is True.

show_only_incorrectbool, optional

Set to True if output should print only the subjacs found to be incorrect.

Returns
dict of dicts of dicts
First key:

is the component name;

Second key:

is the (output, input) tuple of strings;

Third key:

is one of [‘rel error’, ‘abs error’, ‘magnitude’, ‘J_fd’, ‘J_fwd’, ‘J_rev’];

For ‘rel error’, ‘abs error’, ‘magnitude’ the value is: A tuple containing norms for

forward - fd, adjoint - fd, forward - adjoint.

For ‘J_fd’, ‘J_fwd’, ‘J_rev’ the value is: A numpy array representing the computed

Jacobian for the three different methods of computation.

check_totals(self, of=None, wrt=None, out_stream=<object object at 0x7f3378b13860>, compact_print=False, driver_scaling=False, abs_err_tol=1e-06, rel_err_tol=1e-06, method='fd', step=None, form=None, step_calc='abs')

Check total derivatives for the model vs. finite difference.

Parameters
oflist of variable name strings or None

Variables whose derivatives will be computed. Default is None, which uses the driver’s objectives and constraints.

wrtlist of variable name strings or None

Variables with respect to which the derivatives will be computed. Default is None, which uses the driver’s desvars.

out_streamfile-like object

Where to send human readable output. By default it goes to stdout. Set to None to suppress.

compact_printbool

Set to True to just print the essentials, one line per unknown-param pair.

driver_scalingbool

When True, return derivatives that are scaled according to either the adder and scaler or the ref and ref0 values that were specified when add_design_var, add_objective, and add_constraint were called on the model. Default is False, which is unscaled.

abs_err_tolfloat

Threshold value for absolute error. Errors about this value will have a ‘*’ displayed next to them in output, making them easy to search for. Default is 1.0E-6.

rel_err_tolfloat

Threshold value for relative error. Errors about this value will have a ‘*’ displayed next to them in output, making them easy to search for. Note at times there may be a significant relative error due to a minor absolute error. Default is 1.0E-6.

methodstr

Method, ‘fd’ for finite difference or ‘cs’ for complex step. Default is ‘fd’

stepfloat

Step size for approximation. Default is None, which means 1e-6 for ‘fd’ and 1e-40 for ‘cs’.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Default None, which defaults to ‘forward’ for FD.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Default is ‘abs’.

Returns
Dict of Dicts of Tuples of Floats
First key:

is the (output, input) tuple of strings;

Second key:

is one of [‘rel error’, ‘abs error’, ‘magnitude’, ‘fdstep’];

For ‘rel error’, ‘abs error’, ‘magnitude’ the value is: A tuple containing norms for

forward - fd, adjoint - fd, forward - adjoint.

cleanup(self)

Clean up resources prior to exit.

compute_totals(self, of=None, wrt=None, return_format='flat_dict', debug_print=False, driver_scaling=False)

Compute derivatives of desired quantities with respect to desired inputs.

Parameters
oflist of variable name strings or None

Variables whose derivatives will be computed. Default is None, which uses the driver’s objectives and constraints.

wrtlist of variable name strings or None

Variables with respect to which the derivatives will be computed. Default is None, which uses the driver’s desvars.

return_formatstring

Format to return the derivatives. Can be either ‘dict’ or ‘flat_dict’. Default is a ‘flat_dict’, which returns them in a dictionary whose keys are tuples of form (of, wrt).

debug_printbool

Set to True to print out some debug information during linear solve.

driver_scalingbool

When True, return derivatives that are scaled according to either the adder and scaler or the ref and ref0 values that were specified when add_design_var, add_objective, and add_constraint were called on the model. Default is False, which is unscaled.

Returns
derivsobject

Derivatives in form requested by ‘return_format’.

final_setup(self)

Perform final setup phase on problem in preparation for run.

This is the second phase of setup, and is done automatically at the start of run_driver and run_model. At the beginning of final_setup, we have a model hierarchy with defined variables, solvers, case_recorders, and derivative settings. During this phase, the vectors are created and populated, the drivers and solvers are initialized, and the recorders are started, and the rest of the framework is prepared for execution.

get_val(self, name, units=None, indices=None, get_remote=False)

Get an output/input variable.

Function is used if you want to specify display units.

Parameters
namestr

Promoted or relative variable name in the root system’s namespace.

unitsstr, optional

Units to convert to before upon return.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to return.

get_remotebool

If True, retrieve the value even if it is on a remote process. Note that if the variable is remote on ANY process, this function must be called on EVERY process in the Problem’s MPI communicator.

Returns
float or ndarray

The requested output/input variable.

is_local(self, name)

Return True if the named variable or system is local to the current process.

Parameters
namestr

Name of a variable or system.

Returns
bool

True if the named system or variable is local to this process.

list_problem_vars(self, show_promoted_name=True, print_arrays=False, desvar_opts=[], cons_opts=[], objs_opts=[])

Print all design variables and responses (objectives and constraints).

Parameters
show_promoted_namebool

If True, then show the promoted names of the variables.

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.

desvar_optslist of str

List of optional columns to be displayed in the desvars table. Allowed values are: [‘lower’, ‘upper’, ‘ref’, ‘ref0’, ‘indices’, ‘adder’, ‘scaler’, ‘parallel_deriv_color’, ‘vectorize_derivs’, ‘cache_linear_solution’]

cons_optslist of str

List of optional columns to be displayed in the cons table. Allowed values are: [‘lower’, ‘upper’, ‘equals’, ‘ref’, ‘ref0’, ‘indices’, ‘index’, ‘adder’, ‘scaler’, ‘linear’, ‘parallel_deriv_color’, ‘vectorize_derivs’, ‘cache_linear_solution’]

objs_optslist of str

List of optional columns to be displayed in the objs table. Allowed values are: [‘ref’, ‘ref0’, ‘indices’, ‘adder’, ‘scaler’, ‘parallel_deriv_color’, ‘vectorize_derivs’, ‘cache_linear_solution’]

load_case(self, case)

Pull all input and output variables from a case into the model.

Parameters
caseCase object

A Case from a CaseRecorder file.

record_iteration(self, case_name)

Record the variables at the Problem level.

Parameters
case_namestr

Name used to identify this Problem case.

property root

Provide ‘root’ property for backwards compatibility.

Returns
<Group>

reference to the ‘model’ property.

run(self)

Backward compatible call for run_driver.

Returns
boolean

Failure flag; True if failed to converge, False is successful.

run_driver(self, case_prefix=None, reset_iter_counts=True)

Run the driver on the model.

Parameters
case_prefixstr or None

Prefix to prepend to coordinates when recording.

reset_iter_countsbool

If True and model has been run previously, reset all iteration counters.

Returns
boolean

Failure flag; True if failed to converge, False is successful.

run_model(self, case_prefix=None, reset_iter_counts=True)

Run the model by calling the root system’s solve_nonlinear.

Parameters
case_prefixstr or None

Prefix to prepend to coordinates when recording.

reset_iter_countsbool

If True and model has been run previously, reset all iteration counters.

run_once(self)

Backward compatible call for run_model.

set_solver_print(self, level=2, depth=1e+99, type_='all')

Control printing for solvers and subsolvers in the model.

Parameters
levelint

iprint level. Set to 2 to print residuals each iteration; set to 1 to print just the iteration totals; set to 0 to disable all printing except for failures, and set to -1 to disable all printing including failures.

depthint

How deep to recurse. For example, you can set this to 0 if you only want to print the top level linear and nonlinear solver messages. Default prints everything.

type_str

Type of solver to set: ‘LN’ for linear, ‘NL’ for nonlinear, or ‘all’ for all.

set_val(self, name, value, units=None, indices=None)

Set an output/input variable.

Function is used if you want to set a value using a different unit.

Parameters
namestr

Promoted or relative variable name in the root system’s namespace.

valuefloat or ndarray or list

Value to set this variable to.

unitsstr, optional

Units that value is defined in.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to set to specified value.

setup(self, vector_class=None, check=False, logger=None, mode='auto', force_alloc_complex=False, distributed_vector_class=<class 'openmdao.vectors.petsc_vector.PETScVector'>, local_vector_class=<class 'openmdao.vectors.default_vector.DefaultVector'>, derivatives=True)

Set up the model hierarchy.

When setup is called, the model hierarchy is assembled, the processors are allocated (for MPI), and variables and connections are all assigned. This method traverses down the model hierarchy to call setup on each subsystem, and then traverses up the model hierarchy to call configure on each subsystem.

Parameters
vector_classtype

Reference to an actual <Vector> class; not an instance. This is deprecated. Use distributed_vector_class instead.

checkboolean

whether to run config check after setup is complete.

loggerobject

Object for logging config checks if check is True.

modestring

Derivatives calculation mode, ‘fwd’ for forward, and ‘rev’ for reverse (adjoint). Default is ‘auto’, which will pick ‘fwd’ or ‘rev’ based on the direction resulting in the smallest number of linear solves required to compute derivatives.

force_alloc_complexbool

Force allocation of imaginary part in nonlinear vectors. OpenMDAO can generally detect when you need to do this, but in some cases (e.g., complex step is used after a reconfiguration) you may need to set this to True.

distributed_vector_classtype

Reference to the <Vector> class or factory function used to instantiate vectors and associated transfers involved in interprocess communication.

local_vector_classtype

Reference to the <Vector> class or factory function used to instantiate vectors and associated transfers involved in intraprocess communication.

derivativesbool

If True, perform any memory allocations necessary for derivative computation.

Returns
self<Problem>

this enables the user to instantiate and setup in one line.

class openmdao.test_suite.components.sellar.SellarStateConnection(**kwargs)[source]

Bases: openmdao.core.group.Group

Group containing the Sellar MDA. This version uses the disciplines with derivatives.

__init__(self, **kwargs)

Set the solvers to nonlinear and linear block Gauss–Seidel by default.

Parameters
**kwargsdict

dict of arguments available here and in all descendants of this Group.

add(self, name, subsys, promotes=None)

Add a subsystem (deprecated version of <Group.add_subsystem>).

Parameters
namestr

Name of the subsystem being added

subsysSystem

An instantiated, but not-yet-set up system object.

promotesiter of str, optional

A list of variable names specifying which subsystem variables to ‘promote’ up to this group. This is for backwards compatibility with older versions of OpenMDAO.

Returns
System

The System that was passed in.

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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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)

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)

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 argument ref 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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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.

add_subsystem(self, name, subsys, promotes=None, promotes_inputs=None, promotes_outputs=None, min_procs=1, max_procs=None, proc_weight=1.0)

Add a subsystem.

Parameters
namestr

Name of the subsystem being added

subsys<System>

An instantiated, but not-yet-set up system object.

promotesiter of (str or tuple), optional

A list of variable names specifying which subsystem variables to ‘promote’ up to this group. If an entry is a tuple of the form (old_name, new_name), this will rename the variable in the parent group.

promotes_inputsiter of (str or tuple), optional

A list of input variable names specifying which subsystem input variables to ‘promote’ up to this group. If an entry is a tuple of the form (old_name, new_name), this will rename the variable in the parent group.

promotes_outputsiter of (str or tuple), optional

A list of output variable names specifying which subsystem output variables to ‘promote’ up to this group. If an entry is a tuple of the form (old_name, new_name), this will rename the variable in the parent group.

min_procsint

Minimum number of MPI processes usable by the subsystem. Defaults to 1.

max_procsint or None

Maximum number of MPI processes usable by the subsystem. A value of None (the default) indicates there is no maximum limit.

proc_weightfloat

Weight given to the subsystem when allocating available MPI processes to all subsystems. Default is 1.0.

Returns
<System>

the subsystem that was passed in. This is returned to enable users to instantiate and add a subsystem at the same time, and get the reference back.

approx_totals(self, method='fd', step=None, form=None, step_calc=None)

Approximate derivatives for a Group using the specified approximation method.

Parameters
methodstr

The type of approximation that should be used. Valid options include: ‘fd’: Finite Difference, ‘cs’: Complex Step

stepfloat

Step size for approximation. Defaults to None, in which case, the approximation method provides its default value.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Defaults to None, in which case, the approximation method provides its default value.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Defaults to None, in which case, the approximation method provides its default value.

check_config(self, logger)

Perform optional error checks.

Parameters
loggerobject

The object that manages logging output.

cleanup(self)

Clean up resources prior to exit.

compute_sys_graph(self, comps_only=False)

Compute a dependency graph for subsystems in this group.

Variable connection information is stored in each edge of the system graph.

Parameters
comps_onlybool (False)

If True, return a graph of all components within this group or any of its descendants. No sub-groups will be included. Otherwise, a graph containing only direct children (both Components and Groups) of this group will be returned.

Returns
DiGraph

A directed graph containing names of subsystems and their connections.

configure(self)[source]

Configure this group to assign children settings.

This method may optionally be overidden by your Group’s method.

You may only use this method to change settings on your children subsystems. This includes setting solvers in cases where you want to override the defaults.

You can assume that the full hierarchy below your level has been instantiated and has already called its own configure methods.

Available attributes:

name pathname comm options system hieararchy with attribute access

connect(self, src_name, tgt_name, src_indices=None, flat_src_indices=None)

Connect source src_name to target tgt_name in this namespace.

Parameters
src_namestr

name of the source variable to connect

tgt_namestr or [str, … ] or (str, …)

name of the target variable(s) to connect

src_indicesint or list of ints or tuple of ints or int ndarray or Iterable or None

The global indices of the source variable to transfer data from. The shapes of the target and src_indices must match, and form of the entries within is determined by the value of ‘flat_src_indices’.

flat_src_indicesbool

If True, each entry of src_indices is assumed to be an index into the flattened source. Otherwise it must be a tuple or list of size equal to the number of dimensions of the source.

declare_coloring(self, wrt=('*', ), method='fd', form=None, step=None, per_instance=False, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, show_summary=True, show_sparsity=False)

Set options for deriv coloring of a set of wrt vars matching the given pattern(s).

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain input names, output names, or glob patterns.

methodstr

Method used to compute derivative: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference. Leave undeclared to keep unchanged from previous or default value.

per_instancebool

If True, a separate coloring will be generated for each instance of a given class. Otherwise, only one coloring for a given class will be generated and all instances of that class will use it.

num_full_jacsint

Number of times to repeat partial jacobian computation when computing sparsity.

tolfloat

Tolerance used to determine if an array entry is nonzero during sparsity determination.

ordersint

Number of orders above and below the tolerance to check during the tolerance sweep.

perturb_sizefloat

Size of input/output perturbation during generation of sparsity.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

If True, display sparsity with coloring info after generating coloring.

get_approx_coloring_fname(self)

Return the full pathname to a coloring file.

Parameters
systemSystem

The System having its coloring saved or loaded.

Returns
str

Full pathname of the coloring file.

get_constraints(self, recurse=True)

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)

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 design variable.

Returns
dict

The design variables defined in the current system and, if recurse=True, its subsystems.

get_linear_vectors(self, vec_name='linear')

Return the linear inputs, outputs, and residuals vectors.

Parameters
vec_namestr

Name of the linear right-hand-side 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)

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)

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)

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.

guess_nonlinear(self, inputs, outputs, residuals, discrete_inputs=None, discrete_outputs=None)

Provide initial guess for states.

Override this method to set the initial guess for states.

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

outputsVector

unscaled, dimensional output variables read via outputs[key]

residualsVector

unscaled, dimensional residuals written to via residuals[key]

discrete_inputsdict or None

If not None, dict containing discrete input values.

discrete_outputsdict or None

If not None, dict containing discrete output values.

initialize(self)[source]

Perform any one-time initialization run at instantiation.

is_active(self)

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.

property 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only inputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like 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, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.

tagsstr or list of strs

User defined tags that can be used to filter what gets listed. Only outputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.

out_streamfile-like

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

property ln_solver

Get the linear solver for this system.

property metadata

Get the options for this System.

property msginfo

Our instance pathname, if available, or our class name. For use in error messages.

Returns
str

Either our instance pathname or class name.

property nl_solver

Get the nonlinear solver for this system.

property nonlinear_solver

Get the nonlinear solver for this system.

reconfigure(self)

Perform reconfiguration.

Returns
bool

If True, reconfiguration is to be performed.

record_iteration(self)

Record an iteration of the current System.

resetup(self, setup_mode='full')

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)

Compute jac-vec 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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

scope_outset or None

Set of absolute output names in the scope of this mat-vec product. If None, all are in the scope.

scope_inset or None

Set of absolute input names in the scope of this mat-vec product. If None, all are in the scope.

run_apply_nonlinear(self)

Compute residuals.

This calls _apply_nonlinear, but with the model assumed to be in an unscaled state.

run_linearize(self, sub_do_ln=True)

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)

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 right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear(self)

Compute outputs.

This calls _solve_nonlinear, but with the model assumed to be in an unscaled state.

set_initial_values(self)

Set all input and output variables to their declared initial values.

set_order(self, new_order)

Specify a new execution order for this system.

Parameters
new_orderlist of str

List of system names in desired new execution order.

setup(self)[source]

Build this group.

This method should be overidden by your Group’s method. The reason for using this method to add subsystem is to save memory and setup time when using your Group while running under MPI. This avoids the creation of systems that will not be used in the current process.

You may call ‘add_subsystem’ to add systems to this group. You may also issue connections, and set the linear and nonlinear solvers for this group level. You cannot safely change anything on children systems; use the ‘configure’ method instead.

Available attributes:

name pathname comm options

system_iter(self, include_self=False, recurse=True, typ=None)

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.

use_fixed_coloring(self, coloring=<object object at 0x7f338004ca50>, recurse=True)

Use a precomputed coloring for this System.

Parameters
coloringstr

A coloring filename. If no arg is passed, filename will be determined automatically.

recursebool

If True, set fixed coloring in all subsystems that declare a coloring. Ignored if a specific coloring is passed in.

class openmdao.test_suite.components.sellar.StateConnection(**kwargs)[source]

Bases: openmdao.core.implicitcomponent.ImplicitComponent

Define connection with an explicit equation.

__init__(self, **kwargs)

Store some bound methods so we can detect runtime overrides.

Parameters
**kwargsdict of keyword arguments

Keyword arguments that will be mapped into the Component 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref 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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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 argument ref represents the physical value when the scaled value is 1.

add_discrete_input(self, name, val, desc='', tags=None)

Add a discrete input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_discrete_output(self, name, val, desc='', tags=None)

Add an output variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

vala picklable object

The initial value of the variable being added.

descstr

description of the variable.

tagsstr or list of strs or set of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_input(self, name, val=1.0, shape=None, src_indices=None, flat_src_indices=None, units=None, desc='', tags=None)

Add an input variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray or Iterable

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if src_indices not provided and val is not an array. Default is None.

src_indicesint or list of ints or tuple of ints or int ndarray or Iterable or None

The global indices of the source variable to transfer data from. A value of None implies this input depends on all entries of source. Default is None. The shapes of the target and src_indices must match, and form of the entries within is determined by the value of ‘flat_src_indices’.

flat_src_indicesbool

If True, each entry of src_indices is assumed to be an index into the flattened source. Otherwise each entry must be a tuple or list of size equal to the number of dimensions of the source.

unitsstr or None

Units in which this input variable will be provided to the component during execution. Default is None, which means it is unitless.

descstr

description of the variable

tagsstr or list of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

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)

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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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_output(self, name, val=1.0, shape=None, units=None, res_units=None, desc='', lower=None, upper=None, ref=1.0, ref0=0.0, res_ref=1.0, tags=None)

Add an output variable to the component.

Parameters
namestr

name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray

The initial value of the variable being added in user-defined units. Default is 1.0.

shapeint or tuple or list or None

Shape of this variable, only required if val is not an array. Default is None.

unitsstr or None

Units in which the output variables will be provided to the component during execution. Default is None, which means it has no units.

res_unitsstr or None

Units in which the residuals of this output will be given to the user when requested. Default is None, which means it has no units.

descstr

description of the variable.

lowerfloat or list or tuple or ndarray or Iterable or None

lower bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no lower bound. Default is None.

upperfloat or list or tuple or ndarray or or Iterable None

upper bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no upper bound. Default is None.

reffloat or ndarray

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 1. Default is 1.

ref0float or ndarray

Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 0. Default is 0.

res_reffloat or ndarray

Scaling parameter. The value in the user-defined res_units of this output’s residual when the scaled value is 1. Default is 1.

tagsstr or list of strs or set of strs

User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.

Returns
dict

metadata for added variable

add_recorder(self, recorder, recurse=False)

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)

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 argument ref 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 for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.

scalerfloat or ndarray, optional

value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.

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.

apply_linear(self, inputs, outputs, d_inputs, d_outputs, d_residuals, mode)

Compute jac-vector product. The model is assumed to be in an unscaled state.

If mode is:

‘fwd’: (d_inputs, d_outputs) |-> d_residuals

‘rev’: d_residuals |-> (d_inputs, d_outputs)

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

outputsVector

unscaled, dimensional output variables read via outputs[key]

d_inputsVector

see inputs; product must be computed only if var_name in d_inputs

d_outputsVector

see outputs; product must be computed only if var_name in d_outputs

d_residualsVector

see outputs

modestr

either ‘fwd’ or ‘rev’

apply_nonlinear(self, inputs, outputs, residuals)[source]

Don’t solve; just calculate the residual.

check_config(self, logger)

Perform optional error checks.

Parameters
loggerobject

The object that manages logging output.

cleanup(self)

Clean up resources prior to exit.

compute(self, inputs, outputs)[source]

This is a dummy comp that doesn’t modify its state.

declare_coloring(self, wrt=('*', ), method='fd', form=None, step=None, per_instance=False, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, show_summary=True, show_sparsity=False)

Set options for deriv coloring of a set of wrt vars matching the given pattern(s).

Parameters
wrtstr or list of str

The name or names of the variables that derivatives are taken with respect to. This can contain input names, output names, or glob patterns.

methodstr

Method used to compute derivative: “fd” for finite difference, “cs” for complex step.

formstr

Finite difference form, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.

stepfloat

Step size for finite difference. Leave undeclared to keep unchanged from previous or default value.

per_instancebool

If True, a separate coloring will be generated for each instance of a given class. Otherwise, only one coloring for a given class will be generated and all instances of that class will use it.

num_full_jacsint

Number of times to repeat partial jacobian computation when computing sparsity.

tolfloat

Tolerance used to determine if an array entry is nonzero during sparsity determination.

ordersint

Number of orders above and below the tolerance to check during the tolerance sweep.

perturb_sizefloat

Size of input/output perturbation during generation of sparsity.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

If True, display sparsity with coloring info after generating coloring.

declare_partials(self, of, wrt, dependent=True, rows=None, cols=None, val=None, method='exact', step=None, form=None, step_calc=None)

Declare information about this component’s subjacobians.

Parameters
ofstr or list of str

The name of the residual(s) that derivatives are being computed for. May also contain a glob pattern.

wrtstr or list of str

The name of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.

dependentbool(True)

If False, specifies no dependence between the output(s) and the input(s). This is only necessary in the case of a sparse global jacobian, because if ‘dependent=False’ is not specified and declare_partials is not called for a given pair, then a dense matrix of zeros will be allocated in the sparse global jacobian for that pair. In the case of a dense global jacobian it doesn’t matter because the space for a dense subjac will always be allocated for every pair.

rowsndarray of int or None

Row indices for each nonzero entry. For sparse subjacobians only.

colsndarray of int or None

Column indices for each nonzero entry. For sparse subjacobians only.

valfloat or ndarray of float or scipy.sparse

Value of subjacobian. If rows and cols are not None, this will contain the values found at each (row, col) location in the subjac.

methodstr

The type of approximation that should be used. Valid options include: ‘fd’: Finite Difference, ‘cs’: Complex Step, ‘exact’: use the component defined analytic derivatives. Default is ‘exact’.

stepfloat

Step size for approximation. Defaults to None, in which case the approximation method provides its default value.

formstring

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Defaults to None, in which case the approximation method provides its default value.

step_calcstring

Step type for finite difference, can be ‘abs’ for absolute’, or ‘rel’ for relative. Defaults to None, in which case the approximation method provides its default value.

Returns
dict

Metadata dict for the specified partial(s).

property distributed

Provide ‘distributed’ property for backwards compatibility.

Returns
bool

reference to the ‘distributed’ option.

get_approx_coloring_fname(self)

Return the full pathname to a coloring file.

Parameters
systemSystem

The System having its coloring saved or loaded.

Returns
str

Full pathname of the coloring file.

get_constraints(self, recurse=True)

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)

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 design variable.

Returns
dict

The design variables defined in the current system and, if recurse=True, its subsystems.

get_linear_vectors(self, vec_name='linear')

Return the linear inputs, outputs, and residuals vectors.

Parameters
vec_namestr

Name of the linear right-hand-side 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)

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)

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)

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.

guess_nonlinear(self, inputs, outputs, residuals, discrete_inputs=None, discrete_outputs=None)

Provide initial guess for states.

Override this method to set the initial guess for states.

Parameters
inputsVector

unscaled, dimensional input variables read via inputs[key]

outputsVector

unscaled, dimensional output variables read via outputs[key]

residualsVector

unscaled, dimensional residuals written to via residuals[key]

discrete_inputsdict or None

If not None, dict containing discrete input values.

discrete_outputsdict or None

If not None, dict containing discrete output values.

initialize(self)

Perform any one-time initialization run at instantiation.

is_active(self)

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.

property linear_solver

Get the linear solver for this system.

linearize(self, inputs, outputs, J)[source]

Analytical derivatives.

list_inputs(self, values=True, prom_name=False, units=False, shape=False, hierarchical=True, print_arrays=False, tags=None, out_stream=<object object at 0x7f337f90f200>)

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.