Exemplo n.º 1
0
    def __init__(self, name, throttle=1.0, ISA=0.0, **kwargs):
        # Initialize AeroProblem
        AeroProblem.__init__(self, name, **kwargs)

        # Set initial throttle or ISA
        self.throttle = throttle
        self.ISA = ISA

        # Update AeroProblem variable sets with possible engine variables
        newVars = ['throttle', 'ISA']
        self.allVarFuncs += newVars
        self.possibleDVs.update(newVars)
        self.possibleFunctions.update(newVars)
Exemplo n.º 2
0
    def setUp(self):
        # import petsc4py

        # petsc4py.init(arch='real-debug-gfortran-3.7.7')
        # from petsc4py import PETSc

        gridFile = os.path.join(baseDir, '../input_files/conic_conv_nozzle_mb_L4.cgns')
        intSurfFile = os.path.join(baseDir, '../input_files/integration_plane_viscous.fmt')

        self.options = {'gridfile': gridFile}

        self.options['mgstartlevel'] = 1

        self.options['ncycles'] = 1
        self.options['useanksolver'] = False
        self.options['l2convergence'] = 1e-12
        ap = AeroProblem(name='nozzle_flow', alpha=90, 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',
                                'mavgttot_up', 'mavgttot_down', 'mavgttot_plane',
                                'mavgps_up', 'mavgps_down', 'mavgps_plane',
                                ])

        self.ap = ap 

        CFDSolver = ADFLOW(options=self.options)
        CFDSolver.addIntegrationSurface(intSurfFile, '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")

        self.CFDSolver= CFDSolver
Exemplo n.º 3
0
    def setUp(self):
        gridFile = os.path.join(baseDir, '../input_files/conic_conv_nozzle_mb_L4.cgns')
        self.options = {'gridfile': gridFile}

        
        # Aerodynamic problem description (taken from test 17)
        ap = AeroProblem(name='nozzle', alpha=90, mach=0.5, altitude=0,
                        areaRef=1.0, chordRef=1.0, R=287.87)

        # these values come from inspecting the cgns mesh itself
        self.initial_dvs = {
            'downstream': {
                'Pressure': 79326.7,
            },
            'upstream': {
                'PressureStagnation': 100000.0,
                'TemperatureStagnation': 500,
                'VelocityUnitVectorX': 0.,
                'VelocityUnitVectorY': 1.,
                'VelocityUnitVectorZ': 0.,
            }
        }

        self.set_dvs = {
            'downstream': {
                'Pressure': 89326.7,
            },
            'upstream': {
                'PressureStagnation': 100001.0,
                'TemperatureStagnation': 450,
                'VelocityUnitVectorX': 0.1,
                'VelocityUnitVectorY': 0.9,
                'VelocityUnitVectorZ': 0.1,
            }
        }
Exemplo n.º 4
0
    def setUp(self):
        gridFile = os.path.join(baseDir, '../input_files/pipe.cgns')
        self.options = {'gridfile': gridFile,
                        'mgcycle':'sg',
                        'ncycles':1000,
                        'useanksolver':True,
                        'usenksolver':True,
                        'volumevariables': ['temp', 'mach', 'resrho' ],
                        'surfacevariables':['temp', 'vx', 'vy', 'vz', 'p', 'ptloss', 'mach', 'rho'],
                        'equationType':'euler',
                        'l2convergence': 1e-13}
                        
        CFDSolver = ADFLOW(options=self.options)

        CFDSolver.addFunction('mdot', 'inlet', name="mdot_in")
        CFDSolver.addFunction('mdot', 'outlet', name="mdot_out")

        CFDSolver.addFunction('mavgptot', 'outlet', name="mavgptot_out")
        CFDSolver.addFunction('mavgptot', 'inlet', name="mavgptot_in")

        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('mavgps', 'outlet', name="mavgps_out")
        CFDSolver.addFunction('mavgps', 'inlet', name="mavgps_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="vx_in")
        CFDSolver.addFunction('mavgvx', 'outlet', name="vx_out")

        CFDSolver.addFunction('mavgps', 'inlet', name="ps_in")
        CFDSolver.addFunction('mavgps', 'outlet', name="ps_out")

        self.CFDSolver = CFDSolver
        
        self.ap = AeroProblem(name='actuator_in_pipe', alpha=00, mach=0.6, altitude=0,
                        areaRef=1.0, chordRef=1.0,
                    evalFuncs=['mdot_in', 'mdot_out', 
                               'mavgptot_in', 'mavgptot_out', 
                               'mavgttot_in', 'mavgttot_out', 
                               'mavgps_in', 'mavgps_out',
                               'area_in', 'area_out', 
                               'aavgps_in', 'aavgps_out',
                               'aavgptot_in', 'aavgptot_out',
                               'ps_in', 'ps_out',
                               'vx_in', 'vx_out'] )


        self.force = 600
        actuatorFile = os.path.join(baseDir, '../input_files/actuator_disk.xyz')
        self.CFDSolver.addActuatorRegion(actuatorFile, np.array([0,0,0]),np.array([1,0,0]), 'actuator', thrust=self.force )
Exemplo n.º 5
0
    def regression_test(self, handler):
        '''
        This is where the actual testing happens.
        '''
        import copy
        from baseclasses import AeroProblem
        from commonUtils import solution_test, adflowDefOpts, defaultFuncList
        from ... import ADFLOW
        gridFile = 'input_files/mdo_tutorial_viscous_scalar_jst.cgns'

        options = copy.copy(adflowDefOpts)
        options.update({
            'gridfile':
            gridFile,
            'mgcycle':
            '2w',
            'equationtype':
            'Laminar NS',
            'cfl':
            1.5,
            'cflcoarse':
            1.25,
            'ncyclescoarse':
            250,
            'ncycles':
            10000,
            'monitorvariables':
            ['cpu', 'resrho', 'resturb', 'cl', 'cd', 'totalr'],
            'usenksolver':
            True,
            'l2convergence':
            1e-15,
            'l2Convergencecoarse':
            1e-2,
            'nkswitchtol':
            1e-2,
            'adjointl2convergence':
            1e-14,
        })

        # Setup aeroproblem, cfdsolver, mesh and geometry.
        ap = AeroProblem(name='mdo_tutorial',
                         alpha=1.8,
                         beta=0.0,
                         mach=0.50,
                         P=137.0,
                         T=293.15,
                         R=287.87,
                         areaRef=45.5,
                         chordRef=3.25,
                         xRef=0.0,
                         yRef=0.0,
                         zRef=0.0,
                         evalFuncs=defaultFuncList)

        # Create the solver
        CFDSolver = ADFLOW(options=options, debug=False)
        solution_test(handler, CFDSolver, ap)
Exemplo n.º 6
0
    def regression_test(self, handler):
        '''
        This is where the actual testing happens.
        '''
        import copy
        from baseclasses import AeroProblem
        from commonUtils import adflowDefOpts
        from ... import ADFLOW
        gridFile = 'input_files/mdo_tutorial_euler_scalar_jst.cgns'

        options = copy.copy(adflowDefOpts)
        options.update({
            'gridfile':
            gridFile,
            'mgcycle':
            '2w',
            'ncyclescoarse':
            250,
            'ncycles':
            500,
            'monitorvariables': ['resrho', 'cl', 'cd', 'cmz', 'totalr'],
            'usenksolver':
            True,
            'l2convergence':
            1e-14,
            'l2convergencecoarse':
            1e-2,
            'nkswitchtol':
            1e-2,
            'adjointl2convergence':
            1e-14,
            'solutionprecision':
            'single',
            'gridprecision':
            'double',
        })

        # Setup aeroproblem, cfdsolver, mesh and geometry.
        ap = AeroProblem(name='mdo_tutorial',
                         alpha=1.20,
                         mach=0.80,
                         altitude=10000.0,
                         areaRef=45.5,
                         chordRef=3.25)

        # Create the solver
        CFDSolver = ADFLOW(options=options, debug=True)

        # Run CL solve
        CFDSolver.solveCL(ap,
                          0.475,
                          alpha0=1.20,
                          delta=0.025,
                          tol=1e-4,
                          autoReset=False)
        funcs = {}
        CFDSolver.evalFunctions(ap, funcs, evalFuncs=['cl'])
        handler.root_add_val(funcs['mdo_tutorial_cl'] - 0.475, 1e-4, 1e-4)
Exemplo n.º 7
0
    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
        from ... import ADFLOW
        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)
Exemplo n.º 8
0
    def setUp(self):
        gridFile = os.path.join(baseDir, '../input_files/conic_conv_nozzle_mb_L4.cgns')
        self.options = {'gridfile': gridFile}

        ap = AeroProblem(name='nozzle_flow', alpha=90, 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',
                                'mavgttot_up', 'mavgttot_down', 'mavgttot_plane',
                                'mavgps_up', 'mavgps_down', 'mavgps_plane',
                                ])

        self.ap = ap 
