def test_feature_vector(self): import openmdao.api as om from openmdao.core.tests.test_scaling import ScalingExampleVector prob = om.Problem() model = prob.model model.add_subsystem('p', om.IndepVarComp('x', np.ones((2)))) comp = model.add_subsystem('comp', ScalingExampleVector()) model.connect('p.x', 'comp.x') prob.setup() prob.run_model() model.run_apply_nonlinear() with model._scaled_context_all(): val = model.comp._residuals['y'] assert_near_equal(val[0], (1 - 200.) / 200.) assert_near_equal(val[1], (1 - 6000.) / 6000.) val = model.comp._outputs['y'] assert_near_equal(val[0], 2.0) assert_near_equal(val[1], 6.0)
def test_feature_vector(self): from openmdao.api import Problem, Group, IndepVarComp from openmdao.core.tests.test_scaling import ScalingExampleVector prob = Problem() model = prob.model = Group() model.add_subsystem('p', IndepVarComp('x', np.ones((2)))) comp = model.add_subsystem('comp', ScalingExampleVector()) model.connect('p.x', 'comp.x') prob.setup(check=False) prob.run_model() model.run_apply_nonlinear() with model._scaled_context_all(): val = model.comp._residuals['y'] assert_rel_error(self, val[0], (1 - 200.) / 200.) assert_rel_error(self, val[1], (1 - 6000.) / 6000.) val = model.comp._outputs['y'] assert_rel_error(self, val[0], 2.0) assert_rel_error(self, val[1], 6.0)