Setup Your Model

After you have built a model by defining variables and components, organizing them into a hierarchy, and connecting them together you then need to call the setup() method to have the framework do some initialization work in preparation for execution. You can control some details of that initialization with the arguments that you pass into setup(), and it is important to note that you cannot set or get any variable values, nor run until after you call setup().

Problem.setup(check=False, logger=None, mode='auto', force_alloc_complex=False, distributed_vector_class=<class 'openmdao.vectors.petsc_vector.PETScVector'>, local_vector_class=<class 'openmdao.vectors.default_vector.DefaultVector'>, derivatives=True)[source]

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, boolean, list of strings, or the string ‘all’

Determines what config checks, if any, are run after setup is complete. If None or False, no checks are run If True, the default checks (‘out_of_order’, ‘system’, ‘solvers’, ‘dup_inputs’, ‘missing_recorders’, ‘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’, ‘out_of_order’, ‘promotions’, ‘solvers’, ‘system’, ‘unconnected_inputs’) are run

loggerobject

Object for logging config checks if check is True.

modestring

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

Force allocation of imaginary part in nonlinear vectors. OpenMDAO can generally detect when you need to do this, but in some cases (e.g., complex step is used after a reconfiguration) you may need to set this to True.

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.

Returns
self<Problem>

this enables the user to instantiate and setup in one line.