Exemple #1
0
    def test_sellar(self):

        prob = Problem()
        prob.root = SellarNoDerivatives()
        prob.root.nl_solver = Newton()

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

        assert_rel_error(self, prob['y1'], 25.58830273, .00001)
        assert_rel_error(self, prob['y2'], 12.05848819, .00001)

        # Make sure we aren't iterating like crazy
        self.assertLess(prob.root.nl_solver.iter_count, 8)
Exemple #2
0
    def test_sellar_analysis_error(self):

        prob = Problem()
        prob.root = SellarNoDerivatives()
        prob.root.nl_solver = NLGaussSeidel()
        prob.root.nl_solver.options['maxiter'] = 2
        prob.root.nl_solver.options['err_on_maxiter'] = True

        prob.setup(check=False)

        try:
            prob.run()
        except AnalysisError as err:
            self.assertEqual(str(err), "Solve in '': NLGaussSeidel FAILED to converge after 2 iterations")
        else:
            self.fail("expected AnalysisError")
Exemple #3
0
    def test_sellar_with_Aitken(self):
        # This test makes sure the Aitken acc. feature is working correctly

        prob = Problem()
        prob.root = SellarNoDerivatives()
        prob.root.nl_solver = NLGaussSeidel()

        prob.root.nl_solver.options['use_aitken'] = True
        prob.root.cycle.set_order(['d1', 'd2'])

        prob.setup(check=False)
        prob.run()
        
        # check the Aitken relaxation factor value
        assert_rel_error(self, prob.root.nl_solver.aitken_alpha, 0.980998467864, .00001)
        
        # check that the problem converges in 4 iters (1 less than w/o Aitken)
        self.assertTrue(prob.root.nl_solver.iter_count == 4)
Exemple #4
0
    def test_sellar_utol(self):

        prob = Problem()
        prob.root = SellarNoDerivatives()
        prob.root.nl_solver = NLGaussSeidel()

        prob.setup(check=False)

        # make sure we trigger convergence from utol
        prob.root.nl_solver.options['rtol'] = 1e-99
        prob.root.nl_solver.options['atol'] = 1e-99
        prob.root.nl_solver.options['utol'] = 1e-6

        prob.run()

        assert_rel_error(self, prob['y1'], 25.58830273, .00001)
        assert_rel_error(self, prob['y2'], 12.05848819, .00001)

        # Make sure we aren't iterating like crazy
        self.assertLess(prob.root.nl_solver.iter_count, 8)
Exemple #5
0
    def test_sellar(self):

        prob = Problem()
        prob.root = SellarNoDerivatives()
        prob.root.nl_solver = NLGaussSeidel()

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

        assert_rel_error(self, prob['y1'], 25.58830273, .00001)
        assert_rel_error(self, prob['y2'], 12.05848819, .00001)

        # Make sure we aren't iterating like crazy
        self.assertLess(prob.root.nl_solver.iter_count, 8)

        # Make sure we only call apply_linear on 'heads'
        nd1 = prob.root.cycle.d1.execution_count
        nd2 = prob.root.cycle.d2.execution_count
        if prob.root.cycle.d1._run_apply == True:
            self.assertEqual(nd1, 2 * nd2)
        else:
            self.assertEqual(2 * nd1, nd2)