Exemplo n.º 9
0
     'ncycles':400,
     'monitorvariables':['resrho','cl','cd','cmz','totalr'],
     'usenksolver':True,
     'l2convergence':1e-15,
     'l2convergencecoarse':1e-2,
     'nkswitchtol':1e-2,
     'adjointl2convergence': 1e-15,
     'nkls':'non monotone',
     'blocksplitting': True
 }
)
h = 1e-40

# Setup aeroproblem, cfdsolver
ap = AeroProblem(name='mdo_tutorial', alpha=1.8, mach=0.80, R=287.87,
                 altitude=10000.0, areaRef=45.5, chordRef=3.25,
                 evalFuncs=['cl','cmz','drag'])

CFDSolver = ADFLOW(options=aeroOptions)
if 'complex' in sys.argv:
    DVGeo = DVGeometry('../inputFiles/mdo_tutorial_ffd.fmt', complex=True)
else:
    DVGeo = DVGeometry('../inputFiles/mdo_tutorial_ffd.fmt', complex=False)

nTwist = 2
DVGeo.addRefAxis('wing', pyspline.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]
Exemplo n.º 10
0
    os.system('mkdir -p %s' % stdoutDir)
MP.gcomm.barrier()
if comm.rank == 0:
    fName = os.path.join(stdoutDir, '%s_%d.out' % (setName, ptID))
    outFile = open(fName, 'w', buffering=0)
    redirectIO(outFile)

