Note

This feature requires MPI, and may not be able to be run on Colab.

Parallel Groups

When systems are added to a ParallelGroup, they will be executed in parallel, assuming that the ParallelGroup is given an MPI communicator of sufficient size. Adding subsystems to a ParallelGroup is no different than adding them to a normal Group. For example:

%%px

import openmdao.api as om

prob = om.Problem()
model = prob.model

model.set_input_defaults('x', 1.)

parallel = model.add_subsystem('parallel', om.ParallelGroup(), 
                               promotes_inputs=[('c1.x', 'x'), ('c2.x', 'x'), 
                                                ('c3.x', 'x'), ('c4.x', 'x')])
parallel.add_subsystem('c1', om.ExecComp(['y=-2.0*x']))
parallel.add_subsystem('c2', om.ExecComp(['y=5.0*x']))
parallel.add_subsystem('c3', om.ExecComp(['y=-3.0*x']))
parallel.add_subsystem('c4', om.ExecComp(['y=4.0*x']))

model.add_subsystem('c5', om.ExecComp(['y=3.0*x1 + 7.0*x2 - 2.0*x3 + x4']))

model.connect("parallel.c1.y", "c5.x1")
model.connect("parallel.c2.y", "c5.x2")
model.connect("parallel.c3.y", "c5.x3")
model.connect("parallel.c4.y", "c5.x4")

prob.setup(check=False, mode='fwd')
prob.run_model()

print(prob['c5.y'])
[stdout:0] [39.]
[stdout:1] [39.]
[stdout:2] [39.]
[stdout:3] [39.]