meta_model_structured_comp.py

Define the RegularGridInterpComp class.

class openmdao.components.meta_model_structured_comp.MetaModelStructured(*args, **kwargs)[source]

Bases: openmdao.components.meta_model_structured_comp.MetaModelStructuredComp

Deprecated.

__init__(*args, **kwargs)[source]

Capture Initialize to throw warning.

Parameters:
*args : list

Deprecated arguments.

**kwargs : dict

Deprecated arguments.

add_constraint(name, lower=None, upper=None, equals=None, ref=None, ref0=None, adder=None, scaler=None, indices=None, linear=False, parallel_deriv_color=None, vectorize_derivs=False, cache_linear_solution=False)

Add a constraint variable to this system.

Parameters:
name : string

Name of the response variable in the system.

lower : float or ndarray, optional

Lower boundary for the variable

upper : float or ndarray, optional

Upper boundary for the variable

equals : float or ndarray, optional

Equality constraint value for the variable

ref : float or ndarray, optional

Value of response variable that scales to 1.0 in the driver.

ref0 : float or ndarray, optional

Value of response variable that scales to 0.0 in the driver.

adder : float or ndarray, optional

Value to add to the model value to get the scaled value. Adder is first in precedence.

scaler : float or ndarray, optional

value to multiply the model value to get the scaled value. Scaler is second in precedence.

indices : sequence 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.

linear : bool

Set to True if constraint is linear. Default is False.

parallel_deriv_color : string

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

vectorize_derivs : bool

If True, vectorize derivative calculations.

cache_linear_solution : bool

If True, store the linear solution vectors for this variable so they can be used to start the next linear solution with an initial guess equal to the solution from the previous linear solve.

Notes

The response can be scaled using ref and ref0. The argument ref0 represents the physical value when the scaled value is 0. The argument ref represents the physical value when the scaled value is 1.

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

Add a design variable to this system.

Parameters:
name : string

Name of the design variable in the system.

lower : float or ndarray, optional

Lower boundary for the param

upper : upper or ndarray, optional

Upper boundary for the param

ref : float or ndarray, optional

Value of design var that scales to 1.0 in the driver.

ref0 : float or ndarray, optional

Value of design var that scales to 0.0 in the driver.

indices : iter of int, optional

If a param is an array, these indicate which entries are of interest for this particular design variable. These may be positive or negative integers.

adder : float or ndarray, optional

Value to add to the model value to get the scaled value. Adder is first in precedence.

scaler : float or ndarray, optional

value to multiply the model value to get the scaled value. Scaler is second in precedence.

parallel_deriv_color : string

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

vectorize_derivs : bool

If True, vectorize derivative calculations.

cache_linear_solution : bool

If True, store the linear solution vectors for this variable so they can be used to start the next linear solution with an initial guess equal to the solution from the previous linear solve.

Notes

The response can be scaled using ref and ref0. The argument ref0 represents the physical value when the scaled value is 0. The argument ref represents the physical value when the scaled value is 1.

add_discrete_input(name, val, desc='')

Add a discrete input variable to the component.

Parameters:
name : str

name of the variable in this component’s namespace.

val : a picklable object

The initial value of the variable being added.

desc : str

description of the variable

Returns:
dict

metadata for added variable

add_discrete_output(name, val, desc='')

Add an output variable to the component.

Parameters:
name : str

name of the variable in this component’s namespace.

val : a picklable object

The initial value of the variable being added.

desc : str

description of the variable.

Returns:
dict

metadata for added variable

add_input(name, val=1.0, training_data=None, **kwargs)

Add an input to this component and a corresponding training input.

Parameters:
name : string

Name of the input.

val : float or ndarray

Initial value for the input.

training_data : ndarray

training data sample points for this input variable.

**kwargs : dict

Additional agruments for add_input.

add_objective(name, ref=None, ref0=None, index=None, adder=None, scaler=None, parallel_deriv_color=None, vectorize_derivs=False, cache_linear_solution=False)

Add a response variable to this system.

Parameters:
name : string

Name of the response variable in the system.

ref : float or ndarray, optional

Value of response variable that scales to 1.0 in the driver.

ref0 : float or ndarray, optional

Value of response variable that scales to 0.0 in the driver.

index : int, 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.

adder : float or ndarray, optional

Value to add to the model value to get the scaled value. Adder is first in precedence.

scaler : float or ndarray, optional