# ==============================================================================
# Set up case problems
# ==============================================================================
# Setup cruise problems
cruiseProblems = []
ap = AeroProblem(name='cruise',
                 mach=0.8,
                 altitude=10000,
                 areaRef=Sref,
                 alpha=2.0,
                 chordRef=chordRef,
                 evalFuncs=['lift', 'drag'])
ap.addDV('alpha', lower=0, upper=10.0, scale=0.1)
sp = StructProblem(ap.name, evalFuncs=['mass'])
cruiseProblems.append(AeroStructProblem(ap, sp))

# Setup maneuver problems
maneuverProblems = []  # List of maneuver AeroStruct problem objects
ap = AeroProblem(name='maneuver',
                 mach=0.75,
                 altitude=5000,
                 areaRef=Sref,
                 alpha=2.0,
                 chordRef=chordRef,
Exemplo n.º 11
0
}
# Create solver
CFDSolver = ADFLOW(options=aeroOptions, comm=comm)
CFDSolver.addLiftDistribution(200, "z")
# rst adflow (end)
# ======================================================================
#         Set up flow conditions with AeroProblem
# ======================================================================
# rst aeroproblem (beg)
aeroProblems = []
for i in range(nFlowCases):
    ap = AeroProblem(
        name="fc%d" % i,
        alpha=alpha[i],
        mach=mach[i],
        altitude=alt[i],
        areaRef=1.0,
        chordRef=1.0,
        evalFuncs=["cl", "cd"],
    )
    # Add angle of attack variable
    ap.addDV("alpha", value=alpha[i], lower=0, upper=10.0, scale=1.0)
    aeroProblems.append(ap)
