problem.py

OpenMDAO Problem class defintion.

class openmdao.core.problem.Problem(root=None, driver=None, impl=None)[source]

Bases: openmdao.core.system.System

The Problem is always the top object for running an OpenMDAO model.

calc_gradient(indep_list, unknown_list, mode='auto', return_format='array')[source]

Returns the gradient for the system that is slotted in self.root. This function is used by the optimizer but also can be used for testing derivatives on your model.

Args:

indep_list : list of strings

List of independent variable names that derivatives are to be calculated with respect to. All params must have a IndepVarComp.

unknown_list : list of strings

List of output or state names that derivatives are to be calculated for. All must be valid unknowns in OpenMDAO.

mode : string, optional

Deriviative direction, can be ‘fwd’, ‘rev’, ‘fd’, or ‘auto’. Default is ‘auto’, which uses mode specified on the linear solver in root.

return_format : string, optional

Format for the derivatives, can be ‘array’ or ‘dict’.

Returns:

ndarray or dict

Jacobian of unknowns with respect to params.

check_partial_derivatives(out_stream=<open file '<stdout>', mode 'w'>)[source]

Checks partial derivatives comprehensively for all components in your model.

Args:

out_stream : file_like

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

Returns:

Dict of Dicts of Dicts

First key is the component name;

2nd key is the (output, input) tuple of strings;

third key is one of [‘rel error’, ‘abs error’, ‘magnitude’, ‘J_fd’, ‘J_fwd’, ‘J_rev’];

For ‘rel error’, ‘abs error’, ‘magnitude’ the value is:

A tuple containing norms for forward - fd, adjoint - fd, forward - adjoint using the best case fdstep

For ‘J_fd’, ‘J_fwd’, ‘J_rev’ the value is:

A numpy array representing the computed Jacobian for the three different methods of computation

check_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 Problem.

Args:

out_stream : a file-like object, optional

Stream where report will be written.

check_total_derivatives(out_stream=<open file '<stdout>', mode 'w'>)[source]

Checks total derivatives for problem defined at the top.

Args:

out_stream : file_like

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

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’]; Tuple contains

norms for forward - fd, adjoint - fd, forward - adjoint using the

best case fdstep.

run()[source]

Runs the Driver in self.driver.

setup(check=True, out_stream=<open file '<stdout>', mode 'w'>)[source]

Performs all setup of vector storage, data transfer, etc., necessary to perform calculations.

Args:

check : bool, optional

Check for potential issues after setup is complete (the default is True)

out_stream : a file-like object, optional

Stream where report will be written if check is performed.