value to multiply the model value to get the scaled value. Scaler is second in precedence.

parallel_deriv_color : string

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

vectorize_derivs : bool

If True, vectorize derivative calculations.

cache_linear_solution : bool

If True, store the linear solution vectors for this variable so they can be used to start the next linear solution with an initial guess equal to the solution from the previous linear solve.

Notes

The objective can be scaled using scaler and adder, where

\[x_{scaled} = scaler(x + adder)\]

or through the use of ref/ref0, which map to scaler and adder through the equations:

\[ \begin{align}\begin{aligned}0 = scaler(ref_0 + adder)\\1 = scaler(ref + adder)\end{aligned}\end{align} \]

which results in:

\[ \begin{align}\begin{aligned}adder = -ref_0\\scaler = \frac{1}{ref + adder}\end{aligned}\end{align} \]
add_output(name, val=1.0, training_data=None, **kwargs)

Add an output to this component and a corresponding training output.

Parameters:
name : string

Name of the output.

val : float or ndarray

Initial value for the output.

training_data : ndarray

training data sample points for this output variable.

**kwargs : dict

Additional agruments for add_output.

add_recorder(recorder, recurse=False)

Add a recorder to the driver.

Parameters:
recorder : <CaseRecorder>

A recorder instance.

recurse : boolean

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, adder=None, scaler=None, linear=False, parallel_deriv_color=None, vectorize_derivs=False, cache_linear_solution=False)

Add a response variable to this system.

The response can be scaled using ref and ref0. The argument ref0 represents the physical value when the scaled value is 0. The argument ref represents the physical value when the scaled value is 1.

Parameters:
name : string

Name of the response variable in the system.

type_ : string

The type of response. Supported values are ‘con’ and ‘obj’

lower : float or ndarray, optional

Lower boundary for the variable

upper : upper or ndarray, optional

Upper boundary for the variable

equals : equals or ndarray, optional

Equality constraint value for the variable

ref : float or ndarray, optional

Value of response variable that scales to 1.0 in the driver.

ref0 : upper or ndarray, optional

Value of response variable that scales to 0.0 in the driver.

indices : sequence of int, optional

If variable is an array, these indicate which entries are of interest for this particular response.

index : int, optional

If variable is an array, this indicates which entry is of interest for this particular response.

adder : float or ndarray, optional

Value to add to the model value to get the scaled value. Adder is first in precedence.

scaler : float or ndarray, optional

value to multiply the model value to get the scaled value. Scaler is second in precedence.

linear : bool

Set to True if constraint is linear. Default is False.

parallel_deriv_color : string

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

vectorize_derivs : bool

If True, vectorize derivative calculations.

cache_linear_solution : bool

If True, store the linear solution vectors for this variable so they can be used to start the next linear solution with an initial guess equal to the solution from the previous linear solve.

check_config(logger)

Perform optional error checks.

Parameters:
logger : object

The object that manages logging output.

cleanup()

Clean up resources prior to exit.

compute(inputs, outputs)

Perform the interpolation at run time.

Parameters:
inputs : Vector

unscaled, dimensional input variables read via inputs[key]

outputs : Vector

unscaled, dimensional output variables read via outputs[key]

compute_jacvec_product(inputs, d_inputs, d_outputs, mode)

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:
inputs : Vector

unscaled, dimensional input variables read via inputs[key]

d_inputs : Vector

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

d_outputs : Vector

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

mode : str

either ‘fwd’ or ‘rev’

compute_partials(inputs, partials)

Collect computed partial derivatives and return them.

Checks if the needed derivatives are cached already based on the inputs vector. Refreshes the cache by re-computing the current point if necessary.

Parameters:
inputs : Vector

unscaled, dimensional input variables read via inputs[key]

partials : Jacobian

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

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

Declare information about this component’s subjacobians.

Parameters:
of : str or list of str

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

wrt : str or list of str

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