# rst aeroproblem (end)
# ======================================================================
#         Geometric Design Variable Set-up
# ======================================================================
# rst dvgeo (beg)
# Create DVGeometry object
FFDFile = "ffd.xyz"
Exemplo n.º 12
0
    def regression_test(self, handler):
        '''
        This is where the actual testing happens.
        '''
        import copy, os
        from baseclasses import AeroProblem
        from commonUtils import adflowDefOpts, defaultFuncList
        from ... import ADFLOW
        gridFile = 'input_files/naca0012_rans-L2.cgns'

        options = copy.copy(adflowDefOpts)
        k = 0.0808
        M = 0.6
        gamma = 1.4
        R = 287.085
        T = 280.0
        c = 1.0
        alpha_m = 2.77  # 2.89 #2.77 #Modified numbers
        alpha_0 = 2.34  # 2.41 #2.34

        omega = 2 * M * numpy.sqrt(gamma * R * T) * k / c
        deltaAlpha = -alpha_0 * numpy.pi / 180.0

        # Set forcing frequency and other information
        f = 10.0  # [Hz] Forcing frequency of the flow
        period = 1.0 / f  # [sec]
        nStepPerPeriod = 8
        nPeriods = 1
        nfineSteps = nStepPerPeriod * nPeriods
        dt = period / nStepPerPeriod  # [s] The actual timestep

        options.update({
            'gridfile': gridFile,
            'writevolumesolution': False,
            'vis4': .025,
            'vis2': 0.5,
            'restrictionrelaxation': .5,
            'smoother': 'dadi',
            'equationtype': 'RANS',
            'equationmode': 'unsteady',
            'timeIntegrationscheme': 'bdf',
            'ntimestepsfine': nfineSteps,
            'deltat': dt,
            'nsubiterturb': 10,
            'nsubiter': 5,
            'useale': False,
            'usegridmotion': True,
            'cfl': 2.5,
            'cflcoarse': 1.2,
            'ncycles': 2000,
            'mgcycle': '3w',
            'mgstartlevel': 1,
            'monitorvariables': ['cpu', 'resrho', 'cl', 'cd', 'cmz'],
            'usenksolver': False,
            'l2convergence': 1e-6,
            'l2convergencecoarse': 1e-4,
            'qmode': True,
            'alphafollowing': False,
            'blockSplitting': True,
            'useblockettes': False,
        })

        # Setup aeroproblem
        ap = AeroProblem(name='0012pitching',
                         alpha=alpha_m,
                         mach=M,
                         machRef=M,
                         reynolds=4800000.0,
                         reynoldsLength=c,
                         T=T,
                         R=R,
                         areaRef=1.0,
                         chordRef=c,
                         evalFuncs=['cl', 'cd', 'cmz'],
                         xRef=0.25,
                         xRot=0.25,
                         degreePol=0,
                         coefPol=[0.0],
                         degreeFourier=1,
                         omegaFourier=omega,
                         cosCoefFourier=[0.0, 0.0],
                         sinCoefFourier=[deltaAlpha])

        # Create the solver
        CFDSolver = ADFLOW(options=options)
        CFDSolver.addSlices('z', [0.5])

        # Run test
        CFDSolver(ap)
        funcs = {}
        CFDSolver.evalFunctions(ap, funcs)
        CFDSolver.checkSolutionFailure(ap, funcs)
        handler.root_add_dict(funcs, 1e-6, 1e-6)
Exemplo n.º 13
0
     'ncycles':500,
     'monitorvariables':['resrho','resturb','cl','cd','cmz','yplus','totalr'],
     'usenksolver':True,
     'l2convergence':1e-16,
     'l2convergencecoarse':1e-2,
     'nkswitchtol':1e-2,
     'adjointl2convergence': 1e-15,
     'nkls':'non monotone',
     'blocksplitting': True
 }
)


