class TestSolve(reg_test_classes.RegTest): """ Tests that ADflow can change the dvs to achieve the target cl to the given tolerance. Compares the norm of the residuals, norm of states, and the functionals. based on the old regression test 10 """ N_PROCS = 2 ref_file = "solve_cl.json" def setUp(self): super().setUp() gridFile = os.path.join( baseDir, "../../input_files/mdo_tutorial_euler_scalar_jst.cgns") options = copy.copy(adflowDefOpts) options["outputdirectory"] = os.path.join(baseDir, options["outputdirectory"]) options.update({ "gridfile": gridFile, "solutionprecision": "double", "gridprecision": "double", "mgcycle": "2w", "ncyclescoarse": 250, "ncycles": 500, "usenksolver": True, "nkswitchtol": 1e-2, "l2convergence": 1e-14, "l2convergencecoarse": 1e-2, }) # Setup aeroproblem self.ap = copy.copy(ap_tutorial_wing) # Create the solver self.CFDSolver = ADFLOW(options=options, debug=False) def test_solve(self): self.CFDSolver.solveCL(self.ap, 0.475, alpha0=1.20, delta=0.025, tol=1e-4, autoReset=False) self.assert_solution_failure() funcs = {} self.CFDSolver.evalFunctions(self.ap, funcs, evalFuncs=["cl"]) self.handler.root_add_val("CL-CL*", funcs["mdo_tutorial_cl"] - 0.475, rtol=1e-4, atol=1e-4)
ap = AeroProblem(name='wing', mach=0.75, altitude=5000, alpha=1.5, areaRef=45.5, chordRef=3.25, evalFuncs=['cl','cd'] ) # ============================================================================== # Solve for a specific CL # ============================================================================== W = 50000 * 9.81 # total aircraft weight in Newtons n = 2.5 # load factor for 2.5g maneuver Sref = ap.areaRef * 2 # total reference wing area CLstar = W * n / Sref / ap.q # desired CL for load condition if MPI.COMM_WORLD.rank == 0: print('\nSolving for CL={:.5f}\n'.format(CLstar)) CFDSolver.solveCL(ap, CLstar) # ============================================================================== # Print functions and write force file # ============================================================================== funcs = {} CFDSolver.evalFunctions(ap, funcs) # Print the evaluated functions if MPI.COMM_WORLD.rank == 0: print(funcs) CFDSolver.writeForceFile('forces.txt')