Skip to content

Commit

Permalink
added test for a system that's build in one problem then used in another
Browse files Browse the repository at this point in the history
  • Loading branch information
naylor-b committed Jun 3, 2020
1 parent d842a4b commit dbe01e8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions openmdao/core/tests/test_problem.py
Expand Up @@ -1894,5 +1894,27 @@ def solve(self):
p.run_model()


class SystemInTwoProblemsTestCase(unittest.TestCase):
def test_2problems(self):
prob = om.Problem()
G1 = prob.model.add_subsystem("G1", om.Group())
G2 = G1.add_subsystem('G2', om.Group(), promotes_inputs=['x'])
G2.add_subsystem('C1', om.ExecComp('y = 2 * x'), promotes_inputs=['x'])
G2.add_subsystem('C2', om.ExecComp('y = 3 * x'), promotes_inputs=['x'])

prob.setup()
prob.run_model()

# 2nd problem
prob = om.Problem()
prob.model = G2

prob.setup()
prob.run_model()

np.testing.assert_allclose(prob['C1.y'], 2.0)
np.testing.assert_allclose(prob['C2.y'], 3.0)


if __name__ == "__main__":
unittest.main()

0 comments on commit dbe01e8

Please sign in to comment.