# Setup aeroproblem, cfdsolver
ap = AeroProblem(name='mdo_tutorial', alpha=1.8, mach=0.50, R=287.87,
                 reynolds=50000.0, reynoldsLength=3.25, T=293.15,
                 areaRef=45.5, chordRef=3.25, evalFuncs=['cd','cmz','lift'])
ap.addDV('alpha')
ap.addDV('mach')

CFDSolver = ADFLOW(options=aeroOptions)

if not 'complex' in sys.argv:
    # Solve system
    CFDSolver(ap, writeSolution=False)
    funcs = {}
    CFDSolver.evalFunctions(ap, funcs)
    # Solve sensitivities
    funcsSens = {}
    CFDSolver.evalFunctionsSens(ap, funcsSens)
Exemplo n.º 14
0
    'nkswitchtol':
    1e-2,
    'adjointl2convergence':
    1e-15,
    'nkls':
    'non monotone',
    'blocksplitting':
    True
})
h = 1e-40
# Setup aeroproblem, cfdsolver
ap = AeroProblem(name='mdo_tutorial',
                 alpha=1.8,
                 mach=0.50,
                 R=287.87,
                 reynolds=50000.0,
                 reynoldsLength=3.25,
                 T=293.15,
                 areaRef=45.5,
                 chordRef=3.25,
                 evalFuncs=['cl', 'cmz', 'drag'])

CFDSolver = ADFLOW(options=aeroOptions)
if 'complex' in sys.argv:
    DVGeo = DVGeometry('../inputFiles/mdo_tutorial_ffd.fmt', complex=True)
else:
    DVGeo = DVGeometry('../inputFiles/mdo_tutorial_ffd.fmt', complex=False)

