meta_model.py¶
Metamodel provides basic Meta Modeling capability.
-
class
openmdao.components.meta_model.
MetaModel
[source]¶ Bases:
openmdao.core.component.Component
Class that creates a reduced order model for outputs from parameters. Each output may have it’s own surrogate model. Training inputs and outputs are automatically created with ‘train:’ prepended to the corresponding parameter/output name.
For a Float variable, the training data is an array of length m.
Options: deriv_options[‘type’] : str(‘user’)
Derivative calculation type (‘user’, ‘fd’, ‘cs’) Default is ‘user’, where derivative is calculated from user-supplied derivatives. Set to ‘fd’ to finite difference this system. Set to ‘cs’ to perform the complex step if your components support it.
deriv_options[‘form’] : str(‘forward’)
Finite difference mode. (forward, backward, central)
deriv_options[‘step_size’] : float(1e-06)
Default finite difference stepsize
deriv_options[‘step_calc’] : str(‘absolute’)
Set to absolute, relative
deriv_options[‘check_type’] : str(‘fd’)
Type of derivative check for check_partial_derivatives. Set to ‘fd’ to finite difference this system. Set to ‘cs’ to perform the complex step method if your components support it.
deriv_options[‘check_form’] : str(‘forward’)
Finite difference mode: (“forward”, “backward”, “central”) During check_partial_derivatives, the difference form that is used for the check.
deriv_options[‘check_step_calc’] : str(‘absolute’,)
Set to ‘absolute’ or ‘relative’. Default finite difference step calculation for the finite difference check in check_partial_derivatives.
deriv_options[‘check_step_size’] : float(1e-06)
Default finite difference stepsize for the finite difference check in check_partial_derivatives”
deriv_options[‘linearize’] : bool(False)
Set to True if you want linearize to be called even though you are using FD.
-
add_output
(name, val=<object object>, training_data=None, **kwargs)[source]¶ Add an output to this component and a corresponding training output.
Args: name : string
Name of the variable output.
val : float or ndarray
Initial value for the output. While the value is overwritten during execution, it is useful for infering size.
training_data : float or ndarray
training data for this variable. Optional, can be set by the problem later.
-
add_param
(name, val=<object object>, training_data=None, **kwargs)[source]¶ Add a param input to this component and a corresponding training parameter.
Args: name : string
Name of the input.
val : float or ndarray or object
Initial value for the input.
training_data : float or ndarray
training data for this variable. Optional, can be set by the problem later.
-
check_setup
(out_stream=<open file '<stdout>', mode 'w'>)[source]¶ Write a report to the given stream indicating any potential problems found with the current configuration of this
MetaModel
.Args: out_stream : a file-like object, optional
-
linearize
(params, unknowns, resids)[source]¶ - Returns the Jacobian as a dictionary whose keys are tuples of the form
- (‘unknown’, ‘param’) and whose values are ndarrays.
Args: params : VecWrapper
VecWrapper containing parameters. (p)
unknowns : VecWrapper
VecWrapper containing outputs and states. (u)
resids : VecWrapper
VecWrapper containing residuals. (r)
Returns: dict
Dictionary whose keys are tuples of the form (‘unknown’, ‘param’) and whose values are ndarrays.
-
solve_nonlinear
(params, unknowns, resids)[source]¶ Predict outputs. If the training flag is set, train the metamodel first.
Args: params : VecWrapper, optional
VecWrapper containing parameters. (p)
unknowns : VecWrapper, optional
VecWrapper containing outputs and states. (u)
resids : VecWrapper, optional
VecWrapper containing residuals. (r)
-