def regression_test(self, handler, solve=False): ''' This is where the actual testing happens. ''' import copy from baseclasses import AeroProblem from commonUtils import standard_test, adflowDefOpts, defaultFuncList gridFile = 'input_files/mdo_tutorial_euler_scalar_jst.cgns' options = copy.copy(adflowDefOpts) options.update({ 'gridfile': gridFile, 'mgcycle': '2w', 'ncyclescoarse': 250, 'ncycles': 500, 'monitorvariables': ['cpu', 'resrho', 'cl', 'cd', 'cmz', 'totalr'], 'usenksolver': True, 'l2convergence': 1e-14, 'l2convergencecoarse': 1e-2, 'nkswitchtol': 1e-2, 'adjointl2convergence': 1e-14, 'solutionprecision': 'double', 'gridprecision': 'double', }) # Setup aeroproblem, cfdsolver, mesh and geometry. ap = AeroProblem(name='mdo_tutorial', alpha=1.8, mach=0.80, P=20000.0, T=220.0, areaRef=45.5, chordRef=3.25, beta=0.0, R=287.87, xRef=0.0, yRef=0.0, zRef=0.0, evalFuncs=defaultFuncList) if not solve: options['restartfile'] = gridFile # Create the solver CFDSolver = ADFLOW(options=options, debug=True) standard_test(handler, CFDSolver, ap, solve)
def setup_cb(comm): # Create the solver CFDSolver = ADFLOW(options=options, comm=comm, debug=False) # Setup geometry/mesh DVGeo = DVGeometry(ffdFile) nTwist = 6 DVGeo.addRefAxis( 'wing', Curve(x=numpy.linspace(5.0 / 4.0, 1.5 / 4.0 + 7.5, nTwist), y=numpy.zeros(nTwist), z=numpy.linspace(0, 14, nTwist), k=2)) def twist(val, geo): for i in range(nTwist): geo.rot_z['wing'].coef[i] = val[i] DVGeo.addGeoDVGlobal('twist', [0] * nTwist, twist, lower=-10, upper=10, scale=1.0) DVGeo.addGeoDVLocal('shape', lower=-0.5, upper=0.5, axis='y', scale=10.0) mesh = USMesh(options=meshOptions, comm=comm) CFDSolver.setMesh(mesh) CFDSolver.setDVGeo(DVGeo) return CFDSolver, mesh, DVGeo, 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
temp_air = 273 # kelvin Pr = 0.72 mu = 1.81e-5 # kg/(m * s) # Rex = u_inf = 30 # m/s\ p_inf = 101e3 rho_inf = p_inf / (287 * temp_air) ap = AeroProblem(name='fc_therm', V=u_inf, T=temp_air, P=p_inf, areaRef=1.0, chordRef=1.0, evalFuncs=['heatflux'], alpha=0.0, beta=0.00, xRef=0.0, yRef=0.0, zRef=0.0) # Create the solver CFDSolver = ADFLOW(options=options, debug=False) # res = CFDSolver.getResidual(ap) # CFDSolver.callMasterRoutine(ap) # CFDSolver(ap) # # Create a common set of seeds wDot = CFDSolver.getStatePerturbation(314) xVDot = CFDSolver.getSpatialPerturbation(314) dwBar = CFDSolver.getStatePerturbation(314) fBar = CFDSolver.getSurfacePerturbation(314) hfBar = CFDSolver.getSurfacePerturbation(314)[:, 1].reshape((len(fBar), 1)) # wBar = CFDSolver.computeJacobianVectorProductBwd(resBar=dwBar, wDeriv=True)
def setup_cb(comm): # Create the solver CFDSolver = ADFLOW(options=options, debug=False) return CFDSolver, None, None, None
def regression_test(self, handler, solve=False): ''' This is where the actual testing happens. ''' gridFile = 'input_files/conic_conv_nozzle_mb.cgns' integrationSurf = 'input_files/integration_plane_viscous.fmt' options = copy.copy(adflowDefOpts) options.update({ 'gridfile': gridFile, 'equationType': 'euler', 'smoother': 'dadi', 'nsubiter': 3, 'CFL': 4.0, 'CFLCoarse': 1.25, 'MGCycle': 'sg', 'MGStartLevel': -1, 'nCyclesCoarse': 250, 'nCycles': 1000, 'nkcfl0': 1e10, 'monitorvariables': ['cpu', 'resrho', 'cl', 'cd'], 'volumevariables': ['blank'], 'surfacevariables': ['mach', 'cp', 'vx', 'vy', 'vz', 'blank'], 'useNKSolver': True, 'nkswitchtol': .01, 'nkadpc': True, 'nkjacobianlag': 5, 'nkouterpreconits': 3, 'nkinnerpreconits': 2, 'L2Convergence': 1e-10, 'L2ConvergenceCoarse': 1e-4, 'adjointl2convergence': 1e-6, 'forcesAsTractions': True, 'debugzipper': True, 'nearwalldist': .001, 'nkls': 'none', 'solutionprecision': 'double', 'adjointsubspacesize': 200, 'outerpreconits': 3, 'zipperSurfaceFamily': 'output_fam', 'flowtype': 'internal', }) if not solve: options['restartfile'] = gridFile # Setup aeroproblem ap = AeroProblem(name='nozzle', alpha=90.0, mach=0.5, altitude=0, areaRef=1.0, chordRef=1.0, R=287.87, evalFuncs=[ 'mdot_up', 'mdot_down', 'mdot_plane', 'mavgptot_up', 'mavgptot_down', 'mavgptot_plane', 'aavgptot_up', 'aavgptot_down', 'aavgptot_plane', 'mavgttot_up', 'mavgttot_down', 'mavgttot_plane', 'mavgps_up', 'mavgps_down', 'mavgps_plane', 'aavgps_up', 'aavgps_down', 'aavgps_plane', ]) # ap.setBCVar('Pressure', 79326.7, 'downstream') # ap.addDV('Pressure', family='downstream') # ap.setBCVar('PressureStagnation', 100000.0, 'upstream') # ap.addDV('PressureStagnation', family='upstream') # ap.setBCVar('TemperatureStagnation', 500.0, 'upstream') # ap.addDV('TemperatureStagnation', family='upstream') # Create the solver CFDSolver = ADFLOW(options=options) # CFDSolver.addIntegrationSurface(integrationSurf, 'viscous_plane') # CFDSolver.finalizeUserIntegrationSurfaces() CFDSolver.addFamilyGroup('upstream', ['inlet']) CFDSolver.addFamilyGroup('downstream', ['outlet']) CFDSolver.addFamilyGroup('all_flow', ['inlet', 'outlet']) CFDSolver.addFamilyGroup('output_fam', ['all_flow', 'allWalls']) CFDSolver.addFunction('mdot', 'upstream', name="mdot_up") CFDSolver.addFunction('mdot', 'downstream', name="mdot_down") # CFDSolver.addFunction('mdot', 'viscous_plane', name="mdot_plane") CFDSolver.addFunction('mavgptot', 'downstream', name="mavgptot_down") CFDSolver.addFunction('mavgptot', 'upstream', name="mavgptot_up") # CFDSolver.addFunction('mavgptot', 'viscous_plane', name="mavgptot_plane") CFDSolver.addFunction('aavgptot', 'downstream', name="aavgptot_down") CFDSolver.addFunction('aavgptot', 'upstream', name="aavgptot_up") # CFDSolver.addFunction('aavgptot', 'viscous_plane', name="aavgptot_plane") CFDSolver.addFunction('mavgttot', 'downstream', name="mavgttot_down") CFDSolver.addFunction('mavgttot', 'upstream', name="mavgttot_up") # CFDSolver.addFunction('mavgttot', 'viscous_plane', name="mavgttot_plane") CFDSolver.addFunction('mavgps', 'downstream', name="mavgps_down") CFDSolver.addFunction('mavgps', 'upstream', name="mavgps_up") # CFDSolver.addFunction('mavgps', 'viscous_plane', name="mavgps_plane") CFDSolver.addFunction('aavgps', 'downstream', name="aavgps_down") CFDSolver.addFunction('aavgps', 'upstream', name="aavgps_up") # CFDSolver.addFunction('aavgps', 'viscous_plane', name="aavgps_plane") CFDSolver.setOption('ncycles', 1000) # Run test # CFDSolver(ap) # Check the residual # CFDSolver.setAeroProblem(ap) res = CFDSolver.getResidual(ap) # totalR0, totalRStart, totalRFinal = CFDSolver.getResNorms() # res /= totalR0 handler.par_add_norm(res, 1e-10, 1e-10) # Get and check the states handler.par_add_norm(CFDSolver.getStates(), 1e-10, 1e-10) funcs = {} CFDSolver.evalFunctions(ap, funcs) handler.root_add_dict(funcs, 1e-10, 1e-10)
def setup_cb(comm): CFDSolver = ADFLOW(options=options, comm=comm) CFDSolver.addSlices('z', [0.5]) CFDSolver(ap) return CFDSolver, None, None, None
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