nTwist = 2
DVGeo.addRefAxis(
    'wing',
    pyspline.Curve(x=numpy.linspace(5.0 / 4.0, 1.5 / 4.0 + 7.5, nTwist),
Exemplo n.º 15
0
import numpy as np
from baseclasses import AeroProblem
from reg_default_options import defaultFuncList

ap_tutorial_wing = 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,
)

ap_tutorial_wing_laminar = AeroProblem(
    name="mdo_tutorial",
    alpha=1.8,
    beta=0.0,
    mach=0.50,
    P=137.0,
    T=293.15,
    R=287.87,
    areaRef=45.5,
    chordRef=3.25,
    xRef=0.0,
Exemplo n.º 16
0
    def __init__(self, comm=None, options=None, debug=False):

        # Load the compiled module using MExt, allowing multiple
        # imports
        curDir = os.path.dirname(os.path.realpath(__file__))
        self.adflow = MExt.MExt('libadflow', [curDir], debug=debug)._module

        # Information for base class:
        name = 'ADFLOW'
        category = 'Three Dimensional CFD'
        informs = {}

        # If 'options' is not None, go through and make sure all keys
        # are lower case:
        if options is not None:
            for key in options.keys():
                options[key.lower()] = options.pop(key)
        else:
            raise Error(
                "The 'options' keyword argument must be passed "
                "adflow. The options dictionary must contain (at least) "
                "the gridFile entry for the grid")

        # Load all the option/objective/DV information:
        defOpts = self._getDefOptions()
        self.optionMap = self._getOptionMap()
        self.ignoreOptions, self.deprecatedOptions, self.specialOptions = \
                           self._getSpecialOptionLists()

        self.possibleAeroDVs, self.basicCostFunctions = (
            self._getObjectivesAndDVs())

        # This is the real solver so dtype is 'd'
        self.dtype = 'd'

        # Next set the MPI Communicators and associated info
        if comm is None:
            comm = MPI.COMM_WORLD

        self.comm = comm
        self.adflow.communication.adflow_comm_world = self.comm.py2f()
        self.adflow.communication.adflow_comm_self = MPI.COMM_SELF.py2f()
        self.adflow.communication.sendrequests = numpy.zeros(self.comm.size)
        self.adflow.communication.recvrequests = numpy.zeros(self.comm.size)
        self.myid = self.adflow.communication.myid = self.comm.rank
        self.adflow.communication.nproc = self.comm.size

        # Initialize the inherited aerosolver
        AeroSolver.__init__(self,
                            name,
                            category,
                            defOpts,
                            informs,
                            options=options)

        # Initialize petec in case the user has not already
        self.adflow.initializepetsc()

        # Set the stand-alone adflow flag to false...this changes how
        # terminate calls are handled.
        self.adflow.iteration.standalonemode = False

        # Set the frompython flag to true... this also changes how
        # terminate calls are handled
        self.adflow.killsignals.frompython = True

        # Set default values
        self.adflow.setdefaultvalues()
        self.adflow.inputio.autoparameterupdate = False

        # Make sure all the params are ok
        for option in self.options:
            if option != 'defaults':
                self.setOption(option.lower(), self.options[option][1])

        dummyAP = AeroProblem(name='dummy',
                              mach=0.5,
                              altitude=10000.0,
                              areaRef=1.0,
                              chordRef=1.0,
                              alpha=0.0,
                              degreePol=0,
                              coefPol=[0, 0],
                              degreeFourier=1,
                              omegaFourier=6.28,
                              sinCoefFourier=[0, 0],
                              cosCoefFourier=[0, 0])

        self.curAP = dummyAP
        self._setAeroProblemData(firstCall=True)

        # Finally complete loading
        self.adflow.dummyreadparamfile()
        self.adflow.partitionandreadgrid(False)
        self.adflow.preprocessingcustomoverset()
Exemplo n.º 17
0
    "adjointL2Convergence": 1e-10,
}

# Create solver
CFDSolver = ADFLOW(options=aeroOptions, comm=comm)
CFDSolver.addLiftDistribution(150, "z")
CFDSolver.addSlices("z", np.linspace(0.1, 14, 10))
# rst adflow (end)
# ======================================================================
#         Set up flow conditions with AeroProblem
# ======================================================================
# rst aeroproblem (beg)
ap = AeroProblem(name="wing",
                 alpha=1.5,
                 mach=0.8,
                 altitude=10000,
                 areaRef=45.5,
                 chordRef=3.25,
                 evalFuncs=["cl", "cd"])

# Add angle of attack variable
ap.addDV("alpha", value=1.5, lower=0, upper=10.0, scale=0.1)
# rst aeroproblem (end)
# ======================================================================
#         Geometric Design Variable Set-up
# ======================================================================
# rst dvgeo (beg)
# Create DVGeometry object
FFDFile = "ffd.xyz"
DVGeo = DVGeometry(FFDFile)
Exemplo n.º 18
0
    'liftindex':
    3,
    'solutionprecision':
    'double',
    'gridprecision':
    'double',
})

# Setup aeroproblem, cfdsolver, mesh and geometry.
ap = AeroProblem(name='CRM',
                 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)


def setup_cb(comm):

    # Create the solver
    CFDSolver = ADFLOW(options=options, debug=False)

    return CFDSolver, None, None, None
Exemplo n.º 19
0
    'mgstartlevel': 1,
    'monitorvariables': ['cpu', 'resrho', 'cl', 'cd', 'cmz'],
    'usenksolver': False,
    'l2convergence': 1e-6,
    'l2convergencecoarse': 1e-4,
    'qmode': False,
    'alphafollowing': False,
    'blockSplitting': True,
})
ap = AeroProblem(name=name,
                 alpha=alpha_m,
                 mach=M,
                 machRef=M,
                 reynolds=4800000.0,
                 reynoldsLength=c,
                 T=T,
                 R=R,
                 areaRef=1.0,
                 chordRef=c,
                 evalFuncs=['cl', 'cd', 'cmz'],
                 xRef=0.25,
                 xRot=0.25)


