Example #1
0
    def test_simple_function(self):
        def my_func(x):
            return x * 2

        prob = om.Problem()
        prob.model.add_subsystem('f_comp', UnitaryFunctionComp(func=my_func))

        prob.setup()

        prob.set_val('f_comp.x', 5.)

        prob.run_model()
        assert_near_equal(prob.get_val('f_comp.y'), 10.)
    def test_simple_function(self):
        import openmdao.api as om
        from openmdao.test_suite.components.options_feature_function import UnitaryFunctionComp

        def my_func(x):
            return x * 2

        prob = om.Problem()
        prob.model.add_subsystem('f_comp', UnitaryFunctionComp(func=my_func))

        prob.setup()

        prob.set_val('f_comp.x', 5.)

        prob.run_model()
        assert_near_equal(prob.get_val('f_comp.y'), 10.)
    def test_simple_function(self):
        import openmdao.api as om
        from openmdao.test_suite.components.options_feature_function import UnitaryFunctionComp

        def my_func(x):
            return x*2

        prob = om.Problem()
        prob.model.add_subsystem('inputs', om.IndepVarComp('x', 1.))
        prob.model.add_subsystem('f_comp', UnitaryFunctionComp(func=my_func))
        prob.model.connect('inputs.x', 'f_comp.x')

        prob.setup()

        prob['inputs.x'] = 5.

        prob.run_model()

        assert_rel_error(self, prob['f_comp.y'], 10.)