class TestSolveIntegrationPlane(reg_test_classes.RegTest): """ Tests that ADflow can converge the wing from the mdo tutorial using the euler equation to the required accuracy as meassure by the norm of the residuals, and states, and the accuracy of the functions based on the old regression test Test 9: MDO tutorial -- Euler -- Solution Test """ N_PROCS = 2 options = { "gridfile": os.path.join(baseDir, "../../input_files/conic_conv_nozzle_mb.cgns"), "outputdirectory": os.path.join(baseDir, "../output_files"), # Physics Parameters "equationType": "Euler", "smoother": "DADI", "nsubiter": 3, "CFL": 4.0, "CFLCoarse": 1.25, "MGCycle": "3w", "MGStartLevel": -1, "nCyclesCoarse": 250, "nCycles": 1000, "monitorvariables": ["cpu", "resrho", "cl", "cd"], "volumevariables": ["blank"], "surfacevariables": ["mach", "cp", "vx", "vy", "vz", "blank"], "useNKSolver": True, "nkswitchtol": 0.01, "nkadpc": True, "nkjacobianlag": 5, "nkouterpreconits": 3, "nkinnerpreconits": 2, # Convergence Parameters "L2Convergence": 1e-10, "L2ConvergenceCoarse": 1e-2, "adjointl2convergence": 1e-6, "forcesAsTractions": True, "debugzipper": True, "nearwalldist": 0.001, # 'nkls':'none', "solutionprecision": "double", "adjointsubspacesize": 200, "outerpreconits": 3, "zipperSurfaceFamily": "output_fam", "flowtype": "internal", } ref_file = "solve_conic_mb.json" def setUp(self): super().setUp() self.ap = copy.copy(ap_conic_conv_nozzle) options = copy.copy(adflowDefOpts) options.update(self.options) # Setup aeroproblem planeFile = os.path.join( baseDir, "../../input_files/integration_plane_viscous.fmt") options = copy.copy(adflowDefOpts) options.update(self.options) # Setup aeroproblem self.ap.evalFuncs.extend([ "mdot_plane", "mavgptot_plane", "aavgptot_plane", "mavgttot_plane", "mavgps_plane", "aavgps_plane" ]) # Create the solver self.CFDSolver = ADFLOW(options=options, debug=False) self.CFDSolver.addIntegrationSurface(planeFile, "viscous_plane") self.CFDSolver.finalizeUserIntegrationSurfaces() self.CFDSolver.addFamilyGroup("upstream", ["inlet"]) self.CFDSolver.addFamilyGroup("downstream", ["outlet"]) self.CFDSolver.addFamilyGroup("all_flow", ["inlet", "outlet"]) self.CFDSolver.addFamilyGroup("output_fam", ["all_flow", "allWalls"]) self.CFDSolver.addFunction("mdot", "upstream", name="mdot_up") self.CFDSolver.addFunction("mdot", "downstream", name="mdot_down") self.CFDSolver.addFunction("mdot", "viscous_plane", name="mdot_plane") self.CFDSolver.addFunction("mavgptot", "downstream", name="mavgptot_down") self.CFDSolver.addFunction("mavgptot", "upstream", name="mavgptot_up") self.CFDSolver.addFunction("mavgptot", "viscous_plane", name="mavgptot_plane") self.CFDSolver.addFunction("aavgptot", "downstream", name="aavgptot_down") self.CFDSolver.addFunction("aavgptot", "upstream", name="aavgptot_up") self.CFDSolver.addFunction("aavgptot", "viscous_plane", name="aavgptot_plane") self.CFDSolver.addFunction("mavgttot", "downstream", name="mavgttot_down") self.CFDSolver.addFunction("mavgttot", "upstream", name="mavgttot_up") self.CFDSolver.addFunction("mavgttot", "viscous_plane", name="mavgttot_plane") self.CFDSolver.addFunction("mavgps", "downstream", name="mavgps_down") self.CFDSolver.addFunction("mavgps", "upstream", name="mavgps_up") self.CFDSolver.addFunction("mavgps", "viscous_plane", name="mavgps_plane") self.CFDSolver.addFunction("aavgps", "downstream", name="aavgps_down") self.CFDSolver.addFunction("aavgps", "upstream", name="aavgps_up") self.CFDSolver.addFunction("aavgps", "viscous_plane", name="aavgps_plane") def test_solve(self): # do the solve self.CFDSolver(self.ap) # check its accuracy utils.assert_functions_allclose(self.handler, self.CFDSolver, self.ap, tol=1e-9) utils.assert_states_allclose(self.handler, self.CFDSolver, tol=1e-10) utils.assert_residuals_allclose(self.handler, self.CFDSolver, self.ap, tol=1e-10)
class TestSolveOverset(reg_test_classes.RegTest): """ Tests that ADflow can converge the wing from the mdo tutorial using the euler equation to the required accuracy as meassure by the norm of the residuals, and states, and the accuracy of the functions based on the old regression test 17 and 18 """ N_PROCS = 2 options = { "gridfile": os.path.join(baseDir, "../../input_files/conic_conv_nozzle.cgns"), "outputdirectory": os.path.join(baseDir, "../output_files"), # Physics Parameters "equationType": "Euler", "smoother": "DADI", "nsubiter": 3, "CFL": 4.0, "CFLCoarse": 1.25, "MGCycle": "sg", "MGStartLevel": -1, "nCyclesCoarse": 250, "nCycles": 1000, "monitorvariables": ["cpu", "resrho", "cl", "cd"], "volumevariables": ["blank"], "surfacevariables": ["mach", "cp", "vx", "vy", "vz", "blank"], "useNKSolver": True, "nkswitchtol": 0.01, "nkadpc": True, "nkjacobianlag": 5, "nkouterpreconits": 3, "nkinnerpreconits": 2, # Convergence Parameters "L2Convergence": 1e-10, "L2ConvergenceCoarse": 1e-4, "adjointl2convergence": 1e-6, "forcesAsTractions": True, "debugzipper": True, "nearwalldist": 0.001, # 'nkls':'none', "solutionprecision": "double", "adjointsubspacesize": 200, "outerpreconits": 3, "zipperSurfaceFamily": "output_fam", "flowtype": "internal", "blocksplitting": True, } ap = copy.copy(ap_conic_conv_nozzle) ref_file = "solve_conic_overset.json" def setUp(self): super().setUp() options = copy.copy(adflowDefOpts) options.update(self.options) # Setup aeroproblem self.ap.setBCVar("Pressure", 79326.7, "downstream") self.ap.addDV("Pressure", family="downstream") self.ap.setBCVar("PressureStagnation", 100000.0, "upstream") self.ap.addDV("PressureStagnation", family="upstream") self.ap.setBCVar("TemperatureStagnation", 500.0, "upstream") self.ap.addDV("TemperatureStagnation", family="upstream") # Create the solver self.CFDSolver = ADFLOW(options=options, debug=False) self.CFDSolver.addFamilyGroup("upstream", ["inlet"]) self.CFDSolver.addFamilyGroup("downstream", ["outlet"]) self.CFDSolver.addFamilyGroup("all_flow", ["inlet", "outlet"]) self.CFDSolver.addFamilyGroup("output_fam", ["all_flow", "allWalls"]) self.CFDSolver.addFunction("mdot", "upstream", name="mdot_up") self.CFDSolver.addFunction("mdot", "downstream", name="mdot_down") self.CFDSolver.addFunction("mavgptot", "downstream", name="mavgptot_down") self.CFDSolver.addFunction("mavgptot", "upstream", name="mavgptot_up") self.CFDSolver.addFunction("aavgptot", "downstream", name="aavgptot_down") self.CFDSolver.addFunction("aavgptot", "upstream", name="aavgptot_up") self.CFDSolver.addFunction("mavgttot", "downstream", name="mavgttot_down") self.CFDSolver.addFunction("mavgttot", "upstream", name="mavgttot_up") self.CFDSolver.addFunction("mavgps", "downstream", name="mavgps_down") self.CFDSolver.addFunction("mavgps", "upstream", name="mavgps_up") self.CFDSolver.addFunction("aavgps", "downstream", name="aavgps_down") self.CFDSolver.addFunction("aavgps", "upstream", name="aavgps_up") def test_solve(self): # do the solve self.CFDSolver(self.ap) # check its accuracy utils.assert_functions_allclose(self.handler, self.CFDSolver, self.ap, tol=1e-9) utils.assert_states_allclose(self.handler, self.CFDSolver, tol=1e-10) # Check the residual res = self.CFDSolver.getResidual(self.ap) totalR0 = self.CFDSolver.getFreeStreamResidual(self.ap) res /= totalR0 reducedSum = self.CFDSolver.comm.reduce(np.sum(res**2)) if self.CFDSolver.comm.rank == 0: self.assertLessEqual(np.sqrt(reducedSum), self.options["L2Convergence"])
def setUp(self): super().setUp() self.options = { "gridfile": os.path.join(baseDir, "../../input_files/actuator_test_pipe.cgns"), # the restart file was ran with thrust = 600 N and heat = 1e5 W "restartfile": os.path.join(baseDir, "../../input_files/actuator_test_pipe.cgns"), "writevolumesolution": False, "writesurfacesolution": False, "writetecplotsurfacesolution": False, "mgcycle": "sg", "ncycles": 1000, "useanksolver": True, "usenksolver": True, "anksecondordswitchtol": 1e-2, "nkswitchtol": 1e-4, "volumevariables": ["temp", "mach", "resrho"], "surfacevariables": ["temp", "vx", "vy", "vz", "p", "ptloss", "mach", "rho"], "equationType": "Euler", "l2convergence": 1e-13, "adjointl2convergence": 1e-13, } options = copy.copy(adflowDefOpts) options["outputdirectory"] = os.path.join(baseDir, options["outputdirectory"]) options.update(self.options) CFDSolver = ADFLOW(options=options) CFDSolver.addFunction("mdot", "inlet", name="mdot_in") CFDSolver.addFunction("mdot", "outlet", name="mdot_out") CFDSolver.addFunction("aavgptot", "outlet", name="aavgptot_out") CFDSolver.addFunction("aavgptot", "inlet", name="aavgptot_in") CFDSolver.addFunction("mavgttot", "outlet", name="mavgttot_out") CFDSolver.addFunction("mavgttot", "inlet", name="mavgttot_in") CFDSolver.addFunction("aavgps", "outlet", name="aavgps_out") CFDSolver.addFunction("aavgps", "inlet", name="aavgps_in") CFDSolver.addFunction("area", "inlet", name="area_in") CFDSolver.addFunction("area", "outlet", name="area_out") CFDSolver.addFunction("mavgvx", "inlet", name="mavgvx_in") CFDSolver.addFunction("mavgvx", "outlet", name="mavgvx_out") CFDSolver.addFunction("forcexpressure", "inlet", name="forcexpressure_in") CFDSolver.addFunction("forcexpressure", "outlet", name="forcexpressure_out") CFDSolver.addFunction("forcexmomentum", "inlet", name="forcexmomentum_in") CFDSolver.addFunction("forcexmomentum", "outlet", name="forcexmomentum_out") self.CFDSolver = CFDSolver # this is imported from reg_aeroproblems utility script self.ap = ap_actuator_pipe actuatorFile = os.path.join(baseDir, "../../input_files/actuator_test_disk.xyz") self.CFDSolver.addActuatorRegion( actuatorFile, np.array([0, 0, 0]), np.array([1, 0, 0]), "actuator_region", # we will set these individually in the tests below thrust=0.0, torque=0.0, heat=0.0, ) # add thrust and heat as AP DVs self.ap.setBCVar("Thrust", 0.0, "actuator_region") self.ap.addDV("Thrust", family="actuator_region", units="N", name="thrust") self.ap.setBCVar("Heat", 0.0, "actuator_region") self.ap.addDV("Heat", family="actuator_region", units="J/s", name="heat") # also add flowpower as an AZ function CFDSolver.addFunction("flowpower", "actuator_region", name="flowpower_az")
class TestSolve(reg_test_classes.RegTest): """ Tests that ADflow can converge the wing from the mdo tutorial using the euler equation to the required accuracy as meassure by the norm of the residuals, and states, and the accuracy of the functions based on the old regresson test 16 """ N_PROCS = 2 ref_file = "solve_2D_conv_nozzle.json" options = { "gridfile": os.path.join(baseDir, "../../input_files/euler_conv_nozzle.cgns"), "solutionprecision": "double", "gridprecision": "double", "liftIndex": 2, "CFL": 3.0, "CFLCoarse": 1.5, "MGCycle": "2w", "MGStartLevel": 2, "nCyclesCoarse": 500, "nCycles": 2500, "monitorvariables": ["resrho", "cl", "cd", "yplus"], "nsubiterturb": 3, "useNKSolver": True, "NKSubSpaceSize": 60, "L2Convergence": 1e-14, "L2ConvergenceCoarse": 1e-2, "NKSwitchTol": 1e-2, "nkadpc": False, "vis4": 0.006, "vis2": 0.0, "blocksplitting": True, "solutionPrecision": "double", "flowtype": "internal", } ap = ap_2D_conv_nozzle def setUp(self): super().setUp() options = copy.copy(adflowDefOpts) options["outputdirectory"] = os.path.join(baseDir, options["outputdirectory"]) options.update(self.options) # Create the solver self.CFDSolver = ADFLOW(options=options, debug=False) self.CFDSolver.addFamilyGroup("upstream", ["INFLOW"]) self.CFDSolver.addFamilyGroup("downstream", ["OUTFLOW"]) self.CFDSolver.addFamilyGroup("all_flow", ["INFLOW", "OUTFLOW"]) self.CFDSolver.addFunction("mdot", "upstream", name="mdot_up") self.CFDSolver.addFunction("mdot", "downstream", name="mdot_down") self.CFDSolver.addFunction("mavgptot", "downstream", name="mavgptot_down") self.CFDSolver.addFunction("mavgptot", "upstream", name="mavgptot_up") self.CFDSolver.addFunction("aavgptot", "downstream", name="aavgptot_down") self.CFDSolver.addFunction("aavgptot", "upstream", name="aavgptot_up") self.CFDSolver.addFunction("mavgttot", "downstream", name="mavgttot_down") self.CFDSolver.addFunction("mavgttot", "upstream", name="mavgttot_up") self.CFDSolver.addFunction("mavgps", "downstream", name="mavgps_down") self.CFDSolver.addFunction("mavgps", "upstream", name="mavgps_up") self.CFDSolver.addFunction("aavgps", "downstream", name="aavgps_down") self.CFDSolver.addFunction("aavgps", "upstream", name="aavgps_up") self.CFDSolver.addFunction("mavgmn", "downstream", name="mavgmn_down") self.CFDSolver.addFunction("mavgmn", "upstream", name="mavgmn_up") self.CFDSolver.addFunction("drag", "all_flow", name="thrust") # this naming makes it seem like wishful thinking self.CFDSolver.addFunction("dragpressure", "all_flow", name="thrust_pressure") self.CFDSolver.addFunction("dragviscous", "all_flow", name="thrust_viscous") self.CFDSolver.addFunction("dragmomentum", "all_flow", name="thrust_momentum") def test_solve(self): # do the solve self.CFDSolver(self.ap) # check if solution failed self.assert_solution_failure() # check its accuracy utils.assert_functions_allclose(self.handler, self.CFDSolver, self.ap, tol=1e-9) utils.assert_states_allclose(self.handler, self.CFDSolver, tol=1e-10) utils.assert_residuals_allclose(self.handler, self.CFDSolver, self.ap, tol=1e-10)
def setup_cb(comm): solver = ADFLOW(options=options, comm=comm, debug=False) solver.addFamilyGroup('upstream',['INFLOW']) solver.addFamilyGroup('downstream',['OUTFLOW']) solver.addFamilyGroup('all_flow',['INFLOW', 'OUTFLOW']) solver.addFunction('mdot', 'upstream', name="mdot_up") solver.addFunction('mdot', 'downstream', name="mdot_down") solver.addFunction('mavgptot', 'downstream', name="mavgptot_down") solver.addFunction('mavgptot', 'upstream', name="mavgptot_up") solver.addFunction('aavgptot', 'downstream', name="aavgptot_down") solver.addFunction('aavgptot', 'upstream', name="aavgptot_up") solver.addFunction('mavgttot', 'downstream', name="mavgttot_down") solver.addFunction('mavgttot', 'upstream', name="mavgttot_up") solver.addFunction('mavgps', 'downstream', name="mavgps_down") solver.addFunction('mavgps', 'upstream', name="mavgps_up") solver.addFunction('aavgps', 'downstream', name="aavgps_down") solver.addFunction('aavgps', 'upstream', name="aavgps_up") solver.addFunction('mavgmn', 'downstream', name="mavgmn_down") solver.addFunction('mavgmn', 'upstream', name="mavgmn_up") solver.addFunction('drag', 'all_flow', name="thrust") # this naming makes it seem like wishful thinking solver.addFunction('dragpressure', 'all_flow', name="thrust_pressure") solver.addFunction('dragviscous', 'all_flow', name="thrust_viscous") solver.addFunction('dragmomentum', 'all_flow', name="thrust_momentum") return solver, None, None, None
def setup_cb(comm): solver = ADFLOW(options=options, comm=comm, debug=True) solver.addIntegrationSurface('../inputFiles/integration_plane_viscous.fmt', 'viscous_plane') solver.finalizeUserIntegrationSurfaces() solver.addFamilyGroup('upstream', ['inlet']) solver.addFamilyGroup('downstream', ['outlet']) solver.addFamilyGroup('all_flow', ['inlet', 'outlet']) solver.addFamilyGroup('output_fam', ['all_flow', 'allWalls']) solver.addFunction('mdot', 'upstream', name="mdot_up") solver.addFunction('mdot', 'downstream', name="mdot_down") solver.addFunction('mdot', 'viscous_plane', name="mdot_plane") solver.addFunction('mavgptot', 'downstream', name="mavgptot_down") solver.addFunction('mavgptot', 'upstream', name="mavgptot_up") solver.addFunction('mavgptot', 'viscous_plane', name="mavgptot_plane") solver.addFunction('aavgptot', 'downstream', name="aavgptot_down") solver.addFunction('aavgptot', 'upstream', name="aavgptot_up") solver.addFunction('aavgptot', 'viscous_plane', name="aavgptot_plane") solver.addFunction('mavgttot', 'downstream', name="mavgttot_down") solver.addFunction('mavgttot', 'upstream', name="mavgttot_up") solver.addFunction('mavgttot', 'viscous_plane', name="mavgttot_plane") solver.addFunction('mavgps', 'downstream', name="mavgps_down") solver.addFunction('mavgps', 'upstream', name="mavgps_up") solver.addFunction('mavgps', 'viscous_plane', name="mavgps_plane") solver.addFunction('aavgps', 'downstream', name="aavgps_down") solver.addFunction('aavgps', 'upstream', name="aavgps_up") solver.addFunction('aavgps', 'viscous_plane', name="aavgps_plane") solver.setOption('ncycles', 1000) return solver, None, None, None