def test_fan_out_all_grouped(self): prob = Problem(impl=impl) prob.root = FanOutAllGrouped() prob.root.ln_solver = PetscKSP() prob.root.ln_solver.preconditioner = LinearGaussSeidel() prob.root.sub1.ln_solver = DirectSolver() prob.root.sub2.ln_solver = DirectSolver() prob.root.sub3.ln_solver = DirectSolver() prob.setup(check=False) prob.run() indep_list = ['p.x'] unknown_list = ['sub2.comp2.y', "sub3.comp3.y"] J = prob.calc_gradient(indep_list, unknown_list, mode='fwd', return_format='dict') assert_rel_error(self, J['sub2.comp2.y']['p.x'][0][0], -6.0, 1e-6) assert_rel_error(self, J['sub3.comp3.y']['p.x'][0][0], 15.0, 1e-6) J = prob.calc_gradient(indep_list, unknown_list, mode='rev', return_format='dict') assert_rel_error(self, J['sub2.comp2.y']['p.x'][0][0], -6.0, 1e-6) assert_rel_error(self, J['sub3.comp3.y']['p.x'][0][0], 15.0, 1e-6)
def test_fan_out_all_grouped(self): prob = Problem() prob.root = FanOutAllGrouped() prob.root.ln_solver = ScipyGMRES() prob.root.ln_solver.options['precondition'] = True prob.root.sub1.ln_solver = DirectSolver() prob.root.sub2.ln_solver = DirectSolver() prob.root.sub3.ln_solver = DirectSolver() prob.setup(check=False) prob.run() indep_list = ['p.x'] unknown_list = ['sub2.comp2.y', "sub3.comp3.y"] J = prob.calc_gradient(indep_list, unknown_list, mode='fwd', return_format='dict') assert_rel_error(self, J['sub2.comp2.y']['p.x'][0][0], -6.0, 1e-6) assert_rel_error(self, J['sub3.comp3.y']['p.x'][0][0], 15.0, 1e-6) J = prob.calc_gradient(indep_list, unknown_list, mode='rev', return_format='dict') assert_rel_error(self, J['sub2.comp2.y']['p.x'][0][0], -6.0, 1e-6) assert_rel_error(self, J['sub3.comp3.y']['p.x'][0][0], 15.0, 1e-6)