dependent : bool(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.

rows : ndarray of int or None

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

cols : ndarray of int or None

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

val : float 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.

method : str

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

step : float

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

form : string

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

step_calc : string

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

distributed

Provide ‘distributed’ property for backwards compatibility.

Returns:
bool

reference to the ‘distributed’ option.

get_constraints(recurse=True)

Get the Constraint settings from this system.

Retrieve the constraint settings for the current system as a dict, keyed by variable name.

Parameters:
recurse : bool, optional

If True, recurse through the subsystems and return the path of all constraints relative to the this system.

Returns:
dict

The constraints defined in the current system.

get_design_vars(recurse=True, get_sizes=True)

Get the DesignVariable settings from this system.

Retrieve all design variable settings from the system and, if recurse is True, all of its subsystems.

Parameters:
recurse : bool

If True, recurse through the subsystems and return the path of all design vars relative to the this system.

get_sizes : bool, optional

If True, compute the size of each response.

Returns:
dict

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

get_linear_vectors(vec_name='linear')

Return the linear inputs, outputs, and residuals vectors.

Parameters:
vec_name : str

Name of the linear right-hand-side vector. The default is ‘linear’.

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

Yields the inputs, outputs, and residuals linear vectors for vec_name.

get_nonlinear_vectors()

Return the inputs, outputs, and residuals vectors.

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

Yields the inputs, outputs, and residuals nonlinear vectors.

get_objectives(recurse=True)

Get the Objective settings from this system.

Retrieve all objectives settings from the system as a dict, keyed by variable name.

Parameters:
recurse : bool, optional

If True, recurse through the subsystems and return the path of all objective relative to the this system.

Returns:
dict

The objectives defined in the current system.

get_responses(recurse=True, get_sizes=True)

Get the response variable settings from this system.

Retrieve all response variable settings from the system as a dict, keyed by variable name.

Parameters:
recurse : bool, optional

If True, recurse through the subsystems and return the path of all responses relative to the this system.

get_sizes : bool, optional

If True, compute the size of each response.

Returns:
dict

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

initialize()

Initialize the component.

is_active()

Determine if the system is active on this rank.

Returns:
bool

If running under MPI, returns True if this System has a valid communicator. Always returns True if not running under MPI.

linear_solver

Get the linear solver for this system.

list_inputs(values=True, units=False, hierarchical=True, print_arrays=False, out_stream=<object object>)

Return and optionally log a list of input names and other optional information.

If the model is parallel, only the local variables are returned to the process. Also optionally logs the information to a user defined output stream. If the model is parallel, the rank 0 process logs information about all variables across all processes.

Parameters:
values : bool, optional

When True, display/return input values. Default is True.

units : bool, optional

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

hierarchical : bool, optional

When True, human readable output shows variables in hierarchical format.

print_arrays : bool, optional

When False, in the columnar display, just display norm of any ndarrays with size > 1. The norm is surrounded by vertical bars to indicate that it is a norm. When True, also display full values of the ndarray below the row. Format is affected by the values set with numpy.set_printoptions Default is False.

out_stream : file-like object

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

Returns:
list

list of input names and other optional information about those inputs

list_outputs(explicit=True, implicit=True, values=True, prom_name=False, residuals=False, residuals_tol=None, units=False, shape=False, bounds=False, scaling=False, hierarchical=True, print_arrays=False, out_stream=<object object>)

Return and optionally log a list of output names and other optional information.

If the model is parallel, only the local variables are returned to the process. Also optionally logs the information to a user defined output stream. If the model is parallel, the rank 0 process logs information about all variables across all processes.

Parameters:
explicit : bool, optional

include outputs from explicit components. Default is True.

implicit : bool, optional

include outputs from implicit components. Default is True.

values : bool, optional

When True, display/return output values. Default is True.

prom_name : bool, optional

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

residuals : bool, optional

When True, display/return residual values. Default is False.

residuals_tol : float, 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.

units : bool, optional

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

shape : bool, optional

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

bounds : bool, optional

When True, display/return bounds (lower and upper). Default is False.

scaling : bool, optional

When True, display/return scaling (ref, ref0, and res_ref). Default is False.

hierarchical : bool, optional

When True, human readable output shows variables in hierarchical format.

print_arrays : bool, optional

When False, in the columnar display, just display norm of any ndarrays with size > 1. The norm is surrounded by vertical bars to indicate that it is a norm. When True, also display full values of the ndarray below the row. Format is affected by the values set with numpy.set_printoptions Default is False.

out_stream : file-like

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

Returns:
list

list of output names and other optional information about those outputs

ln_solver

Get the linear solver for this system.

metadata

Get the options for this System.

nl_solver

Get the nonlinear solver for this system.

nonlinear_solver

Get the nonlinear solver for this system.

reconfigure()

Perform reconfiguration.

Returns:
bool

If True, reconfiguration is to be performed.

record_iteration()

Record an iteration of the current System.

resetup(setup_mode='full')

Public wrapper for _setup that reconfigures after an initial setup has been performed.

Parameters:
setup_mode : str

Must be one of ‘full’, ‘reconf’, or ‘update’.

run_apply_linear(vec_names, mode, scope_out=None, scope_in=None)

Compute jac-vec product.

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

Parameters:
vec_names : [str, …]

list of names of the right-hand-side vectors.

mode : str

‘fwd’ or ‘rev’.

scope_out : set or None

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

scope_in : set 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_ln : boolean

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

run_solve_linear(vec_names, mode)

Apply inverse jac product.

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

Parameters:
vec_names : [str, …]

list of names of the right-hand-side vectors.

mode : str

‘fwd’ or ‘rev’.

Returns:
boolean

Failure flag; True if failed to converge, False is successful.

float

relative error.

float

absolute error.

run_solve_nonlinear()

Compute outputs.

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

Returns:
boolean

Failure flag; True if failed to converge, False is successful.

float

relative error.

float

absolute error.

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

Set options that will be used for checking partial derivatives.

Parameters:
wrt : str 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.

method : str

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

form : str

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

step : float

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

step_calc : str

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

set_initial_values()

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

setup()

Declare inputs and outputs.

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_self : bool

If True, include this system in the iteration.

recurse : bool

If True, iterate over the whole tree under this system.

typ : type

If not None, only yield Systems that match that are instances of the given type.

class openmdao.components.meta_model_structured_comp.MetaModelStructuredComp(**kwargs)[source]

Bases: openmdao.core.explicitcomponent.ExplicitComponent

Interpolation Component generated from data on a regular grid.

Produces smooth fits through provided training data using polynomial splines of order 1 (linear), 3 (cubic), or 5 (quintic). Analytic derivatives are automatically computed.

For multi-dimensional data, fits are computed on a separable per-axis basis. If a particular dimension does not have enough training data points to support a selected spline order (e.g. 3 sample points, but an order 5 quintic spline is specified) the order of the fitted spline with be automatically reduced for that dimension alone.

Extrapolation is supported, but disabled by default. It can be enabled via initialization attribute (see below).

Attributes

interps (dict) Dictionary of interpolations for each output.
params (list) List containing training data for each input.
pnames (list) Cached list of input names.
sh (tuple) Cached shape of the gradient of the outputs wrt the training inputs.
training_outputs (dict) Dictionary of training data each output.
__init__(**kwargs)[source]

Initialize all attributes.

Parameters:
**kwargs : dict of keyword arguments

Keyword arguments that will be mapped into the Component options.

add_constraint(name, lower=None, upper=None, equals=None, ref=None, ref0=None, adder=None, scaler=None, indices=None, linear=False, parallel_deriv_color=None, vectorize_derivs=False, cache_linear_solution=False)

Add a constraint variable to this system.

Parameters:
name : string

Name of the response variable in the system.

lower : float or ndarray, optional

Lower boundary for the variable

upper : float or ndarray, optional

Upper boundary for the variable

equals : float or ndarray, optional

Equality constraint value for the variable

ref : float or ndarray, optional

Value of response variable that scales to 1.0 in the driver.

ref0 : float or ndarray, optional

Value of response variable that scales to 0.0 in the driver.

adder : float or ndarray, optional

Value to add to the model value to get the scaled value. Adder is first in precedence.

scaler : float or ndarray, optional

value to multiply the model value to get the scaled value. Scaler is second in precedence.

indices : sequence 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.

linear : bool

Set to True if constraint is linear. Default is False.

parallel_deriv_color : string

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

vectorize_derivs : bool

If True, vectorize derivative calculations.

cache_linear_solution : bool

If True, store the linear solution vectors for this variable so they can be used to start the next linear solution with an initial guess equal to the solution from the previous linear solve.

Notes

The response can be scaled using ref and ref0. The argument ref0 represents the physical value when the scaled value is 0. The argument ref represents the physical value when the scaled value is 1.

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

Add a design variable to this system.

Parameters:
name : string

Name of the design variable in the system.

lower : float or ndarray, optional

Lower boundary for the param

upper : upper or ndarray, optional

Upper boundary for the param

ref : float or ndarray, optional

Value of design var that scales to 1.0 in the driver.

ref0 : float or ndarray, optional

Value of design var that scales to 0.0 in the driver.

indices : iter of int, optional

If a param is an array, these indicate which entries are of interest for this particular design variable. These may be positive or negative integers.

adder : float or ndarray, optional

Value to add to the model value to get the scaled value. Adder is first in precedence.

scaler : float or ndarray, optional

value to multiply the model value to get the scaled value. Scaler is second in precedence.

parallel_deriv_color : string

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

vectorize_derivs : bool

If True, vectorize derivative calculations.

cache_linear_solution : bool

If True, store the linear solution vectors for this variable so they can be used to start the next linear solution with an initial guess equal to the solution from the previous linear solve.

Notes

The response can be scaled using ref and ref0. The argument ref0 represents the physical value when the scaled value is 0. The argument ref represents the physical value when the scaled value is 1.

add_discrete_input(name, val, desc='')

Add a discrete input variable to the component.

Parameters:
name : str

name of the variable in this component’s namespace.

val : a picklable object

The initial value of the variable being added.

desc : str

description of the variable

Returns:
dict

metadata for added variable

add_discrete_output(name, val, desc='')

Add an output variable to the component.

Parameters:
name : str

name of the variable in this component’s namespace.

val : a picklable object

The initial value of the variable being added.

desc : str

description of the variable.

Returns:
dict

metadata for added variable

add_input(name, val=1.0, training_data=None, **kwargs)[source]

Add an input to this component and a corresponding training input.

Parameters:
name : string

Name of the input.

val : float or ndarray

Initial value for the input.

training_data : ndarray

training data sample points for this input variable.

**kwargs : dict

Additional agruments for add_input.

add_objective(name, ref=None, ref0=None, index=None, adder=None, scaler=None, parallel_deriv_color=None, vectorize_derivs=False, cache_linear_solution=False)

Add a response variable to this system.

Parameters:
name : string

Name of the response variable in the system.

ref : float or ndarray, optional

Value of response variable that scales to 1.0 in the driver.

ref0 : float or ndarray, optional

Value of response variable that scales to 0.0 in the driver.

index : int, 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.

adder : float or ndarray, optional

Value to add to the model value to get the scaled value. Adder is first in precedence.

scaler : float or ndarray, optional

value to multiply the model value to get the scaled value. Scaler is second in precedence.

parallel_deriv_color : string

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

vectorize_derivs : bool

If True, vectorize derivative calculations.

cache_linear_solution : bool

If True, store the linear solution vectors for this variable so they can be used to start the next linear solution with an initial guess equal to the solution from the previous linear solve.

Notes

The objective can be scaled using scaler and adder, where

\[x_{scaled} = scaler(x + adder)\]

or through the use of ref/ref0, which map to scaler and adder through the equations:

\[ \begin{align}\begin{aligned}0 = scaler(ref_0 + adder)\\1 = scaler(ref + adder)\end{aligned}\end{align} \]

which results in:

\[ \begin{align}\begin{aligned}adder = -ref_0\\scaler = \frac{1}{ref + adder}\end{aligned}\end{align} \]
add_output(name, val=1.0, training_data=None, **kwargs)[source]

Add an output to this component and a corresponding training output.

Parameters:
name : string

Name of the output.

val : float or ndarray

Initial value for the output.

training_data : ndarray

training data sample points for this output variable.

**kwargs : dict

Additional agruments for add_output.

add_recorder(recorder, recurse=False)

Add a recorder to the driver.

Parameters:
recorder : <CaseRecorder>

A recorder instance.

recurse : boolean

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, adder=None, scaler=None, linear=False, parallel_deriv_color=None, vectorize_derivs=False, cache_linear_solution=False)

