group.py

Defines the base class for a Group in OpenMDAO.

class openmdao.core.group.Group[source]

Bases: openmdao.core.system.System

A system that contains other systems.

Options:

fd_options[‘force_fd’] : bool(False)

Set to True to finite difference this system.

fd_options[‘form’] : str(‘forward’)

Finite difference mode. (forward, backward, central) You can also set to ‘complex_step’ to peform the complex step method if your components support it.

fd_options[‘step_size’] : float(1e-06)

Default finite difference stepsize

fd_options[‘step_type’] : str(‘absolute’)

Set to absolute, relative

fd_options[‘extra_check_partials_form’] : None or str

Finite difference mode: (“forward”, “backward”, “central”, “complex_step”) During check_partial_derivatives, you can optionally do a second finite difference with a different mode.

fd_options[‘linearize’] : bool(False)

Set to True if you want linearize to be called even though you are using FD.

add(name, system, promotes=None)[source]

Add a subsystem to this group, specifying its name and any variables that it promotes to the parent level.

Args:

name : str

The name by which the subsystem is to be known.

system : System

The subsystem to be added.

promotes : tuple, optional

The names of variables in the subsystem which are to be promoted.

apply_nonlinear(params, unknowns, resids, metadata=None)[source]

Evaluates the residuals of our children systems.

Args:

params : VecWrapper

VecWrapper containing parameters. (p)

unknowns : VecWrapper

VecWrapper containing outputs and states. (u)

resids : VecWrapper

VecWrapper containing residuals. (r)

metadata : dict, optional

Dictionary containing execution metadata (e.g. iteration coordinate).

children_solve_nonlinear(metadata)[source]

Loops over our children systems and asks them to solve.

Args:

metadata : dict

Dictionary containing execution metadata (e.g. iteration coordinate).

cleanup()[source]

Clean up resources prior to exit.

clear_dparams()[source]

Zeros out the dparams (dp) vector.

components(local=False, recurse=False, include_self=False)[source]
Returns:

iterator

Iterator over sub-Components.

connect(source, targets, src_indices=None)[source]

Connect the given source variable to the given target variable.

Args:

source : source

The name of the source variable.

targets : str OR iterable

The name of one or more target variables.

src_indices : index array, optional

If specified, connect the specified entries of the full distributed source value to the target.

dump(nest=0, out_stream=<open file '<stdout>', mode 'w'>, verbose=False, dvecs=False, sizes=False)[source]

Writes a formated dump of the System tree to file.

Args:

nest : int, optional

Starting nesting level. Defaults to 0.

out_stream : file-like, optional

Where output is written. Defaults to sys.stdout.

verbose : bool, optional

If True, output additional info beyond just the tree structure. Default is False.

dvecs : bool, optional

If True, show contents of du and dp vectors instead of u and p (the default).

sizes : bool, optional

If True, include vector sizes and comm sizes. Default is False.

get_req_procs()[source]
Returns:

tuple

A tuple of the form (min_procs, max_procs), indicating the min and max processors usable by this Group.

linearize(params, unknowns, resids)[source]

Linearize all our subsystems.

Args:

params : VecWrapper

VecWrapper containing parameters. (p)

unknowns : VecWrapper

VecWrapper containing outputs and states. (u)

resids : VecWrapper

VecWrapper containing residuals. (r)

list_auto_order()[source]
Returns:

list of str

Names of subsystems listed in the order that they would be executed if a manual order was not set.

list of str

Edges that where removed from the graph to allow sorting.

list_order()[source]

Lists execution order for systems in this Group.

Returns:list of str : List of system names in execution order.
set_order(new_order)[source]

Specifies a new execution order for this system. This should only be called after all subsystems have been added.

Args:

new_order : list of str

List of system names in desired new execution order.

solve_linear(dumat, drmat, vois, mode=None, solver=None)[source]

Single linear solution applied to whatever input is sitting in the rhs vector.

Args:

dumat : dict of VecWrappers

In forward mode, each VecWrapper contains the incoming vector for the states. There is one vector per quantity of interest for this problem. In reverse mode, it contains the outgoing vector for the states. (du)

drmat : dict of VecWrappers

VecWrapper containing either the outgoing result in forward mode or the incoming vector in reverse mode. There is one vector per quantity of interest for this problem. (dr)

vois: list of strings

List of all quantities of interest to key into the mats.

mode : string, optional

Derivative mode, can be ‘fwd’ or ‘rev’, but generally should be called without mode so that the user can set the mode in this system’s ln_solver.options.

solver : LinearSolver, optional

Solver to use for the linear solution on this system. If not specified, then the system’s ln_solver is used.

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

Solves the group using the nonlinear solver specified in self.nl_solver.

Args:

params : VecWrapper, optional

VecWrapper containing parameters. (p)

unknowns : VecWrapper, optional

VecWrapper containing outputs and states. (u)

resids : VecWrapper, optional

VecWrapper containing residuals. (r)

metadata : dict, optional

Dictionary containing execution metadata (e.g. iteration coordinate).

subgroups(local=False, recurse=False, include_self=False)[source]
Returns:

iterator

Iterator over subgroups.

subsystems(local=False, recurse=False, typ=<class 'openmdao.core.system.System'>, include_self=False)[source]
Args:

local : bool, optional

If True, only return those Components that are local. Default is False.

recurse : bool, optional

If True, return all Components in the system tree, subject to the value of the local arg. Default is False.

typ : type, optional

If a class is specified here, only those subsystems that are instances of that type will be returned. Default type is System.

include_self : bool, optional

If True, yield self before iterating over subsystems, assuming type of self is appropriate. Default is False.

Returns:

iterator

Iterator over subsystems.