Exemplo n.º 1
0
    def test_get_ordered_comps(self):
        from openmdao.core.component import Component
        p = _make_tree_model()
        p.setup()
        p.run_model()
        ordered_names = list(p.model._ordered_comp_name_iter())
        self.assertEqual(ordered_names, [
            '_auto_ivc', 'G1.G2.C1', 'G1.G2.C2', 'G3.C3', 'G3.C4', 'par.G4.C5',
            'par.G4.C6', 'par.G5.C7', 'par.G5.C8', 'C9'
        ])
        locnames = [
            s.pathname
            for s in p.model.system_iter(recurse=True, typ=Component)
        ]
        if p.model.comm.rank == 0:
            self.assertEqual(locnames, [
                '_auto_ivc', 'G1.G2.C1', 'G1.G2.C2', 'G3.C3', 'G3.C4',
                'par.G4.C5', 'par.G4.C6', 'C9'
            ])
        else:
            self.assertEqual(locnames, [
                '_auto_ivc', 'G1.G2.C1', 'G1.G2.C2', 'G3.C3', 'G3.C4',
                'par.G5.C7', 'par.G5.C8', 'C9'
            ])


if __name__ == "__main__":
    from openmdao.utils.mpi import mpirun_tests
    mpirun_tests()
Exemplo n.º 2
0
    N_PROCS = 4

    def test_matmat(self):
        indep_var_comp = IndepVarComp()
        indep_var_comp.add_output('alpha', 2.2)

        indep_var_comp.add_output('shape', 0., shape=8*12*2)
        indep_var_comp.add_output('twist', 0., shape=8-1)

        prob = Problem()
        prob.model.add_subsystem('indep_var_comp', indep_var_comp, promotes=['*'])
        prob.model.add_subsystem('adflow_comp', ADFLOWComp(), promotes=['*'])

        prob.model.add_design_var('shape', lower=-2., upper=2., scaler=100.)
        prob.model.add_design_var('twist', lower=-8., upper=8.)
        prob.model.add_design_var('alpha', lower=-5., upper=5.)
        prob.model.add_objective('cd')
        prob.model.add_constraint('cl', equals=.5)
        prob.model.add_constraint('thickness', lower=.5, upper=5., vectorize_derivs=True)

        prob.setup(mode='rev')

        # this will hang if the bug is present.
        prob.compute_totals(of=['cd', 'cl', 'thickness'],
                            wrt=['shape', 'twist', 'alpha'])


if __name__ == "__main__":
    from openmdao.utils.mpi import mpirun_tests
    mpirun_tests()