Example #1
0
    def regression_test(self, handler, solve=False):
        '''
        This is where the actual testing happens.
        '''
        # gridFile = 'input_files/conic_conv_nozzle.cgns'
        gridFile = '../python/inputFiles/conic_conv_nozzle.cgns'

        options = copy.copy(adflowDefOpts)
        options.update({
            # Common Parameters
            'gridfile':
            gridFile,
            # Physics Parameters
            '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,
            # Convergence Parameters
            '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.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('mavgptot', 'downstream', name="mavgptot_down")
        CFDSolver.addFunction('mavgptot', 'upstream', name="mavgptot_up")

        CFDSolver.addFunction('aavgptot', 'downstream', name="aavgptot_down")
        CFDSolver.addFunction('aavgptot', 'upstream', name="aavgptot_up")

        CFDSolver.addFunction('mavgttot', 'downstream', name="mavgttot_down")
        CFDSolver.addFunction('mavgttot', 'upstream', name="mavgttot_up")

        CFDSolver.addFunction('mavgps', 'downstream', name="mavgps_down")
        CFDSolver.addFunction('mavgps', 'upstream', name="mavgps_up")

        CFDSolver.addFunction('aavgps', 'downstream', name="aavgps_down")
        CFDSolver.addFunction('aavgps', 'upstream', name="aavgps_up")

        CFDSolver.setOption('ncycles', 1000)

        # Run test
        # CFDSolver(ap)

        # Check the residual
        res = CFDSolver.getResidual(ap)
        handler.par_add_norm(res, 1e-10, 1e-10, msg='res')

        # Get and check the states
        handler.par_add_norm(CFDSolver.getStates(), 1e-10, 1e-10, msg='states')

        funcs = {}
        CFDSolver.evalFunctions(ap, funcs)
        handler.root_add_dict(funcs, 1e-10, 1e-10, msg='functions')
Example #2
0
    def regression_test(self, handler):
        '''
        This is where the actual testing happens.
        '''
        gridFile = 'input_files/euler_conv_nozzle.cgns'

        options = copy.copy(adflowDefOpts)
        options.update({
            'gridfile': gridFile,
            'equationType': 'euler',
            'smoother': 'dadi',
            'liftIndex': 2,
            'CFL': 3.,
            'CFLCoarse': 1.5,
            'MGCycle': 'sg',
            'MGStartLevel': 1,
            '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',
            'useblockettes': False
        })

        # Setup aeroproblem
        ap = AeroProblem(
            name='conv_nozzle',
            alpha=00.0,
            mach=0.25,
            T=500,
            P=79326.7,
            areaRef=1.,
            chordRef=2.,
            R=287.87,
            evalFuncs=[
                'mdot', 'mdot_up', 'mdot_down', 'mavgptot_up', 'mavgptot_down',
                'aavgptot_up', 'aavgptot_down', 'mavgttot_up', 'mavgttot_down',
                'mavgps_up', 'mavgps_down', 'aavgps_up', 'aavgps_down',
                'mavgmn_up', 'mavgmn_down', 'thrust', 'thrust_pressure',
                'thrust_viscous', 'thrust_momentum'
            ])

        # Create the solver
        CFDSolver = ADFLOW(options=options)
        CFDSolver.addFamilyGroup('upstream', ['INFLOW'])
        CFDSolver.addFamilyGroup('downstream', ['OUTFLOW'])
        CFDSolver.addFamilyGroup('all_flow', ['INFLOW', 'OUTFLOW'])

        CFDSolver.addFunction('mdot', 'upstream', name="mdot_up")
        CFDSolver.addFunction('mdot', 'downstream', name="mdot_down")

        CFDSolver.addFunction('mavgptot', 'downstream', name="mavgptot_down")
        CFDSolver.addFunction('mavgptot', 'upstream', name="mavgptot_up")

        CFDSolver.addFunction('aavgptot', 'downstream', name="aavgptot_down")
        CFDSolver.addFunction('aavgptot', 'upstream', name="aavgptot_up")

        CFDSolver.addFunction('mavgttot', 'downstream', name="mavgttot_down")
        CFDSolver.addFunction('mavgttot', 'upstream', name="mavgttot_up")

        CFDSolver.addFunction('mavgps', 'downstream', name="mavgps_down")
        CFDSolver.addFunction('mavgps', 'upstream', name="mavgps_up")

        CFDSolver.addFunction('aavgps', 'downstream', name="aavgps_down")
        CFDSolver.addFunction('aavgps', 'upstream', name="aavgps_up")

        CFDSolver.addFunction('mavgmn', 'downstream', name="mavgmn_down")
        CFDSolver.addFunction('mavgmn', 'upstream', name="mavgmn_up")

        CFDSolver.addFunction(
            'drag', 'all_flow',
            name="thrust")  # this naming makes it seem like wishful thinking

        CFDSolver.addFunction('dragpressure',
                              'all_flow',
                              name="thrust_pressure")
        CFDSolver.addFunction('dragviscous', 'all_flow', name="thrust_viscous")
        CFDSolver.addFunction('dragmomentum',
                              'all_flow',
                              name="thrust_momentum")

        # Run test
        # CFDSolver.getResidual(ap)
        CFDSolver(ap)
        # Check the residual
        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)