Skip to content

Instantly share code, notes, and snippets.

@bbrelje
Created April 18, 2020 18:04
Show Gist options
  • Save bbrelje/f1d8af3b3665f3c7fa04ade4ce084193 to your computer and use it in GitHub Desktop.
Save bbrelje/f1d8af3b3665f3c7fa04ade4ce084193 to your computer and use it in GitHub Desktop.
import openmdao.api as om
prob = om.Problem()
model = prob.model
model.add_subsystem('p1', om.IndepVarComp('x', 1.0))
model.add_subsystem('p2', om.IndepVarComp('x', 1.0))
parallel = model.add_subsystem('parallel', om.ParallelGroup())
parallel.add_subsystem('c1', om.ExecComp(['y=-2.0*x']))
parallel.add_subsystem('c2', om.ExecComp(['y=5.0*x']))
parallel.connect('c1.y','c2.x')
model.add_subsystem('c3', om.ExecComp(['y=3.0*x1+7.0*x2']))
model.connect("parallel.c1.y", "c3.x1")
model.connect("parallel.c2.y", "c3.x2")
model.connect("p1.x", "parallel.c1.x")
# model.connect("p2.x", "parallel.c2.x")
prob.setup(check=True, mode='fwd')
prob.run_model()
print(prob['c3.y'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment