OM Tools Group¶
- class omtools.core.group.Group(**kwargs)¶
The
omtools.Group
class buildsopenmdao.Component
objects from Python-like expressions and adds their corresponding subsystems by constructing stockopenmdao.Component
objects.In
self.setup
, first, the user declares inputs, writes expressions, and registers outputs. Afterself.setup
runs,self
builds a Directed Acyclic Graph (DAG) from registered outputs, analyzes the DAG to determine execution order, and adds the appropriate subsystems.In addition to supporting an expression-based style of defining a subsystem,
omtools.Group
also supports adding a subystem defined using a subclass ofomtools.Group
oropenmdao.System
.The
omtools.Group
class only allows for expressions that define explicit relationships. For defining models that use implicit relationships and defining residuals, seeomtools.ImplicitGroup
.- add_subsystem(name: str, subsys: openmdao.core.system.System, promotes: Optional[collections.abc.Iterable] = None, promotes_inputs: Optional[collections.abc.Iterable] = None, promotes_outputs: Optional[collections.abc.Iterable] = None)¶
Add a subsystem to the
Group
.self.add_subsystem
call must be preceded by a call toself.register_output
for each of the subsystem’s inputs, and followed byself.declare_input
for each of the subsystem’s outputs.- Parameters
- name: str
Name of subsystem
- subsys: System
Subsystem to add to Group
- promotes: Iterable
Variables to promote
- promotes_inputs: Iterable
Inputs to promote
- promotes_outputs: Iterable
Outputs to promote
- Returns
- System
Subsystem to add to Group
- create_group(name: str)¶
Create a
Group
object and add as a subsystem, promoting all inputs and outputs. For use inwith
contexts. NOTE: Only use if planning to promote all varaibales within childGroup
object.- Parameters
- name: str
Name of new child
Group
object
- Returns
- Group
Child
Group
object whosevariables are all promoted
- create_implicit_output(name: str, shape: Tuple[int] = (1), val=1) → omtools.core.implicit_output.ImplicitOutput¶
Create a value that is computed implicitly
- Parameters
- name: str
Name of variable in OpenMDAO to be computed by an
ImplicitComponent
- shape: Tuple[int]
Shape of variable
- Returns
- ImplicitOutput
An object to use in expressions
- create_indep_var(name: str, shape: Tuple[int] = (1), val=1, dv: bool = False) → omtools.core.indep.Indep¶
Create a value that is constant during model evaluation
- Parameters
- name: str
Name of variable in OpenMDAO to be computed by
ExplicitComponent
objects connected in a cycle, or by anExplicitComponent
that concatenates variables- shape: Tuple[int]
Shape of variable
- val: Number or ndarray
Value for variable during first model evaluation
- dv: bool
Flag to set design variable
- Returns
- Indep
An object to use in expressions
- create_output(name: str, shape: Tuple[int] = (1), val=1) → omtools.core.explicit_output.ExplicitOutput¶
Create a value that is computed explicitly
- Parameters
- name: str
Name of variable in OpenMDAO to be computed by
ExplicitComponent
objects connected in a cycle, or by anExplicitComponent
that concatenates variables- shape: Tuple[int]
Shape of variable
- Returns
- ExplicitOutput
An object to use in expressions
- declare_input(name: str, shape: Tuple[int] = (1), val=1) → omtools.core.input.Input¶
Declare an input to use in an expression.
An input can be an output of a child
System
. If the user declares an input that is computed by a childSystem
, then the call toself.declare_input
must appear after the call toself.add_subsystem
.- Parameters
- name: str
Name of variable in OpenMDAO to be used as an input in generated
Component
objects- shape: Tuple[int]
Shape of variable
- val: Number or ndarray
Default value for variable
- Returns
- Input
An object to use in expressions
- initialize(*args, **kwargs)¶
User defined method to set options
- register_output(name: str, expr: omtools.core.explicit_output.ExplicitOutput) → omtools.core.explicit_output.ExplicitOutput¶
Register
expr
as an output of theGroup
. When adding subsystems, each of the subsystem’s inputs requires a call toregister_output
prior to the call toadd_subsystem
.- Parameters
- name: str
Name of variable in OpenMDAO
- expr: Variable
Variable that computes output
- Returns
- Variable
Variable that computes output
- setup()¶
User defined method to define expressions and add subsystems for model execution