Add a response variable to this system.

The response can be scaled using ref and ref0. The argument ref0 represents the physical value when the scaled value is 0. The argument ref represents the physical value when the scaled value is 1.

Parameters:
name : string

Name of the response variable in the system.

type_ : string

The type of response. Supported values are ‘con’ and ‘obj’

lower : float or ndarray, optional

Lower boundary for the variable

upper : upper or ndarray, optional

Upper boundary for the variable

equals : equals or ndarray, optional

Equality constraint value for the variable

ref : float or ndarray, optional

Value of response variable that scales to 1.0 in the driver.

ref0 : upper or ndarray, optional

Value of response variable that scales to 0.0 in the driver.

indices : sequence of int, optional

If variable is an array, these indicate which entries are of interest for this particular response.

index : int, optional

If variable is an array, this indicates which entry is of interest for this particular response.

adder : float or ndarray, optional

Value to add to the model value to get the scaled value. Adder is first in precedence.

scaler : float or ndarray, optional

value to multiply the model value to get the scaled value. Scaler is second in precedence.

linear : bool

Set to True if constraint is linear. Default is False.

parallel_deriv_color : string

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

vectorize_derivs : bool

If True, vectorize derivative calculations.

cache_linear_solution : bool

If True, store the linear solution vectors for this variable so they can be used to start the next linear solution with an initial guess equal to the solution from the previous linear solve.

