Ejemplo n.º 1
0
    def test_converge_diverge_groups(self):
        # Test derivatives for converge-diverge-groups topology.
        prob = Problem()
        prob.model = ConvergeDivergeGroups()

        prob.model.linear_solver = LinearRunOnce()
        prob.set_solver_print(level=0)

        g1 = prob.model.g1
        g2 = g1.g2
        g3 = prob.model.g3
        g1.linear_solver = LinearRunOnce()
        g2.linear_solver = LinearRunOnce()
        g3.linear_solver = LinearRunOnce()

        prob.setup(check=False, mode='fwd')
        prob.run_model()

        wrt = ['iv.x']
        of = ['c7.y1']

        # Make sure value is fine.
        assert_rel_error(self, prob['c7.y1'], -102.7, 1e-6)

        J = prob.compute_totals(of=of, wrt=wrt, return_format='flat_dict')
        assert_rel_error(self, J['c7.y1', 'iv.x'][0][0], -40.75, 1e-6)

        prob.setup(check=False, mode='rev')
        prob.run_model()

        J = prob.compute_totals(of=of, wrt=wrt, return_format='flat_dict')
        assert_rel_error(self, J['c7.y1', 'iv.x'][0][0], -40.75, 1e-6)
Ejemplo n.º 2
0
    def test_converge_diverge_groups(self):
        # Test derivatives for converge-diverge-groups topology.
        prob = om.Problem()
        model = prob.model = ConvergeDivergeGroups()

        model.linear_solver = om.ScipyKrylov()
        model.nonlinear_solver = om.NonlinearRunOnce()

        model.g1.nonlinear_solver = om.NonlinearRunOnce()
        model.g1.g2.nonlinear_solver = om.NonlinearRunOnce()
        model.g3.nonlinear_solver = om.NonlinearRunOnce()

        prob.set_solver_print(level=0)
        prob.setup(check=False, mode='fwd')
        prob.run_model()

        # Make sure value is fine.
        assert_rel_error(self, prob['c7.y1'], -102.7, 1e-6)
Ejemplo n.º 3
0
    def test_converge_diverge_groups(self):
        # Test derivatives for converge-diverge-groups topology.
        prob = Problem()
        prob.model = ConvergeDivergeGroups()
        prob.model.linear_solver = ScipyIterativeSolver()
        prob.set_solver_print(level=0)

        prob.model.nonlinear_solver = NonLinearRunOnce()
        g1 = prob.model.get_subsystem('g1')
        g2 = g1.get_subsystem('g2')
        g3 = prob.model.get_subsystem('g3')
        g1.nonlinear_solver = NonLinearRunOnce()
        g2.nonlinear_solver = NonLinearRunOnce()
        g3.nonlinear_solver = NonLinearRunOnce()

        prob.setup(check=False, mode='fwd')
        prob.run_model()

        # Make sure value is fine.
        assert_rel_error(self, prob['c7.y1'], -102.7, 1e-6)
Ejemplo n.º 4
0
        def test_converge_diverge_groups(self):
            # Test derivatives for converge-diverge-groups topology.
            prob = Problem()
            prob.model = ConvergeDivergeGroups()
            prob.model.linear_solver = self.linear_solver_class()
            prob.set_solver_print(level=0)

            prob.setup(check=False, mode='fwd')
            prob.run_model()

            wrt = ['iv.x']
            of = ['c7.y1']

            # Make sure value is fine.
            assert_near_equal(prob['c7.y1'], -102.7, 1e-6)

            J = prob.compute_totals(of=of, wrt=wrt, return_format='flat_dict')
            assert_near_equal(J['c7.y1', 'iv.x'], [[-40.75]], 1e-6)

            prob.setup(check=False, mode='rev')
            prob.run_model()

            J = prob.compute_totals(of=of, wrt=wrt, return_format='flat_dict')
            assert_near_equal(J['c7.y1', 'iv.x'], [[-40.75]], 1e-6)