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: Group

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

__init__(**kwargs)

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

abs_meta_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names and their metadata for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str, dict
abs_name_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str
add_constraint(name, lower=None, upper=None, equals=None, ref=None, ref0=None, adder=None, scaler=None, units=None, indices=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a constraint variable to this system.

Parameters:
namestr

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 alternative to using ref and ref0.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

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. The arguments (lower, upper, equals) can not be strings or variable names.

add_design_var(name, lower=None, upper=None, ref=None, ref0=None, indices=None, adder=None, scaler=None, units=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False)

Add a design variable to this system.

Parameters:
namestr

Promoted name of the design variable in the system.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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 an input 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.

unitsstr, optional

Units to convert to before applying scaling.

parallel_deriv_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

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(name, ref=None, ref0=None, index=None, units=None, adder=None, scaler=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a response variable to this system.

Parameters:
namestr

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple objectives on different indices or slices of a single variable.

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(recorder, recurse=False)

Add a recorder to the system.

Parameters:
recorder<CaseRecorder>

A recorder instance.

recursebool

Flag indicating if the recorder should be added to all the subsystems.

add_response(name, type_, lower=None, upper=None, equals=None, ref=None, ref0=None, indices=None, index=None, units=None, adder=None, scaler=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=None, alias=None)

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:
namestr

Promoted name of the response variable in the system.

type_str

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr or None

Alias for this response. Necessary when adding multiple responses on different indices of the same variable.

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

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.

proc_groupstr or None

Name of a processor group such that any system with that processor group name within the same parent group will be allocated on the same mpi process(es). If this is not None, then any other systems sharing the same proc_group must have identical values of min_procs, max_procs, and proc_weight or an exception will be raised.

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(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.

formstr

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

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value.

best_partial_deriv_direction()

Return the best direction for partial deriv calculations based on input and output sizes.

Returns:
str

The best direction for derivative calculations, ‘fwd’ or ‘rev’.

check_config(logger)

Perform optional error checks.

Parameters:
loggerobject

The object that manages logging output.

cleanup()

Clean up resources prior to exit.

property comm

Return the MPI communicator object for the system.

Returns:
MPI.Comm

MPI communicator object.

comm_info_iter()

Yield comm size for this system and all subsystems.

Yields:
tuple

A tuple of the form (abs_name, comm_size).

compute_sparsity()

Compute the sparsity of the partial jacobian.

Returns:
coo_matrix

The sparsity matrix.

dict

Metadata about the sparsity computation.

compute_sys_graph(comps_only=False, add_edge_info=True)

Compute a dependency graph for subsystems in this group.

Variable connection information is stored in each edge of the system graph if comps_only is True and add_edge_info is True.

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.

add_edge_infobool (True)

If True and comps_only is also True, store variable connection information in each edge of the system graph.

Returns:
DiGraph

A directed graph containing names of subsystems and their connections.

configure()

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(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.

convert2units(name, val, units)

Convert the given value to the specified units.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_from_units(name, val, units)

Convert the given value from the specified units to those of the named variable.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_units(name, val, units_from, units_to)

Wrap the utility convert_units and give a good error message.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

units_fromstr

The units to convert from.

units_tostr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

declare_coloring(wrt=('*',), method='fd', form=None, step=None, per_instance=True, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, min_improve_pct=5.0, 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.

min_improve_pctfloat

If coloring does not improve (decrease) the number of solves more than the given percentage, coloring will not be used.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

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

dist_size_iter(io, top_comm)

Yield names and distributed ranges of all local and remote variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

top_commMPI.Comm or None

The top-level MPI communicator.

Yields:
tuple

A tuple of the form ((abs_name, rank), start, end).

get_boundary_vars(io, local)

Return a set of inputs or outputs connected to variables outside of this Group.

Parameters:
iostr

Either ‘input’ or ‘output’.

localbool

If True, return only the variables local to the current process.

Returns:
set

Set of absolute inputs or outputs connected to variables outside of this Group.

get_coloring_fname(mode)

Return the full pathname to a coloring file.

Parameters:
modestr

The type of coloring file desired. Must be either ‘input’ or ‘output’.

Returns:
pathlib.Path

Full pathname of the coloring file.

get_constraints(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each constraint.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The constraints defined in the current system.

get_design_vars(recurse=True, get_sizes=True, use_prom_ivc=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 Group.

get_sizesbool, optional

If True, compute the size of each design variable.

use_prom_ivcbool

Use promoted names for inputs, else convert to absolute source names.

Returns:
dict

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

get_indep_vars(local)

Return a dict of independant variables contained in this group or any of its subgroups.

Parameters:
localbool

If True, return only the variables local to the current process.

Returns:
dict

Dict of all independant variables in this group and their corresponding metadata.

get_io_metadata(iotypes=('input', 'output'), metadata_keys=None, includes=None, excludes=None, is_indep_var=None, is_design_var=None, tags=None, get_remote=False, rank=None, return_rel_names=True)

Retrieve metadata for a filtered list of variables.

Parameters:
iotypesstr or iter of str

Will contain either ‘input’, ‘output’, or both. Defaults to both.

metadata_keysiter of str or None

Names of metadata entries to be retrieved or None, meaning retrieve all available ‘allprocs’ metadata. If ‘val’ or ‘src_indices’ are required, their keys must be provided explicitly since they are not found in the ‘allprocs’ metadata and must be retrieved from local metadata located in each process.

includesstr, iter of str or None

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all variables.

excludesstr, iter of str or None

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

tagsstr or iter 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.

get_remotebool

If True, retrieve variables from other MPI processes as well.

rankint or None

If None, and get_remote is True, retrieve values from all MPI process to all other MPI processes. Otherwise, if get_remote is True, retrieve values from all MPI processes only to the specified rank.

return_rel_namesbool

If True, the names returned will be relative to the scope of this System. Otherwise they will be absolute names.

Returns:
dict

A dict of metadata keyed on name, where name is either absolute or relative based on the value of the return_rel_names arg, and metadata is a dict containing entries based on the value of the metadata_keys arg. Every metadata dict will always contain two entries, ‘prom_name’ and ‘discrete’, to indicate a given variable’s promoted name and whether or not it is discrete.

get_linear_vectors()

Return the linear inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals): tuple of <Vector> instances

Yields the linear inputs, outputs, and residuals vectors.

get_nonlinear_vectors()

Return the inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals)

Yields the inputs, outputs, and residuals nonlinear vectors.

get_objectives(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each objective.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The objectives defined in the current system.

get_outputs_dir(*subdirs, mkdir=True)

Get the path under which all output files of this system are to be placed.

Parameters:
*subdirsstr

Subdirectories nested under the relevant problem output directory. To create {prob_output_dir}/a/b one would pass system.get_outputs_dir(‘a’, ‘b’).

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path of the outputs directory for the problem.

get_promotions(inprom=None, outprom=None)

Return all promotions for the given promoted variable(s).

In other words, how and where did promotions occur to convert absolute variable names into the given promoted name(s) at the current System level.

Parameters:
inpromstr or None

The promoted input variable name.

outpromstr or None

The promoted output variable name.

Returns:
dict

Dictionary keyed on system pathname containing input and/or output promotion lists for each System where promotions occurred to produce the given promoted variable(s).

get_reports_dir()

Get the path to the directory where the report files should go.

If it doesn’t exist, it will be created.

Returns:
str

The path to the directory where reports should be written.

get_responses(recurse=True, get_sizes=True, use_prom_ivc=False)

Get the response variable settings from this system.

Retrieve all response variable settings from the system as a dict, keyed by either absolute variable name, promoted name, or alias name, depending on the value of use_prom_ivc and whether the original key was a promoted output, promoted input, or an alias.

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.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

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

get_self_statics()

Override this in derived classes if compute_primal references static values.

Do NOT include self._discrete_inputs in the returned tuple. Include things like self.options[‘opt_name’], etc., that are used in compute_primal but are assumed to be constant during derivative computation.

Return value MUST be a tuple. Don’t forget the trailing comma if tuple has only one item. Return value MUST be hashable.

The order of these values doesn’t matter. They are only checked (by computing their hash) to see if they have changed since the last time compute_primal was jitted, and if so, compute_primal will be re-jitted.

Returns:
tuple

Tuple containing all static values required by compute_primal.

get_source(name)

Return the source variable connected to the given named variable.

The name can be a promoted name or an absolute name. If the given variable is an input, the absolute name of the connected source will be returned. If the given variable itself is a source, its own absolute name will be returned.

Parameters:
namestr

Absolute or promoted name of the variable.

Returns:
str

The absolute name of the source variable.

get_val(name, units=None, indices=None, get_remote=False, rank=None, vec_name='nonlinear', kind=None, flat=False, from_src=True)

Get an output/input/residual 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 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 or None

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. If False, only retrieve the value if it is on the current process, or only the part of the value that’s on the current process for a distributed variable. If None and the variable is remote or distributed, a RuntimeError will be raised.

rankint or None

If not None, only gather the value to this rank.

vec_namestr

Name of the vector to use. Defaults to ‘nonlinear’.

kindstr or None

Kind of variable (‘input’, ‘output’, or ‘residual’). If None, returned value will be either an input or output.

flatbool

If True, return the flattened version of the value.

from_srcbool

If True, retrieve value of an input variable from its connected source.

Returns:
object

The value of the requested output/input variable.

get_var_dup_info(name, io)

Return information about how the given variable is duplicated across MPI processes.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
tuple

A tuple of the form (is_duplicated, num_zeros, is_distributed).

get_var_sizes(name, io)

Return the sizes of the given variable on all procs.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
ndarray

Array of sizes of the variable on all procs.

guess_nonlinear(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()[source]

Perform any one-time initialization run at instantiation.

is_explicit()

Return True if this Group contains only explicit systems and has no cycles.

Returns:
bool

True if this is an explicit component.

property linear_solver

Get the linear solver for this system.

list_inputs(val=True, prom_name=True, units=False, shape=False, global_shape=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of input names and other optional information to a specified stream.

Parameters:
valbool, 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 True.

unitsbool, optional

When True, display/return units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global shape of the value. Default is False.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all input variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all ranks. Default is False, which will display output only from rank 0.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the input value is an array, print its smallest value.

print_maxbool

When true, if the input value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of input names and other optional information about those inputs.

list_outputs(explicit=True, implicit=True, val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of output names and other optional information to a specified stream.

Parameters:
explicitbool, optional

Include outputs from explicit components. Default is True.

implicitbool, optional

Include outputs from implicit components. Default is True.

valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

list_vars(val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of inputs and outputs sorted by component in execution order.

Parameters:
valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. Default is False.

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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

load_case(case)

Pull all input and output variables from a Case into this System.

Override this method if the System requires special handling when loading a case.

Parameters:
caseCase or dict

A Case from a CaseReader, or a dictionary with key ‘inputs’ mapped to the output of problem.model.list_inputs and key ‘outputs’ mapped to the output of prob.model.list_outputs. Both list_inputs and list_outputs should be called with prom_name=True and return_format=’dict’.

load_model_options()

Load the relevant model options from Problem._metadata[‘model_options’].

This method examines each path filter and corresponding options in self._problem_meta[‘model_options’]. If this System’s pathname matches the given path filter, it will assume the value for each given option which it possesses.

local_range_iter(io)

Yield names and local ranges of all local variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

Yields:
tuple

A tuple of the form (abs_name, start, end).

property model_options

Get the model options from self._problem_meta.

The user may change the contents of model_options to impact values sent to subsystems of this Group.

Returns:
dict

The model options metadata provided by the associated Problem object.

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 nonlinear_solver

Get the nonlinear solver for this system.

promotes(subsys_name, any=None, inputs=None, outputs=None, src_indices=None, flat_src_indices=None, src_shape=None)

Promote a variable in the model tree.

Parameters:
subsys_namestr

The name of the child subsystem whose inputs/outputs are being promoted.

anySequence of str or tuple

A Sequence of variable names (or tuples) to be promoted, regardless of if they are inputs or outputs. This is equivalent to the items passed via the promotes= argument to add_subsystem. If given as a tuple, we use the “promote as” standard of “(‘real name’, ‘promoted name’)*[]:”.

inputsSequence of str or tuple

A Sequence of input names (or tuples) to be promoted. Tuples are used for the “promote as” capability.

outputsSequence of str or tuple

A Sequence of output names (or tuples) to be promoted. Tuples are used for the “promote as” capability.

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

This argument applies only to promoted inputs. 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

This argument applies only to promoted inputs. 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.

src_shapeint or tuple

Assumed shape of any connected source or higher level promoted input.

record_iteration()

Record an iteration of the current System.

run_apply_linear(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:
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()

Compute residuals.

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

run_linearize(sub_do_ln=True, driver=None)

Compute jacobian / factorization.

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

Parameters:
sub_do_lnbool

Flag indicating if the children should call linearize on their linear solvers.

driverDriver or None

If this system is the top level system and approx derivatives have not been initialized, the driver for this model must be supplied in order to properly initialize the approximations.

run_solve_linear(mode)

Apply inverse jac product.

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

Parameters:
modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear()

Compute outputs.

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

set_constraint_options(name, ref=UNDEFINED, ref0=UNDEFINED, equals=UNDEFINED, lower=UNDEFINED, upper=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for constraints in the model.

Can be used to set options that were set using add_constraint.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

equalsfloat or ndarray, optional

Equality constraint value for the variable.

lowerfloat or ndarray, optional

Lower boundary for the variable.

upperfloat or ndarray, optional

Upper boundary for the variable.

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.

aliasstr, optional

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

set_design_var_options(name, lower=UNDEFINED, upper=UNDEFINED, scaler=UNDEFINED, adder=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED)

Set options for design vars in the model.

Can be used to set the options outside of setting them when calling add_design_var

Parameters:
namestr

Name of the variable in this system’s namespace.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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.

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.

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.

set_initial_values()

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

set_input_defaults(name, val=UNDEFINED, units=None, src_shape=None)

Specify metadata to be assumed when multiple inputs are promoted to the same name.

Parameters:
namestr

Promoted input name.

valobject

Value to assume for the promoted input.

unitsstr or None

Units to assume for the promoted input.

src_shapeint or tuple

Assumed shape of any connected source or higher level promoted input.

set_objective_options(name, ref=UNDEFINED, ref0=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for objectives in the model.

Can be used to set options after they have been set by add_objective.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

aliasstr

Alias for this response. Used to disambiguate variable names when adding multiple objectives on different indices or slices of a single variable. Deprecated.

set_order(new_order)

Specify a new execution order for subsystems in this group.

Parameters:
new_orderlist of str

List of system names in desired new execution order.

set_output_solver_options(name, lower=UNDEFINED, upper=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED, res_ref=UNDEFINED)

Set solver output options.

Allows the user to set output solver options after the output has been defined and metadata set using the add_ouput method.

Parameters:
namestr

Name of the variable in this system’s namespace.

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.

set_solver_print(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(name, val, units=None, indices=None)

Set an input or output variable.

Parameters:
namestr

Promoted or relative variable name in the system’s namespace.

valobject

Value to assign to this variable.

unitsstr, optional

Units of the value.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to set.

setup()[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(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.

Yields:
type or None
property under_approx

Return True if under complex step or finite difference.

Returns:
bool

True if under CS or FD.

use_fixed_coloring(coloring=<object object>, 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: Group

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

__init__(**kwargs)

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

abs_meta_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names and their metadata for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str, dict
abs_name_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str
add_constraint(name, lower=None, upper=None, equals=None, ref=None, ref0=None, adder=None, scaler=None, units=None, indices=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a constraint variable to this system.

Parameters:
namestr

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 alternative to using ref and ref0.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

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. The arguments (lower, upper, equals) can not be strings or variable names.

add_design_var(name, lower=None, upper=None, ref=None, ref0=None, indices=None, adder=None, scaler=None, units=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False)

Add a design variable to this system.

Parameters:
namestr

Promoted name of the design variable in the system.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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 an input 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.

unitsstr, optional

Units to convert to before applying scaling.

parallel_deriv_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

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(name, ref=None, ref0=None, index=None, units=None, adder=None, scaler=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a response variable to this system.

Parameters:
namestr

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple objectives on different indices or slices of a single variable.

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(recorder, recurse=False)

Add a recorder to the system.

Parameters:
recorder<CaseRecorder>

A recorder instance.

recursebool

Flag indicating if the recorder should be added to all the subsystems.

add_response(name, type_, lower=None, upper=None, equals=None, ref=None, ref0=None, indices=None, index=None, units=None, adder=None, scaler=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=None, alias=None)

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:
namestr

Promoted name of the response variable in the system.

type_str

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr or None

Alias for this response. Necessary when adding multiple responses on different indices of the same variable.

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

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.

proc_groupstr or None

Name of a processor group such that any system with that processor group name within the same parent group will be allocated on the same mpi process(es). If this is not None, then any other systems sharing the same proc_group must have identical values of min_procs, max_procs, and proc_weight or an exception will be raised.

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(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.

formstr

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

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value.

best_partial_deriv_direction()

Return the best direction for partial deriv calculations based on input and output sizes.

Returns:
str

The best direction for derivative calculations, ‘fwd’ or ‘rev’.

check_config(logger)

Perform optional error checks.

Parameters:
loggerobject

The object that manages logging output.

cleanup()

Clean up resources prior to exit.

property comm

Return the MPI communicator object for the system.

Returns:
MPI.Comm

MPI communicator object.

comm_info_iter()

Yield comm size for this system and all subsystems.

Yields:
tuple

A tuple of the form (abs_name, comm_size).

compute_sparsity()

Compute the sparsity of the partial jacobian.

Returns:
coo_matrix

The sparsity matrix.

dict

Metadata about the sparsity computation.

compute_sys_graph(comps_only=False, add_edge_info=True)

Compute a dependency graph for subsystems in this group.

Variable connection information is stored in each edge of the system graph if comps_only is True and add_edge_info is True.

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.

add_edge_infobool (True)

If True and comps_only is also True, store variable connection information in each edge of the system graph.

Returns:
DiGraph

A directed graph containing names of subsystems and their connections.

configure()

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(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.

convert2units(name, val, units)

Convert the given value to the specified units.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_from_units(name, val, units)

Convert the given value from the specified units to those of the named variable.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_units(name, val, units_from, units_to)

Wrap the utility convert_units and give a good error message.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

units_fromstr

The units to convert from.

units_tostr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

declare_coloring(wrt=('*',), method='fd', form=None, step=None, per_instance=True, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, min_improve_pct=5.0, 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.

min_improve_pctfloat

If coloring does not improve (decrease) the number of solves more than the given percentage, coloring will not be used.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

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

dist_size_iter(io, top_comm)

Yield names and distributed ranges of all local and remote variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

top_commMPI.Comm or None

The top-level MPI communicator.

Yields:
tuple

A tuple of the form ((abs_name, rank), start, end).

get_boundary_vars(io, local)

Return a set of inputs or outputs connected to variables outside of this Group.

Parameters:
iostr

Either ‘input’ or ‘output’.

localbool

If True, return only the variables local to the current process.

Returns:
set

Set of absolute inputs or outputs connected to variables outside of this Group.

get_coloring_fname(mode)

Return the full pathname to a coloring file.

Parameters:
modestr

The type of coloring file desired. Must be either ‘input’ or ‘output’.

Returns:
pathlib.Path

Full pathname of the coloring file.

get_constraints(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each constraint.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The constraints defined in the current system.

get_design_vars(recurse=True, get_sizes=True, use_prom_ivc=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 Group.

get_sizesbool, optional

If True, compute the size of each design variable.

use_prom_ivcbool

Use promoted names for inputs, else convert to absolute source names.

Returns:
dict

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

get_indep_vars(local)

Return a dict of independant variables contained in this group or any of its subgroups.

Parameters:
localbool

If True, return only the variables local to the current process.

Returns:
dict

Dict of all independant variables in this group and their corresponding metadata.

get_io_metadata(iotypes=('input', 'output'), metadata_keys=None, includes=None, excludes=None, is_indep_var=None, is_design_var=None, tags=None, get_remote=False, rank=None, return_rel_names=True)

Retrieve metadata for a filtered list of variables.

Parameters:
iotypesstr or iter of str

Will contain either ‘input’, ‘output’, or both. Defaults to both.

metadata_keysiter of str or None

Names of metadata entries to be retrieved or None, meaning retrieve all available ‘allprocs’ metadata. If ‘val’ or ‘src_indices’ are required, their keys must be provided explicitly since they are not found in the ‘allprocs’ metadata and must be retrieved from local metadata located in each process.

includesstr, iter of str or None

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all variables.

excludesstr, iter of str or None

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

tagsstr or iter 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.

get_remotebool

If True, retrieve variables from other MPI processes as well.

rankint or None

If None, and get_remote is True, retrieve values from all MPI process to all other MPI processes. Otherwise, if get_remote is True, retrieve values from all MPI processes only to the specified rank.

return_rel_namesbool

If True, the names returned will be relative to the scope of this System. Otherwise they will be absolute names.

Returns:
dict

A dict of metadata keyed on name, where name is either absolute or relative based on the value of the return_rel_names arg, and metadata is a dict containing entries based on the value of the metadata_keys arg. Every metadata dict will always contain two entries, ‘prom_name’ and ‘discrete’, to indicate a given variable’s promoted name and whether or not it is discrete.

get_linear_vectors()

Return the linear inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals): tuple of <Vector> instances

Yields the linear inputs, outputs, and residuals vectors.

get_nonlinear_vectors()

Return the inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals)

Yields the inputs, outputs, and residuals nonlinear vectors.

get_objectives(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each objective.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The objectives defined in the current system.

get_outputs_dir(*subdirs, mkdir=True)

Get the path under which all output files of this system are to be placed.

Parameters:
*subdirsstr

Subdirectories nested under the relevant problem output directory. To create {prob_output_dir}/a/b one would pass system.get_outputs_dir(‘a’, ‘b’).

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path of the outputs directory for the problem.

get_promotions(inprom=None, outprom=None)

Return all promotions for the given promoted variable(s).

In other words, how and where did promotions occur to convert absolute variable names into the given promoted name(s) at the current System level.

Parameters:
inpromstr or None

The promoted input variable name.

outpromstr or None

The promoted output variable name.

Returns:
dict

Dictionary keyed on system pathname containing input and/or output promotion lists for each System where promotions occurred to produce the given promoted variable(s).

get_reports_dir()

Get the path to the directory where the report files should go.

If it doesn’t exist, it will be created.

Returns:
str

The path to the directory where reports should be written.

get_responses(recurse=True, get_sizes=True, use_prom_ivc=False)

Get the response variable settings from this system.

Retrieve all response variable settings from the system as a dict, keyed by either absolute variable name, promoted name, or alias name, depending on the value of use_prom_ivc and whether the original key was a promoted output, promoted input, or an alias.

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.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

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

get_self_statics()

Override this in derived classes if compute_primal references static values.

Do NOT include self._discrete_inputs in the returned tuple. Include things like self.options[‘opt_name’], etc., that are used in compute_primal but are assumed to be constant during derivative computation.

Return value MUST be a tuple. Don’t forget the trailing comma if tuple has only one item. Return value MUST be hashable.

The order of these values doesn’t matter. They are only checked (by computing their hash) to see if they have changed since the last time compute_primal was jitted, and if so, compute_primal will be re-jitted.

Returns:
tuple

Tuple containing all static values required by compute_primal.

get_source(name)

Return the source variable connected to the given named variable.

The name can be a promoted name or an absolute name. If the given variable is an input, the absolute name of the connected source will be returned. If the given variable itself is a source, its own absolute name will be returned.

Parameters:
namestr

Absolute or promoted name of the variable.

Returns:
str

The absolute name of the source variable.

get_val(name, units=None, indices=None, get_remote=False, rank=None, vec_name='nonlinear', kind=None, flat=False, from_src=True)

Get an output/input/residual 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 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 or None

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. If False, only retrieve the value if it is on the current process, or only the part of the value that’s on the current process for a distributed variable. If None and the variable is remote or distributed, a RuntimeError will be raised.

rankint or None

If not None, only gather the value to this rank.

vec_namestr

Name of the vector to use. Defaults to ‘nonlinear’.

kindstr or None

Kind of variable (‘input’, ‘output’, or ‘residual’). If None, returned value will be either an input or output.

flatbool

If True, return the flattened version of the value.

from_srcbool

If True, retrieve value of an input variable from its connected source.

Returns:
object

The value of the requested output/input variable.

get_var_dup_info(name, io)

Return information about how the given variable is duplicated across MPI processes.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
tuple

A tuple of the form (is_duplicated, num_zeros, is_distributed).

get_var_sizes(name, io)

Return the sizes of the given variable on all procs.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
ndarray

Array of sizes of the variable on all procs.

guess_nonlinear(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()

Perform any one-time initialization run at instantiation.

is_explicit()

Return True if this Group contains only explicit systems and has no cycles.

Returns:
bool

True if this is an explicit component.

property linear_solver

Get the linear solver for this system.

list_inputs(val=True, prom_name=True, units=False, shape=False, global_shape=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of input names and other optional information to a specified stream.

Parameters:
valbool, 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 True.

unitsbool, optional

When True, display/return units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global shape of the value. Default is False.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all input variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all ranks. Default is False, which will display output only from rank 0.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the input value is an array, print its smallest value.

print_maxbool

When true, if the input value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of input names and other optional information about those inputs.

list_outputs(explicit=True, implicit=True, val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of output names and other optional information to a specified stream.

Parameters:
explicitbool, optional

Include outputs from explicit components. Default is True.

implicitbool, optional

Include outputs from implicit components. Default is True.

valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

list_vars(val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of inputs and outputs sorted by component in execution order.

Parameters:
valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. Default is False.

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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

load_case(case)

Pull all input and output variables from a Case into this System.

Override this method if the System requires special handling when loading a case.

Parameters:
caseCase or dict

A Case from a CaseReader, or a dictionary with key ‘inputs’ mapped to the output of problem.model.list_inputs and key ‘outputs’ mapped to the output of prob.model.list_outputs. Both list_inputs and list_outputs should be called with prom_name=True and return_format=’dict’.

load_model_options()

Load the relevant model options from Problem._metadata[‘model_options’].

This method examines each path filter and corresponding options in self._problem_meta[‘model_options’]. If this System’s pathname matches the given path filter, it will assume the value for each given option which it possesses.

local_range_iter(io)

Yield names and local ranges of all local variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

Yields:
tuple

A tuple of the form (abs_name, start, end).

property model_options

Get the model options from self._problem_meta.

The user may change the contents of model_options to impact values sent to subsystems of this Group.

Returns:
dict

The model options metadata provided by the associated Problem object.

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 nonlinear_solver

Get the nonlinear solver for this system.

promotes(subsys_name, any=None, inputs=None, outputs=None, src_indices=None, flat_src_indices=None, src_shape=None)

Promote a variable in the model tree.

Parameters:
subsys_namestr

The name of the child subsystem whose inputs/outputs are being promoted.

anySequence of str or tuple

A Sequence of variable names (or tuples) to be promoted, regardless of if they are inputs or outputs. This is equivalent to the items passed via the promotes= argument to add_subsystem. If given as a tuple, we use the “promote as” standard of “(‘real name’, ‘promoted name’)*[]:”.

inputsSequence of str or tuple

A Sequence of input names (or tuples) to be promoted. Tuples are used for the “promote as” capability.

outputsSequence of str or tuple

A Sequence of output names (or tuples) to be promoted. Tuples are used for the “promote as” capability.

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

This argument applies only to promoted inputs. 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

This argument applies only to promoted inputs. 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.

src_shapeint or tuple

Assumed shape of any connected source or higher level promoted input.

record_iteration()

Record an iteration of the current System.

run_apply_linear(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:
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()

Compute residuals.

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

run_linearize(sub_do_ln=True, driver=None)

Compute jacobian / factorization.

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

Parameters:
sub_do_lnbool

Flag indicating if the children should call linearize on their linear solvers.

driverDriver or None

If this system is the top level system and approx derivatives have not been initialized, the driver for this model must be supplied in order to properly initialize the approximations.

run_solve_linear(mode)

Apply inverse jac product.

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

Parameters:
modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear()

Compute outputs.

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

set_constraint_options(name, ref=UNDEFINED, ref0=UNDEFINED, equals=UNDEFINED, lower=UNDEFINED, upper=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for constraints in the model.

Can be used to set options that were set using add_constraint.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

equalsfloat or ndarray, optional

Equality constraint value for the variable.

lowerfloat or ndarray, optional

Lower boundary for the variable.

upperfloat or ndarray, optional

Upper boundary for the variable.

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.

aliasstr, optional

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

set_design_var_options(name, lower=UNDEFINED, upper=UNDEFINED, scaler=UNDEFINED, adder=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED)

Set options for design vars in the model.

Can be used to set the options outside of setting them when calling add_design_var

Parameters:
namestr

Name of the variable in this system’s namespace.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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.

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.

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.

set_initial_values()

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

set_input_defaults(name, val=UNDEFINED, units=None, src_shape=None)

Specify metadata to be assumed when multiple inputs are promoted to the same name.

Parameters:
namestr

Promoted input name.

valobject

Value to assume for the promoted input.

unitsstr or None

Units to assume for the promoted input.

src_shapeint or tuple

Assumed shape of any connected source or higher level promoted input.

set_objective_options(name, ref=UNDEFINED, ref0=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for objectives in the model.

Can be used to set options after they have been set by add_objective.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

aliasstr

Alias for this response. Used to disambiguate variable names when adding multiple objectives on different indices or slices of a single variable. Deprecated.

set_order(new_order)

Specify a new execution order for subsystems in this group.

Parameters:
new_orderlist of str

List of system names in desired new execution order.

set_output_solver_options(name, lower=UNDEFINED, upper=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED, res_ref=UNDEFINED)

Set solver output options.

Allows the user to set output solver options after the output has been defined and metadata set using the add_ouput method.

Parameters:
namestr

Name of the variable in this system’s namespace.

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.

set_solver_print(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(name, val, units=None, indices=None)

Set an input or output variable.

Parameters:
namestr

Promoted or relative variable name in the system’s namespace.

valobject

Value to assign to this variable.

unitsstr, optional

Units of the value.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to set.

setup()[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(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.

Yields:
type or None
property under_approx

Return True if under complex step or finite difference.

Returns:
bool

True if under CS or FD.

use_fixed_coloring(coloring=<object object>, 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: Group

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

__init__(**kwargs)

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

abs_meta_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names and their metadata for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str, dict
abs_name_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str
add_constraint(name, lower=None, upper=None, equals=None, ref=None, ref0=None, adder=None, scaler=None, units=None, indices=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a constraint variable to this system.

Parameters:
namestr

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 alternative to using ref and ref0.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

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. The arguments (lower, upper, equals) can not be strings or variable names.

add_design_var(name, lower=None, upper=None, ref=None, ref0=None, indices=None, adder=None, scaler=None, units=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False)

Add a design variable to this system.

Parameters:
namestr

Promoted name of the design variable in the system.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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 an input 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.

unitsstr, optional

Units to convert to before applying scaling.

parallel_deriv_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

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(name, ref=None, ref0=None, index=None, units=None, adder=None, scaler=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a response variable to this system.

Parameters:
namestr

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple objectives on different indices or slices of a single variable.

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(recorder, recurse=False)

Add a recorder to the system.

Parameters:
recorder<CaseRecorder>

A recorder instance.

recursebool

Flag indicating if the recorder should be added to all the subsystems.

add_response(name, type_, lower=None, upper=None, equals=None, ref=None, ref0=None, indices=None, index=None, units=None, adder=None, scaler=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=None, alias=None)

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:
namestr

Promoted name of the response variable in the system.

type_str

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr or None

Alias for this response. Necessary when adding multiple responses on different indices of the same variable.

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

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.

proc_groupstr or None

Name of a processor group such that any system with that processor group name within the same parent group will be allocated on the same mpi process(es). If this is not None, then any other systems sharing the same proc_group must have identical values of min_procs, max_procs, and proc_weight or an exception will be raised.

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(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.

formstr

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

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value.

best_partial_deriv_direction()

Return the best direction for partial deriv calculations based on input and output sizes.

Returns:
str

The best direction for derivative calculations, ‘fwd’ or ‘rev’.

check_config(logger)

Perform optional error checks.

Parameters:
loggerobject

The object that manages logging output.

cleanup()

Clean up resources prior to exit.

property comm

Return the MPI communicator object for the system.

Returns:
MPI.Comm

MPI communicator object.

comm_info_iter()

Yield comm size for this system and all subsystems.

Yields:
tuple

A tuple of the form (abs_name, comm_size).

compute_sparsity()

Compute the sparsity of the partial jacobian.

Returns:
coo_matrix

The sparsity matrix.

dict

Metadata about the sparsity computation.

compute_sys_graph(comps_only=False, add_edge_info=True)

Compute a dependency graph for subsystems in this group.

Variable connection information is stored in each edge of the system graph if comps_only is True and add_edge_info is True.

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.

add_edge_infobool (True)

If True and comps_only is also True, store variable connection information in each edge of the system graph.

Returns:
DiGraph

A directed graph containing names of subsystems and their connections.

configure()

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(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.

convert2units(name, val, units)

Convert the given value to the specified units.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_from_units(name, val, units)

Convert the given value from the specified units to those of the named variable.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_units(name, val, units_from, units_to)

Wrap the utility convert_units and give a good error message.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

units_fromstr

The units to convert from.

units_tostr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

declare_coloring(wrt=('*',), method='fd', form=None, step=None, per_instance=True, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, min_improve_pct=5.0, 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.

min_improve_pctfloat

If coloring does not improve (decrease) the number of solves more than the given percentage, coloring will not be used.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

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

dist_size_iter(io, top_comm)

Yield names and distributed ranges of all local and remote variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

top_commMPI.Comm or None

The top-level MPI communicator.

Yields:
tuple

A tuple of the form ((abs_name, rank), start, end).

get_boundary_vars(io, local)

Return a set of inputs or outputs connected to variables outside of this Group.

Parameters:
iostr

Either ‘input’ or ‘output’.

localbool

If True, return only the variables local to the current process.

Returns:
set

Set of absolute inputs or outputs connected to variables outside of this Group.

get_coloring_fname(mode)

Return the full pathname to a coloring file.

Parameters:
modestr

The type of coloring file desired. Must be either ‘input’ or ‘output’.

Returns:
pathlib.Path

Full pathname of the coloring file.

get_constraints(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each constraint.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The constraints defined in the current system.

get_design_vars(recurse=True, get_sizes=True, use_prom_ivc=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 Group.

get_sizesbool, optional

If True, compute the size of each design variable.

use_prom_ivcbool

Use promoted names for inputs, else convert to absolute source names.

Returns:
dict

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

get_indep_vars(local)

Return a dict of independant variables contained in this group or any of its subgroups.

Parameters:
localbool

If True, return only the variables local to the current process.

Returns:
dict

Dict of all independant variables in this group and their corresponding metadata.

get_io_metadata(iotypes=('input', 'output'), metadata_keys=None, includes=None, excludes=None, is_indep_var=None, is_design_var=None, tags=None, get_remote=False, rank=None, return_rel_names=True)

Retrieve metadata for a filtered list of variables.

Parameters:
iotypesstr or iter of str

Will contain either ‘input’, ‘output’, or both. Defaults to both.

metadata_keysiter of str or None

Names of metadata entries to be retrieved or None, meaning retrieve all available ‘allprocs’ metadata. If ‘val’ or ‘src_indices’ are required, their keys must be provided explicitly since they are not found in the ‘allprocs’ metadata and must be retrieved from local metadata located in each process.

includesstr, iter of str or None

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all variables.

excludesstr, iter of str or None

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

tagsstr or iter 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.

get_remotebool

If True, retrieve variables from other MPI processes as well.

rankint or None

If None, and get_remote is True, retrieve values from all MPI process to all other MPI processes. Otherwise, if get_remote is True, retrieve values from all MPI processes only to the specified rank.

return_rel_namesbool

If True, the names returned will be relative to the scope of this System. Otherwise they will be absolute names.

Returns:
dict

A dict of metadata keyed on name, where name is either absolute or relative based on the value of the return_rel_names arg, and metadata is a dict containing entries based on the value of the metadata_keys arg. Every metadata dict will always contain two entries, ‘prom_name’ and ‘discrete’, to indicate a given variable’s promoted name and whether or not it is discrete.

get_linear_vectors()

Return the linear inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals): tuple of <Vector> instances

Yields the linear inputs, outputs, and residuals vectors.

get_nonlinear_vectors()

Return the inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals)

Yields the inputs, outputs, and residuals nonlinear vectors.

get_objectives(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each objective.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The objectives defined in the current system.

get_outputs_dir(*subdirs, mkdir=True)

Get the path under which all output files of this system are to be placed.

Parameters:
*subdirsstr

Subdirectories nested under the relevant problem output directory. To create {prob_output_dir}/a/b one would pass system.get_outputs_dir(‘a’, ‘b’).

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path of the outputs directory for the problem.

get_promotions(inprom=None, outprom=None)

Return all promotions for the given promoted variable(s).

In other words, how and where did promotions occur to convert absolute variable names into the given promoted name(s) at the current System level.

Parameters:
inpromstr or None

The promoted input variable name.

outpromstr or None

The promoted output variable name.

Returns:
dict

Dictionary keyed on system pathname containing input and/or output promotion lists for each System where promotions occurred to produce the given promoted variable(s).

get_reports_dir()

Get the path to the directory where the report files should go.

If it doesn’t exist, it will be created.

Returns:
str

The path to the directory where reports should be written.

get_responses(recurse=True, get_sizes=True, use_prom_ivc=False)

Get the response variable settings from this system.

Retrieve all response variable settings from the system as a dict, keyed by either absolute variable name, promoted name, or alias name, depending on the value of use_prom_ivc and whether the original key was a promoted output, promoted input, or an alias.

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.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

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

get_self_statics()

Override this in derived classes if compute_primal references static values.

Do NOT include self._discrete_inputs in the returned tuple. Include things like self.options[‘opt_name’], etc., that are used in compute_primal but are assumed to be constant during derivative computation.

Return value MUST be a tuple. Don’t forget the trailing comma if tuple has only one item. Return value MUST be hashable.

The order of these values doesn’t matter. They are only checked (by computing their hash) to see if they have changed since the last time compute_primal was jitted, and if so, compute_primal will be re-jitted.

Returns:
tuple

Tuple containing all static values required by compute_primal.

get_source(name)

Return the source variable connected to the given named variable.

The name can be a promoted name or an absolute name. If the given variable is an input, the absolute name of the connected source will be returned. If the given variable itself is a source, its own absolute name will be returned.

Parameters:
namestr

Absolute or promoted name of the variable.

Returns:
str

The absolute name of the source variable.

get_val(name, units=None, indices=None, get_remote=False, rank=None, vec_name='nonlinear', kind=None, flat=False, from_src=True)

Get an output/input/residual 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 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 or None

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. If False, only retrieve the value if it is on the current process, or only the part of the value that’s on the current process for a distributed variable. If None and the variable is remote or distributed, a RuntimeError will be raised.

rankint or None

If not None, only gather the value to this rank.

vec_namestr

Name of the vector to use. Defaults to ‘nonlinear’.

kindstr or None

Kind of variable (‘input’, ‘output’, or ‘residual’). If None, returned value will be either an input or output.

flatbool

If True, return the flattened version of the value.

from_srcbool

If True, retrieve value of an input variable from its connected source.

Returns:
object

The value of the requested output/input variable.

get_var_dup_info(name, io)

Return information about how the given variable is duplicated across MPI processes.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
tuple

A tuple of the form (is_duplicated, num_zeros, is_distributed).

get_var_sizes(name, io)

Return the sizes of the given variable on all procs.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
ndarray

Array of sizes of the variable on all procs.

guess_nonlinear(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()[source]

Perform any one-time initialization run at instantiation.

is_explicit()

Return True if this Group contains only explicit systems and has no cycles.

Returns:
bool

True if this is an explicit component.

property linear_solver

Get the linear solver for this system.

list_inputs(val=True, prom_name=True, units=False, shape=False, global_shape=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of input names and other optional information to a specified stream.

Parameters:
valbool, 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 True.

unitsbool, optional

When True, display/return units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global shape of the value. Default is False.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all input variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all ranks. Default is False, which will display output only from rank 0.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the input value is an array, print its smallest value.

print_maxbool

When true, if the input value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of input names and other optional information about those inputs.

list_outputs(explicit=True, implicit=True, val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of output names and other optional information to a specified stream.

Parameters:
explicitbool, optional

Include outputs from explicit components. Default is True.

implicitbool, optional

Include outputs from implicit components. Default is True.

valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

list_vars(val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of inputs and outputs sorted by component in execution order.

Parameters:
valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. Default is False.

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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

load_case(case)

Pull all input and output variables from a Case into this System.

Override this method if the System requires special handling when loading a case.

Parameters:
caseCase or dict

A Case from a CaseReader, or a dictionary with key ‘inputs’ mapped to the output of problem.model.list_inputs and key ‘outputs’ mapped to the output of prob.model.list_outputs. Both list_inputs and list_outputs should be called with prom_name=True and return_format=’dict’.

load_model_options()

Load the relevant model options from Problem._metadata[‘model_options’].

This method examines each path filter and corresponding options in self._problem_meta[‘model_options’]. If this System’s pathname matches the given path filter, it will assume the value for each given option which it possesses.

local_range_iter(io)

Yield names and local ranges of all local variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

Yields:
tuple

A tuple of the form (abs_name, start, end).

property model_options

Get the model options from self._problem_meta.

The user may change the contents of model_options to impact values sent to subsystems of this Group.

Returns:
dict

The model options metadata provided by the associated Problem object.

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 nonlinear_solver

Get the nonlinear solver for this system.

promotes(subsys_name, any=None, inputs=None, outputs=None, src_indices=None, flat_src_indices=None, src_shape=None)

Promote a variable in the model tree.

Parameters:
subsys_namestr

The name of the child subsystem whose inputs/outputs are being promoted.

anySequence of str or tuple

A Sequence of variable names (or tuples) to be promoted, regardless of if they are inputs or outputs. This is equivalent to the items passed via the promotes= argument to add_subsystem. If given as a tuple, we use the “promote as” standard of “(‘real name’, ‘promoted name’)*[]:”.

inputsSequence of str or tuple

A Sequence of input names (or tuples) to be promoted. Tuples are used for the “promote as” capability.

outputsSequence of str or tuple

A Sequence of output names (or tuples) to be promoted. Tuples are used for the “promote as” capability.

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

This argument applies only to promoted inputs. 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

This argument applies only to promoted inputs. 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.

src_shapeint or tuple

Assumed shape of any connected source or higher level promoted input.

record_iteration()

Record an iteration of the current System.

run_apply_linear(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:
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()

Compute residuals.

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

run_linearize(sub_do_ln=True, driver=None)

Compute jacobian / factorization.

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

Parameters:
sub_do_lnbool

Flag indicating if the children should call linearize on their linear solvers.

driverDriver or None

If this system is the top level system and approx derivatives have not been initialized, the driver for this model must be supplied in order to properly initialize the approximations.

run_solve_linear(mode)

Apply inverse jac product.

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

Parameters:
modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear()

Compute outputs.

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

set_constraint_options(name, ref=UNDEFINED, ref0=UNDEFINED, equals=UNDEFINED, lower=UNDEFINED, upper=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for constraints in the model.

Can be used to set options that were set using add_constraint.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

equalsfloat or ndarray, optional

Equality constraint value for the variable.

lowerfloat or ndarray, optional

Lower boundary for the variable.

upperfloat or ndarray, optional

Upper boundary for the variable.

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.

aliasstr, optional

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

set_design_var_options(name, lower=UNDEFINED, upper=UNDEFINED, scaler=UNDEFINED, adder=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED)

Set options for design vars in the model.

Can be used to set the options outside of setting them when calling add_design_var

Parameters:
namestr

Name of the variable in this system’s namespace.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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.

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.

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.

set_initial_values()

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

set_input_defaults(name, val=UNDEFINED, units=None, src_shape=None)

Specify metadata to be assumed when multiple inputs are promoted to the same name.

Parameters:
namestr

Promoted input name.

valobject

Value to assume for the promoted input.

unitsstr or None

Units to assume for the promoted input.

src_shapeint or tuple

Assumed shape of any connected source or higher level promoted input.

set_objective_options(name, ref=UNDEFINED, ref0=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for objectives in the model.

Can be used to set options after they have been set by add_objective.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

aliasstr

Alias for this response. Used to disambiguate variable names when adding multiple objectives on different indices or slices of a single variable. Deprecated.

set_order(new_order)

Specify a new execution order for subsystems in this group.

Parameters:
new_orderlist of str

List of system names in desired new execution order.

set_output_solver_options(name, lower=UNDEFINED, upper=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED, res_ref=UNDEFINED)

Set solver output options.

Allows the user to set output solver options after the output has been defined and metadata set using the add_ouput method.

Parameters:
namestr

Name of the variable in this system’s namespace.

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.

set_solver_print(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(name, val, units=None, indices=None)

Set an input or output variable.

Parameters:
namestr

Promoted or relative variable name in the system’s namespace.

valobject

Value to assign to this variable.

unitsstr, optional

Units of the value.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to set.

setup()[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(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.

Yields:
type or None
property under_approx

Return True if under complex step or finite difference.

Returns:
bool

True if under CS or FD.

use_fixed_coloring(coloring=<object object>, 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: ExplicitComponent

Component containing Discipline 1 – no derivatives version.

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

Store some bound methods so we can detect runtime overrides.

abs_meta_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names and their metadata for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str, dict
abs_name_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str
add_constraint(name, lower=None, upper=None, equals=None, ref=None, ref0=None, adder=None, scaler=None, units=None, indices=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a constraint variable to this system.

Parameters:
namestr

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 alternative to using ref and ref0.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

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. The arguments (lower, upper, equals) can not be strings or variable names.

add_design_var(name, lower=None, upper=None, ref=None, ref0=None, indices=None, adder=None, scaler=None, units=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False)

Add a design variable to this system.

Parameters:
namestr

Promoted name of the design variable in the system.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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 an input 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.

unitsstr, optional

Units to convert to before applying scaling.

parallel_deriv_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

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(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(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(name, val=1.0, shape=None, units=None, desc='', tags=None, shape_by_conn=False, copy_shape=None, compute_shape=None, require_connection=False, distributed=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 val is not an array. Default is None.

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.

shape_by_connbool

If True, shape this input to match its connected output.

copy_shapestr or None

If a str, that str is the name of a variable. Shape this input to match that of the named variable.

compute_shapefunction

A function taking a dict arg containing names and shapes of this component’s outputs and returning the shape of this input.

require_connectionbool

If True and this input is not a design variable, it must be connected to an output.

distributedbool

If True, this variable is a distributed variable, so it can have different sizes/values across MPI processes.

Returns:
dict

Metadata for added variable.

add_objective(name, ref=None, ref0=None, index=None, units=None, adder=None, scaler=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a response variable to this system.

Parameters:
namestr

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple objectives on different indices or slices of a single variable.

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(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, shape_by_conn=False, copy_shape=None, compute_shape=None, distributed=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.

shape_by_connbool

If True, shape this output to match its connected input(s).

copy_shapestr or None

If a str, that str is the name of a variable. Shape this output to match that of the named variable.

compute_shapefunction or None

If a function, that function is called to determine the shape of this output.

distributedbool

If True, this variable is a distributed variable, so it can have different sizes/values across MPI processes.

Returns:
dict

Metadata for added variable.

add_recorder(recorder, recurse=False)

Add a recorder to the system.

Parameters:
recorder<CaseRecorder>

A recorder instance.

recursebool

Flag indicating if the recorder should be added to all the subsystems.

add_response(name, type_, lower=None, upper=None, equals=None, ref=None, ref0=None, indices=None, index=None, units=None, adder=None, scaler=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=None, alias=None)

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:
namestr

Promoted name of the response variable in the system.

type_str

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr or None

Alias for this response. Necessary when adding multiple responses on different indices of the same variable.

best_partial_deriv_direction()

Return the best direction for partial deriv calculations based on input and output sizes.

Returns:
str

The best direction for derivative calculations, ‘fwd’ or ‘rev’.

check_config(logger)

Perform optional error checks.

Parameters:
loggerobject

The object that manages logging output.

check_subjac_sparsity()

Check the declared sparsity of the sub-jacobians vs. the computed sparsity.

property checking

Return True if check_partials or check_totals is executing.

Returns:
bool

True if we’re running within check_partials or check_totals.

cleanup()

Clean up resources prior to exit.

property comm

Return the MPI communicator object for the system.

Returns:
MPI.Comm

MPI communicator object.

comm_info_iter()

Yield comm size for this system and all subsystems.

Yields:
tuple

A tuple of the form (abs_name, comm_size).

compute(inputs, outputs)[source]

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

compute_jacvec_product(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(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.

compute_sparsity()

Compute the sparsity of the partial jacobian.

Returns:
coo_matrix

The sparsity matrix.

dict

Metadata about the sparsity computation.

convert2units(name, val, units)

Convert the given value to the specified units.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_from_units(name, val, units)

Convert the given value from the specified units to those of the named variable.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_units(name, val, units_from, units_to)

Wrap the utility convert_units and give a good error message.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

units_fromstr

The units to convert from.

units_tostr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

declare_coloring(wrt=('*',), method='fd', form=None, step=None, per_instance=True, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, min_improve_pct=5.0, 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.

min_improve_pctfloat

If coloring does not improve (decrease) the number of solves more than the given percentage, coloring will not be used.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

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

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

Declare information about this component’s subjacobians.

Parameters:
ofstr or iter of str

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

wrtstr or iter 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.

formstr

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

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value.

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

Returns:
dict

Metadata dict for the specified partial(s).

dist_size_iter(io, top_comm)

Yield names and distributed ranges of all local and remote variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

top_commMPI.Comm or None

The top-level MPI communicator.

Yields:
tuple

A tuple of the form ((abs_name, rank), start, end).

get_coloring_fname(mode)

Return the full pathname to a coloring file.

Parameters:
modestr

The type of coloring file desired. Must be either ‘input’ or ‘output’.

Returns:
pathlib.Path

Full pathname of the coloring file.

get_constraints(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each constraint.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The constraints defined in the current system.

get_design_vars(recurse=True, get_sizes=True, use_prom_ivc=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 of a group 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.

use_prom_ivcbool

Use promoted names for inputs, else convert to absolute source names.

Returns:
dict

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

get_io_metadata(iotypes=('input', 'output'), metadata_keys=None, includes=None, excludes=None, is_indep_var=None, is_design_var=None, tags=None, get_remote=False, rank=None, return_rel_names=True)

Retrieve metadata for a filtered list of variables.

Parameters:
iotypesstr or iter of str

Will contain either ‘input’, ‘output’, or both. Defaults to both.

metadata_keysiter of str or None

Names of metadata entries to be retrieved or None, meaning retrieve all available ‘allprocs’ metadata. If ‘val’ or ‘src_indices’ are required, their keys must be provided explicitly since they are not found in the ‘allprocs’ metadata and must be retrieved from local metadata located in each process.

includesstr, iter of str or None

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all variables.

excludesstr, iter of str or None

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

tagsstr or iter 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.

get_remotebool

If True, retrieve variables from other MPI processes as well.

rankint or None

If None, and get_remote is True, retrieve values from all MPI process to all other MPI processes. Otherwise, if get_remote is True, retrieve values from all MPI processes only to the specified rank.

return_rel_namesbool

If True, the names returned will be relative to the scope of this System. Otherwise they will be absolute names.

Returns:
dict

A dict of metadata keyed on name, where name is either absolute or relative based on the value of the return_rel_names arg, and metadata is a dict containing entries based on the value of the metadata_keys arg. Every metadata dict will always contain two entries, ‘prom_name’ and ‘discrete’, to indicate a given variable’s promoted name and whether or not it is discrete.

get_linear_vectors()

Return the linear inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals): tuple of <Vector> instances

Yields the linear inputs, outputs, and residuals vectors.

get_nonlinear_vectors()

Return the inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals)

Yields the inputs, outputs, and residuals nonlinear vectors.

get_objectives(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each objective.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The objectives defined in the current system.

get_outputs_dir(*subdirs, mkdir=True)

Get the path under which all output files of this system are to be placed.

Parameters:
*subdirsstr

Subdirectories nested under the relevant problem output directory. To create {prob_output_dir}/a/b one would pass system.get_outputs_dir(‘a’, ‘b’).

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path of the outputs directory for the problem.

get_promotions(inprom=None, outprom=None)

Return all promotions for the given promoted variable(s).

In other words, how and where did promotions occur to convert absolute variable names into the given promoted name(s) at the current System level.

Parameters:
inpromstr or None

The promoted input variable name.

outpromstr or None

The promoted output variable name.

Returns:
dict

Dictionary keyed on system pathname containing input and/or output promotion lists for each System where promotions occurred to produce the given promoted variable(s).

get_reports_dir()

Get the path to the directory where the report files should go.

If it doesn’t exist, it will be created.

Returns:
str

The path to the directory where reports should be written.

get_responses(recurse=True, get_sizes=True, use_prom_ivc=False)

Get the response variable settings from this system.

Retrieve all response variable settings from the system as a dict, keyed by either absolute variable name, promoted name, or alias name, depending on the value of use_prom_ivc and whether the original key was a promoted output, promoted input, or an alias.

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.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

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

get_self_statics()

Override this in derived classes if compute_primal references static values.

Do NOT include self._discrete_inputs in the returned tuple. Include things like self.options[‘opt_name’], etc., that are used in compute_primal but are assumed to be constant during derivative computation.

Return value MUST be a tuple. Don’t forget the trailing comma if tuple has only one item. Return value MUST be hashable.

The order of these values doesn’t matter. They are only checked (by computing their hash) to see if they have changed since the last time compute_primal was jitted, and if so, compute_primal will be re-jitted.

Returns:
tuple

Tuple containing all static values required by compute_primal.

get_source(name)

Return the source variable connected to the given named variable.

The name can be a promoted name or an absolute name. If the given variable is an input, the absolute name of the connected source will be returned. If the given variable itself is a source, its own absolute name will be returned.

Parameters:
namestr

Absolute or promoted name of the variable.

Returns:
str

The absolute name of the source variable.

get_val(name, units=None, indices=None, get_remote=False, rank=None, vec_name='nonlinear', kind=None, flat=False, from_src=True)

Get an output/input/residual 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 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 or None

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. If False, only retrieve the value if it is on the current process, or only the part of the value that’s on the current process for a distributed variable. If None and the variable is remote or distributed, a RuntimeError will be raised.

rankint or None

If not None, only gather the value to this rank.

vec_namestr

Name of the vector to use. Defaults to ‘nonlinear’.

kindstr or None

Kind of variable (‘input’, ‘output’, or ‘residual’). If None, returned value will be either an input or output.

flatbool

If True, return the flattened version of the value.

from_srcbool

If True, retrieve value of an input variable from its connected source.

Returns:
object

The value of the requested output/input variable.

get_var_dup_info(name, io)

Return information about how the given variable is duplicated across MPI processes.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
tuple

A tuple of the form (is_duplicated, num_zeros, is_distributed).

get_var_sizes(name, io)

Return the sizes of the given variable on all procs.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
ndarray

Array of sizes of the variable on all procs.

initialize()

Perform any one-time initialization run at instantiation.

is_explicit()

Return True if this is an explicit component.

Returns:
bool

True if this is an explicit component.

property linear_solver

Get the linear solver for this system.

list_inputs(val=True, prom_name=True, units=False, shape=False, global_shape=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of input names and other optional information to a specified stream.

Parameters:
valbool, 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 True.

unitsbool, optional

When True, display/return units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global shape of the value. Default is False.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all input variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all ranks. Default is False, which will display output only from rank 0.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the input value is an array, print its smallest value.

print_maxbool

When true, if the input value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of input names and other optional information about those inputs.

list_outputs(explicit=True, implicit=True, val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of output names and other optional information to a specified stream.

Parameters:
explicitbool, optional

Include outputs from explicit components. Default is True.

implicitbool, optional

Include outputs from implicit components. Default is True.

valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

list_vars(val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of inputs and outputs sorted by component in execution order.

Parameters:
valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. Default is False.

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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

load_case(case)

Pull all input and output variables from a Case into this System.

Override this method if the System requires special handling when loading a case.

Parameters:
caseCase or dict

A Case from a CaseReader, or a dictionary with key ‘inputs’ mapped to the output of problem.model.list_inputs and key ‘outputs’ mapped to the output of prob.model.list_outputs. Both list_inputs and list_outputs should be called with prom_name=True and return_format=’dict’.

load_model_options()

Load the relevant model options from Problem._metadata[‘model_options’].

This method examines each path filter and corresponding options in self._problem_meta[‘model_options’]. If this System’s pathname matches the given path filter, it will assume the value for each given option which it possesses.

local_range_iter(io)

Yield names and local ranges of all local variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

Yields:
tuple

A tuple of the form (abs_name, start, end).

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 nonlinear_solver

Get the nonlinear solver for this system.

record_iteration()

Record an iteration of the current System.

run_apply_linear(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:
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()

Compute residuals.

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

run_linearize(sub_do_ln=True)

Compute jacobian / factorization.

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

Parameters:
sub_do_lnbool

Flag indicating if the children should call linearize on their linear solvers.

run_solve_linear(mode)

Apply inverse jac product.

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

Parameters:
modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear()

Compute outputs.

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

set_check_partial_options(wrt, method='fd', form=None, step=None, step_calc=None, minimum_step=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

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value..

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

directionalbool

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

set_constraint_options(name, ref=UNDEFINED, ref0=UNDEFINED, equals=UNDEFINED, lower=UNDEFINED, upper=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for constraints in the model.

Can be used to set options that were set using add_constraint.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

equalsfloat or ndarray, optional

Equality constraint value for the variable.

lowerfloat or ndarray, optional

Lower boundary for the variable.

upperfloat or ndarray, optional

Upper boundary for the variable.

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.

aliasstr, optional

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

set_design_var_options(name, lower=UNDEFINED, upper=UNDEFINED, scaler=UNDEFINED, adder=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED)

Set options for design vars in the model.

Can be used to set the options outside of setting them when calling add_design_var

Parameters:
namestr

Name of the variable in this system’s namespace.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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.

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.

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.

set_objective_options(name, ref=UNDEFINED, ref0=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for objectives in the model.

Can be used to set options after they have been set by add_objective.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

aliasstr

Alias for this response. Used to disambiguate variable names when adding multiple objectives on different indices or slices of a single variable. Deprecated.

set_output_solver_options(name, lower=UNDEFINED, upper=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED, res_ref=UNDEFINED)

Set solver output options.

Allows the user to set output solver options after the output has been defined and metadata set using the add_ouput method.

Parameters:
namestr

Name of the variable in this system’s namespace.

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.

set_solver_print(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(name, val, units=None, indices=None)

Set an input or output variable.

Parameters:
namestr

Promoted or relative variable name in the system’s namespace.

valobject

Value to assign to this variable.

unitsstr, optional

Units of the value.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to set.

setup()[source]

Declare inputs and outputs.

Available attributes:

name pathname comm options

setup_partials()[source]

Declare partials.

This is meant to be overridden by component classes. All partials should be declared here since this is called after all size/shape information is known for all variables.

system_iter(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.

Yields:
type or None
property under_approx

Return True if under complex step or finite difference.

Returns:
bool

True if under CS or FD.

use_fixed_coloring(coloring=<object object>, 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: SellarDis1

Component containing Discipline 1 – complex step version.

__init__(units=None, scaling=None)

Store some bound methods so we can detect runtime overrides.

abs_meta_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names and their metadata for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str, dict
abs_name_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str
add_constraint(name, lower=None, upper=None, equals=None, ref=None, ref0=None, adder=None, scaler=None, units=None, indices=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a constraint variable to this system.

Parameters:
namestr

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 alternative to using ref and ref0.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

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. The arguments (lower, upper, equals) can not be strings or variable names.

add_design_var(name, lower=None, upper=None, ref=None, ref0=None, indices=None, adder=None, scaler=None, units=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False)

Add a design variable to this system.

Parameters:
namestr

Promoted name of the design variable in the system.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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 an input 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.

unitsstr, optional

Units to convert to before applying scaling.

parallel_deriv_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

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(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(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(name, val=1.0, shape=None, units=None, desc='', tags=None, shape_by_conn=False, copy_shape=None, compute_shape=None, require_connection=False, distributed=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 val is not an array. Default is None.

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.

shape_by_connbool

If True, shape this input to match its connected output.

copy_shapestr or None

If a str, that str is the name of a variable. Shape this input to match that of the named variable.

compute_shapefunction

A function taking a dict arg containing names and shapes of this component’s outputs and returning the shape of this input.

require_connectionbool

If True and this input is not a design variable, it must be connected to an output.

distributedbool

If True, this variable is a distributed variable, so it can have different sizes/values across MPI processes.

Returns:
dict

Metadata for added variable.

add_objective(name, ref=None, ref0=None, index=None, units=None, adder=None, scaler=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a response variable to this system.

Parameters:
namestr

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple objectives on different indices or slices of a single variable.

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(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, shape_by_conn=False, copy_shape=None, compute_shape=None, distributed=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.

shape_by_connbool

If True, shape this output to match its connected input(s).

copy_shapestr or None

If a str, that str is the name of a variable. Shape this output to match that of the named variable.

compute_shapefunction or None

If a function, that function is called to determine the shape of this output.

distributedbool

If True, this variable is a distributed variable, so it can have different sizes/values across MPI processes.

Returns:
dict

Metadata for added variable.

add_recorder(recorder, recurse=False)

Add a recorder to the system.

Parameters:
recorder<CaseRecorder>

A recorder instance.

recursebool

Flag indicating if the recorder should be added to all the subsystems.

add_response(name, type_, lower=None, upper=None, equals=None, ref=None, ref0=None, indices=None, index=None, units=None, adder=None, scaler=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=None, alias=None)

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:
namestr

Promoted name of the response variable in the system.

type_str

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr or None

Alias for this response. Necessary when adding multiple responses on different indices of the same variable.

best_partial_deriv_direction()

Return the best direction for partial deriv calculations based on input and output sizes.

Returns:
str

The best direction for derivative calculations, ‘fwd’ or ‘rev’.

check_config(logger)

Perform optional error checks.

Parameters:
loggerobject

The object that manages logging output.

check_subjac_sparsity()

Check the declared sparsity of the sub-jacobians vs. the computed sparsity.

property checking

Return True if check_partials or check_totals is executing.

Returns:
bool

True if we’re running within check_partials or check_totals.

cleanup()

Clean up resources prior to exit.

property comm

Return the MPI communicator object for the system.

Returns:
MPI.Comm

MPI communicator object.

comm_info_iter()

Yield comm size for this system and all subsystems.

Yields:
tuple

A tuple of the form (abs_name, comm_size).

compute(inputs, outputs)

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

compute_jacvec_product(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(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.

compute_sparsity()

Compute the sparsity of the partial jacobian.

Returns:
coo_matrix

The sparsity matrix.

dict

Metadata about the sparsity computation.

convert2units(name, val, units)

Convert the given value to the specified units.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_from_units(name, val, units)

Convert the given value from the specified units to those of the named variable.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_units(name, val, units_from, units_to)

Wrap the utility convert_units and give a good error message.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

units_fromstr

The units to convert from.

units_tostr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

declare_coloring(wrt=('*',), method='fd', form=None, step=None, per_instance=True, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, min_improve_pct=5.0, 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.

min_improve_pctfloat

If coloring does not improve (decrease) the number of solves more than the given percentage, coloring will not be used.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

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

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

Declare information about this component’s subjacobians.

Parameters:
ofstr or iter of str

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

wrtstr or iter 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.

formstr

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

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value.

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

Returns:
dict

Metadata dict for the specified partial(s).

dist_size_iter(io, top_comm)

Yield names and distributed ranges of all local and remote variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

top_commMPI.Comm or None

The top-level MPI communicator.

Yields:
tuple

A tuple of the form ((abs_name, rank), start, end).

get_coloring_fname(mode)

Return the full pathname to a coloring file.

Parameters:
modestr

The type of coloring file desired. Must be either ‘input’ or ‘output’.

Returns:
pathlib.Path

Full pathname of the coloring file.

get_constraints(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each constraint.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The constraints defined in the current system.

get_design_vars(recurse=True, get_sizes=True, use_prom_ivc=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 of a group 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.

use_prom_ivcbool

Use promoted names for inputs, else convert to absolute source names.

Returns:
dict

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

get_io_metadata(iotypes=('input', 'output'), metadata_keys=None, includes=None, excludes=None, is_indep_var=None, is_design_var=None, tags=None, get_remote=False, rank=None, return_rel_names=True)

Retrieve metadata for a filtered list of variables.

Parameters:
iotypesstr or iter of str

Will contain either ‘input’, ‘output’, or both. Defaults to both.

metadata_keysiter of str or None

Names of metadata entries to be retrieved or None, meaning retrieve all available ‘allprocs’ metadata. If ‘val’ or ‘src_indices’ are required, their keys must be provided explicitly since they are not found in the ‘allprocs’ metadata and must be retrieved from local metadata located in each process.

includesstr, iter of str or None

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all variables.

excludesstr, iter of str or None

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

tagsstr or iter 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.

get_remotebool

If True, retrieve variables from other MPI processes as well.

rankint or None

If None, and get_remote is True, retrieve values from all MPI process to all other MPI processes. Otherwise, if get_remote is True, retrieve values from all MPI processes only to the specified rank.

return_rel_namesbool

If True, the names returned will be relative to the scope of this System. Otherwise they will be absolute names.

Returns:
dict

A dict of metadata keyed on name, where name is either absolute or relative based on the value of the return_rel_names arg, and metadata is a dict containing entries based on the value of the metadata_keys arg. Every metadata dict will always contain two entries, ‘prom_name’ and ‘discrete’, to indicate a given variable’s promoted name and whether or not it is discrete.

get_linear_vectors()

Return the linear inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals): tuple of <Vector> instances

Yields the linear inputs, outputs, and residuals vectors.

get_nonlinear_vectors()

Return the inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals)

Yields the inputs, outputs, and residuals nonlinear vectors.

get_objectives(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each objective.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The objectives defined in the current system.

get_outputs_dir(*subdirs, mkdir=True)

Get the path under which all output files of this system are to be placed.

Parameters:
*subdirsstr

Subdirectories nested under the relevant problem output directory. To create {prob_output_dir}/a/b one would pass system.get_outputs_dir(‘a’, ‘b’).

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path of the outputs directory for the problem.

get_promotions(inprom=None, outprom=None)

Return all promotions for the given promoted variable(s).

In other words, how and where did promotions occur to convert absolute variable names into the given promoted name(s) at the current System level.

Parameters:
inpromstr or None

The promoted input variable name.

outpromstr or None

The promoted output variable name.

Returns:
dict

Dictionary keyed on system pathname containing input and/or output promotion lists for each System where promotions occurred to produce the given promoted variable(s).

get_reports_dir()

Get the path to the directory where the report files should go.

If it doesn’t exist, it will be created.

Returns:
str

The path to the directory where reports should be written.

get_responses(recurse=True, get_sizes=True, use_prom_ivc=False)

Get the response variable settings from this system.

Retrieve all response variable settings from the system as a dict, keyed by either absolute variable name, promoted name, or alias name, depending on the value of use_prom_ivc and whether the original key was a promoted output, promoted input, or an alias.

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.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

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

get_self_statics()

Override this in derived classes if compute_primal references static values.

Do NOT include self._discrete_inputs in the returned tuple. Include things like self.options[‘opt_name’], etc., that are used in compute_primal but are assumed to be constant during derivative computation.

Return value MUST be a tuple. Don’t forget the trailing comma if tuple has only one item. Return value MUST be hashable.

The order of these values doesn’t matter. They are only checked (by computing their hash) to see if they have changed since the last time compute_primal was jitted, and if so, compute_primal will be re-jitted.

Returns:
tuple

Tuple containing all static values required by compute_primal.

get_source(name)

Return the source variable connected to the given named variable.

The name can be a promoted name or an absolute name. If the given variable is an input, the absolute name of the connected source will be returned. If the given variable itself is a source, its own absolute name will be returned.

Parameters:
namestr

Absolute or promoted name of the variable.

Returns:
str

The absolute name of the source variable.

get_val(name, units=None, indices=None, get_remote=False, rank=None, vec_name='nonlinear', kind=None, flat=False, from_src=True)

Get an output/input/residual 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 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 or None

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. If False, only retrieve the value if it is on the current process, or only the part of the value that’s on the current process for a distributed variable. If None and the variable is remote or distributed, a RuntimeError will be raised.

rankint or None

If not None, only gather the value to this rank.

vec_namestr

Name of the vector to use. Defaults to ‘nonlinear’.

kindstr or None

Kind of variable (‘input’, ‘output’, or ‘residual’). If None, returned value will be either an input or output.

flatbool

If True, return the flattened version of the value.

from_srcbool

If True, retrieve value of an input variable from its connected source.

Returns:
object

The value of the requested output/input variable.

get_var_dup_info(name, io)

Return information about how the given variable is duplicated across MPI processes.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
tuple

A tuple of the form (is_duplicated, num_zeros, is_distributed).

get_var_sizes(name, io)

Return the sizes of the given variable on all procs.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
ndarray

Array of sizes of the variable on all procs.

initialize()

Perform any one-time initialization run at instantiation.

is_explicit()

Return True if this is an explicit component.

Returns:
bool

True if this is an explicit component.

property linear_solver

Get the linear solver for this system.

list_inputs(val=True, prom_name=True, units=False, shape=False, global_shape=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of input names and other optional information to a specified stream.

Parameters:
valbool, 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 True.

unitsbool, optional

When True, display/return units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global shape of the value. Default is False.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all input variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all ranks. Default is False, which will display output only from rank 0.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the input value is an array, print its smallest value.

print_maxbool

When true, if the input value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of input names and other optional information about those inputs.

list_outputs(explicit=True, implicit=True, val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of output names and other optional information to a specified stream.

Parameters:
explicitbool, optional

Include outputs from explicit components. Default is True.

implicitbool, optional

Include outputs from implicit components. Default is True.

valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

list_vars(val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of inputs and outputs sorted by component in execution order.

Parameters:
valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. Default is False.

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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

load_case(case)

Pull all input and output variables from a Case into this System.

Override this method if the System requires special handling when loading a case.

Parameters:
caseCase or dict

A Case from a CaseReader, or a dictionary with key ‘inputs’ mapped to the output of problem.model.list_inputs and key ‘outputs’ mapped to the output of prob.model.list_outputs. Both list_inputs and list_outputs should be called with prom_name=True and return_format=’dict’.

load_model_options()

Load the relevant model options from Problem._metadata[‘model_options’].

This method examines each path filter and corresponding options in self._problem_meta[‘model_options’]. If this System’s pathname matches the given path filter, it will assume the value for each given option which it possesses.

local_range_iter(io)

Yield names and local ranges of all local variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

Yields:
tuple

A tuple of the form (abs_name, start, end).

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 nonlinear_solver

Get the nonlinear solver for this system.

record_iteration()

Record an iteration of the current System.

run_apply_linear(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:
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()

Compute residuals.

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

run_linearize(sub_do_ln=True)

Compute jacobian / factorization.

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

Parameters:
sub_do_lnbool

Flag indicating if the children should call linearize on their linear solvers.

run_solve_linear(mode)

Apply inverse jac product.

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

Parameters:
modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear()

Compute outputs.

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

set_check_partial_options(wrt, method='fd', form=None, step=None, step_calc=None, minimum_step=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

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value..

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

directionalbool

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

set_constraint_options(name, ref=UNDEFINED, ref0=UNDEFINED, equals=UNDEFINED, lower=UNDEFINED, upper=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for constraints in the model.

Can be used to set options that were set using add_constraint.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

equalsfloat or ndarray, optional

Equality constraint value for the variable.

lowerfloat or ndarray, optional

Lower boundary for the variable.

upperfloat or ndarray, optional

Upper boundary for the variable.

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.

aliasstr, optional

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

set_design_var_options(name, lower=UNDEFINED, upper=UNDEFINED, scaler=UNDEFINED, adder=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED)

Set options for design vars in the model.

Can be used to set the options outside of setting them when calling add_design_var

Parameters:
namestr

Name of the variable in this system’s namespace.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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.

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.

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.

set_objective_options(name, ref=UNDEFINED, ref0=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for objectives in the model.

Can be used to set options after they have been set by add_objective.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

aliasstr

Alias for this response. Used to disambiguate variable names when adding multiple objectives on different indices or slices of a single variable. Deprecated.

set_output_solver_options(name, lower=UNDEFINED, upper=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED, res_ref=UNDEFINED)

Set solver output options.

Allows the user to set output solver options after the output has been defined and metadata set using the add_ouput method.

Parameters:
namestr

Name of the variable in this system’s namespace.

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.

set_solver_print(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(name, val, units=None, indices=None)

Set an input or output variable.

Parameters:
namestr

Promoted or relative variable name in the system’s namespace.

valobject

Value to assign to this variable.

unitsstr, optional

Units of the value.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to set.

setup()

Declare inputs and outputs.

Available attributes:

name pathname comm options

setup_partials()[source]

Declare partials.

This is meant to be overridden by component classes. All partials should be declared here since this is called after all size/shape information is known for all variables.

system_iter(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.

Yields:
type or None
property under_approx

Return True if under complex step or finite difference.

Returns:
bool

True if under CS or FD.

use_fixed_coloring(coloring=<object object>, 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: SellarDis1

Component containing Discipline 1 – derivatives version.

__init__(units=None, scaling=None)

Store some bound methods so we can detect runtime overrides.

abs_meta_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names and their metadata for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str, dict
abs_name_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str
add_constraint(name, lower=None, upper=None, equals=None, ref=None, ref0=None, adder=None, scaler=None, units=None, indices=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a constraint variable to this system.

Parameters:
namestr

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 alternative to using ref and ref0.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

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. The arguments (lower, upper, equals) can not be strings or variable names.

add_design_var(name, lower=None, upper=None, ref=None, ref0=None, indices=None, adder=None, scaler=None, units=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False)

Add a design variable to this system.

Parameters:
namestr

Promoted name of the design variable in the system.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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 an input 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.

unitsstr, optional

Units to convert to before applying scaling.

parallel_deriv_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

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(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(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(name, val=1.0, shape=None, units=None, desc='', tags=None, shape_by_conn=False, copy_shape=None, compute_shape=None, require_connection=False, distributed=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 val is not an array. Default is None.

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.

shape_by_connbool

If True, shape this input to match its connected output.

copy_shapestr or None

If a str, that str is the name of a variable. Shape this input to match that of the named variable.

compute_shapefunction

A function taking a dict arg containing names and shapes of this component’s outputs and returning the shape of this input.

require_connectionbool

If True and this input is not a design variable, it must be connected to an output.

distributedbool

If True, this variable is a distributed variable, so it can have different sizes/values across MPI processes.

Returns:
dict

Metadata for added variable.

add_objective(name, ref=None, ref0=None, index=None, units=None, adder=None, scaler=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a response variable to this system.

Parameters:
namestr

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple objectives on different indices or slices of a single variable.

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(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, shape_by_conn=False, copy_shape=None, compute_shape=None, distributed=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.

shape_by_connbool

If True, shape this output to match its connected input(s).

copy_shapestr or None

If a str, that str is the name of a variable. Shape this output to match that of the named variable.

compute_shapefunction or None

If a function, that function is called to determine the shape of this output.

distributedbool

If True, this variable is a distributed variable, so it can have different sizes/values across MPI processes.

Returns:
dict

Metadata for added variable.

add_recorder(recorder, recurse=False)

Add a recorder to the system.

Parameters:
recorder<CaseRecorder>

A recorder instance.

recursebool

Flag indicating if the recorder should be added to all the subsystems.

add_response(name, type_, lower=None, upper=None, equals=None, ref=None, ref0=None, indices=None, index=None, units=None, adder=None, scaler=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=None, alias=None)

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:
namestr

Promoted name of the response variable in the system.

type_str

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr or None

Alias for this response. Necessary when adding multiple responses on different indices of the same variable.

best_partial_deriv_direction()

Return the best direction for partial deriv calculations based on input and output sizes.

Returns:
str

The best direction for derivative calculations, ‘fwd’ or ‘rev’.

check_config(logger)

Perform optional error checks.

Parameters:
loggerobject

The object that manages logging output.

check_subjac_sparsity()

Check the declared sparsity of the sub-jacobians vs. the computed sparsity.

property checking

Return True if check_partials or check_totals is executing.

Returns:
bool

True if we’re running within check_partials or check_totals.

cleanup()

Clean up resources prior to exit.

property comm

Return the MPI communicator object for the system.

Returns:
MPI.Comm

MPI communicator object.

comm_info_iter()

Yield comm size for this system and all subsystems.

Yields:
tuple

A tuple of the form (abs_name, comm_size).

compute(inputs, outputs)

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

compute_jacvec_product(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(inputs, partials)[source]

Jacobian for Sellar discipline 1.

compute_sparsity()

Compute the sparsity of the partial jacobian.

Returns:
coo_matrix

The sparsity matrix.

dict

Metadata about the sparsity computation.

convert2units(name, val, units)

Convert the given value to the specified units.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_from_units(name, val, units)

Convert the given value from the specified units to those of the named variable.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_units(name, val, units_from, units_to)

Wrap the utility convert_units and give a good error message.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

units_fromstr

The units to convert from.

units_tostr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

declare_coloring(wrt=('*',), method='fd', form=None, step=None, per_instance=True, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, min_improve_pct=5.0, 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.

min_improve_pctfloat

If coloring does not improve (decrease) the number of solves more than the given percentage, coloring will not be used.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

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

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

Declare information about this component’s subjacobians.

Parameters:
ofstr or iter of str

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

wrtstr or iter 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.

formstr

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

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value.

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

Returns:
dict

Metadata dict for the specified partial(s).

dist_size_iter(io, top_comm)

Yield names and distributed ranges of all local and remote variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

top_commMPI.Comm or None

The top-level MPI communicator.

Yields:
tuple

A tuple of the form ((abs_name, rank), start, end).

get_coloring_fname(mode)

Return the full pathname to a coloring file.

Parameters:
modestr

The type of coloring file desired. Must be either ‘input’ or ‘output’.

Returns:
pathlib.Path

Full pathname of the coloring file.

get_constraints(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each constraint.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The constraints defined in the current system.

get_design_vars(recurse=True, get_sizes=True, use_prom_ivc=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 of a group 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.

use_prom_ivcbool

Use promoted names for inputs, else convert to absolute source names.

Returns:
dict

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

get_io_metadata(iotypes=('input', 'output'), metadata_keys=None, includes=None, excludes=None, is_indep_var=None, is_design_var=None, tags=None, get_remote=False, rank=None, return_rel_names=True)

Retrieve metadata for a filtered list of variables.

Parameters:
iotypesstr or iter of str

Will contain either ‘input’, ‘output’, or both. Defaults to both.

metadata_keysiter of str or None

Names of metadata entries to be retrieved or None, meaning retrieve all available ‘allprocs’ metadata. If ‘val’ or ‘src_indices’ are required, their keys must be provided explicitly since they are not found in the ‘allprocs’ metadata and must be retrieved from local metadata located in each process.

includesstr, iter of str or None

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all variables.

excludesstr, iter of str or None

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

tagsstr or iter 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.

get_remotebool

If True, retrieve variables from other MPI processes as well.

rankint or None

If None, and get_remote is True, retrieve values from all MPI process to all other MPI processes. Otherwise, if get_remote is True, retrieve values from all MPI processes only to the specified rank.

return_rel_namesbool

If True, the names returned will be relative to the scope of this System. Otherwise they will be absolute names.

Returns:
dict

A dict of metadata keyed on name, where name is either absolute or relative based on the value of the return_rel_names arg, and metadata is a dict containing entries based on the value of the metadata_keys arg. Every metadata dict will always contain two entries, ‘prom_name’ and ‘discrete’, to indicate a given variable’s promoted name and whether or not it is discrete.

get_linear_vectors()

Return the linear inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals): tuple of <Vector> instances

Yields the linear inputs, outputs, and residuals vectors.

get_nonlinear_vectors()

Return the inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals)

Yields the inputs, outputs, and residuals nonlinear vectors.

get_objectives(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each objective.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The objectives defined in the current system.

get_outputs_dir(*subdirs, mkdir=True)

Get the path under which all output files of this system are to be placed.

Parameters:
*subdirsstr

Subdirectories nested under the relevant problem output directory. To create {prob_output_dir}/a/b one would pass system.get_outputs_dir(‘a’, ‘b’).

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path of the outputs directory for the problem.

get_promotions(inprom=None, outprom=None)

Return all promotions for the given promoted variable(s).

In other words, how and where did promotions occur to convert absolute variable names into the given promoted name(s) at the current System level.

Parameters:
inpromstr or None

The promoted input variable name.

outpromstr or None

The promoted output variable name.

Returns:
dict

Dictionary keyed on system pathname containing input and/or output promotion lists for each System where promotions occurred to produce the given promoted variable(s).

get_reports_dir()

Get the path to the directory where the report files should go.

If it doesn’t exist, it will be created.

Returns:
str

The path to the directory where reports should be written.

get_responses(recurse=True, get_sizes=True, use_prom_ivc=False)

Get the response variable settings from this system.

Retrieve all response variable settings from the system as a dict, keyed by either absolute variable name, promoted name, or alias name, depending on the value of use_prom_ivc and whether the original key was a promoted output, promoted input, or an alias.

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.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

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

get_self_statics()

Override this in derived classes if compute_primal references static values.

Do NOT include self._discrete_inputs in the returned tuple. Include things like self.options[‘opt_name’], etc., that are used in compute_primal but are assumed to be constant during derivative computation.

Return value MUST be a tuple. Don’t forget the trailing comma if tuple has only one item. Return value MUST be hashable.

The order of these values doesn’t matter. They are only checked (by computing their hash) to see if they have changed since the last time compute_primal was jitted, and if so, compute_primal will be re-jitted.

Returns:
tuple

Tuple containing all static values required by compute_primal.

get_source(name)

Return the source variable connected to the given named variable.

The name can be a promoted name or an absolute name. If the given variable is an input, the absolute name of the connected source will be returned. If the given variable itself is a source, its own absolute name will be returned.

Parameters:
namestr

Absolute or promoted name of the variable.

Returns:
str

The absolute name of the source variable.

get_val(name, units=None, indices=None, get_remote=False, rank=None, vec_name='nonlinear', kind=None, flat=False, from_src=True)

Get an output/input/residual 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 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 or None

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. If False, only retrieve the value if it is on the current process, or only the part of the value that’s on the current process for a distributed variable. If None and the variable is remote or distributed, a RuntimeError will be raised.

rankint or None

If not None, only gather the value to this rank.

vec_namestr

Name of the vector to use. Defaults to ‘nonlinear’.

kindstr or None

Kind of variable (‘input’, ‘output’, or ‘residual’). If None, returned value will be either an input or output.

flatbool

If True, return the flattened version of the value.

from_srcbool

If True, retrieve value of an input variable from its connected source.

Returns:
object

The value of the requested output/input variable.

get_var_dup_info(name, io)

Return information about how the given variable is duplicated across MPI processes.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
tuple

A tuple of the form (is_duplicated, num_zeros, is_distributed).

get_var_sizes(name, io)

Return the sizes of the given variable on all procs.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
ndarray

Array of sizes of the variable on all procs.

initialize()

Perform any one-time initialization run at instantiation.

is_explicit()

Return True if this is an explicit component.

Returns:
bool

True if this is an explicit component.

property linear_solver

Get the linear solver for this system.

list_inputs(val=True, prom_name=True, units=False, shape=False, global_shape=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of input names and other optional information to a specified stream.

Parameters:
valbool, 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 True.

unitsbool, optional

When True, display/return units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global shape of the value. Default is False.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all input variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all ranks. Default is False, which will display output only from rank 0.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the input value is an array, print its smallest value.

print_maxbool

When true, if the input value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of input names and other optional information about those inputs.

list_outputs(explicit=True, implicit=True, val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of output names and other optional information to a specified stream.

Parameters:
explicitbool, optional

Include outputs from explicit components. Default is True.

implicitbool, optional

Include outputs from implicit components. Default is True.

valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

list_vars(val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of inputs and outputs sorted by component in execution order.

Parameters:
valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. Default is False.

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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

load_case(case)

Pull all input and output variables from a Case into this System.

Override this method if the System requires special handling when loading a case.

Parameters:
caseCase or dict

A Case from a CaseReader, or a dictionary with key ‘inputs’ mapped to the output of problem.model.list_inputs and key ‘outputs’ mapped to the output of prob.model.list_outputs. Both list_inputs and list_outputs should be called with prom_name=True and return_format=’dict’.

load_model_options()

Load the relevant model options from Problem._metadata[‘model_options’].

This method examines each path filter and corresponding options in self._problem_meta[‘model_options’]. If this System’s pathname matches the given path filter, it will assume the value for each given option which it possesses.

local_range_iter(io)

Yield names and local ranges of all local variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

Yields:
tuple

A tuple of the form (abs_name, start, end).

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 nonlinear_solver

Get the nonlinear solver for this system.

record_iteration()

Record an iteration of the current System.

run_apply_linear(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:
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()

Compute residuals.

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

run_linearize(sub_do_ln=True)

Compute jacobian / factorization.

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

Parameters:
sub_do_lnbool

Flag indicating if the children should call linearize on their linear solvers.

run_solve_linear(mode)

Apply inverse jac product.

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

Parameters:
modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear()

Compute outputs.

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

set_check_partial_options(wrt, method='fd', form=None, step=None, step_calc=None, minimum_step=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

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value..

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

directionalbool

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

set_constraint_options(name, ref=UNDEFINED, ref0=UNDEFINED, equals=UNDEFINED, lower=UNDEFINED, upper=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for constraints in the model.

Can be used to set options that were set using add_constraint.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

equalsfloat or ndarray, optional

Equality constraint value for the variable.

lowerfloat or ndarray, optional

Lower boundary for the variable.

upperfloat or ndarray, optional

Upper boundary for the variable.

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.

aliasstr, optional

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

set_design_var_options(name, lower=UNDEFINED, upper=UNDEFINED, scaler=UNDEFINED, adder=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED)

Set options for design vars in the model.

Can be used to set the options outside of setting them when calling add_design_var

Parameters:
namestr

Name of the variable in this system’s namespace.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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.

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.

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.

set_objective_options(name, ref=UNDEFINED, ref0=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for objectives in the model.

Can be used to set options after they have been set by add_objective.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

aliasstr

Alias for this response. Used to disambiguate variable names when adding multiple objectives on different indices or slices of a single variable. Deprecated.

set_output_solver_options(name, lower=UNDEFINED, upper=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED, res_ref=UNDEFINED)

Set solver output options.

Allows the user to set output solver options after the output has been defined and metadata set using the add_ouput method.

Parameters:
namestr

Name of the variable in this system’s namespace.

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.

set_solver_print(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(name, val, units=None, indices=None)

Set an input or output variable.

Parameters:
namestr

Promoted or relative variable name in the system’s namespace.

valobject

Value to assign to this variable.

unitsstr, optional

Units of the value.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to set.

setup()

Declare inputs and outputs.

Available attributes:

name pathname comm options

setup_partials()[source]

Declare partials.

This is meant to be overridden by component classes. All partials should be declared here since this is called after all size/shape information is known for all variables.

system_iter(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.

Yields:
type or None
property under_approx

Return True if under complex step or finite difference.

Returns:
bool

True if under CS or FD.

use_fixed_coloring(coloring=<object object>, 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: ExplicitComponent

Component containing Discipline 2 – no derivatives version.

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

Store some bound methods so we can detect runtime overrides.

abs_meta_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names and their metadata for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str, dict
abs_name_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str
add_constraint(name, lower=None, upper=None, equals=None, ref=None, ref0=None, adder=None, scaler=None, units=None, indices=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a constraint variable to this system.

Parameters:
namestr

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 alternative to using ref and ref0.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

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. The arguments (lower, upper, equals) can not be strings or variable names.

add_design_var(name, lower=None, upper=None, ref=None, ref0=None, indices=None, adder=None, scaler=None, units=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False)

Add a design variable to this system.

Parameters:
namestr

Promoted name of the design variable in the system.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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 an input 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.

unitsstr, optional

Units to convert to before applying scaling.

parallel_deriv_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

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(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(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(name, val=1.0, shape=None, units=None, desc='', tags=None, shape_by_conn=False, copy_shape=None, compute_shape=None, require_connection=False, distributed=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 val is not an array. Default is None.

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.

shape_by_connbool

If True, shape this input to match its connected output.

copy_shapestr or None

If a str, that str is the name of a variable. Shape this input to match that of the named variable.

compute_shapefunction

A function taking a dict arg containing names and shapes of this component’s outputs and returning the shape of this input.

require_connectionbool

If True and this input is not a design variable, it must be connected to an output.

distributedbool

If True, this variable is a distributed variable, so it can have different sizes/values across MPI processes.

Returns:
dict

Metadata for added variable.

add_objective(name, ref=None, ref0=None, index=None, units=None, adder=None, scaler=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a response variable to this system.

Parameters:
namestr

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple objectives on different indices or slices of a single variable.

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(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, shape_by_conn=False, copy_shape=None, compute_shape=None, distributed=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.

shape_by_connbool

If True, shape this output to match its connected input(s).

copy_shapestr or None

If a str, that str is the name of a variable. Shape this output to match that of the named variable.

compute_shapefunction or None

If a function, that function is called to determine the shape of this output.

distributedbool

If True, this variable is a distributed variable, so it can have different sizes/values across MPI processes.

Returns:
dict

Metadata for added variable.

add_recorder(recorder, recurse=False)

Add a recorder to the system.

Parameters:
recorder<CaseRecorder>

A recorder instance.

recursebool

Flag indicating if the recorder should be added to all the subsystems.

add_response(name, type_, lower=None, upper=None, equals=None, ref=None, ref0=None, indices=None, index=None, units=None, adder=None, scaler=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=None, alias=None)

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:
namestr

Promoted name of the response variable in the system.

type_str

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr or None

Alias for this response. Necessary when adding multiple responses on different indices of the same variable.

best_partial_deriv_direction()

Return the best direction for partial deriv calculations based on input and output sizes.

Returns:
str

The best direction for derivative calculations, ‘fwd’ or ‘rev’.

check_config(logger)

Perform optional error checks.

Parameters:
loggerobject

The object that manages logging output.

check_subjac_sparsity()

Check the declared sparsity of the sub-jacobians vs. the computed sparsity.

property checking

Return True if check_partials or check_totals is executing.

Returns:
bool

True if we’re running within check_partials or check_totals.

cleanup()

Clean up resources prior to exit.

property comm

Return the MPI communicator object for the system.

Returns:
MPI.Comm

MPI communicator object.

comm_info_iter()

Yield comm size for this system and all subsystems.

Yields:
tuple

A tuple of the form (abs_name, comm_size).

compute(inputs, outputs)[source]

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

compute_jacvec_product(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(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.

compute_sparsity()

Compute the sparsity of the partial jacobian.

Returns:
coo_matrix

The sparsity matrix.

dict

Metadata about the sparsity computation.

convert2units(name, val, units)

Convert the given value to the specified units.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_from_units(name, val, units)

Convert the given value from the specified units to those of the named variable.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_units(name, val, units_from, units_to)

Wrap the utility convert_units and give a good error message.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

units_fromstr

The units to convert from.

units_tostr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

declare_coloring(wrt=('*',), method='fd', form=None, step=None, per_instance=True, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, min_improve_pct=5.0, 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.

min_improve_pctfloat

If coloring does not improve (decrease) the number of solves more than the given percentage, coloring will not be used.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

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

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

Declare information about this component’s subjacobians.

Parameters:
ofstr or iter of str

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

wrtstr or iter 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.

formstr

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

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value.

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

Returns:
dict

Metadata dict for the specified partial(s).

dist_size_iter(io, top_comm)

Yield names and distributed ranges of all local and remote variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

top_commMPI.Comm or None

The top-level MPI communicator.

Yields:
tuple

A tuple of the form ((abs_name, rank), start, end).

get_coloring_fname(mode)

Return the full pathname to a coloring file.

Parameters:
modestr

The type of coloring file desired. Must be either ‘input’ or ‘output’.

Returns:
pathlib.Path

Full pathname of the coloring file.

get_constraints(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each constraint.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The constraints defined in the current system.

get_design_vars(recurse=True, get_sizes=True, use_prom_ivc=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 of a group 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.

use_prom_ivcbool

Use promoted names for inputs, else convert to absolute source names.

Returns:
dict

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

get_io_metadata(iotypes=('input', 'output'), metadata_keys=None, includes=None, excludes=None, is_indep_var=None, is_design_var=None, tags=None, get_remote=False, rank=None, return_rel_names=True)

Retrieve metadata for a filtered list of variables.

Parameters:
iotypesstr or iter of str

Will contain either ‘input’, ‘output’, or both. Defaults to both.

metadata_keysiter of str or None

Names of metadata entries to be retrieved or None, meaning retrieve all available ‘allprocs’ metadata. If ‘val’ or ‘src_indices’ are required, their keys must be provided explicitly since they are not found in the ‘allprocs’ metadata and must be retrieved from local metadata located in each process.

includesstr, iter of str or None

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all variables.

excludesstr, iter of str or None

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

tagsstr or iter 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.

get_remotebool

If True, retrieve variables from other MPI processes as well.

rankint or None

If None, and get_remote is True, retrieve values from all MPI process to all other MPI processes. Otherwise, if get_remote is True, retrieve values from all MPI processes only to the specified rank.

return_rel_namesbool

If True, the names returned will be relative to the scope of this System. Otherwise they will be absolute names.

Returns:
dict

A dict of metadata keyed on name, where name is either absolute or relative based on the value of the return_rel_names arg, and metadata is a dict containing entries based on the value of the metadata_keys arg. Every metadata dict will always contain two entries, ‘prom_name’ and ‘discrete’, to indicate a given variable’s promoted name and whether or not it is discrete.

get_linear_vectors()

Return the linear inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals): tuple of <Vector> instances

Yields the linear inputs, outputs, and residuals vectors.

get_nonlinear_vectors()

Return the inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals)

Yields the inputs, outputs, and residuals nonlinear vectors.

get_objectives(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each objective.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The objectives defined in the current system.

get_outputs_dir(*subdirs, mkdir=True)

Get the path under which all output files of this system are to be placed.

Parameters:
*subdirsstr

Subdirectories nested under the relevant problem output directory. To create {prob_output_dir}/a/b one would pass system.get_outputs_dir(‘a’, ‘b’).

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path of the outputs directory for the problem.

get_promotions(inprom=None, outprom=None)

Return all promotions for the given promoted variable(s).

In other words, how and where did promotions occur to convert absolute variable names into the given promoted name(s) at the current System level.

Parameters:
inpromstr or None

The promoted input variable name.

outpromstr or None

The promoted output variable name.

Returns:
dict

Dictionary keyed on system pathname containing input and/or output promotion lists for each System where promotions occurred to produce the given promoted variable(s).

get_reports_dir()

Get the path to the directory where the report files should go.

If it doesn’t exist, it will be created.

Returns:
str

The path to the directory where reports should be written.

get_responses(recurse=True, get_sizes=True, use_prom_ivc=False)

Get the response variable settings from this system.

Retrieve all response variable settings from the system as a dict, keyed by either absolute variable name, promoted name, or alias name, depending on the value of use_prom_ivc and whether the original key was a promoted output, promoted input, or an alias.

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.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

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

get_self_statics()

Override this in derived classes if compute_primal references static values.

Do NOT include self._discrete_inputs in the returned tuple. Include things like self.options[‘opt_name’], etc., that are used in compute_primal but are assumed to be constant during derivative computation.

Return value MUST be a tuple. Don’t forget the trailing comma if tuple has only one item. Return value MUST be hashable.

The order of these values doesn’t matter. They are only checked (by computing their hash) to see if they have changed since the last time compute_primal was jitted, and if so, compute_primal will be re-jitted.

Returns:
tuple

Tuple containing all static values required by compute_primal.

get_source(name)

Return the source variable connected to the given named variable.

The name can be a promoted name or an absolute name. If the given variable is an input, the absolute name of the connected source will be returned. If the given variable itself is a source, its own absolute name will be returned.

Parameters:
namestr

Absolute or promoted name of the variable.

Returns:
str

The absolute name of the source variable.

get_val(name, units=None, indices=None, get_remote=False, rank=None, vec_name='nonlinear', kind=None, flat=False, from_src=True)

Get an output/input/residual 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 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 or None

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. If False, only retrieve the value if it is on the current process, or only the part of the value that’s on the current process for a distributed variable. If None and the variable is remote or distributed, a RuntimeError will be raised.

rankint or None

If not None, only gather the value to this rank.

vec_namestr

Name of the vector to use. Defaults to ‘nonlinear’.

kindstr or None

Kind of variable (‘input’, ‘output’, or ‘residual’). If None, returned value will be either an input or output.

flatbool

If True, return the flattened version of the value.

from_srcbool

If True, retrieve value of an input variable from its connected source.

Returns:
object

The value of the requested output/input variable.

get_var_dup_info(name, io)

Return information about how the given variable is duplicated across MPI processes.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
tuple

A tuple of the form (is_duplicated, num_zeros, is_distributed).

get_var_sizes(name, io)

Return the sizes of the given variable on all procs.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
ndarray

Array of sizes of the variable on all procs.

initialize()

Perform any one-time initialization run at instantiation.

is_explicit()

Return True if this is an explicit component.

Returns:
bool

True if this is an explicit component.

property linear_solver

Get the linear solver for this system.

list_inputs(val=True, prom_name=True, units=False, shape=False, global_shape=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of input names and other optional information to a specified stream.

Parameters:
valbool, 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 True.

unitsbool, optional

When True, display/return units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global shape of the value. Default is False.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all input variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all ranks. Default is False, which will display output only from rank 0.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the input value is an array, print its smallest value.

print_maxbool

When true, if the input value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of input names and other optional information about those inputs.

list_outputs(explicit=True, implicit=True, val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of output names and other optional information to a specified stream.

Parameters:
explicitbool, optional

Include outputs from explicit components. Default is True.

implicitbool, optional

Include outputs from implicit components. Default is True.

valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

list_vars(val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of inputs and outputs sorted by component in execution order.

Parameters:
valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. Default is False.

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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

load_case(case)

Pull all input and output variables from a Case into this System.

Override this method if the System requires special handling when loading a case.

Parameters:
caseCase or dict

A Case from a CaseReader, or a dictionary with key ‘inputs’ mapped to the output of problem.model.list_inputs and key ‘outputs’ mapped to the output of prob.model.list_outputs. Both list_inputs and list_outputs should be called with prom_name=True and return_format=’dict’.

load_model_options()

Load the relevant model options from Problem._metadata[‘model_options’].

This method examines each path filter and corresponding options in self._problem_meta[‘model_options’]. If this System’s pathname matches the given path filter, it will assume the value for each given option which it possesses.

local_range_iter(io)

Yield names and local ranges of all local variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

Yields:
tuple

A tuple of the form (abs_name, start, end).

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 nonlinear_solver

Get the nonlinear solver for this system.

record_iteration()

Record an iteration of the current System.

run_apply_linear(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:
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()

Compute residuals.

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

run_linearize(sub_do_ln=True)

Compute jacobian / factorization.

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

Parameters:
sub_do_lnbool

Flag indicating if the children should call linearize on their linear solvers.

run_solve_linear(mode)

Apply inverse jac product.

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

Parameters:
modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear()

Compute outputs.

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

set_check_partial_options(wrt, method='fd', form=None, step=None, step_calc=None, minimum_step=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

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value..

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

directionalbool

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

set_constraint_options(name, ref=UNDEFINED, ref0=UNDEFINED, equals=UNDEFINED, lower=UNDEFINED, upper=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for constraints in the model.

Can be used to set options that were set using add_constraint.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

equalsfloat or ndarray, optional

Equality constraint value for the variable.

lowerfloat or ndarray, optional

Lower boundary for the variable.

upperfloat or ndarray, optional

Upper boundary for the variable.

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.

aliasstr, optional

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

set_design_var_options(name, lower=UNDEFINED, upper=UNDEFINED, scaler=UNDEFINED, adder=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED)

Set options for design vars in the model.

Can be used to set the options outside of setting them when calling add_design_var

Parameters:
namestr

Name of the variable in this system’s namespace.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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.

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.

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.

set_objective_options(name, ref=UNDEFINED, ref0=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for objectives in the model.

Can be used to set options after they have been set by add_objective.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

aliasstr

Alias for this response. Used to disambiguate variable names when adding multiple objectives on different indices or slices of a single variable. Deprecated.

set_output_solver_options(name, lower=UNDEFINED, upper=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED, res_ref=UNDEFINED)

Set solver output options.

Allows the user to set output solver options after the output has been defined and metadata set using the add_ouput method.

Parameters:
namestr

Name of the variable in this system’s namespace.

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.

set_solver_print(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(name, val, units=None, indices=None)

Set an input or output variable.

Parameters:
namestr

Promoted or relative variable name in the system’s namespace.

valobject

Value to assign to this variable.

unitsstr, optional

Units of the value.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to set.

setup()[source]

Declare inputs and outputs.

Available attributes:

name pathname comm options

setup_partials()[source]

Declare partials.

This is meant to be overridden by component classes. All partials should be declared here since this is called after all size/shape information is known for all variables.

system_iter(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.

Yields:
type or None
property under_approx

Return True if under complex step or finite difference.

Returns:
bool

True if under CS or FD.

use_fixed_coloring(coloring=<object object>, 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: SellarDis2

Component containing Discipline 2 – complex step version.

__init__(units=None, scaling=None)

Store some bound methods so we can detect runtime overrides.

abs_meta_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names and their metadata for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str, dict
abs_name_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str
add_constraint(name, lower=None, upper=None, equals=None, ref=None, ref0=None, adder=None, scaler=None, units=None, indices=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a constraint variable to this system.

Parameters:
namestr

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 alternative to using ref and ref0.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

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. The arguments (lower, upper, equals) can not be strings or variable names.

add_design_var(name, lower=None, upper=None, ref=None, ref0=None, indices=None, adder=None, scaler=None, units=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False)

Add a design variable to this system.

Parameters:
namestr

Promoted name of the design variable in the system.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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 an input 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.

unitsstr, optional

Units to convert to before applying scaling.

parallel_deriv_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

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(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(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(name, val=1.0, shape=None, units=None, desc='', tags=None, shape_by_conn=False, copy_shape=None, compute_shape=None, require_connection=False, distributed=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 val is not an array. Default is None.

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.

shape_by_connbool

If True, shape this input to match its connected output.

copy_shapestr or None

If a str, that str is the name of a variable. Shape this input to match that of the named variable.

compute_shapefunction

A function taking a dict arg containing names and shapes of this component’s outputs and returning the shape of this input.

require_connectionbool

If True and this input is not a design variable, it must be connected to an output.

distributedbool

If True, this variable is a distributed variable, so it can have different sizes/values across MPI processes.

Returns:
dict

Metadata for added variable.

add_objective(name, ref=None, ref0=None, index=None, units=None, adder=None, scaler=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a response variable to this system.

Parameters:
namestr

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple objectives on different indices or slices of a single variable.

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(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, shape_by_conn=False, copy_shape=None, compute_shape=None, distributed=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.

shape_by_connbool

If True, shape this output to match its connected input(s).

copy_shapestr or None

If a str, that str is the name of a variable. Shape this output to match that of the named variable.

compute_shapefunction or None

If a function, that function is called to determine the shape of this output.

distributedbool

If True, this variable is a distributed variable, so it can have different sizes/values across MPI processes.

Returns:
dict

Metadata for added variable.

add_recorder(recorder, recurse=False)

Add a recorder to the system.

Parameters:
recorder<CaseRecorder>

A recorder instance.

recursebool

Flag indicating if the recorder should be added to all the subsystems.

add_response(name, type_, lower=None, upper=None, equals=None, ref=None, ref0=None, indices=None, index=None, units=None, adder=None, scaler=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=None, alias=None)

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:
namestr

Promoted name of the response variable in the system.

type_str

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr or None

Alias for this response. Necessary when adding multiple responses on different indices of the same variable.

best_partial_deriv_direction()

Return the best direction for partial deriv calculations based on input and output sizes.

Returns:
str

The best direction for derivative calculations, ‘fwd’ or ‘rev’.

check_config(logger)

Perform optional error checks.

Parameters:
loggerobject

The object that manages logging output.

check_subjac_sparsity()

Check the declared sparsity of the sub-jacobians vs. the computed sparsity.

property checking

Return True if check_partials or check_totals is executing.

Returns:
bool

True if we’re running within check_partials or check_totals.

cleanup()

Clean up resources prior to exit.

property comm

Return the MPI communicator object for the system.

Returns:
MPI.Comm

MPI communicator object.

comm_info_iter()

Yield comm size for this system and all subsystems.

Yields:
tuple

A tuple of the form (abs_name, comm_size).

compute(inputs, outputs)

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

compute_jacvec_product(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(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.

compute_sparsity()

Compute the sparsity of the partial jacobian.

Returns:
coo_matrix

The sparsity matrix.

dict

Metadata about the sparsity computation.

convert2units(name, val, units)

Convert the given value to the specified units.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_from_units(name, val, units)

Convert the given value from the specified units to those of the named variable.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_units(name, val, units_from, units_to)

Wrap the utility convert_units and give a good error message.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

units_fromstr

The units to convert from.

units_tostr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

declare_coloring(wrt=('*',), method='fd', form=None, step=None, per_instance=True, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, min_improve_pct=5.0, 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.

min_improve_pctfloat

If coloring does not improve (decrease) the number of solves more than the given percentage, coloring will not be used.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

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

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

Declare information about this component’s subjacobians.

Parameters:
ofstr or iter of str

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

wrtstr or iter 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.

formstr

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

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value.

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

Returns:
dict

Metadata dict for the specified partial(s).

dist_size_iter(io, top_comm)

Yield names and distributed ranges of all local and remote variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

top_commMPI.Comm or None

The top-level MPI communicator.

Yields:
tuple

A tuple of the form ((abs_name, rank), start, end).

get_coloring_fname(mode)

Return the full pathname to a coloring file.

Parameters:
modestr

The type of coloring file desired. Must be either ‘input’ or ‘output’.

Returns:
pathlib.Path

Full pathname of the coloring file.

get_constraints(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each constraint.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The constraints defined in the current system.

get_design_vars(recurse=True, get_sizes=True, use_prom_ivc=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 of a group 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.

use_prom_ivcbool

Use promoted names for inputs, else convert to absolute source names.

Returns:
dict

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

get_io_metadata(iotypes=('input', 'output'), metadata_keys=None, includes=None, excludes=None, is_indep_var=None, is_design_var=None, tags=None, get_remote=False, rank=None, return_rel_names=True)

Retrieve metadata for a filtered list of variables.

Parameters:
iotypesstr or iter of str

Will contain either ‘input’, ‘output’, or both. Defaults to both.

metadata_keysiter of str or None

Names of metadata entries to be retrieved or None, meaning retrieve all available ‘allprocs’ metadata. If ‘val’ or ‘src_indices’ are required, their keys must be provided explicitly since they are not found in the ‘allprocs’ metadata and must be retrieved from local metadata located in each process.

includesstr, iter of str or None

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all variables.

excludesstr, iter of str or None

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

tagsstr or iter 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.

get_remotebool

If True, retrieve variables from other MPI processes as well.

rankint or None

If None, and get_remote is True, retrieve values from all MPI process to all other MPI processes. Otherwise, if get_remote is True, retrieve values from all MPI processes only to the specified rank.

return_rel_namesbool

If True, the names returned will be relative to the scope of this System. Otherwise they will be absolute names.

Returns:
dict

A dict of metadata keyed on name, where name is either absolute or relative based on the value of the return_rel_names arg, and metadata is a dict containing entries based on the value of the metadata_keys arg. Every metadata dict will always contain two entries, ‘prom_name’ and ‘discrete’, to indicate a given variable’s promoted name and whether or not it is discrete.

get_linear_vectors()

Return the linear inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals): tuple of <Vector> instances

Yields the linear inputs, outputs, and residuals vectors.

get_nonlinear_vectors()

Return the inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals)

Yields the inputs, outputs, and residuals nonlinear vectors.

get_objectives(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each objective.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The objectives defined in the current system.

get_outputs_dir(*subdirs, mkdir=True)

Get the path under which all output files of this system are to be placed.

Parameters:
*subdirsstr

Subdirectories nested under the relevant problem output directory. To create {prob_output_dir}/a/b one would pass system.get_outputs_dir(‘a’, ‘b’).

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path of the outputs directory for the problem.

get_promotions(inprom=None, outprom=None)

Return all promotions for the given promoted variable(s).

In other words, how and where did promotions occur to convert absolute variable names into the given promoted name(s) at the current System level.

Parameters:
inpromstr or None

The promoted input variable name.

outpromstr or None

The promoted output variable name.

Returns:
dict

Dictionary keyed on system pathname containing input and/or output promotion lists for each System where promotions occurred to produce the given promoted variable(s).

get_reports_dir()

Get the path to the directory where the report files should go.

If it doesn’t exist, it will be created.

Returns:
str

The path to the directory where reports should be written.

get_responses(recurse=True, get_sizes=True, use_prom_ivc=False)

Get the response variable settings from this system.

Retrieve all response variable settings from the system as a dict, keyed by either absolute variable name, promoted name, or alias name, depending on the value of use_prom_ivc and whether the original key was a promoted output, promoted input, or an alias.

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.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

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

get_self_statics()

Override this in derived classes if compute_primal references static values.

Do NOT include self._discrete_inputs in the returned tuple. Include things like self.options[‘opt_name’], etc., that are used in compute_primal but are assumed to be constant during derivative computation.

Return value MUST be a tuple. Don’t forget the trailing comma if tuple has only one item. Return value MUST be hashable.

The order of these values doesn’t matter. They are only checked (by computing their hash) to see if they have changed since the last time compute_primal was jitted, and if so, compute_primal will be re-jitted.

Returns:
tuple

Tuple containing all static values required by compute_primal.

get_source(name)

Return the source variable connected to the given named variable.

The name can be a promoted name or an absolute name. If the given variable is an input, the absolute name of the connected source will be returned. If the given variable itself is a source, its own absolute name will be returned.

Parameters:
namestr

Absolute or promoted name of the variable.

Returns:
str

The absolute name of the source variable.

get_val(name, units=None, indices=None, get_remote=False, rank=None, vec_name='nonlinear', kind=None, flat=False, from_src=True)

Get an output/input/residual 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 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 or None

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. If False, only retrieve the value if it is on the current process, or only the part of the value that’s on the current process for a distributed variable. If None and the variable is remote or distributed, a RuntimeError will be raised.

rankint or None

If not None, only gather the value to this rank.

vec_namestr

Name of the vector to use. Defaults to ‘nonlinear’.

kindstr or None

Kind of variable (‘input’, ‘output’, or ‘residual’). If None, returned value will be either an input or output.

flatbool

If True, return the flattened version of the value.

from_srcbool

If True, retrieve value of an input variable from its connected source.

Returns:
object

The value of the requested output/input variable.

get_var_dup_info(name, io)

Return information about how the given variable is duplicated across MPI processes.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
tuple

A tuple of the form (is_duplicated, num_zeros, is_distributed).

get_var_sizes(name, io)

Return the sizes of the given variable on all procs.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
ndarray

Array of sizes of the variable on all procs.

initialize()

Perform any one-time initialization run at instantiation.

is_explicit()

Return True if this is an explicit component.

Returns:
bool

True if this is an explicit component.

property linear_solver

Get the linear solver for this system.

list_inputs(val=True, prom_name=True, units=False, shape=False, global_shape=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of input names and other optional information to a specified stream.

Parameters:
valbool, 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 True.

unitsbool, optional

When True, display/return units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global shape of the value. Default is False.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all input variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all ranks. Default is False, which will display output only from rank 0.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the input value is an array, print its smallest value.

print_maxbool

When true, if the input value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of input names and other optional information about those inputs.

list_outputs(explicit=True, implicit=True, val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of output names and other optional information to a specified stream.

Parameters:
explicitbool, optional

Include outputs from explicit components. Default is True.

implicitbool, optional

Include outputs from implicit components. Default is True.

valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

list_vars(val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of inputs and outputs sorted by component in execution order.

Parameters:
valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. Default is False.

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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

load_case(case)

Pull all input and output variables from a Case into this System.

Override this method if the System requires special handling when loading a case.

Parameters:
caseCase or dict

A Case from a CaseReader, or a dictionary with key ‘inputs’ mapped to the output of problem.model.list_inputs and key ‘outputs’ mapped to the output of prob.model.list_outputs. Both list_inputs and list_outputs should be called with prom_name=True and return_format=’dict’.

load_model_options()

Load the relevant model options from Problem._metadata[‘model_options’].

This method examines each path filter and corresponding options in self._problem_meta[‘model_options’]. If this System’s pathname matches the given path filter, it will assume the value for each given option which it possesses.

local_range_iter(io)

Yield names and local ranges of all local variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

Yields:
tuple

A tuple of the form (abs_name, start, end).

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 nonlinear_solver

Get the nonlinear solver for this system.

record_iteration()

Record an iteration of the current System.

run_apply_linear(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:
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()

Compute residuals.

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

run_linearize(sub_do_ln=True)

Compute jacobian / factorization.

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

Parameters:
sub_do_lnbool

Flag indicating if the children should call linearize on their linear solvers.

run_solve_linear(mode)

Apply inverse jac product.

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

Parameters:
modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear()

Compute outputs.

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

set_check_partial_options(wrt, method='fd', form=None, step=None, step_calc=None, minimum_step=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

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value..

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

directionalbool

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

set_constraint_options(name, ref=UNDEFINED, ref0=UNDEFINED, equals=UNDEFINED, lower=UNDEFINED, upper=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for constraints in the model.

Can be used to set options that were set using add_constraint.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

equalsfloat or ndarray, optional

Equality constraint value for the variable.

lowerfloat or ndarray, optional

Lower boundary for the variable.

upperfloat or ndarray, optional

Upper boundary for the variable.

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.

aliasstr, optional

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

set_design_var_options(name, lower=UNDEFINED, upper=UNDEFINED, scaler=UNDEFINED, adder=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED)

Set options for design vars in the model.

Can be used to set the options outside of setting them when calling add_design_var

Parameters:
namestr

Name of the variable in this system’s namespace.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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.

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.

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.

set_objective_options(name, ref=UNDEFINED, ref0=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for objectives in the model.

Can be used to set options after they have been set by add_objective.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

aliasstr

Alias for this response. Used to disambiguate variable names when adding multiple objectives on different indices or slices of a single variable. Deprecated.

set_output_solver_options(name, lower=UNDEFINED, upper=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED, res_ref=UNDEFINED)

Set solver output options.

Allows the user to set output solver options after the output has been defined and metadata set using the add_ouput method.

Parameters:
namestr

Name of the variable in this system’s namespace.

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.

set_solver_print(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(name, val, units=None, indices=None)

Set an input or output variable.

Parameters:
namestr

Promoted or relative variable name in the system’s namespace.

valobject

Value to assign to this variable.

unitsstr, optional

Units of the value.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to set.

setup()

Declare inputs and outputs.

Available attributes:

name pathname comm options

setup_partials()[source]

Declare partials.

This is meant to be overridden by component classes. All partials should be declared here since this is called after all size/shape information is known for all variables.

system_iter(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.

Yields:
type or None
property under_approx

Return True if under complex step or finite difference.

Returns:
bool

True if under CS or FD.

use_fixed_coloring(coloring=<object object>, 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: SellarDis2

Component containing Discipline 2 – derivatives version.

__init__(units=None, scaling=None)

Store some bound methods so we can detect runtime overrides.

abs_meta_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names and their metadata for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str, dict
abs_name_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str
add_constraint(name, lower=None, upper=None, equals=None, ref=None, ref0=None, adder=None, scaler=None, units=None, indices=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a constraint variable to this system.

Parameters:
namestr

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 alternative to using ref and ref0.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

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. The arguments (lower, upper, equals) can not be strings or variable names.

add_design_var(name, lower=None, upper=None, ref=None, ref0=None, indices=None, adder=None, scaler=None, units=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False)

Add a design variable to this system.

Parameters:
namestr

Promoted name of the design variable in the system.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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 an input 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.

unitsstr, optional

Units to convert to before applying scaling.

parallel_deriv_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

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(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(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(name, val=1.0, shape=None, units=None, desc='', tags=None, shape_by_conn=False, copy_shape=None, compute_shape=None, require_connection=False, distributed=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 val is not an array. Default is None.

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.

shape_by_connbool

If True, shape this input to match its connected output.

copy_shapestr or None

If a str, that str is the name of a variable. Shape this input to match that of the named variable.

compute_shapefunction

A function taking a dict arg containing names and shapes of this component’s outputs and returning the shape of this input.

require_connectionbool

If True and this input is not a design variable, it must be connected to an output.

distributedbool

If True, this variable is a distributed variable, so it can have different sizes/values across MPI processes.

Returns:
dict

Metadata for added variable.

add_objective(name, ref=None, ref0=None, index=None, units=None, adder=None, scaler=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a response variable to this system.

Parameters:
namestr

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple objectives on different indices or slices of a single variable.

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(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, shape_by_conn=False, copy_shape=None, compute_shape=None, distributed=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.

shape_by_connbool

If True, shape this output to match its connected input(s).

copy_shapestr or None

If a str, that str is the name of a variable. Shape this output to match that of the named variable.

compute_shapefunction or None

If a function, that function is called to determine the shape of this output.

distributedbool

If True, this variable is a distributed variable, so it can have different sizes/values across MPI processes.

Returns:
dict

Metadata for added variable.

add_recorder(recorder, recurse=False)

Add a recorder to the system.

Parameters:
recorder<CaseRecorder>

A recorder instance.

recursebool

Flag indicating if the recorder should be added to all the subsystems.

add_response(name, type_, lower=None, upper=None, equals=None, ref=None, ref0=None, indices=None, index=None, units=None, adder=None, scaler=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=None, alias=None)

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:
namestr

Promoted name of the response variable in the system.

type_str

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr or None

Alias for this response. Necessary when adding multiple responses on different indices of the same variable.

best_partial_deriv_direction()

Return the best direction for partial deriv calculations based on input and output sizes.

Returns:
str

The best direction for derivative calculations, ‘fwd’ or ‘rev’.

check_config(logger)

Perform optional error checks.

Parameters:
loggerobject

The object that manages logging output.

check_subjac_sparsity()

Check the declared sparsity of the sub-jacobians vs. the computed sparsity.

property checking

Return True if check_partials or check_totals is executing.

Returns:
bool

True if we’re running within check_partials or check_totals.

cleanup()

Clean up resources prior to exit.

property comm

Return the MPI communicator object for the system.

Returns:
MPI.Comm

MPI communicator object.

comm_info_iter()

Yield comm size for this system and all subsystems.

Yields:
tuple

A tuple of the form (abs_name, comm_size).

compute(inputs, outputs)

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

compute_jacvec_product(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(inputs, J)[source]

Jacobian for Sellar discipline 2.

compute_sparsity()

Compute the sparsity of the partial jacobian.

Returns:
coo_matrix

The sparsity matrix.

dict

Metadata about the sparsity computation.

convert2units(name, val, units)

Convert the given value to the specified units.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_from_units(name, val, units)

Convert the given value from the specified units to those of the named variable.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_units(name, val, units_from, units_to)

Wrap the utility convert_units and give a good error message.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

units_fromstr

The units to convert from.

units_tostr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

declare_coloring(wrt=('*',), method='fd', form=None, step=None, per_instance=True, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, min_improve_pct=5.0, 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.

min_improve_pctfloat

If coloring does not improve (decrease) the number of solves more than the given percentage, coloring will not be used.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

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

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

Declare information about this component’s subjacobians.

Parameters:
ofstr or iter of str

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

wrtstr or iter 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.

formstr

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

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value.

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

Returns:
dict

Metadata dict for the specified partial(s).

dist_size_iter(io, top_comm)

Yield names and distributed ranges of all local and remote variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

top_commMPI.Comm or None

The top-level MPI communicator.

Yields:
tuple

A tuple of the form ((abs_name, rank), start, end).

get_coloring_fname(mode)

Return the full pathname to a coloring file.

Parameters:
modestr

The type of coloring file desired. Must be either ‘input’ or ‘output’.

Returns:
pathlib.Path

Full pathname of the coloring file.

get_constraints(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each constraint.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The constraints defined in the current system.

get_design_vars(recurse=True, get_sizes=True, use_prom_ivc=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 of a group 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.

use_prom_ivcbool

Use promoted names for inputs, else convert to absolute source names.

Returns:
dict

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

get_io_metadata(iotypes=('input', 'output'), metadata_keys=None, includes=None, excludes=None, is_indep_var=None, is_design_var=None, tags=None, get_remote=False, rank=None, return_rel_names=True)

Retrieve metadata for a filtered list of variables.

Parameters:
iotypesstr or iter of str

Will contain either ‘input’, ‘output’, or both. Defaults to both.

metadata_keysiter of str or None

Names of metadata entries to be retrieved or None, meaning retrieve all available ‘allprocs’ metadata. If ‘val’ or ‘src_indices’ are required, their keys must be provided explicitly since they are not found in the ‘allprocs’ metadata and must be retrieved from local metadata located in each process.

includesstr, iter of str or None

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all variables.

excludesstr, iter of str or None

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

tagsstr or iter 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.

get_remotebool

If True, retrieve variables from other MPI processes as well.

rankint or None

If None, and get_remote is True, retrieve values from all MPI process to all other MPI processes. Otherwise, if get_remote is True, retrieve values from all MPI processes only to the specified rank.

return_rel_namesbool

If True, the names returned will be relative to the scope of this System. Otherwise they will be absolute names.

Returns:
dict

A dict of metadata keyed on name, where name is either absolute or relative based on the value of the return_rel_names arg, and metadata is a dict containing entries based on the value of the metadata_keys arg. Every metadata dict will always contain two entries, ‘prom_name’ and ‘discrete’, to indicate a given variable’s promoted name and whether or not it is discrete.

get_linear_vectors()

Return the linear inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals): tuple of <Vector> instances

Yields the linear inputs, outputs, and residuals vectors.

get_nonlinear_vectors()

Return the inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals)

Yields the inputs, outputs, and residuals nonlinear vectors.

get_objectives(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each objective.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The objectives defined in the current system.

get_outputs_dir(*subdirs, mkdir=True)

Get the path under which all output files of this system are to be placed.

Parameters:
*subdirsstr

Subdirectories nested under the relevant problem output directory. To create {prob_output_dir}/a/b one would pass system.get_outputs_dir(‘a’, ‘b’).

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path of the outputs directory for the problem.

get_promotions(inprom=None, outprom=None)

Return all promotions for the given promoted variable(s).

In other words, how and where did promotions occur to convert absolute variable names into the given promoted name(s) at the current System level.

Parameters:
inpromstr or None

The promoted input variable name.

outpromstr or None

The promoted output variable name.

Returns:
dict

Dictionary keyed on system pathname containing input and/or output promotion lists for each System where promotions occurred to produce the given promoted variable(s).

get_reports_dir()

Get the path to the directory where the report files should go.

If it doesn’t exist, it will be created.

Returns:
str

The path to the directory where reports should be written.

get_responses(recurse=True, get_sizes=True, use_prom_ivc=False)

Get the response variable settings from this system.

Retrieve all response variable settings from the system as a dict, keyed by either absolute variable name, promoted name, or alias name, depending on the value of use_prom_ivc and whether the original key was a promoted output, promoted input, or an alias.

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.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

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

get_self_statics()

Override this in derived classes if compute_primal references static values.

Do NOT include self._discrete_inputs in the returned tuple. Include things like self.options[‘opt_name’], etc., that are used in compute_primal but are assumed to be constant during derivative computation.

Return value MUST be a tuple. Don’t forget the trailing comma if tuple has only one item. Return value MUST be hashable.

The order of these values doesn’t matter. They are only checked (by computing their hash) to see if they have changed since the last time compute_primal was jitted, and if so, compute_primal will be re-jitted.

Returns:
tuple

Tuple containing all static values required by compute_primal.

get_source(name)

Return the source variable connected to the given named variable.

The name can be a promoted name or an absolute name. If the given variable is an input, the absolute name of the connected source will be returned. If the given variable itself is a source, its own absolute name will be returned.

Parameters:
namestr

Absolute or promoted name of the variable.

Returns:
str

The absolute name of the source variable.

get_val(name, units=None, indices=None, get_remote=False, rank=None, vec_name='nonlinear', kind=None, flat=False, from_src=True)

Get an output/input/residual 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 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 or None

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. If False, only retrieve the value if it is on the current process, or only the part of the value that’s on the current process for a distributed variable. If None and the variable is remote or distributed, a RuntimeError will be raised.

rankint or None

If not None, only gather the value to this rank.

vec_namestr

Name of the vector to use. Defaults to ‘nonlinear’.

kindstr or None

Kind of variable (‘input’, ‘output’, or ‘residual’). If None, returned value will be either an input or output.

flatbool

If True, return the flattened version of the value.

from_srcbool

If True, retrieve value of an input variable from its connected source.

Returns:
object

The value of the requested output/input variable.

get_var_dup_info(name, io)

Return information about how the given variable is duplicated across MPI processes.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
tuple

A tuple of the form (is_duplicated, num_zeros, is_distributed).

get_var_sizes(name, io)

Return the sizes of the given variable on all procs.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
ndarray

Array of sizes of the variable on all procs.

initialize()

Perform any one-time initialization run at instantiation.

is_explicit()

Return True if this is an explicit component.

Returns:
bool

True if this is an explicit component.

property linear_solver

Get the linear solver for this system.

list_inputs(val=True, prom_name=True, units=False, shape=False, global_shape=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of input names and other optional information to a specified stream.

Parameters:
valbool, 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 True.

unitsbool, optional

When True, display/return units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global shape of the value. Default is False.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all input variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all ranks. Default is False, which will display output only from rank 0.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the input value is an array, print its smallest value.

print_maxbool

When true, if the input value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of input names and other optional information about those inputs.

list_outputs(explicit=True, implicit=True, val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of output names and other optional information to a specified stream.

Parameters:
explicitbool, optional

Include outputs from explicit components. Default is True.

implicitbool, optional

Include outputs from implicit components. Default is True.

valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

list_vars(val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of inputs and outputs sorted by component in execution order.

Parameters:
valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. Default is False.

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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

load_case(case)

Pull all input and output variables from a Case into this System.

Override this method if the System requires special handling when loading a case.

Parameters:
caseCase or dict

A Case from a CaseReader, or a dictionary with key ‘inputs’ mapped to the output of problem.model.list_inputs and key ‘outputs’ mapped to the output of prob.model.list_outputs. Both list_inputs and list_outputs should be called with prom_name=True and return_format=’dict’.

load_model_options()

Load the relevant model options from Problem._metadata[‘model_options’].

This method examines each path filter and corresponding options in self._problem_meta[‘model_options’]. If this System’s pathname matches the given path filter, it will assume the value for each given option which it possesses.

local_range_iter(io)

Yield names and local ranges of all local variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

Yields:
tuple

A tuple of the form (abs_name, start, end).

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 nonlinear_solver

Get the nonlinear solver for this system.

record_iteration()

Record an iteration of the current System.

run_apply_linear(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:
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()

Compute residuals.

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

run_linearize(sub_do_ln=True)

Compute jacobian / factorization.

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

Parameters:
sub_do_lnbool

Flag indicating if the children should call linearize on their linear solvers.

run_solve_linear(mode)

Apply inverse jac product.

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

Parameters:
modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear()

Compute outputs.

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

set_check_partial_options(wrt, method='fd', form=None, step=None, step_calc=None, minimum_step=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

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value..

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

directionalbool

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

set_constraint_options(name, ref=UNDEFINED, ref0=UNDEFINED, equals=UNDEFINED, lower=UNDEFINED, upper=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for constraints in the model.

Can be used to set options that were set using add_constraint.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

equalsfloat or ndarray, optional

Equality constraint value for the variable.

lowerfloat or ndarray, optional

Lower boundary for the variable.

upperfloat or ndarray, optional

Upper boundary for the variable.

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.

aliasstr, optional

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

set_design_var_options(name, lower=UNDEFINED, upper=UNDEFINED, scaler=UNDEFINED, adder=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED)

Set options for design vars in the model.

Can be used to set the options outside of setting them when calling add_design_var

Parameters:
namestr

Name of the variable in this system’s namespace.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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.

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.

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.

set_objective_options(name, ref=UNDEFINED, ref0=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for objectives in the model.

Can be used to set options after they have been set by add_objective.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

aliasstr

Alias for this response. Used to disambiguate variable names when adding multiple objectives on different indices or slices of a single variable. Deprecated.

set_output_solver_options(name, lower=UNDEFINED, upper=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED, res_ref=UNDEFINED)

Set solver output options.

Allows the user to set output solver options after the output has been defined and metadata set using the add_ouput method.

Parameters:
namestr

Name of the variable in this system’s namespace.

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.

set_solver_print(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(name, val, units=None, indices=None)

Set an input or output variable.

Parameters:
namestr

Promoted or relative variable name in the system’s namespace.

valobject

Value to assign to this variable.

unitsstr, optional

Units of the value.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to set.

setup()

Declare inputs and outputs.

Available attributes:

name pathname comm options

setup_partials()[source]

Declare partials.

This is meant to be overridden by component classes. All partials should be declared here since this is called after all size/shape information is known for all variables.

system_iter(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.

Yields:
type or None
property under_approx

Return True if under complex step or finite difference.

Returns:
bool

True if under CS or FD.

use_fixed_coloring(coloring=<object object>, 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: ImplicitComponent

Component containing Discipline 1 – no derivatives version.

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

Store some bound methods so we can detect runtime overrides.

abs_meta_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names and their metadata for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str, dict
abs_name_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str
add_constraint(name, lower=None, upper=None, equals=None, ref=None, ref0=None, adder=None, scaler=None, units=None, indices=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a constraint variable to this system.

Parameters:
namestr

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 alternative to using ref and ref0.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

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. The arguments (lower, upper, equals) can not be strings or variable names.

add_design_var(name, lower=None, upper=None, ref=None, ref0=None, indices=None, adder=None, scaler=None, units=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False)

Add a design variable to this system.

Parameters:
namestr

Promoted name of the design variable in the system.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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 an input 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.

unitsstr, optional

Units to convert to before applying scaling.

parallel_deriv_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

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(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(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(name, val=1.0, shape=None, units=None, desc='', tags=None, shape_by_conn=False, copy_shape=None, compute_shape=None, require_connection=False, distributed=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 val is not an array. Default is None.

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.

shape_by_connbool

If True, shape this input to match its connected output.

copy_shapestr or None

If a str, that str is the name of a variable. Shape this input to match that of the named variable.

compute_shapefunction

A function taking a dict arg containing names and shapes of this component’s outputs and returning the shape of this input.

require_connectionbool

If True and this input is not a design variable, it must be connected to an output.

distributedbool

If True, this variable is a distributed variable, so it can have different sizes/values across MPI processes.

Returns:
dict

Metadata for added variable.

add_objective(name, ref=None, ref0=None, index=None, units=None, adder=None, scaler=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a response variable to this system.

Parameters:
namestr

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple objectives on different indices or slices of a single variable.

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(name, val=1.0, **kwargs)

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.

**kwargsdict

Keyword args to store. The value corresponding to each key is a dict containing the metadata for the input name that matches that key.

Returns:
dict

Metadata for added variable.

add_recorder(recorder, recurse=False)

Add a recorder to the system.

Parameters:
recorder<CaseRecorder>

A recorder instance.

recursebool

Flag indicating if the recorder should be added to all the subsystems.

add_residual(name, shape=(1,), units=None, desc='', ref=None)

Add a residual variable to the component.

Note that the total size of the residual vector must match the total size of the outputs vector for this component.

Parameters:
namestr

Name of the residual in this component’s namespace.

shapeint or tuple

Shape of this residual.

unitsstr or None

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

descstr

Description of the residual.

reffloat or ndarray or None

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

Returns:
dict

Metadata for the added residual.

add_response(name, type_, lower=None, upper=None, equals=None, ref=None, ref0=None, indices=None, index=None, units=None, adder=None, scaler=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=None, alias=None)

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:
namestr

Promoted name of the response variable in the system.

type_str

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr or None

Alias for this response. Necessary when adding multiple responses on different indices of the same variable.

apply_linear(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(inputs, outputs, resids)[source]

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

best_partial_deriv_direction()

Return the best direction for partial deriv calculations based on input and output sizes.

Returns:
str

The best direction for derivative calculations, ‘fwd’ or ‘rev’.

check_config(logger)

Perform optional error checks.

Parameters:
loggerobject

The object that manages logging output.

check_subjac_sparsity()

Check the declared sparsity of the sub-jacobians vs. the computed sparsity.

property checking

Return True if check_partials or check_totals is executing.

Returns:
bool

True if we’re running within check_partials or check_totals.

cleanup()

Clean up resources prior to exit.

property comm

Return the MPI communicator object for the system.

Returns:
MPI.Comm

MPI communicator object.

comm_info_iter()

Yield comm size for this system and all subsystems.

Yields:
tuple

A tuple of the form (abs_name, comm_size).

compute_sparsity()

Compute the sparsity of the partial jacobian.

Returns:
coo_matrix

The sparsity matrix.

dict

Metadata about the sparsity computation.

convert2units(name, val, units)

Convert the given value to the specified units.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_from_units(name, val, units)

Convert the given value from the specified units to those of the named variable.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_units(name, val, units_from, units_to)

Wrap the utility convert_units and give a good error message.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

units_fromstr

The units to convert from.

units_tostr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

declare_coloring(wrt=('*',), method='fd', form=None, step=None, per_instance=True, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, min_improve_pct=5.0, 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.

min_improve_pctfloat

If coloring does not improve (decrease) the number of solves more than the given percentage, coloring will not be used.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

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

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

Declare information about this component’s subjacobians.

Parameters:
ofstr or iter of str

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

wrtstr or iter 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.

formstr

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

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value.

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

Returns:
dict

Metadata dict for the specified partial(s).

dist_size_iter(io, top_comm)

Yield names and distributed ranges of all local and remote variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

top_commMPI.Comm or None

The top-level MPI communicator.

Yields:
tuple

A tuple of the form ((abs_name, rank), start, end).

get_coloring_fname(mode)

Return the full pathname to a coloring file.

Parameters:
modestr

The type of coloring file desired. Must be either ‘input’ or ‘output’.

Returns:
pathlib.Path

Full pathname of the coloring file.

get_constraints(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each constraint.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The constraints defined in the current system.

get_design_vars(recurse=True, get_sizes=True, use_prom_ivc=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 of a group 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.

use_prom_ivcbool

Use promoted names for inputs, else convert to absolute source names.

Returns:
dict

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

get_io_metadata(iotypes=('input', 'output'), metadata_keys=None, includes=None, excludes=None, is_indep_var=None, is_design_var=None, tags=None, get_remote=False, rank=None, return_rel_names=True)

Retrieve metadata for a filtered list of variables.

Parameters:
iotypesstr or iter of str

Will contain either ‘input’, ‘output’, or both. Defaults to both.

metadata_keysiter of str or None

Names of metadata entries to be retrieved or None, meaning retrieve all available ‘allprocs’ metadata. If ‘val’ or ‘src_indices’ are required, their keys must be provided explicitly since they are not found in the ‘allprocs’ metadata and must be retrieved from local metadata located in each process.

includesstr, iter of str or None

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all variables.

excludesstr, iter of str or None

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

tagsstr or iter 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.

get_remotebool

If True, retrieve variables from other MPI processes as well.

rankint or None

If None, and get_remote is True, retrieve values from all MPI process to all other MPI processes. Otherwise, if get_remote is True, retrieve values from all MPI processes only to the specified rank.

return_rel_namesbool

If True, the names returned will be relative to the scope of this System. Otherwise they will be absolute names.

Returns:
dict

A dict of metadata keyed on name, where name is either absolute or relative based on the value of the return_rel_names arg, and metadata is a dict containing entries based on the value of the metadata_keys arg. Every metadata dict will always contain two entries, ‘prom_name’ and ‘discrete’, to indicate a given variable’s promoted name and whether or not it is discrete.

get_linear_vectors()

Return the linear inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals): tuple of <Vector> instances

Yields the linear inputs, outputs, and residuals vectors.

get_nonlinear_vectors()

Return the inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals)

Yields the inputs, outputs, and residuals nonlinear vectors.

get_objectives(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each objective.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The objectives defined in the current system.

get_outputs_dir(*subdirs, mkdir=True)

Get the path under which all output files of this system are to be placed.

Parameters:
*subdirsstr

Subdirectories nested under the relevant problem output directory. To create {prob_output_dir}/a/b one would pass system.get_outputs_dir(‘a’, ‘b’).

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path of the outputs directory for the problem.

get_promotions(inprom=None, outprom=None)

Return all promotions for the given promoted variable(s).

In other words, how and where did promotions occur to convert absolute variable names into the given promoted name(s) at the current System level.

Parameters:
inpromstr or None

The promoted input variable name.

outpromstr or None

The promoted output variable name.

Returns:
dict

Dictionary keyed on system pathname containing input and/or output promotion lists for each System where promotions occurred to produce the given promoted variable(s).

get_reports_dir()

Get the path to the directory where the report files should go.

If it doesn’t exist, it will be created.

Returns:
str

The path to the directory where reports should be written.

get_responses(recurse=True, get_sizes=True, use_prom_ivc=False)

Get the response variable settings from this system.

Retrieve all response variable settings from the system as a dict, keyed by either absolute variable name, promoted name, or alias name, depending on the value of use_prom_ivc and whether the original key was a promoted output, promoted input, or an alias.

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.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

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

get_self_statics()

Override this in derived classes if compute_primal references static values.

Do NOT include self._discrete_inputs in the returned tuple. Include things like self.options[‘opt_name’], etc., that are used in compute_primal but are assumed to be constant during derivative computation.

Return value MUST be a tuple. Don’t forget the trailing comma if tuple has only one item. Return value MUST be hashable.

The order of these values doesn’t matter. They are only checked (by computing their hash) to see if they have changed since the last time compute_primal was jitted, and if so, compute_primal will be re-jitted.

Returns:
tuple

Tuple containing all static values required by compute_primal.

get_source(name)

Return the source variable connected to the given named variable.

The name can be a promoted name or an absolute name. If the given variable is an input, the absolute name of the connected source will be returned. If the given variable itself is a source, its own absolute name will be returned.

Parameters:
namestr

Absolute or promoted name of the variable.

Returns:
str

The absolute name of the source variable.

get_val(name, units=None, indices=None, get_remote=False, rank=None, vec_name='nonlinear', kind=None, flat=False, from_src=True)

Get an output/input/residual 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 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 or None

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. If False, only retrieve the value if it is on the current process, or only the part of the value that’s on the current process for a distributed variable. If None and the variable is remote or distributed, a RuntimeError will be raised.

rankint or None

If not None, only gather the value to this rank.

vec_namestr

Name of the vector to use. Defaults to ‘nonlinear’.

kindstr or None

Kind of variable (‘input’, ‘output’, or ‘residual’). If None, returned value will be either an input or output.

flatbool

If True, return the flattened version of the value.

from_srcbool

If True, retrieve value of an input variable from its connected source.

Returns:
object

The value of the requested output/input variable.

get_var_dup_info(name, io)

Return information about how the given variable is duplicated across MPI processes.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
tuple

A tuple of the form (is_duplicated, num_zeros, is_distributed).

get_var_sizes(name, io)

Return the sizes of the given variable on all procs.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
ndarray

Array of sizes of the variable on all procs.

guess_nonlinear(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()

Perform any one-time initialization run at instantiation.

is_explicit()

Return True if this is an explicit component.

Returns:
bool

True if this is an explicit component.

property linear_solver

Get the linear solver for this system.

linearize(inputs, outputs, J)[source]

Jacobian for Sellar discipline 1.

list_inputs(val=True, prom_name=True, units=False, shape=False, global_shape=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of input names and other optional information to a specified stream.

Parameters:
valbool, 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 True.

unitsbool, optional

When True, display/return units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global shape of the value. Default is False.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all input variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all ranks. Default is False, which will display output only from rank 0.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the input value is an array, print its smallest value.

print_maxbool

When true, if the input value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of input names and other optional information about those inputs.

list_outputs(explicit=True, implicit=True, val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of output names and other optional information to a specified stream.

Parameters:
explicitbool, optional

Include outputs from explicit components. Default is True.

implicitbool, optional

Include outputs from implicit components. Default is True.

valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

list_vars(val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of inputs and outputs sorted by component in execution order.

Parameters:
valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. Default is False.

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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

load_case(case)

Pull all input and output variables from a Case into this System.

Override this method if the System requires special handling when loading a case.

Parameters:
caseCase or dict

A Case from a CaseReader, or a dictionary with key ‘inputs’ mapped to the output of problem.model.list_inputs and key ‘outputs’ mapped to the output of prob.model.list_outputs. Both list_inputs and list_outputs should be called with prom_name=True and return_format=’dict’.

load_model_options()

Load the relevant model options from Problem._metadata[‘model_options’].

This method examines each path filter and corresponding options in self._problem_meta[‘model_options’]. If this System’s pathname matches the given path filter, it will assume the value for each given option which it possesses.

local_range_iter(io)

Yield names and local ranges of all local variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

Yields:
tuple

A tuple of the form (abs_name, start, end).

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 nonlinear_solver

Get the nonlinear solver for this system.

record_iteration()

Record an iteration of the current System.

run_apply_linear(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:
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()

Compute residuals.

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

run_linearize(sub_do_ln=True)

Compute jacobian / factorization.

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

Parameters:
sub_do_lnbool

Flag indicating if the children should call linearize on their linear solvers.

run_solve_linear(mode)

Apply inverse jac product.

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

Parameters:
modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear()

Compute outputs.

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

set_check_partial_options(wrt, method='fd', form=None, step=None, step_calc=None, minimum_step=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

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value..

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

directionalbool

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

set_constraint_options(name, ref=UNDEFINED, ref0=UNDEFINED, equals=UNDEFINED, lower=UNDEFINED, upper=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for constraints in the model.

Can be used to set options that were set using add_constraint.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

equalsfloat or ndarray, optional

Equality constraint value for the variable.

lowerfloat or ndarray, optional

Lower boundary for the variable.

upperfloat or ndarray, optional

Upper boundary for the variable.

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.

aliasstr, optional

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

set_design_var_options(name, lower=UNDEFINED, upper=UNDEFINED, scaler=UNDEFINED, adder=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED)

Set options for design vars in the model.

Can be used to set the options outside of setting them when calling add_design_var

Parameters:
namestr

Name of the variable in this system’s namespace.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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.

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.

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.

set_objective_options(name, ref=UNDEFINED, ref0=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for objectives in the model.

Can be used to set options after they have been set by add_objective.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

aliasstr

Alias for this response. Used to disambiguate variable names when adding multiple objectives on different indices or slices of a single variable. Deprecated.

set_output_solver_options(name, lower=UNDEFINED, upper=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED, res_ref=UNDEFINED)

Set solver output options.

Allows the user to set output solver options after the output has been defined and metadata set using the add_ouput method.

Parameters:
namestr

Name of the variable in this system’s namespace.

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.

set_solver_print(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(name, val, units=None, indices=None)

Set an input or output variable.

Parameters:
namestr

Promoted or relative variable name in the system’s namespace.

valobject

Value to assign to this variable.

unitsstr, optional

Units of the value.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to set.

setup()[source]

Declare inputs and outputs.

Available attributes:

name pathname comm options

setup_partials()[source]

Declare partials.

This is meant to be overridden by component classes. All partials should be declared here since this is called after all size/shape information is known for all variables.

setup_residuals()

User hook for adding named residuals to this component.

solve_linear(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(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(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.

Yields:
type or None
property under_approx

Return True if under complex step or finite difference.

Returns:
bool

True if under CS or FD.

use_fixed_coloring(coloring=<object object>, 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: ImplicitComponent

Component containing Discipline 2 – implicit version.

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

Store some bound methods so we can detect runtime overrides.

abs_meta_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names and their metadata for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str, dict
abs_name_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str
add_constraint(name, lower=None, upper=None, equals=None, ref=None, ref0=None, adder=None, scaler=None, units=None, indices=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a constraint variable to this system.

Parameters:
namestr

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 alternative to using ref and ref0.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

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. The arguments (lower, upper, equals) can not be strings or variable names.

add_design_var(name, lower=None, upper=None, ref=None, ref0=None, indices=None, adder=None, scaler=None, units=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False)

Add a design variable to this system.

Parameters:
namestr

Promoted name of the design variable in the system.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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 an input 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.

unitsstr, optional

Units to convert to before applying scaling.

parallel_deriv_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

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(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(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(name, val=1.0, shape=None, units=None, desc='', tags=None, shape_by_conn=False, copy_shape=None, compute_shape=None, require_connection=False, distributed=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 val is not an array. Default is None.

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.

shape_by_connbool

If True, shape this input to match its connected output.

copy_shapestr or None

If a str, that str is the name of a variable. Shape this input to match that of the named variable.

compute_shapefunction

A function taking a dict arg containing names and shapes of this component’s outputs and returning the shape of this input.

require_connectionbool

If True and this input is not a design variable, it must be connected to an output.

distributedbool

If True, this variable is a distributed variable, so it can have different sizes/values across MPI processes.

Returns:
dict

Metadata for added variable.

add_objective(name, ref=None, ref0=None, index=None, units=None, adder=None, scaler=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a response variable to this system.

Parameters:
namestr

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple objectives on different indices or slices of a single variable.

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(name, val=1.0, **kwargs)

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.

**kwargsdict

Keyword args to store. The value corresponding to each key is a dict containing the metadata for the input name that matches that key.

Returns:
dict

Metadata for added variable.

add_recorder(recorder, recurse=False)

Add a recorder to the system.

Parameters:
recorder<CaseRecorder>

A recorder instance.

recursebool

Flag indicating if the recorder should be added to all the subsystems.

add_residual(name, shape=(1,), units=None, desc='', ref=None)

Add a residual variable to the component.

Note that the total size of the residual vector must match the total size of the outputs vector for this component.

Parameters:
namestr

Name of the residual in this component’s namespace.

shapeint or tuple

Shape of this residual.

unitsstr or None

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

descstr

Description of the residual.

reffloat or ndarray or None

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

Returns:
dict

Metadata for the added residual.

add_response(name, type_, lower=None, upper=None, equals=None, ref=None, ref0=None, indices=None, index=None, units=None, adder=None, scaler=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=None, alias=None)

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:
namestr

Promoted name of the response variable in the system.

type_str

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr or None

Alias for this response. Necessary when adding multiple responses on different indices of the same variable.

apply_linear(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(inputs, outputs, resids)[source]

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

best_partial_deriv_direction()

Return the best direction for partial deriv calculations based on input and output sizes.

Returns:
str

The best direction for derivative calculations, ‘fwd’ or ‘rev’.

check_config(logger)

Perform optional error checks.

Parameters:
loggerobject

The object that manages logging output.

check_subjac_sparsity()

Check the declared sparsity of the sub-jacobians vs. the computed sparsity.

property checking

Return True if check_partials or check_totals is executing.

Returns:
bool

True if we’re running within check_partials or check_totals.

cleanup()

Clean up resources prior to exit.

property comm

Return the MPI communicator object for the system.

Returns:
MPI.Comm

MPI communicator object.

comm_info_iter()

Yield comm size for this system and all subsystems.

Yields:
tuple

A tuple of the form (abs_name, comm_size).

compute_sparsity()

Compute the sparsity of the partial jacobian.

Returns:
coo_matrix

The sparsity matrix.

dict

Metadata about the sparsity computation.

convert2units(name, val, units)

Convert the given value to the specified units.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_from_units(name, val, units)

Convert the given value from the specified units to those of the named variable.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_units(name, val, units_from, units_to)

Wrap the utility convert_units and give a good error message.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

units_fromstr

The units to convert from.

units_tostr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

declare_coloring(wrt=('*',), method='fd', form=None, step=None, per_instance=True, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, min_improve_pct=5.0, 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.

min_improve_pctfloat

If coloring does not improve (decrease) the number of solves more than the given percentage, coloring will not be used.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

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

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

Declare information about this component’s subjacobians.

Parameters:
ofstr or iter of str

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

wrtstr or iter 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.

formstr

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

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value.

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

Returns:
dict

Metadata dict for the specified partial(s).

dist_size_iter(io, top_comm)

Yield names and distributed ranges of all local and remote variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

top_commMPI.Comm or None

The top-level MPI communicator.

Yields:
tuple

A tuple of the form ((abs_name, rank), start, end).

get_coloring_fname(mode)

Return the full pathname to a coloring file.

Parameters:
modestr

The type of coloring file desired. Must be either ‘input’ or ‘output’.

Returns:
pathlib.Path

Full pathname of the coloring file.

get_constraints(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each constraint.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The constraints defined in the current system.

get_design_vars(recurse=True, get_sizes=True, use_prom_ivc=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 of a group 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.

use_prom_ivcbool

Use promoted names for inputs, else convert to absolute source names.

Returns:
dict

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

get_io_metadata(iotypes=('input', 'output'), metadata_keys=None, includes=None, excludes=None, is_indep_var=None, is_design_var=None, tags=None, get_remote=False, rank=None, return_rel_names=True)

Retrieve metadata for a filtered list of variables.

Parameters:
iotypesstr or iter of str

Will contain either ‘input’, ‘output’, or both. Defaults to both.

metadata_keysiter of str or None

Names of metadata entries to be retrieved or None, meaning retrieve all available ‘allprocs’ metadata. If ‘val’ or ‘src_indices’ are required, their keys must be provided explicitly since they are not found in the ‘allprocs’ metadata and must be retrieved from local metadata located in each process.

includesstr, iter of str or None

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all variables.

excludesstr, iter of str or None

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

tagsstr or iter 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.

get_remotebool

If True, retrieve variables from other MPI processes as well.

rankint or None

If None, and get_remote is True, retrieve values from all MPI process to all other MPI processes. Otherwise, if get_remote is True, retrieve values from all MPI processes only to the specified rank.

return_rel_namesbool

If True, the names returned will be relative to the scope of this System. Otherwise they will be absolute names.

Returns:
dict

A dict of metadata keyed on name, where name is either absolute or relative based on the value of the return_rel_names arg, and metadata is a dict containing entries based on the value of the metadata_keys arg. Every metadata dict will always contain two entries, ‘prom_name’ and ‘discrete’, to indicate a given variable’s promoted name and whether or not it is discrete.

get_linear_vectors()

Return the linear inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals): tuple of <Vector> instances

Yields the linear inputs, outputs, and residuals vectors.

get_nonlinear_vectors()

Return the inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals)

Yields the inputs, outputs, and residuals nonlinear vectors.

get_objectives(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each objective.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The objectives defined in the current system.

get_outputs_dir(*subdirs, mkdir=True)

Get the path under which all output files of this system are to be placed.

Parameters:
*subdirsstr

Subdirectories nested under the relevant problem output directory. To create {prob_output_dir}/a/b one would pass system.get_outputs_dir(‘a’, ‘b’).

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path of the outputs directory for the problem.

get_promotions(inprom=None, outprom=None)

Return all promotions for the given promoted variable(s).

In other words, how and where did promotions occur to convert absolute variable names into the given promoted name(s) at the current System level.

Parameters:
inpromstr or None

The promoted input variable name.

outpromstr or None

The promoted output variable name.

Returns:
dict

Dictionary keyed on system pathname containing input and/or output promotion lists for each System where promotions occurred to produce the given promoted variable(s).

get_reports_dir()

Get the path to the directory where the report files should go.

If it doesn’t exist, it will be created.

Returns:
str

The path to the directory where reports should be written.

get_responses(recurse=True, get_sizes=True, use_prom_ivc=False)

Get the response variable settings from this system.

Retrieve all response variable settings from the system as a dict, keyed by either absolute variable name, promoted name, or alias name, depending on the value of use_prom_ivc and whether the original key was a promoted output, promoted input, or an alias.

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.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

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

get_self_statics()

Override this in derived classes if compute_primal references static values.

Do NOT include self._discrete_inputs in the returned tuple. Include things like self.options[‘opt_name’], etc., that are used in compute_primal but are assumed to be constant during derivative computation.

Return value MUST be a tuple. Don’t forget the trailing comma if tuple has only one item. Return value MUST be hashable.

The order of these values doesn’t matter. They are only checked (by computing their hash) to see if they have changed since the last time compute_primal was jitted, and if so, compute_primal will be re-jitted.

Returns:
tuple

Tuple containing all static values required by compute_primal.

get_source(name)

Return the source variable connected to the given named variable.

The name can be a promoted name or an absolute name. If the given variable is an input, the absolute name of the connected source will be returned. If the given variable itself is a source, its own absolute name will be returned.

Parameters:
namestr

Absolute or promoted name of the variable.

Returns:
str

The absolute name of the source variable.

get_val(name, units=None, indices=None, get_remote=False, rank=None, vec_name='nonlinear', kind=None, flat=False, from_src=True)

Get an output/input/residual 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 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 or None

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. If False, only retrieve the value if it is on the current process, or only the part of the value that’s on the current process for a distributed variable. If None and the variable is remote or distributed, a RuntimeError will be raised.

rankint or None

If not None, only gather the value to this rank.

vec_namestr

Name of the vector to use. Defaults to ‘nonlinear’.

kindstr or None

Kind of variable (‘input’, ‘output’, or ‘residual’). If None, returned value will be either an input or output.

flatbool

If True, return the flattened version of the value.

from_srcbool

If True, retrieve value of an input variable from its connected source.

Returns:
object

The value of the requested output/input variable.

get_var_dup_info(name, io)

Return information about how the given variable is duplicated across MPI processes.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
tuple

A tuple of the form (is_duplicated, num_zeros, is_distributed).

get_var_sizes(name, io)

Return the sizes of the given variable on all procs.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
ndarray

Array of sizes of the variable on all procs.

guess_nonlinear(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()

Perform any one-time initialization run at instantiation.

is_explicit()

Return True if this is an explicit component.

Returns:
bool

True if this is an explicit component.

property linear_solver

Get the linear solver for this system.

linearize(inputs, outputs, J)[source]

Jacobian for Sellar discipline 2.

list_inputs(val=True, prom_name=True, units=False, shape=False, global_shape=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of input names and other optional information to a specified stream.

Parameters:
valbool, 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 True.

unitsbool, optional

When True, display/return units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global shape of the value. Default is False.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all input variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all ranks. Default is False, which will display output only from rank 0.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the input value is an array, print its smallest value.

print_maxbool

When true, if the input value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of input names and other optional information about those inputs.

list_outputs(explicit=True, implicit=True, val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of output names and other optional information to a specified stream.

Parameters:
explicitbool, optional

Include outputs from explicit components. Default is True.

implicitbool, optional

Include outputs from implicit components. Default is True.

valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

list_vars(val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of inputs and outputs sorted by component in execution order.

Parameters:
valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. Default is False.

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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

load_case(case)

Pull all input and output variables from a Case into this System.

Override this method if the System requires special handling when loading a case.

Parameters:
caseCase or dict

A Case from a CaseReader, or a dictionary with key ‘inputs’ mapped to the output of problem.model.list_inputs and key ‘outputs’ mapped to the output of prob.model.list_outputs. Both list_inputs and list_outputs should be called with prom_name=True and return_format=’dict’.

load_model_options()

Load the relevant model options from Problem._metadata[‘model_options’].

This method examines each path filter and corresponding options in self._problem_meta[‘model_options’]. If this System’s pathname matches the given path filter, it will assume the value for each given option which it possesses.

local_range_iter(io)

Yield names and local ranges of all local variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

Yields:
tuple

A tuple of the form (abs_name, start, end).

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 nonlinear_solver

Get the nonlinear solver for this system.

record_iteration()

Record an iteration of the current System.

run_apply_linear(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:
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()

Compute residuals.

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

run_linearize(sub_do_ln=True)

Compute jacobian / factorization.

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

Parameters:
sub_do_lnbool

Flag indicating if the children should call linearize on their linear solvers.

run_solve_linear(mode)

Apply inverse jac product.

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

Parameters:
modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear()

Compute outputs.

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

set_check_partial_options(wrt, method='fd', form=None, step=None, step_calc=None, minimum_step=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

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value..

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

directionalbool

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

set_constraint_options(name, ref=UNDEFINED, ref0=UNDEFINED, equals=UNDEFINED, lower=UNDEFINED, upper=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for constraints in the model.

Can be used to set options that were set using add_constraint.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

equalsfloat or ndarray, optional

Equality constraint value for the variable.

lowerfloat or ndarray, optional

Lower boundary for the variable.

upperfloat or ndarray, optional

Upper boundary for the variable.

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.

aliasstr, optional

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

set_design_var_options(name, lower=UNDEFINED, upper=UNDEFINED, scaler=UNDEFINED, adder=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED)

Set options for design vars in the model.

Can be used to set the options outside of setting them when calling add_design_var

Parameters:
namestr

Name of the variable in this system’s namespace.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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.

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.

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.

set_objective_options(name, ref=UNDEFINED, ref0=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for objectives in the model.

Can be used to set options after they have been set by add_objective.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

aliasstr

Alias for this response. Used to disambiguate variable names when adding multiple objectives on different indices or slices of a single variable. Deprecated.

set_output_solver_options(name, lower=UNDEFINED, upper=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED, res_ref=UNDEFINED)

Set solver output options.

Allows the user to set output solver options after the output has been defined and metadata set using the add_ouput method.

Parameters:
namestr

Name of the variable in this system’s namespace.

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.

set_solver_print(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(name, val, units=None, indices=None)

Set an input or output variable.

Parameters:
namestr

Promoted or relative variable name in the system’s namespace.

valobject

Value to assign to this variable.

unitsstr, optional

Units of the value.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to set.

setup()[source]

Declare inputs and outputs.

Available attributes:

name pathname comm options

setup_partials()[source]

Declare partials.

This is meant to be overridden by component classes. All partials should be declared here since this is called after all size/shape information is known for all variables.

setup_residuals()

User hook for adding named residuals to this component.

solve_linear(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(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(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.

Yields:
type or None
property under_approx

Return True if under complex step or finite difference.

Returns:
bool

True if under CS or FD.

use_fixed_coloring(coloring=<object object>, 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: Group

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

__init__(**kwargs)

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

abs_meta_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names and their metadata for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str, dict
abs_name_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str
add_constraint(name, lower=None, upper=None, equals=None, ref=None, ref0=None, adder=None, scaler=None, units=None, indices=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a constraint variable to this system.

Parameters:
namestr

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 alternative to using ref and ref0.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

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. The arguments (lower, upper, equals) can not be strings or variable names.

add_design_var(name, lower=None, upper=None, ref=None, ref0=None, indices=None, adder=None, scaler=None, units=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False)

Add a design variable to this system.

Parameters:
namestr

Promoted name of the design variable in the system.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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 an input 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.

unitsstr, optional

Units to convert to before applying scaling.

parallel_deriv_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

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(name, ref=None, ref0=None, index=None, units=None, adder=None, scaler=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a response variable to this system.

Parameters:
namestr

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple objectives on different indices or slices of a single variable.

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(recorder, recurse=False)

Add a recorder to the system.

Parameters:
recorder<CaseRecorder>

A recorder instance.

recursebool

Flag indicating if the recorder should be added to all the subsystems.

add_response(name, type_, lower=None, upper=None, equals=None, ref=None, ref0=None, indices=None, index=None, units=None, adder=None, scaler=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=None, alias=None)

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:
namestr

Promoted name of the response variable in the system.

type_str

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr or None

Alias for this response. Necessary when adding multiple responses on different indices of the same variable.

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

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.

proc_groupstr or None

Name of a processor group such that any system with that processor group name within the same parent group will be allocated on the same mpi process(es). If this is not None, then any other systems sharing the same proc_group must have identical values of min_procs, max_procs, and proc_weight or an exception will be raised.

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(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.

formstr

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

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value.

best_partial_deriv_direction()

Return the best direction for partial deriv calculations based on input and output sizes.

Returns:
str

The best direction for derivative calculations, ‘fwd’ or ‘rev’.

check_config(logger)

Perform optional error checks.

Parameters:
loggerobject

The object that manages logging output.

cleanup()

Clean up resources prior to exit.

property comm

Return the MPI communicator object for the system.

Returns:
MPI.Comm

MPI communicator object.

comm_info_iter()

Yield comm size for this system and all subsystems.

Yields:
tuple

A tuple of the form (abs_name, comm_size).

compute_sparsity()

Compute the sparsity of the partial jacobian.

Returns:
coo_matrix

The sparsity matrix.

dict

Metadata about the sparsity computation.

compute_sys_graph(comps_only=False, add_edge_info=True)

Compute a dependency graph for subsystems in this group.

Variable connection information is stored in each edge of the system graph if comps_only is True and add_edge_info is True.

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.

add_edge_infobool (True)

If True and comps_only is also True, store variable connection information in each edge of the system graph.

Returns:
DiGraph

A directed graph containing names of subsystems and their connections.

configure()[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(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.

convert2units(name, val, units)

Convert the given value to the specified units.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_from_units(name, val, units)

Convert the given value from the specified units to those of the named variable.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_units(name, val, units_from, units_to)

Wrap the utility convert_units and give a good error message.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

units_fromstr

The units to convert from.

units_tostr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

declare_coloring(wrt=('*',), method='fd', form=None, step=None, per_instance=True, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, min_improve_pct=5.0, 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.

min_improve_pctfloat

If coloring does not improve (decrease) the number of solves more than the given percentage, coloring will not be used.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

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

dist_size_iter(io, top_comm)

Yield names and distributed ranges of all local and remote variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

top_commMPI.Comm or None

The top-level MPI communicator.

Yields:
tuple

A tuple of the form ((abs_name, rank), start, end).

get_boundary_vars(io, local)

Return a set of inputs or outputs connected to variables outside of this Group.

Parameters:
iostr

Either ‘input’ or ‘output’.

localbool

If True, return only the variables local to the current process.

Returns:
set

Set of absolute inputs or outputs connected to variables outside of this Group.

get_coloring_fname(mode)

Return the full pathname to a coloring file.

Parameters:
modestr

The type of coloring file desired. Must be either ‘input’ or ‘output’.

Returns:
pathlib.Path

Full pathname of the coloring file.

get_constraints(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each constraint.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The constraints defined in the current system.

get_design_vars(recurse=True, get_sizes=True, use_prom_ivc=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 Group.

get_sizesbool, optional

If True, compute the size of each design variable.

use_prom_ivcbool

Use promoted names for inputs, else convert to absolute source names.

Returns:
dict

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

get_indep_vars(local)

Return a dict of independant variables contained in this group or any of its subgroups.

Parameters:
localbool

If True, return only the variables local to the current process.

Returns:
dict

Dict of all independant variables in this group and their corresponding metadata.

get_io_metadata(iotypes=('input', 'output'), metadata_keys=None, includes=None, excludes=None, is_indep_var=None, is_design_var=None, tags=None, get_remote=False, rank=None, return_rel_names=True)

Retrieve metadata for a filtered list of variables.

Parameters:
iotypesstr or iter of str

Will contain either ‘input’, ‘output’, or both. Defaults to both.

metadata_keysiter of str or None

Names of metadata entries to be retrieved or None, meaning retrieve all available ‘allprocs’ metadata. If ‘val’ or ‘src_indices’ are required, their keys must be provided explicitly since they are not found in the ‘allprocs’ metadata and must be retrieved from local metadata located in each process.

includesstr, iter of str or None

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all variables.

excludesstr, iter of str or None

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

tagsstr or iter 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.

get_remotebool

If True, retrieve variables from other MPI processes as well.

rankint or None

If None, and get_remote is True, retrieve values from all MPI process to all other MPI processes. Otherwise, if get_remote is True, retrieve values from all MPI processes only to the specified rank.

return_rel_namesbool

If True, the names returned will be relative to the scope of this System. Otherwise they will be absolute names.

Returns:
dict

A dict of metadata keyed on name, where name is either absolute or relative based on the value of the return_rel_names arg, and metadata is a dict containing entries based on the value of the metadata_keys arg. Every metadata dict will always contain two entries, ‘prom_name’ and ‘discrete’, to indicate a given variable’s promoted name and whether or not it is discrete.

get_linear_vectors()

Return the linear inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals): tuple of <Vector> instances

Yields the linear inputs, outputs, and residuals vectors.

get_nonlinear_vectors()

Return the inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals)

Yields the inputs, outputs, and residuals nonlinear vectors.

get_objectives(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each objective.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The objectives defined in the current system.

get_outputs_dir(*subdirs, mkdir=True)

Get the path under which all output files of this system are to be placed.

Parameters:
*subdirsstr

Subdirectories nested under the relevant problem output directory. To create {prob_output_dir}/a/b one would pass system.get_outputs_dir(‘a’, ‘b’).

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path of the outputs directory for the problem.

get_promotions(inprom=None, outprom=None)

Return all promotions for the given promoted variable(s).

In other words, how and where did promotions occur to convert absolute variable names into the given promoted name(s) at the current System level.

Parameters:
inpromstr or None

The promoted input variable name.

outpromstr or None

The promoted output variable name.

Returns:
dict

Dictionary keyed on system pathname containing input and/or output promotion lists for each System where promotions occurred to produce the given promoted variable(s).

get_reports_dir()

Get the path to the directory where the report files should go.

If it doesn’t exist, it will be created.

Returns:
str

The path to the directory where reports should be written.

get_responses(recurse=True, get_sizes=True, use_prom_ivc=False)

Get the response variable settings from this system.

Retrieve all response variable settings from the system as a dict, keyed by either absolute variable name, promoted name, or alias name, depending on the value of use_prom_ivc and whether the original key was a promoted output, promoted input, or an alias.

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.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

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

get_self_statics()

Override this in derived classes if compute_primal references static values.

Do NOT include self._discrete_inputs in the returned tuple. Include things like self.options[‘opt_name’], etc., that are used in compute_primal but are assumed to be constant during derivative computation.

Return value MUST be a tuple. Don’t forget the trailing comma if tuple has only one item. Return value MUST be hashable.

The order of these values doesn’t matter. They are only checked (by computing their hash) to see if they have changed since the last time compute_primal was jitted, and if so, compute_primal will be re-jitted.

Returns:
tuple

Tuple containing all static values required by compute_primal.

get_source(name)

Return the source variable connected to the given named variable.

The name can be a promoted name or an absolute name. If the given variable is an input, the absolute name of the connected source will be returned. If the given variable itself is a source, its own absolute name will be returned.

Parameters:
namestr

Absolute or promoted name of the variable.

Returns:
str

The absolute name of the source variable.

get_val(name, units=None, indices=None, get_remote=False, rank=None, vec_name='nonlinear', kind=None, flat=False, from_src=True)

Get an output/input/residual 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 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 or None

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. If False, only retrieve the value if it is on the current process, or only the part of the value that’s on the current process for a distributed variable. If None and the variable is remote or distributed, a RuntimeError will be raised.

rankint or None

If not None, only gather the value to this rank.

vec_namestr

Name of the vector to use. Defaults to ‘nonlinear’.

kindstr or None

Kind of variable (‘input’, ‘output’, or ‘residual’). If None, returned value will be either an input or output.

flatbool

If True, return the flattened version of the value.

from_srcbool

If True, retrieve value of an input variable from its connected source.

Returns:
object

The value of the requested output/input variable.

get_var_dup_info(name, io)

Return information about how the given variable is duplicated across MPI processes.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
tuple

A tuple of the form (is_duplicated, num_zeros, is_distributed).

get_var_sizes(name, io)

Return the sizes of the given variable on all procs.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
ndarray

Array of sizes of the variable on all procs.

guess_nonlinear(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()[source]

Perform any one-time initialization run at instantiation.

is_explicit()

Return True if this Group contains only explicit systems and has no cycles.

Returns:
bool

True if this is an explicit component.

property linear_solver

Get the linear solver for this system.

list_inputs(val=True, prom_name=True, units=False, shape=False, global_shape=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of input names and other optional information to a specified stream.

Parameters:
valbool, 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 True.

unitsbool, optional

When True, display/return units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global shape of the value. Default is False.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all input variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all ranks. Default is False, which will display output only from rank 0.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the input value is an array, print its smallest value.

print_maxbool

When true, if the input value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of input names and other optional information about those inputs.

list_outputs(explicit=True, implicit=True, val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of output names and other optional information to a specified stream.

Parameters:
explicitbool, optional

Include outputs from explicit components. Default is True.

implicitbool, optional

Include outputs from implicit components. Default is True.

valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

list_vars(val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of inputs and outputs sorted by component in execution order.

Parameters:
valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. Default is False.

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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

load_case(case)

Pull all input and output variables from a Case into this System.

Override this method if the System requires special handling when loading a case.

Parameters:
caseCase or dict

A Case from a CaseReader, or a dictionary with key ‘inputs’ mapped to the output of problem.model.list_inputs and key ‘outputs’ mapped to the output of prob.model.list_outputs. Both list_inputs and list_outputs should be called with prom_name=True and return_format=’dict’.

load_model_options()

Load the relevant model options from Problem._metadata[‘model_options’].

This method examines each path filter and corresponding options in self._problem_meta[‘model_options’]. If this System’s pathname matches the given path filter, it will assume the value for each given option which it possesses.

local_range_iter(io)

Yield names and local ranges of all local variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

Yields:
tuple

A tuple of the form (abs_name, start, end).

property model_options

Get the model options from self._problem_meta.

The user may change the contents of model_options to impact values sent to subsystems of this Group.

Returns:
dict

The model options metadata provided by the associated Problem object.

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 nonlinear_solver

Get the nonlinear solver for this system.

promotes(subsys_name, any=None, inputs=None, outputs=None, src_indices=None, flat_src_indices=None, src_shape=None)

Promote a variable in the model tree.

Parameters:
subsys_namestr

The name of the child subsystem whose inputs/outputs are being promoted.

anySequence of str or tuple

A Sequence of variable names (or tuples) to be promoted, regardless of if they are inputs or outputs. This is equivalent to the items passed via the promotes= argument to add_subsystem. If given as a tuple, we use the “promote as” standard of “(‘real name’, ‘promoted name’)*[]:”.

inputsSequence of str or tuple

A Sequence of input names (or tuples) to be promoted. Tuples are used for the “promote as” capability.

outputsSequence of str or tuple

A Sequence of output names (or tuples) to be promoted. Tuples are used for the “promote as” capability.

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

This argument applies only to promoted inputs. 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

This argument applies only to promoted inputs. 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.

src_shapeint or tuple

Assumed shape of any connected source or higher level promoted input.

record_iteration()

Record an iteration of the current System.

run_apply_linear(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:
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()

Compute residuals.

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

run_linearize(sub_do_ln=True, driver=None)

Compute jacobian / factorization.

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

Parameters:
sub_do_lnbool

Flag indicating if the children should call linearize on their linear solvers.

driverDriver or None

If this system is the top level system and approx derivatives have not been initialized, the driver for this model must be supplied in order to properly initialize the approximations.

run_solve_linear(mode)

Apply inverse jac product.

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

Parameters:
modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear()

Compute outputs.

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

set_constraint_options(name, ref=UNDEFINED, ref0=UNDEFINED, equals=UNDEFINED, lower=UNDEFINED, upper=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for constraints in the model.

Can be used to set options that were set using add_constraint.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

equalsfloat or ndarray, optional

Equality constraint value for the variable.

lowerfloat or ndarray, optional

Lower boundary for the variable.

upperfloat or ndarray, optional

Upper boundary for the variable.

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.

aliasstr, optional

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

set_design_var_options(name, lower=UNDEFINED, upper=UNDEFINED, scaler=UNDEFINED, adder=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED)

Set options for design vars in the model.

Can be used to set the options outside of setting them when calling add_design_var

Parameters:
namestr

Name of the variable in this system’s namespace.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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.

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.

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.

set_initial_values()

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

set_input_defaults(name, val=UNDEFINED, units=None, src_shape=None)

Specify metadata to be assumed when multiple inputs are promoted to the same name.

Parameters:
namestr

Promoted input name.

valobject

Value to assume for the promoted input.

unitsstr or None

Units to assume for the promoted input.

src_shapeint or tuple

Assumed shape of any connected source or higher level promoted input.

set_objective_options(name, ref=UNDEFINED, ref0=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for objectives in the model.

Can be used to set options after they have been set by add_objective.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

aliasstr

Alias for this response. Used to disambiguate variable names when adding multiple objectives on different indices or slices of a single variable. Deprecated.

set_order(new_order)

Specify a new execution order for subsystems in this group.

Parameters:
new_orderlist of str

List of system names in desired new execution order.

set_output_solver_options(name, lower=UNDEFINED, upper=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED, res_ref=UNDEFINED)

Set solver output options.

Allows the user to set output solver options after the output has been defined and metadata set using the add_ouput method.

Parameters:
namestr

Name of the variable in this system’s namespace.

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.

set_solver_print(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(name, val, units=None, indices=None)

Set an input or output variable.

Parameters:
namestr

Promoted or relative variable name in the system’s namespace.

valobject

Value to assign to this variable.

unitsstr, optional

Units of the value.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to set.

setup()[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(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.

Yields:
type or None
property under_approx

Return True if under complex step or finite difference.

Returns:
bool

True if under CS or FD.

use_fixed_coloring(coloring=<object object>, 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: Problem

The Sellar problem with configurable model class.

__getitem__(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__(model_class=<class 'openmdao.test_suite.components.sellar.SellarDerivatives'>, **kwargs)[source]

Initialize attributes.

__setitem__(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(recorder)

Add a recorder to the problem.

Parameters:
recorderCaseRecorder

A recorder instance.

check_config(logger=None, checks={'auto_ivc_warnings': <function _check_auto_ivc_warnings>, 'comp_has_no_outputs': <function _check_comp_has_no_outputs>, 'dup_inputs': <function _check_dup_comp_inputs>, 'missing_recorders': <function _check_missing_recorders>, 'out_of_order': <function _check_ubcs_prob>, 'solvers': <function _check_solvers>, 'system': <function _check_system_configs>, 'unserializable_options': <function _check_unserializable_options>}, out_file='openmdao_checks.out')

Perform optional error checks on a Problem.

Parameters:
loggerobject

Logging object.

checkslist of str or None or the str ‘all’

Determines what config checks are run. If None, no checks are run If list of str, run those config checks If ‘all’, all the checks (‘auto_ivc_warnings’, ‘comp_has_no_outputs’, ‘cycles’, ‘dup_inputs’, ‘missing_recorders’, ‘out_of_order’, ‘promotions’, ‘solvers’, ‘system’, ‘unconnected_inputs’) are run.

out_filestr or None

If not None, output will be written to this file in addition to stdout.

check_partials(out_stream=DEFAULT_OUT_STREAM, 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', minimum_step=1e-12, 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 input-output 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’.

stepNone, float, or list/tuple of float

Step size(s) for approximation. Default is None, which means 1e-6 for ‘fd’ and 1e-40 for ‘cs’.

formstr

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Default ‘forward’.

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value.

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

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’, ‘rank_inconsistent’]. For ‘rel error’, ‘abs error’, and ‘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. The boolean ‘rank_inconsistent’ indicates if the derivative wrt a serial variable is inconsistent across MPI ranks.

check_totals(of=None, wrt=None, out_stream=DEFAULT_OUT_STREAM, 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', show_progress=False, show_only_incorrect=False, directional=False, sort=False)

Check total derivatives for the model vs. finite difference.

Parameters:
oflist of variable name str or None

Variables whose derivatives will be computed. Default is None, which uses the driver’s objectives and constraints.

wrtlist of variable name str 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 input-output 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’.

stepNone, float, or list/tuple of float

Step size for approximation. Default is None, which means 1e-6 for ‘fd’ and 1e-40 for ‘cs’.

formstr

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Default None, which defaults to ‘forward’ for FD.

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value..

show_progressbool

True to show progress of check_totals.

show_only_incorrectbool, optional

Set to True if output should print only the subjacs found to be incorrect.

directionalbool

If True, compute a single directional derivative for each ‘of’ in rev mode or each ‘wrt’ in fwd mode.

sortbool

If True, sort the subjacobian keys alphabetically.

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()

Clean up resources prior to exit.

compute_jacvec_product(of, wrt, mode, seed)

Given a seed and ‘of’ and ‘wrt’ variables, compute the total jacobian vector product.

Parameters:
oflist of str

Variables whose derivatives will be computed.

wrtlist of str

Derivatives will be computed with respect to these variables.

modestr

Derivative direction (‘fwd’ or ‘rev’).

seeddict or list

Either a dict keyed by ‘wrt’ varnames (fwd) or ‘of’ varnames (rev), containing dresidual (fwd) or doutput (rev) values, OR a list of dresidual or doutput values that matches the corresponding ‘wrt’ (fwd) or ‘of’ (rev) varname list.

Returns:
dict

The total jacobian vector product, keyed by variable name.

compute_totals(of=None, wrt=None, return_format='flat_dict', debug_print=False, driver_scaling=False, use_abs_names=False, get_remote=True, coloring_info=None)

Compute derivatives of desired quantities with respect to desired inputs.

Parameters:
oflist of variable name str or None

Variables whose derivatives will be computed. Default is None, which uses the driver’s objectives and constraints.

wrtlist of variable name str or None

Variables with respect to which the derivatives will be computed. Default is None, which uses the driver’s desvars.

return_formatstr

Format to return the derivatives. Can be ‘dict’, ‘flat_dict’, or ‘array’. 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.

use_abs_namesbool

This is deprecated and has no effect.

get_remotebool

If True, the default, the full distributed total jacobian will be retrieved.

coloring_infoColoringMeta, None, or False

If False, do no coloring. If None, use driver coloring info to compute the coloring. Otherwise use the given coloring info object to provide the coloring, if it exists.

Returns:
object

Derivatives in form requested by ‘return_format’.

property driver

Get the Driver for this Problem.

final_setup()

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_coloring_dir(mode, mkdir=False)

Get the path to the directory for the coloring files.

Parameters:
modestr

Must be one of ‘input’ or ‘output’. A problem will always write its coloring files to its standard output directory in {prob_name}_out/coloring_files, but input coloring files to be loaded may be read from a different directory specifed by the problem’s coloring_dir option.

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path to the directory where reports should be written.

get_outputs_dir(*subdirs, mkdir=True)

Get the path under which all output files of this problem are to be placed.

Parameters:
*subdirsstr

Subdirectories nested under the relevant problem output directory. To create {prob_output_dir}/a/b one would pass prob.get_outputs_dir(‘a’, ‘b’).

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path of the outputs directory for the problem.

get_reports_dir(force=False)

Get the path to the directory where the report files should go.

If it doesn’t exist, it will be created.

Parameters:
forcebool

If True, create the reports directory if it doesn’t exist, even if this Problem does not have any active reports. This can happen when running testflo.

Returns:
pathlib.Path

The path to the directory where reports should be written.

get_total_coloring(coloring_info=None, of=None, wrt=None, run_model=None)

Get the total coloring.

If necessary, dynamically generate it.

Parameters:
coloring_infodict

Coloring metadata dict.

oflist of str or None

List of response names.

wrtlist of str or None

List of design variable names.

run_modelbool or None

If False, don’t run model. If None, use problem._run_counter to determine if model should be run.

Returns:
Coloring or None

Coloring object, possibly dynamically generated, or None.

get_val(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 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 or None

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. If False, only retrieve the value if it is on the current process, or only the part of the value that’s on the current process for a distributed variable. If None and the variable is remote or distributed, a RuntimeError will be raised.

Returns:
object

The value of the requested output/input variable.

is_local(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.

iter_count_iter(include_driver=True, include_solvers=True, include_systems=False)

Yield iteration counts for driver, solvers and/or systems.

Parameters:
include_driverbool

If True, include the driver in the iteration counts.

include_solversbool

If True, include solvers in the iteration counts.

include_systemsbool

If True, include systems in the iteration counts.

Yields:
str

Name of the object.

str

Name of the counter.

int

Value of the counter.

list_driver_vars(show_promoted_name=True, print_arrays=False, driver_scaling=True, desvar_opts=[], cons_opts=[], objs_opts=[], out_stream=DEFAULT_OUT_STREAM)

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.

driver_scalingbool, optional

When True, return values 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 True.

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’, ‘cache_linear_solution’, ‘units’, ‘min’, ‘max’].

cons_optslist of str

List of optional columns to be displayed in the cons table. Allowed values are: [‘lower’, ‘upper’, ‘equals’, ‘ref’, ‘ref0’, ‘indices’, ‘adder’, ‘scaler’, ‘linear’, ‘parallel_deriv_color’, ‘cache_linear_solution’, ‘units’, ‘min’, ‘max’].

objs_optslist of str

List of optional columns to be displayed in the objs table. Allowed values are: [‘ref’, ‘ref0’, ‘indices’, ‘adder’, ‘scaler’, ‘units’, ‘parallel_deriv_color’, ‘cache_linear_solution’].

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

Returns:
dict

Name, size, val, and other requested parameters of design variables, constraints, and objectives.

list_indep_vars(include_design_vars=True, options=None, print_arrays=False, out_stream=DEFAULT_OUT_STREAM)

Retrieve the independent variables in the Problem.

Returns a dictionary mapping the promoted names of indep_vars which the user is expected to provide to the metadata for the associated independent variable.

A output is designated as an independent variable if it is tagged with ‘openmdao:indep_var’. This includes IndepVarComp by default, and users are able to apply this tag to their own component outputs if they wish to provide components with IndepVarComp-like capability.

Parameters:
include_design_varsbool

If True, include design variables in the list of problem inputs. The user may provide values for these but ultimately they will be overwritten by the Driver. Default is False.

optionslist of str or None

List of optional columns to be displayed in the independent variable table. Allowed values are: [‘name’, ‘units’, ‘shape’, ‘size’, ‘desc’, ‘ref’, ‘ref0’, ‘res_ref’, ‘distributed’, ‘lower’, ‘upper’, ‘tags’, ‘shape_by_conn’, ‘copy_shape’, ‘compute_shape’, ‘global_size’, ‘global_shape’, ‘value’].

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.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

Returns:
dict

A dictionary mapping the promoted names of all independent variables in the model to their metadata.

list_pre_post(outfile=None)

Display the pre and post optimization components.

Parameters:
outfilefile-like or str or None

Where to send human readable output. Default is None, which sends output to stdout.

list_problem_vars(show_promoted_name=True, print_arrays=False, driver_scaling=True, desvar_opts=[], cons_opts=[], objs_opts=[], out_stream=DEFAULT_OUT_STREAM)

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.

driver_scalingbool, optional

When True, return values 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 True.

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’, ‘cache_linear_solution’, ‘units’, ‘min’, ‘max’].

cons_optslist of str

List of optional columns to be displayed in the cons table. Allowed values are: [‘lower’, ‘upper’, ‘equals’, ‘ref’, ‘ref0’, ‘indices’, ‘adder’, ‘scaler’, ‘linear’, ‘parallel_deriv_color’, ‘cache_linear_solution’, ‘units’, ‘min’, ‘max’].

objs_optslist of str

List of optional columns to be displayed in the objs table. Allowed values are: [‘ref’, ‘ref0’, ‘indices’, ‘adder’, ‘scaler’, ‘units’, ‘parallel_deriv_color’, ‘cache_linear_solution’].

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

Returns:
dict

Name, size, val, and other requested parameters of design variables, constraints, and objectives.

load_case(case)

Pull all input and output variables from a case into the model.

Parameters:
caseCase or dict

A Case from a CaseReader, or a dictionary with key ‘inputs’ mapped to the output of problem.model.list_inputs and key ‘outputs’ mapped to the output of prob.model.list_outputs. Both list_inputs and list_outputs should be called with prom_name=True and return_format=’dict’.

property msginfo

Return info to prepend to messages.

Returns:
str

Info to prepend to messages.

record(case_name)

Record the variables at the Problem level.

Must be called after final_setup has been called. This can either happen automatically through run_driver or run_model, or it can be called manually.

Parameters:
case_namestr

Name used to identify this Problem case.

run_driver(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. None means keep the preexisting prefix.

reset_iter_countsbool

If True and model has been run previously, reset all iteration counters.

Returns:
bool

Failure flag; True if failed to converge, False is successful.

run_model(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. None means keep the preexisting prefix.

reset_iter_countsbool

If True and model has been run previously, reset all iteration counters.

set_complex_step_mode(active)

Turn on or off complex stepping mode.

Parameters:
activebool

Complex mode flag; set to True prior to commencing complex step.

set_solver_print(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(name, val=None, 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.

valobject

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(check=None, logger=None, mode='auto', force_alloc_complex=False, distributed_vector_class=None, local_vector_class=<class 'openmdao.vectors.default_vector.DefaultVector'>, derivatives=True, parent=None)

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:
checkNone, bool, list of str, or the strs ‘all’

Determines what config checks, if any, are run after setup is complete. If None: no checks are run unless the ‘checks’ report is active, in which case the default reports will be run. If False, no checks are run If True, the default checks (‘out_of_order’, ‘system’, ‘solvers’, ‘dup_inputs’, ‘missing_recorders’, ‘unserializable_options’, ‘comp_has_no_outputs’, ‘auto_ivc_warnings’) are run If list of str, run those config checks If ‘all’, all the checks (‘auto_ivc_warnings’, ‘comp_has_no_outputs’, ‘cycles’, ‘dup_inputs’, ‘missing_recorders’, ‘all_unserializable_options’, ‘out_of_order’, ‘promotions’, ‘solvers’, ‘system’, ‘unconnected_inputs’) are run.

loggerobject

Object for logging config checks if check is True.

modestr

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

If True, sufficient memory will be allocated to allow nonlinear vectors to store complex values while operating under complex step.

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.

parentProblem, System, Solver, or None

The “parent” object of this problem instance in a tree of potentially nested problems.

Returns:
<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: Problem

The Sellar problem with ndarray variable options

__getitem__(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__(model_class=<class 'openmdao.test_suite.components.sellar.SellarDerivatives'>, **kwargs)[source]

Initialize attributes.

__setitem__(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(recorder)

Add a recorder to the problem.

Parameters:
recorderCaseRecorder

A recorder instance.

check_config(logger=None, checks={'auto_ivc_warnings': <function _check_auto_ivc_warnings>, 'comp_has_no_outputs': <function _check_comp_has_no_outputs>, 'dup_inputs': <function _check_dup_comp_inputs>, 'missing_recorders': <function _check_missing_recorders>, 'out_of_order': <function _check_ubcs_prob>, 'solvers': <function _check_solvers>, 'system': <function _check_system_configs>, 'unserializable_options': <function _check_unserializable_options>}, out_file='openmdao_checks.out')

Perform optional error checks on a Problem.

Parameters:
loggerobject

Logging object.

checkslist of str or None or the str ‘all’

Determines what config checks are run. If None, no checks are run If list of str, run those config checks If ‘all’, all the checks (‘auto_ivc_warnings’, ‘comp_has_no_outputs’, ‘cycles’, ‘dup_inputs’, ‘missing_recorders’, ‘out_of_order’, ‘promotions’, ‘solvers’, ‘system’, ‘unconnected_inputs’) are run.

out_filestr or None

If not None, output will be written to this file in addition to stdout.

check_partials(out_stream=DEFAULT_OUT_STREAM, 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', minimum_step=1e-12, 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 input-output 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’.

stepNone, float, or list/tuple of float

Step size(s) for approximation. Default is None, which means 1e-6 for ‘fd’ and 1e-40 for ‘cs’.

formstr

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Default ‘forward’.

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value.

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

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’, ‘rank_inconsistent’]. For ‘rel error’, ‘abs error’, and ‘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. The boolean ‘rank_inconsistent’ indicates if the derivative wrt a serial variable is inconsistent across MPI ranks.

check_totals(of=None, wrt=None, out_stream=DEFAULT_OUT_STREAM, 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', show_progress=False, show_only_incorrect=False, directional=False, sort=False)

Check total derivatives for the model vs. finite difference.

Parameters:
oflist of variable name str or None

Variables whose derivatives will be computed. Default is None, which uses the driver’s objectives and constraints.

wrtlist of variable name str 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 input-output 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’.

stepNone, float, or list/tuple of float

Step size for approximation. Default is None, which means 1e-6 for ‘fd’ and 1e-40 for ‘cs’.

formstr

Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Default None, which defaults to ‘forward’ for FD.

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value..

show_progressbool

True to show progress of check_totals.

show_only_incorrectbool, optional

Set to True if output should print only the subjacs found to be incorrect.

directionalbool

If True, compute a single directional derivative for each ‘of’ in rev mode or each ‘wrt’ in fwd mode.

sortbool

If True, sort the subjacobian keys alphabetically.

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()

Clean up resources prior to exit.

compute_jacvec_product(of, wrt, mode, seed)

Given a seed and ‘of’ and ‘wrt’ variables, compute the total jacobian vector product.

Parameters:
oflist of str

Variables whose derivatives will be computed.

wrtlist of str

Derivatives will be computed with respect to these variables.

modestr

Derivative direction (‘fwd’ or ‘rev’).

seeddict or list

Either a dict keyed by ‘wrt’ varnames (fwd) or ‘of’ varnames (rev), containing dresidual (fwd) or doutput (rev) values, OR a list of dresidual or doutput values that matches the corresponding ‘wrt’ (fwd) or ‘of’ (rev) varname list.

Returns:
dict

The total jacobian vector product, keyed by variable name.

compute_totals(of=None, wrt=None, return_format='flat_dict', debug_print=False, driver_scaling=False, use_abs_names=False, get_remote=True, coloring_info=None)

Compute derivatives of desired quantities with respect to desired inputs.

Parameters:
oflist of variable name str or None

Variables whose derivatives will be computed. Default is None, which uses the driver’s objectives and constraints.

wrtlist of variable name str or None

Variables with respect to which the derivatives will be computed. Default is None, which uses the driver’s desvars.

return_formatstr

Format to return the derivatives. Can be ‘dict’, ‘flat_dict’, or ‘array’. 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.

use_abs_namesbool

This is deprecated and has no effect.

get_remotebool

If True, the default, the full distributed total jacobian will be retrieved.

coloring_infoColoringMeta, None, or False

If False, do no coloring. If None, use driver coloring info to compute the coloring. Otherwise use the given coloring info object to provide the coloring, if it exists.

Returns:
object

Derivatives in form requested by ‘return_format’.

property driver

Get the Driver for this Problem.

final_setup()

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_coloring_dir(mode, mkdir=False)

Get the path to the directory for the coloring files.

Parameters:
modestr

Must be one of ‘input’ or ‘output’. A problem will always write its coloring files to its standard output directory in {prob_name}_out/coloring_files, but input coloring files to be loaded may be read from a different directory specifed by the problem’s coloring_dir option.

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path to the directory where reports should be written.

get_outputs_dir(*subdirs, mkdir=True)

Get the path under which all output files of this problem are to be placed.

Parameters:
*subdirsstr

Subdirectories nested under the relevant problem output directory. To create {prob_output_dir}/a/b one would pass prob.get_outputs_dir(‘a’, ‘b’).

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path of the outputs directory for the problem.

get_reports_dir(force=False)

Get the path to the directory where the report files should go.

If it doesn’t exist, it will be created.

Parameters:
forcebool

If True, create the reports directory if it doesn’t exist, even if this Problem does not have any active reports. This can happen when running testflo.

Returns:
pathlib.Path

The path to the directory where reports should be written.

get_total_coloring(coloring_info=None, of=None, wrt=None, run_model=None)

Get the total coloring.

If necessary, dynamically generate it.

Parameters:
coloring_infodict

Coloring metadata dict.

oflist of str or None

List of response names.

wrtlist of str or None

List of design variable names.

run_modelbool or None

If False, don’t run model. If None, use problem._run_counter to determine if model should be run.

Returns:
Coloring or None

Coloring object, possibly dynamically generated, or None.

get_val(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 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 or None

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. If False, only retrieve the value if it is on the current process, or only the part of the value that’s on the current process for a distributed variable. If None and the variable is remote or distributed, a RuntimeError will be raised.

Returns:
object

The value of the requested output/input variable.

is_local(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.

iter_count_iter(include_driver=True, include_solvers=True, include_systems=False)

Yield iteration counts for driver, solvers and/or systems.

Parameters:
include_driverbool

If True, include the driver in the iteration counts.

include_solversbool

If True, include solvers in the iteration counts.

include_systemsbool

If True, include systems in the iteration counts.

Yields:
str

Name of the object.

str

Name of the counter.

int

Value of the counter.

list_driver_vars(show_promoted_name=True, print_arrays=False, driver_scaling=True, desvar_opts=[], cons_opts=[], objs_opts=[], out_stream=DEFAULT_OUT_STREAM)

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.

driver_scalingbool, optional

When True, return values 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 True.

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’, ‘cache_linear_solution’, ‘units’, ‘min’, ‘max’].

cons_optslist of str

List of optional columns to be displayed in the cons table. Allowed values are: [‘lower’, ‘upper’, ‘equals’, ‘ref’, ‘ref0’, ‘indices’, ‘adder’, ‘scaler’, ‘linear’, ‘parallel_deriv_color’, ‘cache_linear_solution’, ‘units’, ‘min’, ‘max’].

objs_optslist of str

List of optional columns to be displayed in the objs table. Allowed values are: [‘ref’, ‘ref0’, ‘indices’, ‘adder’, ‘scaler’, ‘units’, ‘parallel_deriv_color’, ‘cache_linear_solution’].

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

Returns:
dict

Name, size, val, and other requested parameters of design variables, constraints, and objectives.

list_indep_vars(include_design_vars=True, options=None, print_arrays=False, out_stream=DEFAULT_OUT_STREAM)

Retrieve the independent variables in the Problem.

Returns a dictionary mapping the promoted names of indep_vars which the user is expected to provide to the metadata for the associated independent variable.

A output is designated as an independent variable if it is tagged with ‘openmdao:indep_var’. This includes IndepVarComp by default, and users are able to apply this tag to their own component outputs if they wish to provide components with IndepVarComp-like capability.

Parameters:
include_design_varsbool

If True, include design variables in the list of problem inputs. The user may provide values for these but ultimately they will be overwritten by the Driver. Default is False.

optionslist of str or None

List of optional columns to be displayed in the independent variable table. Allowed values are: [‘name’, ‘units’, ‘shape’, ‘size’, ‘desc’, ‘ref’, ‘ref0’, ‘res_ref’, ‘distributed’, ‘lower’, ‘upper’, ‘tags’, ‘shape_by_conn’, ‘copy_shape’, ‘compute_shape’, ‘global_size’, ‘global_shape’, ‘value’].

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.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

Returns:
dict

A dictionary mapping the promoted names of all independent variables in the model to their metadata.

list_pre_post(outfile=None)

Display the pre and post optimization components.

Parameters:
outfilefile-like or str or None

Where to send human readable output. Default is None, which sends output to stdout.

list_problem_vars(show_promoted_name=True, print_arrays=False, driver_scaling=True, desvar_opts=[], cons_opts=[], objs_opts=[], out_stream=DEFAULT_OUT_STREAM)

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.

driver_scalingbool, optional

When True, return values 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 True.

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’, ‘cache_linear_solution’, ‘units’, ‘min’, ‘max’].

cons_optslist of str

List of optional columns to be displayed in the cons table. Allowed values are: [‘lower’, ‘upper’, ‘equals’, ‘ref’, ‘ref0’, ‘indices’, ‘adder’, ‘scaler’, ‘linear’, ‘parallel_deriv_color’, ‘cache_linear_solution’, ‘units’, ‘min’, ‘max’].

objs_optslist of str

List of optional columns to be displayed in the objs table. Allowed values are: [‘ref’, ‘ref0’, ‘indices’, ‘adder’, ‘scaler’, ‘units’, ‘parallel_deriv_color’, ‘cache_linear_solution’].

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

Returns:
dict

Name, size, val, and other requested parameters of design variables, constraints, and objectives.

load_case(case)

Pull all input and output variables from a case into the model.

Parameters:
caseCase or dict

A Case from a CaseReader, or a dictionary with key ‘inputs’ mapped to the output of problem.model.list_inputs and key ‘outputs’ mapped to the output of prob.model.list_outputs. Both list_inputs and list_outputs should be called with prom_name=True and return_format=’dict’.

property msginfo

Return info to prepend to messages.

Returns:
str

Info to prepend to messages.

record(case_name)

Record the variables at the Problem level.

Must be called after final_setup has been called. This can either happen automatically through run_driver or run_model, or it can be called manually.

Parameters:
case_namestr

Name used to identify this Problem case.

run_driver(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. None means keep the preexisting prefix.

reset_iter_countsbool

If True and model has been run previously, reset all iteration counters.

Returns:
bool

Failure flag; True if failed to converge, False is successful.

run_model(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. None means keep the preexisting prefix.

reset_iter_countsbool

If True and model has been run previously, reset all iteration counters.

set_complex_step_mode(active)

Turn on or off complex stepping mode.

Parameters:
activebool

Complex mode flag; set to True prior to commencing complex step.

set_solver_print(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(name, val=None, 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.

valobject

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(check=None, logger=None, mode='auto', force_alloc_complex=False, distributed_vector_class=None, local_vector_class=<class 'openmdao.vectors.default_vector.DefaultVector'>, derivatives=True, parent=None)

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:
checkNone, bool, list of str, or the strs ‘all’

Determines what config checks, if any, are run after setup is complete. If None: no checks are run unless the ‘checks’ report is active, in which case the default reports will be run. If False, no checks are run If True, the default checks (‘out_of_order’, ‘system’, ‘solvers’, ‘dup_inputs’, ‘missing_recorders’, ‘unserializable_options’, ‘comp_has_no_outputs’, ‘auto_ivc_warnings’) are run If list of str, run those config checks If ‘all’, all the checks (‘auto_ivc_warnings’, ‘comp_has_no_outputs’, ‘cycles’, ‘dup_inputs’, ‘missing_recorders’, ‘all_unserializable_options’, ‘out_of_order’, ‘promotions’, ‘solvers’, ‘system’, ‘unconnected_inputs’) are run.

loggerobject

Object for logging config checks if check is True.

modestr

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

If True, sufficient memory will be allocated to allow nonlinear vectors to store complex values while operating under complex step.

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.

parentProblem, System, Solver, or None

The “parent” object of this problem instance in a tree of potentially nested problems.

Returns:
<Problem>

This enables the user to instantiate and setup in one line.

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

Bases: Group

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

__init__(**kwargs)

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

abs_meta_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names and their metadata for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str, dict
abs_name_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str
add_constraint(name, lower=None, upper=None, equals=None, ref=None, ref0=None, adder=None, scaler=None, units=None, indices=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a constraint variable to this system.

Parameters:
namestr

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 alternative to using ref and ref0.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

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. The arguments (lower, upper, equals) can not be strings or variable names.

add_design_var(name, lower=None, upper=None, ref=None, ref0=None, indices=None, adder=None, scaler=None, units=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False)

Add a design variable to this system.

Parameters:
namestr

Promoted name of the design variable in the system.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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 an input 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.

unitsstr, optional

Units to convert to before applying scaling.

parallel_deriv_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

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(name, ref=None, ref0=None, index=None, units=None, adder=None, scaler=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a response variable to this system.

Parameters:
namestr

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple objectives on different indices or slices of a single variable.

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(recorder, recurse=False)

Add a recorder to the system.

Parameters:
recorder<CaseRecorder>

A recorder instance.

recursebool

Flag indicating if the recorder should be added to all the subsystems.

add_response(name, type_, lower=None, upper=None, equals=None, ref=None, ref0=None, indices=None, index=None, units=None, adder=None, scaler=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=None, alias=None)

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:
namestr

Promoted name of the response variable in the system.

type_str

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr or None

Alias for this response. Necessary when adding multiple responses on different indices of the same variable.

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

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.

proc_groupstr or None

Name of a processor group such that any system with that processor group name within the same parent group will be allocated on the same mpi process(es). If this is not None, then any other systems sharing the same proc_group must have identical values of min_procs, max_procs, and proc_weight or an exception will be raised.

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(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.

formstr

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

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value.

best_partial_deriv_direction()

Return the best direction for partial deriv calculations based on input and output sizes.

Returns:
str

The best direction for derivative calculations, ‘fwd’ or ‘rev’.

check_config(logger)

Perform optional error checks.

Parameters:
loggerobject

The object that manages logging output.

cleanup()

Clean up resources prior to exit.

property comm

Return the MPI communicator object for the system.

Returns:
MPI.Comm

MPI communicator object.

comm_info_iter()

Yield comm size for this system and all subsystems.

Yields:
tuple

A tuple of the form (abs_name, comm_size).

compute_sparsity()

Compute the sparsity of the partial jacobian.

Returns:
coo_matrix

The sparsity matrix.

dict

Metadata about the sparsity computation.

compute_sys_graph(comps_only=False, add_edge_info=True)

Compute a dependency graph for subsystems in this group.

Variable connection information is stored in each edge of the system graph if comps_only is True and add_edge_info is True.

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.

add_edge_infobool (True)

If True and comps_only is also True, store variable connection information in each edge of the system graph.

Returns:
DiGraph

A directed graph containing names of subsystems and their connections.

configure()[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(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.

convert2units(name, val, units)

Convert the given value to the specified units.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_from_units(name, val, units)

Convert the given value from the specified units to those of the named variable.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_units(name, val, units_from, units_to)

Wrap the utility convert_units and give a good error message.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

units_fromstr

The units to convert from.

units_tostr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

declare_coloring(wrt=('*',), method='fd', form=None, step=None, per_instance=True, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, min_improve_pct=5.0, 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.

min_improve_pctfloat

If coloring does not improve (decrease) the number of solves more than the given percentage, coloring will not be used.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

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

dist_size_iter(io, top_comm)

Yield names and distributed ranges of all local and remote variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

top_commMPI.Comm or None

The top-level MPI communicator.

Yields:
tuple

A tuple of the form ((abs_name, rank), start, end).

get_boundary_vars(io, local)

Return a set of inputs or outputs connected to variables outside of this Group.

Parameters:
iostr

Either ‘input’ or ‘output’.

localbool

If True, return only the variables local to the current process.

Returns:
set

Set of absolute inputs or outputs connected to variables outside of this Group.

get_coloring_fname(mode)

Return the full pathname to a coloring file.

Parameters:
modestr

The type of coloring file desired. Must be either ‘input’ or ‘output’.

Returns:
pathlib.Path

Full pathname of the coloring file.

get_constraints(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each constraint.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The constraints defined in the current system.

get_design_vars(recurse=True, get_sizes=True, use_prom_ivc=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 Group.

get_sizesbool, optional

If True, compute the size of each design variable.

use_prom_ivcbool

Use promoted names for inputs, else convert to absolute source names.

Returns:
dict

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

get_indep_vars(local)

Return a dict of independant variables contained in this group or any of its subgroups.

Parameters:
localbool

If True, return only the variables local to the current process.

Returns:
dict

Dict of all independant variables in this group and their corresponding metadata.

get_io_metadata(iotypes=('input', 'output'), metadata_keys=None, includes=None, excludes=None, is_indep_var=None, is_design_var=None, tags=None, get_remote=False, rank=None, return_rel_names=True)

Retrieve metadata for a filtered list of variables.

Parameters:
iotypesstr or iter of str

Will contain either ‘input’, ‘output’, or both. Defaults to both.

metadata_keysiter of str or None

Names of metadata entries to be retrieved or None, meaning retrieve all available ‘allprocs’ metadata. If ‘val’ or ‘src_indices’ are required, their keys must be provided explicitly since they are not found in the ‘allprocs’ metadata and must be retrieved from local metadata located in each process.

includesstr, iter of str or None

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all variables.

excludesstr, iter of str or None

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

tagsstr or iter 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.

get_remotebool

If True, retrieve variables from other MPI processes as well.

rankint or None

If None, and get_remote is True, retrieve values from all MPI process to all other MPI processes. Otherwise, if get_remote is True, retrieve values from all MPI processes only to the specified rank.

return_rel_namesbool

If True, the names returned will be relative to the scope of this System. Otherwise they will be absolute names.

Returns:
dict

A dict of metadata keyed on name, where name is either absolute or relative based on the value of the return_rel_names arg, and metadata is a dict containing entries based on the value of the metadata_keys arg. Every metadata dict will always contain two entries, ‘prom_name’ and ‘discrete’, to indicate a given variable’s promoted name and whether or not it is discrete.

get_linear_vectors()

Return the linear inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals): tuple of <Vector> instances

Yields the linear inputs, outputs, and residuals vectors.

get_nonlinear_vectors()

Return the inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals)

Yields the inputs, outputs, and residuals nonlinear vectors.

get_objectives(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each objective.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The objectives defined in the current system.

get_outputs_dir(*subdirs, mkdir=True)

Get the path under which all output files of this system are to be placed.

Parameters:
*subdirsstr

Subdirectories nested under the relevant problem output directory. To create {prob_output_dir}/a/b one would pass system.get_outputs_dir(‘a’, ‘b’).

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path of the outputs directory for the problem.

get_promotions(inprom=None, outprom=None)

Return all promotions for the given promoted variable(s).

In other words, how and where did promotions occur to convert absolute variable names into the given promoted name(s) at the current System level.

Parameters:
inpromstr or None

The promoted input variable name.

outpromstr or None

The promoted output variable name.

Returns:
dict

Dictionary keyed on system pathname containing input and/or output promotion lists for each System where promotions occurred to produce the given promoted variable(s).

get_reports_dir()

Get the path to the directory where the report files should go.

If it doesn’t exist, it will be created.

Returns:
str

The path to the directory where reports should be written.

get_responses(recurse=True, get_sizes=True, use_prom_ivc=False)

Get the response variable settings from this system.

Retrieve all response variable settings from the system as a dict, keyed by either absolute variable name, promoted name, or alias name, depending on the value of use_prom_ivc and whether the original key was a promoted output, promoted input, or an alias.

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.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

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

get_self_statics()

Override this in derived classes if compute_primal references static values.

Do NOT include self._discrete_inputs in the returned tuple. Include things like self.options[‘opt_name’], etc., that are used in compute_primal but are assumed to be constant during derivative computation.

Return value MUST be a tuple. Don’t forget the trailing comma if tuple has only one item. Return value MUST be hashable.

The order of these values doesn’t matter. They are only checked (by computing their hash) to see if they have changed since the last time compute_primal was jitted, and if so, compute_primal will be re-jitted.

Returns:
tuple

Tuple containing all static values required by compute_primal.

get_source(name)

Return the source variable connected to the given named variable.

The name can be a promoted name or an absolute name. If the given variable is an input, the absolute name of the connected source will be returned. If the given variable itself is a source, its own absolute name will be returned.

Parameters:
namestr

Absolute or promoted name of the variable.

Returns:
str

The absolute name of the source variable.

get_val(name, units=None, indices=None, get_remote=False, rank=None, vec_name='nonlinear', kind=None, flat=False, from_src=True)

Get an output/input/residual 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 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 or None

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. If False, only retrieve the value if it is on the current process, or only the part of the value that’s on the current process for a distributed variable. If None and the variable is remote or distributed, a RuntimeError will be raised.

rankint or None

If not None, only gather the value to this rank.

vec_namestr

Name of the vector to use. Defaults to ‘nonlinear’.

kindstr or None

Kind of variable (‘input’, ‘output’, or ‘residual’). If None, returned value will be either an input or output.

flatbool

If True, return the flattened version of the value.

from_srcbool

If True, retrieve value of an input variable from its connected source.

Returns:
object

The value of the requested output/input variable.

get_var_dup_info(name, io)

Return information about how the given variable is duplicated across MPI processes.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
tuple

A tuple of the form (is_duplicated, num_zeros, is_distributed).

get_var_sizes(name, io)

Return the sizes of the given variable on all procs.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
ndarray

Array of sizes of the variable on all procs.

guess_nonlinear(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()[source]

Perform any one-time initialization run at instantiation.

is_explicit()

Return True if this Group contains only explicit systems and has no cycles.

Returns:
bool

True if this is an explicit component.

property linear_solver

Get the linear solver for this system.

list_inputs(val=True, prom_name=True, units=False, shape=False, global_shape=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of input names and other optional information to a specified stream.

Parameters:
valbool, 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 True.

unitsbool, optional

When True, display/return units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global shape of the value. Default is False.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all input variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all ranks. Default is False, which will display output only from rank 0.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the input value is an array, print its smallest value.

print_maxbool

When true, if the input value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of input names and other optional information about those inputs.

list_outputs(explicit=True, implicit=True, val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of output names and other optional information to a specified stream.

Parameters:
explicitbool, optional

Include outputs from explicit components. Default is True.

implicitbool, optional

Include outputs from implicit components. Default is True.

valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

list_vars(val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of inputs and outputs sorted by component in execution order.

Parameters:
valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. Default is False.

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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

load_case(case)

Pull all input and output variables from a Case into this System.

Override this method if the System requires special handling when loading a case.

Parameters:
caseCase or dict

A Case from a CaseReader, or a dictionary with key ‘inputs’ mapped to the output of problem.model.list_inputs and key ‘outputs’ mapped to the output of prob.model.list_outputs. Both list_inputs and list_outputs should be called with prom_name=True and return_format=’dict’.

load_model_options()

Load the relevant model options from Problem._metadata[‘model_options’].

This method examines each path filter and corresponding options in self._problem_meta[‘model_options’]. If this System’s pathname matches the given path filter, it will assume the value for each given option which it possesses.

local_range_iter(io)

Yield names and local ranges of all local variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

Yields:
tuple

A tuple of the form (abs_name, start, end).

property model_options

Get the model options from self._problem_meta.

The user may change the contents of model_options to impact values sent to subsystems of this Group.

Returns:
dict

The model options metadata provided by the associated Problem object.

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 nonlinear_solver

Get the nonlinear solver for this system.

promotes(subsys_name, any=None, inputs=None, outputs=None, src_indices=None, flat_src_indices=None, src_shape=None)

Promote a variable in the model tree.

Parameters:
subsys_namestr

The name of the child subsystem whose inputs/outputs are being promoted.

anySequence of str or tuple

A Sequence of variable names (or tuples) to be promoted, regardless of if they are inputs or outputs. This is equivalent to the items passed via the promotes= argument to add_subsystem. If given as a tuple, we use the “promote as” standard of “(‘real name’, ‘promoted name’)*[]:”.

inputsSequence of str or tuple

A Sequence of input names (or tuples) to be promoted. Tuples are used for the “promote as” capability.

outputsSequence of str or tuple

A Sequence of output names (or tuples) to be promoted. Tuples are used for the “promote as” capability.

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

This argument applies only to promoted inputs. 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

This argument applies only to promoted inputs. 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.

src_shapeint or tuple

Assumed shape of any connected source or higher level promoted input.

record_iteration()

Record an iteration of the current System.

run_apply_linear(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:
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()

Compute residuals.

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

run_linearize(sub_do_ln=True, driver=None)

Compute jacobian / factorization.

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

Parameters:
sub_do_lnbool

Flag indicating if the children should call linearize on their linear solvers.

driverDriver or None

If this system is the top level system and approx derivatives have not been initialized, the driver for this model must be supplied in order to properly initialize the approximations.

run_solve_linear(mode)

Apply inverse jac product.

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

Parameters:
modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear()

Compute outputs.

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

set_constraint_options(name, ref=UNDEFINED, ref0=UNDEFINED, equals=UNDEFINED, lower=UNDEFINED, upper=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for constraints in the model.

Can be used to set options that were set using add_constraint.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

equalsfloat or ndarray, optional

Equality constraint value for the variable.

lowerfloat or ndarray, optional

Lower boundary for the variable.

upperfloat or ndarray, optional

Upper boundary for the variable.

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.

aliasstr, optional

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

set_design_var_options(name, lower=UNDEFINED, upper=UNDEFINED, scaler=UNDEFINED, adder=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED)

Set options for design vars in the model.

Can be used to set the options outside of setting them when calling add_design_var

Parameters:
namestr

Name of the variable in this system’s namespace.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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.

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.

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.

set_initial_values()

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

set_input_defaults(name, val=UNDEFINED, units=None, src_shape=None)

Specify metadata to be assumed when multiple inputs are promoted to the same name.

Parameters:
namestr

Promoted input name.

valobject

Value to assume for the promoted input.

unitsstr or None

Units to assume for the promoted input.

src_shapeint or tuple

Assumed shape of any connected source or higher level promoted input.

set_objective_options(name, ref=UNDEFINED, ref0=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for objectives in the model.

Can be used to set options after they have been set by add_objective.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

aliasstr

Alias for this response. Used to disambiguate variable names when adding multiple objectives on different indices or slices of a single variable. Deprecated.

set_order(new_order)

Specify a new execution order for subsystems in this group.

Parameters:
new_orderlist of str

List of system names in desired new execution order.

set_output_solver_options(name, lower=UNDEFINED, upper=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED, res_ref=UNDEFINED)

Set solver output options.

Allows the user to set output solver options after the output has been defined and metadata set using the add_ouput method.

Parameters:
namestr

Name of the variable in this system’s namespace.

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.

set_solver_print(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(name, val, units=None, indices=None)

Set an input or output variable.

Parameters:
namestr

Promoted or relative variable name in the system’s namespace.

valobject

Value to assign to this variable.

unitsstr, optional

Units of the value.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to set.

setup()[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(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.

Yields:
type or None
property under_approx

Return True if under complex step or finite difference.

Returns:
bool

True if under CS or FD.

use_fixed_coloring(coloring=<object object>, 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: ImplicitComponent

Define connection with an explicit equation.

__init__(**kwargs)

Store some bound methods so we can detect runtime overrides.

abs_meta_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names and their metadata for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str, dict
abs_name_iter(iotype, local=True, cont=True, discrete=False)

Iterate over absolute variable names for this System.

By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.

Parameters:
iotypestr

Either ‘input’ or ‘output’.

localbool

If True, include only names of local variables. Default is True.

contbool

If True, include names of continuous variables. Default is True.

discretebool

If True, include names of discrete variables. Default is False.

Yields:
str
add_constraint(name, lower=None, upper=None, equals=None, ref=None, ref0=None, adder=None, scaler=None, units=None, indices=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a constraint variable to this system.

Parameters:
namestr

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 alternative to using ref and ref0.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

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. The arguments (lower, upper, equals) can not be strings or variable names.

add_design_var(name, lower=None, upper=None, ref=None, ref0=None, indices=None, adder=None, scaler=None, units=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False)

Add a design variable to this system.

Parameters:
namestr

Promoted name of the design variable in the system.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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 an input 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.

unitsstr, optional

Units to convert to before applying scaling.

parallel_deriv_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

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(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(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(name, val=1.0, shape=None, units=None, desc='', tags=None, shape_by_conn=False, copy_shape=None, compute_shape=None, require_connection=False, distributed=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 val is not an array. Default is None.

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.

shape_by_connbool

If True, shape this input to match its connected output.

copy_shapestr or None

If a str, that str is the name of a variable. Shape this input to match that of the named variable.

compute_shapefunction

A function taking a dict arg containing names and shapes of this component’s outputs and returning the shape of this input.

require_connectionbool

If True and this input is not a design variable, it must be connected to an output.

distributedbool

If True, this variable is a distributed variable, so it can have different sizes/values across MPI processes.

Returns:
dict

Metadata for added variable.

add_objective(name, ref=None, ref0=None, index=None, units=None, adder=None, scaler=None, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=False, alias=None)

Add a response variable to this system.

Parameters:
namestr

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr

Alias for this response. Necessary when adding multiple objectives on different indices or slices of a single variable.

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(name, val=1.0, **kwargs)

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.

**kwargsdict

Keyword args to store. The value corresponding to each key is a dict containing the metadata for the input name that matches that key.

Returns:
dict

Metadata for added variable.

add_recorder(recorder, recurse=False)

Add a recorder to the system.

Parameters:
recorder<CaseRecorder>

A recorder instance.

recursebool

Flag indicating if the recorder should be added to all the subsystems.

add_residual(name, shape=(1,), units=None, desc='', ref=None)

Add a residual variable to the component.

Note that the total size of the residual vector must match the total size of the outputs vector for this component.

Parameters:
namestr

Name of the residual in this component’s namespace.

shapeint or tuple

Shape of this residual.

unitsstr or None

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

descstr

Description of the residual.

reffloat or ndarray or None

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

Returns:
dict

Metadata for the added residual.

add_response(name, type_, lower=None, upper=None, equals=None, ref=None, ref0=None, indices=None, index=None, units=None, adder=None, scaler=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=None, alias=None)

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:
namestr

Promoted name of the response variable in the system.

type_str

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.

unitsstr, optional

Units to convert to before applying scaling.

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_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

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.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr or None

Alias for this response. Necessary when adding multiple responses on different indices of the same variable.

apply_linear(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(inputs, outputs, residuals)[source]

Don’t solve; just calculate the residual.

best_partial_deriv_direction()

Return the best direction for partial deriv calculations based on input and output sizes.

Returns:
str

The best direction for derivative calculations, ‘fwd’ or ‘rev’.

check_config(logger)

Perform optional error checks.

Parameters:
loggerobject

The object that manages logging output.

check_subjac_sparsity()

Check the declared sparsity of the sub-jacobians vs. the computed sparsity.

property checking

Return True if check_partials or check_totals is executing.

Returns:
bool

True if we’re running within check_partials or check_totals.

cleanup()

Clean up resources prior to exit.

property comm

Return the MPI communicator object for the system.

Returns:
MPI.Comm

MPI communicator object.

comm_info_iter()

Yield comm size for this system and all subsystems.

Yields:
tuple

A tuple of the form (abs_name, comm_size).

compute(inputs, outputs)[source]

This is a dummy comp that doesn’t modify its state.

compute_sparsity()

Compute the sparsity of the partial jacobian.

Returns:
coo_matrix

The sparsity matrix.

dict

Metadata about the sparsity computation.

convert2units(name, val, units)

Convert the given value to the specified units.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_from_units(name, val, units)

Convert the given value from the specified units to those of the named variable.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

unitsstr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

convert_units(name, val, units_from, units_to)

Wrap the utility convert_units and give a good error message.

Parameters:
namestr

Name of the variable.

valfloat or ndarray of float

The value of the variable.

units_fromstr

The units to convert from.

units_tostr

The units to convert to.

Returns:
float or ndarray of float

The value converted to the specified units.

declare_coloring(wrt=('*',), method='fd', form=None, step=None, per_instance=True, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, min_improve_pct=5.0, 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.

min_improve_pctfloat

If coloring does not improve (decrease) the number of solves more than the given percentage, coloring will not be used.

show_summarybool

If True, display summary information after generating coloring.

show_sparsitybool

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

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

Declare information about this component’s subjacobians.

Parameters:
ofstr or iter of str

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

wrtstr or iter 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.

formstr

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

step_calcstr

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value.

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

Returns:
dict

Metadata dict for the specified partial(s).

dist_size_iter(io, top_comm)

Yield names and distributed ranges of all local and remote variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

top_commMPI.Comm or None

The top-level MPI communicator.

Yields:
tuple

A tuple of the form ((abs_name, rank), start, end).

get_coloring_fname(mode)

Return the full pathname to a coloring file.

Parameters:
modestr

The type of coloring file desired. Must be either ‘input’ or ‘output’.

Returns:
pathlib.Path

Full pathname of the coloring file.

get_constraints(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each constraint.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The constraints defined in the current system.

get_design_vars(recurse=True, get_sizes=True, use_prom_ivc=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 of a group 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.

use_prom_ivcbool

Use promoted names for inputs, else convert to absolute source names.

Returns:
dict

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

get_io_metadata(iotypes=('input', 'output'), metadata_keys=None, includes=None, excludes=None, is_indep_var=None, is_design_var=None, tags=None, get_remote=False, rank=None, return_rel_names=True)

Retrieve metadata for a filtered list of variables.

Parameters:
iotypesstr or iter of str

Will contain either ‘input’, ‘output’, or both. Defaults to both.

metadata_keysiter of str or None

Names of metadata entries to be retrieved or None, meaning retrieve all available ‘allprocs’ metadata. If ‘val’ or ‘src_indices’ are required, their keys must be provided explicitly since they are not found in the ‘allprocs’ metadata and must be retrieved from local metadata located in each process.

includesstr, iter of str or None

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all variables.

excludesstr, iter of str or None

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

tagsstr or iter 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.

get_remotebool

If True, retrieve variables from other MPI processes as well.

rankint or None

If None, and get_remote is True, retrieve values from all MPI process to all other MPI processes. Otherwise, if get_remote is True, retrieve values from all MPI processes only to the specified rank.

return_rel_namesbool

If True, the names returned will be relative to the scope of this System. Otherwise they will be absolute names.

Returns:
dict

A dict of metadata keyed on name, where name is either absolute or relative based on the value of the return_rel_names arg, and metadata is a dict containing entries based on the value of the metadata_keys arg. Every metadata dict will always contain two entries, ‘prom_name’ and ‘discrete’, to indicate a given variable’s promoted name and whether or not it is discrete.

get_linear_vectors()

Return the linear inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals): tuple of <Vector> instances

Yields the linear inputs, outputs, and residuals vectors.

get_nonlinear_vectors()

Return the inputs, outputs, and residuals vectors.

Returns:
(inputs, outputs, residuals)

Yields the inputs, outputs, and residuals nonlinear vectors.

get_objectives(recurse=True, get_sizes=True, use_prom_ivc=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.

get_sizesbool, optional

If True, compute the size of each objective.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

The objectives defined in the current system.

get_outputs_dir(*subdirs, mkdir=True)

Get the path under which all output files of this system are to be placed.

Parameters:
*subdirsstr

Subdirectories nested under the relevant problem output directory. To create {prob_output_dir}/a/b one would pass system.get_outputs_dir(‘a’, ‘b’).

mkdirbool

If True, attempt to create this directory if it does not exist.

Returns:
pathlib.Path

The path of the outputs directory for the problem.

get_promotions(inprom=None, outprom=None)

Return all promotions for the given promoted variable(s).

In other words, how and where did promotions occur to convert absolute variable names into the given promoted name(s) at the current System level.

Parameters:
inpromstr or None

The promoted input variable name.

outpromstr or None

The promoted output variable name.

Returns:
dict

Dictionary keyed on system pathname containing input and/or output promotion lists for each System where promotions occurred to produce the given promoted variable(s).

get_reports_dir()

Get the path to the directory where the report files should go.

If it doesn’t exist, it will be created.

Returns:
str

The path to the directory where reports should be written.

get_responses(recurse=True, get_sizes=True, use_prom_ivc=False)

Get the response variable settings from this system.

Retrieve all response variable settings from the system as a dict, keyed by either absolute variable name, promoted name, or alias name, depending on the value of use_prom_ivc and whether the original key was a promoted output, promoted input, or an alias.

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.

use_prom_ivcbool

Translate ivc names to their promoted input names.

Returns:
dict

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

get_self_statics()

Override this in derived classes if compute_primal references static values.

Do NOT include self._discrete_inputs in the returned tuple. Include things like self.options[‘opt_name’], etc., that are used in compute_primal but are assumed to be constant during derivative computation.

Return value MUST be a tuple. Don’t forget the trailing comma if tuple has only one item. Return value MUST be hashable.

The order of these values doesn’t matter. They are only checked (by computing their hash) to see if they have changed since the last time compute_primal was jitted, and if so, compute_primal will be re-jitted.

Returns:
tuple

Tuple containing all static values required by compute_primal.

get_source(name)

Return the source variable connected to the given named variable.

The name can be a promoted name or an absolute name. If the given variable is an input, the absolute name of the connected source will be returned. If the given variable itself is a source, its own absolute name will be returned.

Parameters:
namestr

Absolute or promoted name of the variable.

Returns:
str

The absolute name of the source variable.

get_val(name, units=None, indices=None, get_remote=False, rank=None, vec_name='nonlinear', kind=None, flat=False, from_src=True)

Get an output/input/residual 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 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 or None

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. If False, only retrieve the value if it is on the current process, or only the part of the value that’s on the current process for a distributed variable. If None and the variable is remote or distributed, a RuntimeError will be raised.

rankint or None

If not None, only gather the value to this rank.

vec_namestr

Name of the vector to use. Defaults to ‘nonlinear’.

kindstr or None

Kind of variable (‘input’, ‘output’, or ‘residual’). If None, returned value will be either an input or output.

flatbool

If True, return the flattened version of the value.

from_srcbool

If True, retrieve value of an input variable from its connected source.

Returns:
object

The value of the requested output/input variable.

get_var_dup_info(name, io)

Return information about how the given variable is duplicated across MPI processes.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
tuple

A tuple of the form (is_duplicated, num_zeros, is_distributed).

get_var_sizes(name, io)

Return the sizes of the given variable on all procs.

Parameters:
namestr

Name of the variable.

iostr

Either ‘input’ or ‘output’.

Returns:
ndarray

Array of sizes of the variable on all procs.

guess_nonlinear(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()

Perform any one-time initialization run at instantiation.

is_explicit()

Return True if this is an explicit component.

Returns:
bool

True if this is an explicit component.

property linear_solver

Get the linear solver for this system.

linearize(inputs, outputs, J)[source]

Analytical derivatives.

list_inputs(val=True, prom_name=True, units=False, shape=False, global_shape=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of input names and other optional information to a specified stream.

Parameters:
valbool, 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 True.

unitsbool, optional

When True, display/return units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global shape of the value. Default is False.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all input variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all ranks. Default is False, which will display output only from rank 0.

out_streamfile-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the input value is an array, print its smallest value.

print_maxbool

When true, if the input value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of input names and other optional information about those inputs.

list_outputs(explicit=True, implicit=True, val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of output names and other optional information to a specified stream.

Parameters:
explicitbool, optional

Include outputs from explicit components. Default is True.

implicitbool, optional

Include outputs from implicit components. Default is True.

valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. 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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

list_vars(val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')

Write a list of inputs and outputs sorted by component in execution order.

Parameters:
valbool, optional

When True, display output values. Default is True.

prom_namebool, optional

When True, display the promoted name of the variable. Default is True.

residualsbool, optional

When True, display 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 units. Default is False.

shapebool, optional

When True, display/return the shape of the value. Default is False.

global_shapebool, optional

When True, display/return the global 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.

descbool, optional

When True, display/return description. Default is False.

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.

print_tagsbool

When true, display tags in the columnar display.

includesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.

excludesNone, str, or iter of str

Collection of glob patterns for pathnames of variables to exclude. Default is None.

is_indep_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.

is_design_varbool or None

If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.

all_procsbool, optional

When True, display output on all processors. Default is False.

list_autoivcsbool

If True, include auto_ivc outputs in the listing. Defaults to False.

out_streamfile-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

print_minbool

When true, if the output value is an array, print its smallest value.

print_maxbool

When true, if the output value is an array, print its largest value.

return_formatstr

Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.

Returns:
list of (name, metadata) or dict of {name: metadata}

List or dict of output names and other optional information about those outputs.

load_case(case)

Pull all input and output variables from a Case into this System.

Override this method if the System requires special handling when loading a case.

Parameters:
caseCase or dict

A Case from a CaseReader, or a dictionary with key ‘inputs’ mapped to the output of problem.model.list_inputs and key ‘outputs’ mapped to the output of prob.model.list_outputs. Both list_inputs and list_outputs should be called with prom_name=True and return_format=’dict’.

load_model_options()

Load the relevant model options from Problem._metadata[‘model_options’].

This method examines each path filter and corresponding options in self._problem_meta[‘model_options’]. If this System’s pathname matches the given path filter, it will assume the value for each given option which it possesses.

local_range_iter(io)

Yield names and local ranges of all local variables in this system.

Parameters:
iostr

Either ‘input’ or ‘output’.

Yields:
tuple

A tuple of the form (abs_name, start, end).

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 nonlinear_solver

Get the nonlinear solver for this system.

record_iteration()

Record an iteration of the current System.

run_apply_linear(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:
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()

Compute residuals.

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

run_linearize(sub_do_ln=True)

Compute jacobian / factorization.

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

Parameters:
sub_do_lnbool

Flag indicating if the children should call linearize on their linear solvers.

run_solve_linear(mode)

Apply inverse jac product.

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

Parameters:
modestr

‘fwd’ or ‘rev’.

run_solve_nonlinear()

Compute outputs.

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

set_check_partial_options(wrt, method='fd', form=None, step=None, step_calc=None, minimum_step=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

Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value..

minimum_stepfloat

Minimum step size allowed when using one of the relative step_calc options.

directionalbool

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

set_constraint_options(name, ref=UNDEFINED, ref0=UNDEFINED, equals=UNDEFINED, lower=UNDEFINED, upper=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for constraints in the model.

Can be used to set options that were set using add_constraint.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

equalsfloat or ndarray, optional

Equality constraint value for the variable.

lowerfloat or ndarray, optional

Lower boundary for the variable.

upperfloat or ndarray, optional

Upper boundary for the variable.

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.

aliasstr, optional

Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.

set_design_var_options(name, lower=UNDEFINED, upper=UNDEFINED, scaler=UNDEFINED, adder=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED)

Set options for design vars in the model.

Can be used to set the options outside of setting them when calling add_design_var

Parameters:
namestr

Name of the variable in this system’s namespace.

lowerfloat or ndarray, optional

Lower boundary for the input.

upperupper or ndarray, optional

Upper boundary for the input.

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.

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.

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.

set_objective_options(name, ref=UNDEFINED, ref0=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)

Set options for objectives in the model.

Can be used to set options after they have been set by add_objective.

Parameters:
namestr

Name of the response variable in the system, or alias if given.

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.

aliasstr

Alias for this response. Used to disambiguate variable names when adding multiple objectives on different indices or slices of a single variable. Deprecated.

set_output_solver_options(name, lower=UNDEFINED, upper=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED, res_ref=UNDEFINED)

Set solver output options.

Allows the user to set output solver options after the output has been defined and metadata set using the add_ouput method.

Parameters:
namestr

Name of the variable in this system’s namespace.

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.

set_solver_print(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(name, val, units=None, indices=None)

Set an input or output variable.

Parameters:
namestr

Promoted or relative variable name in the system’s namespace.

valobject

Value to assign to this variable.

unitsstr, optional

Units of the value.

indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional

Indices or slice to set.

setup()[source]

Declare inputs and outputs.

Available attributes:

name pathname comm options

setup_partials()[source]

Declare partials.

This is meant to be overridden by component classes. All partials should be declared here since this is called after all size/shape information is known for all variables.

setup_residuals()

User hook for adding named residuals to this component.

solve_linear(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(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(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.

Yields:
type or None
property under_approx

Return True if under complex step or finite difference.

Returns:
bool

True if under CS or FD.

use_fixed_coloring(coloring=<object object>, 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.