def callback(refGrid, t, ts):
    newGrid = numpy.copy(refGrid)
    x = refGrid[:, 0]
    y = refGrid[:, 1]
    p = deltaAlpha * numpy.sin(omega * t)
    c = numpy.cos(p)
    s = numpy.sin(p)
Exemplo n.º 20
0
    def regression_test(self, handler):
        '''
        This is where the actual testing happens.
        '''
        import copy
        from baseclasses import AeroProblem
        from commonUtils import adflowDefOpts
        from ... import ADFLOW
        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': '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',
        })

        # 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(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)
Exemplo n.º 21
0
npAero = gcomm.size - npStruct

# Create aero/structural comms
comm, flags = createGroups([npStruct, npAero], comm=gcomm)
structID = 0  # zeroth group is structure
aeroID = 1  # first group is aero
#rst comms (end)
# ==============================================================================
#         Set up case problems
# ==============================================================================
#rst problems (start)
# Set up aerodynamic problem
ap = AeroProblem(name='cruise',
                 mach=0.8,
                 altitude=10000,
                 areaRef=45.5,
                 alpha=2.0,
                 chordRef=3.25,
                 evalFuncs=['lift', 'drag'])

# Set up structural problem
sp = StructProblem(ap.name, evalFuncs=['mass'])

# Create aerostructural problem
asp = AeroStructProblem(ap, sp)
#rst problems (end)
# ==============================================================================
#         Set up aerodynamic analysis
# ==============================================================================
#rst aeroOptions (start)
aeroOptions = {
Exemplo n.º 22
0
    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,
                 xRef=0.0,
                 yRef=0.0,
                 zRef=0.0,
                 evalFuncs=defaultFuncList)


def setup_cb(comm):

    # Create the solver
    CFDSolver = ADFLOW(options=options, debug=False)

    return CFDSolver, None, None, None

Exemplo n.º 23
0
}

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)
fluxes = CFDSolver.getHeatFluxes()
print(fluxes.imag / 1e-40)

# from python.pyADflow import ADFLOW
Exemplo n.º 24
0
     'ncycles':750,
     'monitorvariables':['resrho','resturb','cl','cd','cmz','yplus','totalr'],
     'usenksolver':True,
     'l2convergence':1e-17,
     'l2convergencecoarse':1e-2,
     'nkswitchtol':1e-4,
     'adjointl2convergence': 1e-16,
     'nkls': 'non monotone',
     'frozenturbulence':False,
     'nkjacobianlag':2,
     'blocksplitting': True
 }
)
h = 1e-40
# Setup aeroproblem, cfdsolver
ap = AeroProblem(name='mdo_tutorial', alpha=1.8, mach=0.80, R=287.87,
                 altitude=10000.0, areaRef=45.5, chordRef=3.25, evalFuncs=['cl','cmz','drag'])

ap.addDV('alpha')
ap.addDV('mach')
CFDSolver = ADFLOW(options=aeroOptions)
if 'complex' in sys.argv:
    DVGeo = DVGeometry('../inputFiles/mdo_tutorial_ffd.fmt', complex=True)
else:
    DVGeo = DVGeometry('../inputFiles/mdo_tutorial_ffd.fmt', complex=False)

nTwist = 2
DVGeo.addRefAxis('wing', pyspline.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 xrange(nTwist):
Exemplo n.º 25
0
    'nkls':
    'non monotone',
    'frozenturbulence':
    False,
    'nkjacobianlag':
    2,
    'blocksplitting':
    True
})
h = 1e-40

# Setup aeroproblem, cfdsolver
ap = AeroProblem(name='mdo_tutorial',
                 alpha=1.8,
                 mach=0.80,
                 R=287.87,
                 altitude=10000.0,
                 areaRef=45.5,
                 chordRef=3.25,
                 evalFuncs=['cd', 'cmz', 'lift'])
ap.addDV('alpha')
ap.addDV('mach')
ap.addDV('altitude')
CFDSolver = ADFLOW(options=aeroOptions, debug=True)

