Exemple #1
0
    def test_assert_no_dict_jacobians_exception_expected(self):

        prob = Problem()
        prob.model = SellarNoDerivativesCS()

        prob.setup(check=False)

        try:
            assert_no_dict_jacobians(prob.model, include_self=True, recurse=True)

        except AssertionError as err:
            expected_err = "The following groups use dictionary jacobians:\n    \n    cycle"
            self.assertEqual(str(err), expected_err)
        else:
            self.fail('Exception expected.')
    def test_assert_no_dict_jacobians_exception_expected(self):

        prob = Problem()
        prob.model = SellarNoDerivativesCS()

        prob.setup(check=False)
        prob.model.cycle._jacobian = DictionaryJacobian(prob.model.cycle)

        try:
            assert_no_dict_jacobians(prob.model, include_self=True, recurse=True)

        except AssertionError as err:
            expected_err = "The following groups use dictionary jacobians:\n\n    cycle"
            self.assertEqual(str(err), expected_err)
        else:
            self.fail('Exception expected.')
Exemple #3
0
    def test_assert_no_dict_jacobians_exception_not_expected(self):

        model = Group()
        ivc = IndepVarComp()
        ivc.add_output('x', 3.0)
        ivc.add_output('y', -4.0)
        model.add_subsystem('des_vars', ivc)
        model.add_subsystem('parab_comp', Paraboloid())

        model.connect('des_vars.x', 'parab_comp.x')
        model.connect('des_vars.y', 'parab_comp.y')

        prob = Problem(model)
        prob.model.jacobian = DenseJacobian()

        prob.setup(check=False)

        assert_no_dict_jacobians(prob.model, include_self=True, recurse=True)
Exemple #4
0
    def test_assert_no_dict_jacobians_exception_not_expected(self):

        model = om.Group(assembled_jac_type='dense')
        ivc = om.IndepVarComp()
        ivc.add_output('x', 3.0)
        ivc.add_output('y', -4.0)
        model.add_subsystem('des_vars', ivc)
        model.add_subsystem('parab_comp', Paraboloid())

        model.connect('des_vars.x', 'parab_comp.x')
        model.connect('des_vars.y', 'parab_comp.y')

        prob = om.Problem(model)
        prob.model.linear_solver = om.DirectSolver(assemble_jac=True)

        prob.setup()

        assert_no_dict_jacobians(prob.model, include_self=True, recurse=True)
    def test_assert_no_dict_jacobians_exception_not_expected(self):

        model = Group(assembled_jac_type='dense')
        ivc = IndepVarComp()
        ivc.add_output('x', 3.0)
        ivc.add_output('y', -4.0)
        model.add_subsystem('des_vars', ivc)
        model.add_subsystem('parab_comp', Paraboloid())

        model.connect('des_vars.x', 'parab_comp.x')
        model.connect('des_vars.y', 'parab_comp.y')

        prob = Problem(model)
        prob.model.linear_solver = DirectSolver(assemble_jac=True)

        prob.setup(check=False)

        assert_no_dict_jacobians(prob.model, include_self=True, recurse=True)