コード例 #1
0
ファイル: test_scaling.py プロジェクト: znccxl/OpenMDAO
    def test_feature3(self):
        import openmdao.api as om
        from openmdao.core.tests.test_scaling import ScalingExample3

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

        model.add_subsystem('p1', om.IndepVarComp('x1', 1.0))
        model.add_subsystem('p2', om.IndepVarComp('x2', 1.0))
        comp = model.add_subsystem('comp', ScalingExample3())
        model.connect('p1.x1', 'comp.x1')
        model.connect('p2.x2', 'comp.x2')

        prob.setup()
        prob.run_model()

        model.run_apply_nonlinear()

        with model._scaled_context_all():
            val = model.comp._residuals['y1']
            assert_near_equal(val, -.995)
            val = model.comp._residuals['y2']
            assert_near_equal(val, (1 - 6000.) / 6000.)
コード例 #2
0
ファイル: test_scaling.py プロジェクト: ardalanghadimi/ATC
    def test_feature3(self):
        from openmdao.api import Problem, Group, IndepVarComp
        from openmdao.core.tests.test_scaling import ScalingExample3

        prob = Problem()
        model = prob.model = Group()

        model.add_subsystem('p1', IndepVarComp('x1', 1.0))
        model.add_subsystem('p2', IndepVarComp('x2', 1.0))
        comp = model.add_subsystem('comp', ScalingExample3())
        model.connect('p1.x1', 'comp.x1')
        model.connect('p2.x2', 'comp.x2')

        prob.setup(check=False)
        prob.run_model()

        model.run_apply_nonlinear()

        with model._scaled_context_all():
            val = model.comp._residuals['y1']
            assert_rel_error(self, val, -.995)
            val = model.comp._residuals['y2']
            assert_rel_error(self, val, (1 - 6000.) / 6000.)