bag.mdao.components

This module defines various OpenMDAO component classes.

Module Contents

Classes

VecFunComponent

A component based on a list of functions.

class bag.mdao.components.VecFunComponent(output_name, fun_list, params, vector_params=None)[source]

Bases: openmdao.api.Component

A component based on a list of functions.

A component that evaluates multiple functions on the given inputs, then returns the result as an 1D array. Each of the inputs may be a scalar or a vector with the same size as the output. If a vector input is given, each function will use a different element of the vector.

Parameters:
  • output_name (str) – output name.

  • fun_list (list[bag.math.dfun.DiffFunction]) – list of interpolator functions, one for each dimension.

  • params (list[str]) – list of parameter names. Parameter names may repeat, in which case the same parameter will be used for multiple arguments of the function.

  • vector_params (set[str]) – set of parameters that are vector instead of scalar. If a parameter is a vector, it will be the same size as the output, and each function only takes in the corresponding element of the parameter.

__call__(**kwargs)[source]

Evaluate on the given inputs.

Parameters:

kwargs (dict[str, np.array or float]) – the inputs as a dictionary.

Returns:

out – the output array.

Return type:

np.array

_get_inputs(params)[source]

Given parameter values, construct inputs for functions.

Parameters:

params (VecWrapper, optional) – VecWrapper containing parameters. (p)

Returns:

ans – input lists.

Return type:

list[list[float]]

solve_nonlinear(params, unknowns, resids=None)[source]

Compute the output parameter.

Parameters:
  • params (VecWrapper, optional) – VecWrapper containing parameters. (p)

  • unknowns (VecWrapper, optional) – VecWrapper containing outputs and states. (u)

  • resids (VecWrapper, optional) – VecWrapper containing residuals. (r)

linearize(params, unknowns=None, resids=None)[source]

Compute the Jacobian of the parameter.

Parameters:
  • params (VecWrapper, optional) – VecWrapper containing parameters. (p)

  • unknowns (VecWrapper, optional) – VecWrapper containing outputs and states. (u)

  • resids (VecWrapper, optional) – VecWrapper containing residuals. (r)