if not 'complex' in sys.argv:
    # Solve system
    CFDSolver(ap, writeSolution=False)
    funcs = {}
    CFDSolver.evalFunctions(ap, funcs)
    # Solve sensitivities
    funcsSens = {}
Exemplo n.º 26
0
    'gridfile': gridFile,
    'mgcycle': '2w',
    'ncyclescoarse': 250,
    'ncycles': 500,
    'monitorvariables': ['resrho', 'cl', 'cd', 'cmz', 'totalr'],
    'usenksolver': True,
    'l2convergence': 1e-14,
    'l2convergencecoarse': 1e-2,
    'nkswitchtol': 1e-2,
    'adjointl2convergence': 1e-14,
    'solutionprecision': 'single',
    'gridprecision': 'double',
})
ap = AeroProblem(name='mdo_tutorial',
                 alpha=1.20,
                 mach=0.80,
                 altitude=10000.0,
                 areaRef=45.5,
                 chordRef=3.25)


def setup_cb(comm):

    # Create the solver
    CFDSolver = ADFLOW(options=options, debug=True)

    return CFDSolver, None, None, None


if __name__ == "__main__":

    CFDSolver, _, _, _ = setup_cb(MPI.COMM_WORLD)
Exemplo n.º 27
0
    'double',
    'gridprecision':
    'double',
})

meshOptions = copy.copy(IDWarpDefOpts)
meshOptions.update({'gridFile': gridFile})

# 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=['cl', 'cd'])


def setup_cb(comm):

    # Create the solver
    CFDSolver = ADFLOW(options=options, comm=comm, debug=False)

    # Setup geometry/mesh
    DVGeo = DVGeometry(ffdFile)
Exemplo n.º 28
0
    "L2ConvergenceCoarse": 1e-2,
    "nCycles": 1000,
}
# rst Start ADflow
# Create solver
CFDSolver = ADFLOW(options=aeroOptions)

# Add features
CFDSolver.addLiftDistribution(150, "z")
CFDSolver.addSlices("z", np.linspace(0.1, 14, 10))

# rst Create AeroProblem
ap = AeroProblem(name="wing",
                 mach=0.8,
                 altitude=10000,
                 alpha=1.5,
                 areaRef=45.5,
                 chordRef=3.25,
                 evalFuncs=["cl", "cd"])

# rst Create polar arrays

# Create an array of alpha values.
# In this case we create 6 evenly spaced values from 0 - 5.
alphaList = np.linspace(0, 5, 6)

# Create storage for the evaluated lift and drag coefficients
CL = []
CD = []
# rst Start loop
# Loop over the alpha values and evaluate the polar
Exemplo n.º 29
0
# Aerodynamic problem description
ap = AeroProblem(name=name,
                 alpha=alpha,
                 mach=mach,
                 altitude=altitude,
                 areaRef=areaRef,
                 chordRef=chordRef,
                 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')
Exemplo n.º 30
0
    'l2convergencecoarse': 1e-4,
    'qmode': True,
    'alphafollowing': False,
    'blockSplitting': True,
    'useblockettes': False,
})
ap = AeroProblem(name=name,
                 alpha=alpha_m,
                 mach=M,
                 machRef=M,
                 reynolds=4800000.0,
                 reynoldsLength=c,
                 T=T,
                 R=R,
                 areaRef=1.0,
                 chordRef=c,
                 evalFuncs=['cl', 'cd', 'cmz'],
                 xRef=0.25,
                 xRot=0.25,
                 degreePol=0,
                 coefPol=[0.0],
                 degreeFourier=1,
                 omegaFourier=omega,
                 cosCoefFourier=[0.0, 0.0],
                 sinCoefFourier=[deltaAlpha])


def setup_cb(comm):
    CFDSolver = ADFLOW(options=options, comm=comm)
    CFDSolver.addSlices('z', [0.5])
    CFDSolver(ap)