def test_crossover(self, mode):
        # multiple crossovers in fwd and rev
        prob = om.Problem()
        model = prob.model

        model.add_subsystem('ivc', om.IndepVarComp('x'))

        par1 = model.add_subsystem('par1', om.ParallelGroup())
        par1.add_subsystem('C1', om.ExecComp('y = 1.5 * x'))
        par1.add_subsystem('C2', om.ExecComp('y = 2.5 * x'))

        model.add_subsystem('C3', om.ExecComp('y = 3.5 * x1 - .5 * x2'))

        par2 = model.add_subsystem('par2', om.ParallelGroup())
        par2.add_subsystem('C4', om.ExecComp('y = 4.5 * x'))
        par2.add_subsystem('C5', om.ExecComp('y = 5.5 * x'))

        model.add_subsystem('C6', om.ExecComp('y = 6.5 * x1 + 1.1 * x2'))

        model.connect('ivc.x', 'par1.C1.x')
        model.connect('ivc.x', 'par1.C2.x')
        model.connect('par1.C1.y', 'C3.x1')
        model.connect('par1.C2.y', 'C3.x2')
        model.connect('C3.y', 'par2.C4.x')
        model.connect('C3.y', 'par2.C5.x')
        model.connect('par2.C4.y', 'C6.x1')
        model.connect('par2.C5.y', 'C6.x2')

        of = ['C6.y']
        wrt = ['ivc.x']

        #import wingdbstub

        prob.setup(check=False, mode=mode)
        prob.set_solver_print(level=0)
        prob.run_model()

        from openmdao.devtools.debug import dump_dist_idxs
        dump_dist_idxs(prob)

        np.testing.assert_allclose(prob.get_val('C6.y', get_remote=True),
                                   141.2)

        J = prob.compute_totals(of=of, wrt=wrt)
        print(J)

        np.testing.assert_allclose(J['C6.y', 'ivc.x'][0][0], 141.2)
        np.testing.assert_allclose(prob.get_val('C6.y', get_remote=True),
                                   141.2)
Exemple #2
0
 def _dumpdist(prob):
     dump_dist_idxs(prob, vec_name=options.vecname, stream=out)
     exit()
Exemple #3
0
 def _dumpdist(prob):
     dump_dist_idxs(prob, vec_name=options.vecname, stream=out)
     exit()