def test_converge_diverge(self, solver, nlsolver): prob = om.Problem() prob.model = ConvergeDiverge() prob.model.linear_solver = solver() prob.model.nonlinear_solver = nlsolver() prob.setup(check=False, mode='fwd') prob.set_solver_print(level=0) prob.run_model() assert_near_equal(prob['c7.y1'], -102.7, 1e-6) indep_list = ['iv.x'] unknown_list = ['c7.y1'] J = prob.compute_totals(of=unknown_list, wrt=indep_list) assert_near_equal(J['c7.y1', 'iv.x'][0][0], -40.75, 1e-6) prob.setup(check=False, mode='rev') prob.run_model() assert_near_equal(prob['c7.y1'], -102.7, 1e-6) J = prob.compute_totals(of=unknown_list, wrt=indep_list) assert_near_equal(J['c7.y1', 'iv.x'][0][0], -40.75, 1e-6) assert_near_equal(prob['c7.y1'], -102.7, 1e-6)
def test_converge_diverge(self): prob = Problem() prob.model = ConvergeDiverge() prob.setup(check=False, mode='fwd') prob.set_solver_print(level=0) prob.run_model() assert_rel_error(self, prob['c7.y1'], -102.7, 1e-6) indep_list = ['iv.x'] unknown_list = ['c7.y1'] J = prob.compute_totals(of=unknown_list, wrt=indep_list) assert_rel_error(self, J['c7.y1', 'iv.x'][0][0], -40.75, 1e-6) prob.setup(check=False, mode='rev') prob.run_model() assert_rel_error(self, prob['c7.y1'], -102.7, 1e-6) J = prob.compute_totals(of=unknown_list, wrt=indep_list) assert_rel_error(self, J['c7.y1', 'iv.x'][0][0], -40.75, 1e-6) assert_rel_error(self, prob['c7.y1'], -102.7, 1e-6)