check_config(logger)

Perform optional error checks.

Parameters:
logger : object

The object that manages logging output.

cleanup()

Clean up resources prior to exit.

compute(inputs, outputs)[source]

Perform the interpolation at run time.

Parameters:
inputs : Vector

unscaled, dimensional input variables read via inputs[key]

outputs : Vector

unscaled, dimensional output variables read via outputs[key]

compute_jacvec_product(inputs, d_inputs, d_outputs, mode)

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:
inputs : Vector

unscaled, dimensional input variables read via inputs[key]

d_inputs : Vector

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

d_outputs : Vector

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

mode : str

either ‘fwd’ or ‘rev’

compute_partials(inputs, partials)[source]

Collect computed partial derivatives and return them.

Checks if the needed derivatives are cached already based on the inputs vector. Refreshes the cache by re-computing the current point if necessary.

Parameters:
inputs : Vector

unscaled, dimensional input variables read via inputs[key]

partials : Jacobian

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

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

Declare information about this component’s subjacobians.

Parameters:
of : str or list of str

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

wrt : str or list of str

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

dependent : bool(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.

rows : ndarray of int or None

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

cols : ndarray of int or None

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

val : float 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.

method : str

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

step : float

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

form : string

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

step_calc : string

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

distributed

Provide ‘distributed’ property for backwards compatibility.

Returns:
bool

reference to the ‘distributed’ option.

get_constraints(recurse=True)

Get the Constraint settings from this system.

Retrieve the constraint settings for the current system as a dict, keyed by variable name.

Parameters:
recurse : bool, optional

If True, recurse through the subsystems and return the path of all constraints relative to the this system.

Returns:
dict

The constraints defined in the current system.

get_design_vars(recurse=True, get_sizes=True)

Get the DesignVariable settings from this system.

Retrieve all design variable settings from the system and, if recurse is True, all of its subsystems.

Parameters:
recurse : bool

If True, recurse through the subsystems and return the path of all design vars relative to the this system.

get_sizes : bool, optional

If True, compute the size of each response.

Returns:
dict

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

get_linear_vectors(vec_name='linear')

Return the linear inputs, outputs, and residuals vectors.

Parameters:
vec_name : str

Name of the linear right-hand-side vector. The default is ‘linear’.

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

Yields the inputs, outputs, and residuals linear vectors for vec_name.

get_nonlinear_vectors()

Return the inputs, outputs, and residuals vectors.

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

Yields the inputs, outputs, and residuals nonlinear vectors.

get_objectives(recurse=True)

Get the Objective settings from this system.

Retrieve all objectives settings from the system as a dict, keyed by variable name.

Parameters:
recurse : bool, optional

If True, recurse through the subsystems and return the path of all objective relative to the this system.

Returns:
dict

The objectives defined in the current system.

get_responses(recurse=True, get_sizes=True)

Get the response variable settings from this system.

Retrieve all response variable settings from the system as a dict, keyed by variable name.

Parameters:
recurse : bool, optional

If True, recurse through the subsystems and return the path of all responses relative to the this system.

get_sizes : bool, optional

If True, compute the size of each response.

Returns:
dict

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

initialize()[source]

Initialize the component.

is_active()

Determine if the system is active on this rank.

Returns:
bool

If running under MPI, returns True if this System has a valid communicator. Always returns True if not running under MPI.

linear_solver

Get the linear solver for this system.

list_inputs(values=True, units=False, hierarchical=True, print_arrays=False, out_stream=<object object>)

Return and optionally log a list of input names and other optional information.

If the model is parallel, only the local variables are returned to the process. Also optionally logs the information to a user defined output stream. If the model is parallel, the rank 0 process logs information about all variables across all processes.

Parameters:
values : bool, optional

When True, display/return input values. Default is True.

units : bool, optional

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

hierarchical : bool, optional

When True, human readable output shows variables in hierarchical format.

print_arrays : bool, optional

When False, in the columnar display, just display norm of any ndarrays with size > 1. The norm is surrounded by vertical bars to indicate that it is a norm. When True, also display full values of the ndarray below the row. Format is affected by the values set with numpy.set_printoptions Default is False.

out_stream : file-like object

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

Returns:
list

list of input names and other optional information about those inputs

list_outputs(explicit=True, implicit=True, values=True, prom_name=False, residuals=False, residuals_tol=None, units=False, shape=False, bounds=False, scaling=False, hierarchical=True, print_arrays=False, out_stream=<object object>)

Return and optionally log a list of output names and other optional information.

If the model is parallel, only the local variables are returned to the process. Also optionally logs the information to a user defined output stream. If the model is parallel, the rank 0 process logs information about all variables across all processes.

Parameters:
explicit : bool, optional

include outputs from explicit components. Default is True.

implicit : bool, optional

include outputs from implicit components. Default is True.

values : bool, optional

When True, display/return output values. Default is True.

prom_name : bool, optional

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

residuals : bool, optional

When True, display/return residual values. Default is False.

residuals_tol : float, 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.

units : bool, optional

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

shape : bool, optional

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

bounds : bool, optional

When True, display/return bounds (lower and upper). Default is False.

scaling : bool, optional

When True, display/return scaling (ref, ref0, and res_ref). Default is False.

hierarchical : bool, optional

When True, human readable output shows variables in hierarchical format.

print_arrays : bool, optional

When False, in the columnar display, just display norm of any ndarrays with size > 1. The norm is surrounded by vertical bars to indicate that it is a norm. When True, also display full values of the ndarray below the row. Format is affected by the values set with numpy.set_printoptions Default is False.

out_stream : file-like

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

Returns:
list

list of output names and other optional information about those outputs

ln_solver

Get the linear solver for this system.

metadata

Get the options for this System.

nl_solver

Get the nonlinear solver for this system.

nonlinear_solver

Get the nonlinear solver for this system.

reconfigure()

Perform reconfiguration.

Returns:
bool

If True, reconfiguration is to be performed.

record_iteration()

Record an iteration of the current System.

resetup(setup_mode='full')

Public wrapper for _setup that reconfigures after an initial setup has been performed.

Parameters:
setup_mode : str

Must be one of ‘full’, ‘reconf’, or ‘update’.

run_apply_linear(vec_names, mode, scope_out=None, scope_in=None)

Compute jac-vec product.

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

Parameters:
vec_names : [str, …]

list of names of the right-hand-side vectors.

mode : str

‘fwd’ or ‘rev’.

scope_out : set or None

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

scope_in : set 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_ln : boolean

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

run_solve_linear(vec_names, mode)

Apply inverse jac product.

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

Parameters:
vec_names : [str, …]

list of names of the right-hand-side vectors.

mode : str

‘fwd’ or ‘rev’.

Returns:
boolean

Failure flag; True if failed to converge, False is successful.

float

relative error.

float

absolute error.

run_solve_nonlinear()

Compute outputs.

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

Returns:
boolean

Failure flag; True if failed to converge, False is successful.

float

relative error.

float

absolute error.

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

Set options that will be used for checking partial derivatives.

Parameters:
wrt : str 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.

method : str

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

form : str

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

step : float

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

step_calc : str

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

set_initial_values()

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

setup()

Declare inputs and outputs.

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_self : bool

If True, include this system in the iteration.

recurse : bool

If True, iterate over the whole tree under this system.

typ : type

If not None, only yield Systems that match that are instances of the given type.

exception openmdao.components.meta_model_structured_comp.OutOfBoundsError(message, idx, value, lower, upper)[source]

Bases: Exception

Handles error when interpolated values are requested outside of the domain of the input data.

Attributes

idx (int) index of the variable that is out of bounds.
value (double) value of the variable that is out of bounds.
lower (double) lower bounds of the variable that is out of bounds.
upper (double) upper bounds of the variable that is out of bounds.
__init__(message, idx, value, lower, upper)[source]

Initialize instance of OutOfBoundsError class.

Parameters:
message : str

description of error.

idx : int

index of the variable that is out of bounds.

value : double

value of the variable that is out of bounds.

lower : double

lower bounds of the variable that is out of bounds.

upper : double

upper bounds of the variable that is out of bounds.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.