def fun_pEqn( mesh, runTime, pimple, thermo, rho, p, h, psi, U, phi, mrfZones, turbulence, UEqn, dpdt, K, cumulativeContErr, rhoMax, rhoMin ):

    rho << thermo.rho()
    rho << rho().ext_max( rhoMin )
    rho << rho().ext_min( rhoMax )
    rho.relax()

    rAU = 1.0 / UEqn.A()
    U << rAU() * UEqn.H()

    if pimple.transonic():
        phid = ref.surfaceScalarField( ref.word( "phid" ), ref.fvc.interpolate( psi ) * ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) \
                                                                                          + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) ) );
        mrfZones.relativeFlux( ref.fvc.interpolate( psi ), phid )
        
        while pimple.correctNonOrthogonal():
            pEqn = ref.fvm.ddt( psi, p) + ref.fvm.div( phid, p ) - ref.fvm.laplacian( rho() * rAU, p ) # mixed calculations
            
            pEqn.solve( mesh.solver( p.select( pimple.finalInnerIter() ) ) )

            if pimple.finalNonOrthogonalIter():
                phi == pEqn.flux()
                pass
            pass
        pass
    else:
        phi << ref.fvc.interpolate( rho ) * ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) )
        
        mrfZones.relativeFlux( ref.fvc.interpolate( rho ), phi )
        
        while pimple.correctNonOrthogonal():
            pEqn = ref.fvm.ddt( psi, p ) + ref.fvc.div( phi ) - ref.fvm.laplacian( rho()*rAU, p )  # mixed calculations
            
            pEqn.solve( mesh.solver( p.select( pimple.finalInnerIter() ) ) )
            
            if pimple.finalNonOrthogonalIter():
                phi += pEqn.flux()
                pass
            pass    
        pass

    ref.rhoEqn( rho, phi )
    cumulativeContErr = ref.compressibleContinuityErrs( rho(), thermo, cumulativeContErr ) # mixed calculations
    # Explicitly relax pressure for momentum corrector
    p.relax()
    
    # Recalculate density from the relaxed pressure
    rho << thermo.rho()
    rho << rho().ext_max( rhoMin )
    rho << rho().ext_min( rhoMax )
    rho.relax()
    ref.ext_Info()<< "rho max/min : " << rho.ext_max().value()  << " " << rho.ext_min().value() << ref.nl

    U -= rAU * ref.fvc.grad( p )
    U.correctBoundaryConditions()

    K << 0.5 * U.magSqr()
    dpdt << ref.fvc.ddt( p )
    
    return cumulativeContErr
Esempio n. 2
0
def solveFluid( i, mesh, thermo, rad, thermoFluid, rho, K, U, phi, h, turb, DpDt, p, psi, initialMass, p_rgh, gh, ghf,\
                oCorr, nCorr, nOuterCorr, nNonOrthCorr, momentumPredictor,cumulativeContErr, finalIter ) :
    if finalIter:
        mesh.add( ref.word( "finalIteration" ), True )
        pass

    if oCorr == 0 :
        ref.rhoEqn( rho, phi )
        pass
    
    UEqn = fun_UEqn( rho, U, phi, ghf, p_rgh, turb, mesh, momentumPredictor, finalIter )
    fun_hEqn( rho, h, phi, turb, DpDt, thermo, rad,  mesh, oCorr, nOuterCorr, finalIter )
    
    # --- PISO loop
    for corr in range( nCorr ):
        cumulativeContErr =  fun_pEqn( i, mesh, p, rho, turb, thermo, thermoFluid, K, UEqn, U, phi, psi, DpDt, initialMass, p_rgh, gh, ghf,
                                       nNonOrthCorr, oCorr, nOuterCorr, corr, nCorr, cumulativeContErr )
        pass
    
    turb.correct()
    rho << thermo.rho()
    
    if finalIter:
        mesh.remove( ref.word( "finalIteration" ) )
        pass
    
    return cumulativeContErr
Esempio n. 3
0
def fun_pEqn( mesh, runTime, thermo, rho, p, psi, U, phi, turbulence, UEqn, cumulativeContErr, nNonOrthCorr ):
      
     rho<<thermo.rho()
 
     rAU = 1.0 / UEqn.A()
  
     U<< rAU * UEqn.H()
     
     phid = ref.surfaceScalarField( ref.word( "phid" ),
                                    ref.fvc.interpolate( psi ) * 
                                             ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) ) )

     for nonOrth in range( nNonOrthCorr + 1 ):
         pEqn = ref.fvm.ddt( psi, p ) + ref.fvm.div( phid, p ) - ref.fvm.laplacian( rho * rAU, p )
         
         pEqn.solve()
         pass

     if nonOrth == nNonOrthCorr:
         phi<<  pEqn.flux()
         pass
         
     ref.rhoEqn( rho, phi )
  
     cumulativeContErr = ref.compressibleContinuityErrs( rho(), thermo, cumulativeContErr ) #it is necessary to force "mixed calculations" implementation

     U -= rAU * ref.fvc.grad( p )
     U.correctBoundaryConditions()
      
     return cumulativeContErr
Esempio n. 4
0
def solveFluid( i, mesh, thermo, rad, thermoFluid, rho, K, U, phi, h, turb, DpDt, p, psi, initialMass, p_rgh, gh, ghf,\
                oCorr, nCorr, nOuterCorr, nNonOrthCorr, momentumPredictor,cumulativeContErr, finalIter ) :
    if finalIter:
        mesh.add(ref.word("finalIteration"), True)
        pass

    if oCorr == 0:
        ref.rhoEqn(rho, phi)
        pass

    UEqn = fun_UEqn(rho, U, phi, ghf, p_rgh, turb, mesh, momentumPredictor,
                    finalIter)
    fun_hEqn(rho, h, phi, turb, DpDt, thermo, rad, mesh, oCorr, nOuterCorr,
             finalIter)

    # --- PISO loop
    for corr in range(nCorr):
        cumulativeContErr = fun_pEqn(i, mesh, p, rho, turb, thermo,
                                     thermoFluid, K, UEqn, U, phi, psi, DpDt,
                                     initialMass, p_rgh, gh, ghf, nNonOrthCorr,
                                     oCorr, nOuterCorr, corr, nCorr,
                                     cumulativeContErr)
        pass

    turb.correct()
    rho << thermo.rho()

    if finalIter:
        mesh.remove(ref.word("finalIteration"))
        pass

    return cumulativeContErr
Esempio n. 5
0
def fun_pEqn(mesh, runTime, thermo, rho, p, psi, U, phi, turbulence, UEqn,
             cumulativeContErr, nNonOrthCorr):

    rho << thermo.rho()

    rAU = 1.0 / UEqn.A()

    U << rAU * UEqn.H()

    phid = ref.surfaceScalarField(
        ref.word("phid"),
        ref.fvc.interpolate(psi) * ((ref.fvc.interpolate(U) & mesh.Sf()) +
                                    ref.fvc.ddtPhiCorr(rAU, rho, U, phi)))

    for nonOrth in range(nNonOrthCorr + 1):
        pEqn = ref.fvm.ddt(psi, p) + ref.fvm.div(phid, p) - ref.fvm.laplacian(
            rho * rAU, p)

        pEqn.solve()
        pass

    if nonOrth == nNonOrthCorr:
        phi << pEqn.flux()
        pass

    ref.rhoEqn(rho, phi)

    cumulativeContErr = ref.compressibleContinuityErrs(
        rho(), thermo, cumulativeContErr
    )  #it is necessary to force "mixed calculations" implementation

    U -= rAU * ref.fvc.grad(p)
    U.correctBoundaryConditions()

    return cumulativeContErr
def main_standalone( argc, argv ):
 
    args = ref.setRootCase( argc, argv )
    
    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )
    
    pimple = man.pimpleControl(mesh)
    
    pThermo, p, h, psi, rho, U, phi, rhoMax, rhoMin, turbulence, dpdt, K = createFields( runTime, mesh, pimple )
    
    mrfZones, pZones, pressureImplicitPorosity = createZones( mesh, U )
  
    cumulativeContErr = ref.initContinuityErrs()
  
    ref.ext_Info()<< "\nStarting time loop\n" << ref.nl;

    while runTime.run():
    
        adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls( runTime )
        CoNum, meanCoNum = ref.compressibleCourantNo( mesh, phi, rho, runTime )

        runTime = ref.setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
        runTime.increment()

        ref.ext_Info()<< "Time = " << runTime.timeName() << ref.nl << ref.nl;

        ref.rhoEqn( rho, phi )

        # --- Pressure-velocity PIMPLE corrector loop
        while pimple.loop():

            UEqn = fun_Ueqn( pimple, rho, p, U, phi, turbulence, mrfZones, pZones )
      
            fun_hEqn(pThermo, rho, p, h, phi, turbulence, dpdt, K )

            # --- PISO loop
            while (pimple.correct()):
                cumulativeContErr = fun_pEqn( mesh, runTime, pimple, pThermo, rho, p, h, psi, U, phi, mrfZones,
                                              turbulence, UEqn, dpdt, K, cumulativeContErr, rhoMax, rhoMin )
                pass
            
            if pimple.turbCorr():
                turbulence.correct()
                pass
            
            pass
        
        runTime.write()
            
        ref.ext_Info()<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \
                      << "  ClockTime = " << runTime.elapsedClockTime() << " s" \
                      << ref.nl << ref.nl
        pass

    ref.ext_Info()<< "End\n" << ref.nl
        
    import os
    return os.EX_OK
Esempio n. 7
0
def fun_pEqn(mesh, runTime, pimple, thermo, rho, p, h, psi, U, phi, turbulence,
             gh, ghf, p_rgh, UEqn, DpDt, cumulativeContErr, corr):
    rho << thermo.rho()

    # Thermodynamic density needs to be updated by psi*d(p) after the
    # pressure solution - done in 2 parts. Part 1:
    thermo.rho() << thermo.rho() - psi() * p_rgh()  # mixed calculations

    rAU = 1.0 / UEqn.A()
    rhorAUf = ref.surfaceScalarField(ref.word("(rho*(1|A(U)))"),
                                     ref.fvc.interpolate(rho * rAU))

    U << rAU * UEqn.H()

    phi << ref.fvc.interpolate(rho) * ((ref.fvc.interpolate(U) & mesh.Sf()) +
                                       ref.fvc.ddtPhiCorr(rAU, rho, U, phi))

    buoyancyPhi = -rhorAUf * ghf * ref.fvc.snGrad(rho) * mesh.magSf()

    phi += buoyancyPhi

    p_rghDDtEqn = ref.fvc.ddt(rho) + psi * ref.correction(
        ref.fvm.ddt(p_rgh)) + ref.fvc.div(phi)

    for nonOrth in range(pimple.nNonOrthCorr() + 1):
        p_rghEqn = p_rghDDtEqn - ref.fvm.laplacian(rhorAUf, p_rgh)

        p_rghEqn.solve(
            mesh.solver(p_rgh.select(pimple.finalInnerIter(corr, nonOrth))))

        if nonOrth == pimple.nNonOrthCorr():
            # Calculate the conservative fluxes
            phi += p_rghEqn.flux()
            # Explicitly relax pressure for momentum corrector
            p_rgh.relax()

            # Correct the momentum source with the pressure gradient flux
            # calculated from the relaxed pressure
            U += rAU * ref.fvc.reconstruct(
                (buoyancyPhi + p_rghEqn.flux()) / rhorAUf)
            U.correctBoundaryConditions()
            pass
        pass

    p << p_rgh + rho * gh

    # Second part of thermodynamic density update
    thermo.rho() << thermo.rho() + psi() * p_rgh  # mixed calculations

    DpDt << ref.fvc.DDt(
        ref.surfaceScalarField(ref.word("phiU"),
                               phi() / ref.fvc.interpolate(rho)),
        p)  # mixed calculations

    ref.rhoEqn(rho, phi)
    cumulativeContErr = ref.compressibleContinuityErrs(
        rho(), thermo, cumulativeContErr)  #mixed calculations

    return cumulativeContErr
Esempio n. 8
0
def fun_pEqn( mesh, runTime, pimple, thermo, rho, p, h, psi, U, phi, mrfZones, turbulence, UEqn, DpDt, cumulativeContErr, corr, rhoMax, rhoMin ):

    rho << thermo.rho()
    rho << rho().ext_max( rhoMin )
    rho << rho().ext_min( rhoMax )
    rho.relax()

    rAU = 1.0 / UEqn.A()
    U << rAU() * UEqn.H()

    if pimple.transonic():
        phid = ref.surfaceScalarField( ref.word( "phid" ), ref.fvc.interpolate( psi ) * ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) \
                                                                                          + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) ) );
        mrfZones.relativeFlux( ref.fvc.interpolate( psi ), phid )
        
        for nonOrth in range( pimple.nNonOrthCorr() + 1 ):
            pEqn = ref.fvm.ddt( psi, p) + ref.fvm.div( phid, p ) - ref.fvm.laplacian( rho() * rAU, p ) # mixed calculations
            
            pEqn.solve( mesh.solver( p.select( pimple.finalInnerIter( corr, nonOrth ) ) ) )

            if nonOrth == pimple.nNonOrthCorr():
                phi == pEqn.flux()
                pass
            pass
        pass
    else:
        phi << ref.fvc.interpolate( rho ) * ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) )
        
        mrfZones.relativeFlux( ref.fvc.interpolate( rho ), phi )
        
        for nonOrth in range( pimple.nNonOrthCorr() + 1 ):
            pEqn = ref.fvm.ddt( psi, p ) + ref.fvc.div( phi ) - ref.fvm.laplacian( rho()*rAU, p )  # mixed calculations
            
            pEqn.solve( mesh.solver( p.select( pimple.finalInnerIter( corr, nonOrth ) ) ) )
            
            if nonOrth == pimple.nNonOrthCorr():
                phi += pEqn.flux()
                pass
            pass    
        pass

    ref.rhoEqn( rho, phi )
    cumulativeContErr = ref.compressibleContinuityErrs( rho(), thermo, cumulativeContErr ) # mixed calculations
    # Explicitly relax pressure for momentum corrector
    p.relax()
    
    # Recalculate density from the relaxed pressure
    rho << thermo.rho()
    rho << rho().ext_max( rhoMin )
    rho << rho().ext_min( rhoMax )
    rho.relax()
    ref.ext_Info()<< "rho max/min : " << rho.ext_max().value()  << " " << rho.ext_min().value() << ref.nl

    U -= rAU * ref.fvc.grad( p )
    U.correctBoundaryConditions()

    DpDt << ref.fvc.DDt( ref.surfaceScalarField( ref.word( "phiU" ), phi() / ref.fvc.interpolate( rho ) ), p ) # mixed calculations
    
    return cumulativeContErr
Esempio n. 9
0
def fun_pEqn( mesh, runTime, pimple, thermo, rho, p, h, psi, U, phi, turbulence, UEqn, rAU, DpDt, cumulativeContErr, corr, rhoMax, rhoMin ):

    rho << thermo.rho()
    rho << rho().ext_max( rhoMin )
    rho << rho().ext_min( rhoMax )
    rho.relax()

    U << rAU() * UEqn.H()

    if pimple.transonic():
        phid = ref.surfaceScalarField( ref.word( "phid" ), ref.fvc.interpolate( psi ) * ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) \
                                                                                          + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) ) );
        for nonOrth in range( pimple.nNonOrthCorr() + 1 ):
            pEqn = ref.fvm.ddt( psi, p) + ref.fvm.div( phid, p ) - ref.fvm.laplacian( rho() * rAU, p ) # mixed calculations
            
            pEqn.solve( mesh.solver( p.select( pimple.finalInnerIter( corr, nonOrth ) ) ) )

            if nonOrth == pimple.nNonOrthCorr():
                phi == pEqn.flux()
                pass
            pass
        pass
    else:
        phi << ref.fvc.interpolate( rho ) * ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) )
        
        for nonOrth in range( pimple.nNonOrthCorr() + 1 ):
            pEqn = ref.fvm.ddt( psi, p ) + ref.fvc.div( phi ) - ref.fvm.laplacian( rho()*rAU, p )  # mixed calculations
            
            pEqn.solve( mesh.solver( p.select( pimple.finalInnerIter( corr, nonOrth ) ) ) )
            
            if nonOrth == pimple.nNonOrthCorr():
                phi += pEqn.flux()
                pass
            pass    
        pass

    ref.rhoEqn( rho, phi )
    cumulativeContErr = ref.compressibleContinuityErrs( rho(), thermo, cumulativeContErr ) # mixed calculations
    # Explicitly relax pressure for momentum corrector
    p.relax()
    
    # Recalculate density from the relaxed pressure
    rho << thermo.rho()
    rho << rho().ext_max( rhoMin )
    rho << rho().ext_min( rhoMax )
    rho.relax()
    ref.ext_Info()<< "rho max/min : " << rho.ext_max().value()  << " " << rho.ext_min().value() << ref.nl

    U -= rAU * ref.fvc.grad( p )
    U.correctBoundaryConditions()

    DpDt << ref.fvc.DDt( ref.surfaceScalarField( ref.word( "phiU" ), phi() / ref.fvc.interpolate( rho ) ), p ) # mixed calculations
    
    return cumulativeContErr
Esempio n. 10
0
def fun_pEqn(
    mesh, runTime, pimple, thermo, rho, p, h, psi, U, phi, turbulence, gh, ghf, p_rgh, UEqn, dpdt, K, cumulativeContErr
):
    rho << thermo.rho()

    # Thermodynamic density needs to be updated by psi*d(p) after the
    # pressure solution - done in 2 parts. Part 1:
    thermo.rho() << thermo.rho() - psi() * p_rgh()  # mixed calculations

    rAU = 1.0 / UEqn.A()
    rhorAUf = ref.surfaceScalarField(ref.word("(rho*(1|A(U)))"), ref.fvc.interpolate(rho * rAU))

    U << rAU * UEqn.H()

    phi << ref.fvc.interpolate(rho) * ((ref.fvc.interpolate(U) & mesh.Sf()) + ref.fvc.ddtPhiCorr(rAU, rho, U, phi))

    buoyancyPhi = -rhorAUf * ghf * ref.fvc.snGrad(rho) * mesh.magSf()

    phi += buoyancyPhi

    p_rghDDtEqn = ref.fvc.ddt(rho) + psi * ref.correction(ref.fvm.ddt(p_rgh)) + ref.fvc.div(phi)

    while pimple.correctNonOrthogonal():
        p_rghEqn = p_rghDDtEqn - ref.fvm.laplacian(rhorAUf, p_rgh)

        p_rghEqn.solve(mesh.solver(p_rgh.select(pimple.finalInnerIter())))

        if pimple.finalNonOrthogonalIter():
            # Calculate the conservative fluxes
            phi += p_rghEqn.flux()
            # Explicitly relax pressure for momentum corrector
            p_rgh.relax()

            # Correct the momentum source with the pressure gradient flux
            # calculated from the relaxed pressure
            U += rAU * ref.fvc.reconstruct((buoyancyPhi + p_rghEqn.flux()) / rhorAUf)
            U.correctBoundaryConditions()
            K << 0.5 * U.magSqr()
            pass
        pass

    p << p_rgh + rho * gh

    # Second part of thermodynamic density update
    thermo.rho() << thermo.rho() + psi() * p_rgh  # mixed calculations

    dpdt << ref.fvc.ddt(p)  # mixed calculations

    ref.rhoEqn(rho, phi)
    cumulativeContErr = ref.compressibleContinuityErrs(rho(), thermo, cumulativeContErr)  # mixed calculations

    return cumulativeContErr
Esempio n. 11
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    pThermo, p, e, psi, rho, U, phi, turbulence = createFields(runTime, mesh)

    cumulativeContErr = ref.initContinuityErrs()

    ref.ext_Info() << "\nStarting time loop\n" << ref.nl

    while runTime.loop():
        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl

        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = ref.readPISOControls(
            mesh)

        CoNum, meanCoNum = ref.compressibleCourantNo(mesh, phi, rho, runTime)

        ref.rhoEqn(rho, phi)

        UEqn = fun_Ueqn(rho, U, phi, turbulence, p)

        fun_eEqn(rho, e, phi, turbulence, p, pThermo)

        for corr in range(nCorr):
            cumulativeContErr = fun_pEqn(mesh, runTime, pThermo, rho, p, psi,
                                         U, phi, turbulence, UEqn,
                                         cumulativeContErr, nNonOrthCorr)
            pass

        turbulence.correct()

        rho << pThermo.rho()

        runTime.write()

        ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime(
        ) << " s" << "  ClockTime = " << runTime.elapsedClockTime(
        ) << " s" << ref.nl << ref.nl
        pass

    ref.ext_Info() << "End\n"

    import os
    return os.EX_OK
Esempio n. 12
0
def compressibleContinuityErrs( rho, phi,p, rho0, p0, psi, cumulativeContErr ):
    ref.rhoEqn( rho, phi )
    
    tmp = ( rho() - rho0 - psi * ( p() - p0 ) ).mag()            #
    sumLocalContErr = ( tmp.ext_sum() / rho.ext_sum() ).value()  # mixed calculations
    
    tmp =  rho() - rho0 - psi * ( p() - p0 )                     #
    globalContErr = ( tmp.ext_sum() / rho().ext_sum() ).value()  # mixed calculations

    cumulativeContErr += globalContErr

    ref.ext_Info() << "time step continuity errors : sum local = " << sumLocalContErr \
                   << ", global = " << globalContErr \
                   << ", cumulative = " << cumulativeContErr << ref.nl
    
    return cumulativeContErr
Esempio n. 13
0
def compressibleContinuityErrs(rho, phi, p, rho0, p0, psi, cumulativeContErr):
    ref.rhoEqn(rho, phi)

    tmp = (rho() - rho0 - psi * (p() - p0)).mag()  #
    sumLocalContErr = (tmp.ext_sum() /
                       rho.ext_sum()).value()  # mixed calculations

    tmp = rho() - rho0 - psi * (p() - p0)  #
    globalContErr = (tmp.ext_sum() /
                     rho().ext_sum()).value()  # mixed calculations

    cumulativeContErr += globalContErr

    ref.ext_Info() << "time step continuity errors : sum local = " << sumLocalContErr \
                   << ", global = " << globalContErr \
                   << ", cumulative = " << cumulativeContErr << ref.nl

    return cumulativeContErr
Esempio n. 14
0
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )
    
    pThermo, p, e, psi, rho, U, phi, turbulence = createFields( runTime, mesh )

    cumulativeContErr = ref.initContinuityErrs()
    
    ref.ext_Info() << "\nStarting time loop\n" << ref.nl

    while runTime.loop():
        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl

        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = ref.readPISOControls( mesh )
        
        CoNum, meanCoNum = ref.compressibleCourantNo( mesh, phi, rho, runTime )
        
        ref.rhoEqn( rho, phi );
        
        UEqn = fun_Ueqn( rho, U, phi, turbulence, p )

        fun_eEqn( rho, e, phi, turbulence, p, pThermo )

        for corr in range( nCorr ) :
            cumulativeContErr = fun_pEqn( mesh, runTime, pThermo, rho, p, psi, U, phi, turbulence, UEqn, cumulativeContErr, nNonOrthCorr )
            pass

        turbulence.correct()

        rho << pThermo.rho()

        runTime.write()

        ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << "  ClockTime = " << runTime.elapsedClockTime() << " s" << ref.nl << ref.nl
        pass

    ref.ext_Info() << "End\n"

    import os
    return os.EX_OK
Esempio n. 15
0
def main_standalone( argc, argv ):

    args = ref.setRootCase( argc, argv )
   
    runTime = man.createTime( args )
    
    mesh = man.createMesh( runTime )
  
    thermodynamicProperties, rho0, p0, psi, rhoO =  readThermodynamicProperties( runTime, mesh )
    
    transportProperties, mu = readTransportProperties( runTime, mesh )
    
    p, U, rho, phi = createFields( runTime, mesh, rhoO, psi )
  
    cumulativeContErr = ref.initContinuityErrs()
  
    #// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    ref.ext_Info()<< "\nStarting time loop\n" << ref.nl

    while runTime.loop():
 
        ref.ext_Info()<< "Time = " << runTime.timeName() << ref.nl << ref.nl
       
        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = ref.readPISOControls( mesh )

        CoNum, meanCoNum = ref.compressibleCourantNo( mesh, phi, rho, runTime )

        ref.rhoEqn( rho, phi )

        UEqn = man.fvm.ddt( rho, U ) + man.fvm.div( phi, U ) - man.fvm.laplacian( mu, U )
        
        ref.solve( UEqn == -man.fvc.grad( p ) )

        # --- PISO loop
        for corr in range( nCorr ):
               
            rAU = 1.0 / UEqn.A()
            U << rAU * UEqn.H()

            phid = ref.surfaceScalarField( ref.word( "phid" ), 
                                           psi * ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rAU, rho(), U(), phi() ) ) )

            phi << ( rhoO / psi ) * phid
            pEqn = ref.fvm.ddt( psi, p() ) + ref.fvc.div( phi() ) + ref.fvm.div( phid, p() ) - ref.fvm.laplacian( rho() * rAU, p() )
 
            pEqn.solve()

            phi += pEqn.flux()
        
            cumulativeContErr = compressibleContinuityErrs( rho, phi,p, rho0, p0, psi, cumulativeContErr )
        
            U -= rAU * ref.fvc.grad( p )
            U.correctBoundaryConditions()
            pass
        rho << rhoO + psi * p

        runTime.write()

        ref.ext_Info()<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \
                      << "  ClockTime = " << runTime.elapsedClockTime() << " s" \
                      << ref.nl << ref.nl
        pass

    ref.ext_Info()<< "End\n" << ref.nl
    
    import os
    return os.EX_OK
Esempio n. 16
0
def fun_pEqn( i, mesh, p, rho, turb, thermo, thermoFluid, K, UEqn, U, phi, psi, DpDt, initialMass, p_rgh, gh, ghf, \
              nNonOrthCorr, oCorr, nOuterCorr, corr, nCorr, cumulativeContErr ) :
    
    closedVolume = p_rgh.needReference()
    
    compressibility = ref.fvc.domainIntegrate( psi )
    
    compressible = ( compressibility.value() > ref.SMALL )

    rho << thermo.rho()
    
    rUA = 1.0 / UEqn.A()
    
    rhorUAf = ref.surfaceScalarField( ref.word( "(rho*(1|A(U)))" ) , ref.fvc.interpolate( rho * rUA ) )

    U << rUA * UEqn.H() 

    phiU = ( ref.fvc.interpolate( rho ) *
                 (  ( ref.fvc.interpolate( U ) & mesh.Sf() ) +
                      ref.fvc.ddtPhiCorr( rUA, rho, U, phi ) ) )
    phi << phiU - rhorUAf * ghf * ref.fvc.snGrad( rho ) * mesh.magSf()

    p_rghDDtEqn = ref.fvc.ddt( rho ) + psi * ref.correction( ref.fvm.ddt( p_rgh ) ) + ref.fvc.div( phi )
    
    # Thermodynamic density needs to be updated by psi*d(p) after the
    # pressure solution - done in 2 parts. Part 1:
    thermo.rho() << thermo.rho() - psi * p_rgh

    for nonOrth in range ( nNonOrthCorr + 1 ):
        p_rghEqn = p_rghDDtEqn - ref.fvm.laplacian( rhorUAf, p_rgh )
        p_rghEqn.solve( mesh.solver( p_rgh.select( ( oCorr == nOuterCorr-1 and corr == nCorr-1 and nonOrth == nNonOrthCorr ) ) ) )
        
        if nonOrth == nNonOrthCorr :
           phi += p_rghEqn.flux()
           pass
        pass
    
    # Second part of thermodynamic density update
    thermo.rho() << thermo.rho() + psi * p_rgh
    
    # Correct velocity field
    U += rUA * ref.fvc.reconstruct( ( phi() - phiU ) / rhorUAf ) # mixed calculations
    U.correctBoundaryConditions()
    
    p << p_rgh + rho * gh

    #Update pressure substantive derivative
    DpDt << ref.fvc.DDt( ref.surfaceScalarField( ref.word( "phiU" ), phi() / ref.fvc.interpolate( rho ) ), p ) # mixed calculations
    
    # Solve continuity
    ref.rhoEqn( rho, phi )   
    
    # Update continuity errors
    cumulativeContErr = compressibleContinuityErrors( i, mesh, rho, thermo, cumulativeContErr )
    
    # For closed-volume cases adjust the pressure and density levels
    # to obey overall mass continuity
    if closedVolume and compressible:
       p += ( initialMass - ref.fvc.domainIntegrate( thermo.rho() ) ) / compressibility
       rho << thermo.rho()
       p_rgh << p - rho * gh()
       pass
    #Update thermal conductivity
    K << thermoFluid[ i ].Cp() * turb.alphaEff()
        
    return cumulativeContErr
Esempio n. 17
0
def fun_pEqn( i, mesh, p, rho, turb, thermo, thermoFluid, K, UEqn, U, phi, psi, DpDt, initialMass, p_rgh, gh, ghf, \
              nNonOrthCorr, oCorr, nOuterCorr, corr, nCorr, cumulativeContErr ) :

    closedVolume = p_rgh.needReference()

    compressibility = ref.fvc.domainIntegrate(psi)

    compressible = (compressibility.value() > ref.SMALL)

    rho << thermo.rho()

    rUA = 1.0 / UEqn.A()

    rhorUAf = ref.surfaceScalarField(ref.word("(rho*(1|A(U)))"),
                                     ref.fvc.interpolate(rho * rUA))

    U << rUA * UEqn.H()

    phiU = (ref.fvc.interpolate(rho) * ((ref.fvc.interpolate(U) & mesh.Sf()) +
                                        ref.fvc.ddtPhiCorr(rUA, rho, U, phi)))
    phi << phiU - rhorUAf * ghf * ref.fvc.snGrad(rho) * mesh.magSf()

    p_rghDDtEqn = ref.fvc.ddt(rho) + psi * ref.correction(
        ref.fvm.ddt(p_rgh)) + ref.fvc.div(phi)

    # Thermodynamic density needs to be updated by psi*d(p) after the
    # pressure solution - done in 2 parts. Part 1:
    thermo.rho() << thermo.rho() - psi * p_rgh

    for nonOrth in range(nNonOrthCorr + 1):
        p_rghEqn = p_rghDDtEqn - ref.fvm.laplacian(rhorUAf, p_rgh)
        p_rghEqn.solve(
            mesh.solver(
                p_rgh.select((oCorr == nOuterCorr - 1 and corr == nCorr - 1
                              and nonOrth == nNonOrthCorr))))

        if nonOrth == nNonOrthCorr:
            phi += p_rghEqn.flux()
            pass
        pass

    # Second part of thermodynamic density update
    thermo.rho() << thermo.rho() + psi * p_rgh

    # Correct velocity field
    U += rUA * ref.fvc.reconstruct(
        (phi() - phiU) / rhorUAf)  # mixed calculations
    U.correctBoundaryConditions()

    p << p_rgh + rho * gh

    #Update pressure substantive derivative
    DpDt << ref.fvc.DDt(
        ref.surfaceScalarField(ref.word("phiU"),
                               phi() / ref.fvc.interpolate(rho)),
        p)  # mixed calculations

    # Solve continuity
    ref.rhoEqn(rho, phi)

    # Update continuity errors
    cumulativeContErr = compressibleContinuityErrors(i, mesh, rho, thermo,
                                                     cumulativeContErr)

    # For closed-volume cases adjust the pressure and density levels
    # to obey overall mass continuity
    if closedVolume and compressible:
        p += (initialMass -
              ref.fvc.domainIntegrate(thermo.rho())) / compressibility
        rho << thermo.rho()
        p_rgh << p - rho * gh()
        pass
    #Update thermal conductivity
    K << thermoFluid[i].Cp() * turb.alphaEff()

    return cumulativeContErr
Esempio n. 18
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    thermodynamicProperties, rho0, p0, psi, rhoO = readThermodynamicProperties(
        runTime, mesh)

    transportProperties, mu = readTransportProperties(runTime, mesh)

    p, U, rho, phi = createFields(runTime, mesh, rhoO, psi)

    cumulativeContErr = ref.initContinuityErrs()

    #// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    ref.ext_Info() << "\nStarting time loop\n" << ref.nl

    while runTime.loop():

        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl

        piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr = ref.readPISOControls(
            mesh)

        CoNum, meanCoNum = ref.compressibleCourantNo(mesh, phi, rho, runTime)

        ref.rhoEqn(rho, phi)

        UEqn = man.fvm.ddt(rho, U) + man.fvm.div(phi, U) - man.fvm.laplacian(
            mu, U)

        ref.solve(UEqn == -man.fvc.grad(p))

        # --- PISO loop
        for corr in range(nCorr):

            rAU = 1.0 / UEqn.A()
            U << rAU * UEqn.H()

            phid = ref.surfaceScalarField(
                ref.word("phid"),
                psi * ((ref.fvc.interpolate(U) & mesh.Sf()) +
                       ref.fvc.ddtPhiCorr(rAU, rho(), U(), phi())))

            phi << (rhoO / psi) * phid
            pEqn = ref.fvm.ddt(psi, p()) + ref.fvc.div(phi()) + ref.fvm.div(
                phid, p()) - ref.fvm.laplacian(rho() * rAU, p())

            pEqn.solve()

            phi += pEqn.flux()

            cumulativeContErr = compressibleContinuityErrs(
                rho, phi, p, rho0, p0, psi, cumulativeContErr)

            U -= rAU * ref.fvc.grad(p)
            U.correctBoundaryConditions()
            pass
        rho << rhoO + psi * p

        runTime.write()

        ref.ext_Info()<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \
                      << "  ClockTime = " << runTime.elapsedClockTime() << " s" \
                      << ref.nl << ref.nl
        pass

    ref.ext_Info() << "End\n" << ref.nl

    import os
    return os.EX_OK
Esempio n. 19
0
def main_standalone(argc, argv):

    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    pimple = man.pimpleControl(mesh)

    maxDeltaT, rDeltaT = setInitialrDeltaT(runTime, mesh, pimple)

    pThermo, p, h, psi, rho, U, phi, rhoMax, rhoMin, turbulence, dpdt, K = createFields(
        runTime, mesh, pimple)

    mrfZones, pZones, pressureImplicitPorosity = createZones(mesh, U)

    cumulativeContErr = ref.initContinuityErrs()

    ref.ext_Info() << "\nStarting time loop\n" << ref.nl

    while runTime.run():

        adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls(runTime)

        CoNum, meanCoNum = ref.compressibleCourantNo(mesh, phi, rho, runTime)

        runTime = ref.setDeltaT(runTime, adjustTimeStep, maxCo, maxDeltaT,
                                CoNum)
        runTime.increment()

        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl

        setrDeltaT(runTime, mesh, pimple, phi, psi, U, rho, rDeltaT, maxDeltaT)

        ref.rhoEqn(rho, phi)

        # --- Pressure-velocity PIMPLE corrector loop
        while pimple.loop():

            turbulence.correct()

            UEqn = fun_Ueqn(pimple, rho, p, U, phi, turbulence, mrfZones,
                            pZones)

            fun_hEqn(pThermo, rho, p, h, phi, turbulence, dpdt, K)

            # --- PISO loop
            while (pimple.correct()):
                cumulativeContErr = fun_pEqn(mesh, runTime, pimple, pThermo,
                                             rho, p, h, psi, U, phi, mrfZones,
                                             turbulence, UEqn, dpdt, K,
                                             cumulativeContErr, rhoMax, rhoMin)
                pass

            pass

        runTime.write()

        ref.ext_Info()<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \
                      << "  ClockTime = " << runTime.elapsedClockTime() << " s" \
                      << ref.nl << ref.nl
        pass

    ref.ext_Info() << "End\n" << ref.nl

    import os
    return os.EX_OK
Esempio n. 20
0
def main_standalone(argc, argv):
    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    g = ref.readGravitationalAcceleration(runTime, mesh)

    thermo, p, rho, h, psi, U, phi, turbulence, gh, ghf, p_rgh, DpDt = createFields(runTime, mesh, g)

    cumulativeContErr = ref.initContinuityErrs()

    adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls(runTime)

    CoNum, meanCoNum = ref.compressibleCourantNo(mesh, phi, rho, runTime)

    runTime = ref.setInitialDeltaT(runTime, adjustTimeStep, maxCo, CoNum)

    pimple = man.pimpleControl(mesh)

    # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    ref.ext_Info() << "\nStarting time loop\n" << ref.nl

    while runTime.run():

        adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls(runTime)
        CoNum, meanCoNum = ref.compressibleCourantNo(mesh, phi, rho, runTime)

        runTime = ref.setDeltaT(runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum)
        runTime.increment()

        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl

        ref.rhoEqn(rho, phi)

        # --- Pressure-velocity PIMPLE corrector loop
        pimple.start()
        while pimple.loop():
            if pimple.nOuterCorr() != 1:
                p_rgh.storePrevIter()
                pass

            UEqn = fun_Ueqn(pimple, mesh, rho, U, phi, turbulence, ghf, p_rgh)
            fun_hEqn(thermo, rho, p, h, phi, turbulence, DpDt)

            # --- PISO loop
            for corr in range(pimple.nCorr()):
                cumulativeContErr = fun_pEqn(
                    mesh,
                    runTime,
                    pimple,
                    thermo,
                    rho,
                    p,
                    h,
                    psi,
                    U,
                    phi,
                    turbulence,
                    gh,
                    ghf,
                    p_rgh,
                    UEqn,
                    DpDt,
                    cumulativeContErr,
                    corr,
                )
                pass
            if pimple.turbCorr():
                turbulence.correct()
                pass

            pimple.increment()
            pass
        rho << thermo.rho()

        runTime.write()

        ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << "  ClockTime = " << runTime.elapsedClockTime() << " s" << ref.nl << ref.nl
    ref.ext_Info() << "End\n" << ref.nl

    import os

    return os.EX_OK
Esempio n. 21
0
def main_standalone( argc, argv ):
 
    args = ref.setRootCase( argc, argv )
    
    runTime = man.createTime( args )

    mesh = man.createMesh( runTime )
    
    pThermo, p, h, psi, rho, U, phi, rhoMax, rhoMin, turbulence, DpDt = createFields( runTime, mesh )
  
    cumulativeContErr = ref.initContinuityErrs()
  
    pimple = man.pimpleControl(mesh)

    ref.ext_Info()<< "\nStarting time loop\n" << ref.nl;

    while runTime.run():
    
        adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls( runTime )
        CoNum, meanCoNum = ref.compressibleCourantNo( mesh, phi, rho, runTime )

        runTime = ref.setDeltaT( runTime, adjustTimeStep, maxCo, maxDeltaT, CoNum )
        runTime.increment()

        ref.ext_Info()<< "Time = " << runTime.timeName() << ref.nl << ref.nl;

        ref.rhoEqn( rho, phi )

        # --- Pressure-velocity PIMPLE corrector loop
        pimple.start()
        while pimple.loop():
            if pimple.nOuterCorr() != 1:
                p.storePrevIter()
                rho.storePrevIter()
                pass
            
            UEqn, rAU = fun_Ueqn( pimple, rho, p, U, phi, turbulence )
      
            fun_hEqn( pThermo, rho, p, h, phi, turbulence, DpDt )

            # --- PISO loop
            for corr in range( pimple.nCorr() ):
                cumulativeContErr = fun_pEqn( mesh, runTime, pimple, pThermo, rho, p, h, psi, U, phi, 
                                              turbulence, UEqn, rAU, DpDt, cumulativeContErr, corr, rhoMax, rhoMin )
                pass
            
            if pimple.turbCorr():
                turbulence.correct()
                pass
            
            pimple.increment()
            pass
        
        runTime.write()
            
        ref.ext_Info()<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \
                      << "  ClockTime = " << runTime.elapsedClockTime() << " s" \
                      << ref.nl << ref.nl
        pass

    ref.ext_Info()<< "End\n" << ref.nl
        
    import os
    return os.EX_OK
Esempio n. 22
0
def main_standalone(argc, argv):
    args = ref.setRootCase(argc, argv)

    runTime = man.createTime(args)

    mesh = man.createMesh(runTime)

    g = ref.readGravitationalAcceleration(runTime, mesh)

    thermo, p, rho, h, psi, U, phi, turbulence, gh, ghf, p_rgh, dpdt, K = createFields(
        runTime, mesh, g)

    cumulativeContErr = ref.initContinuityErrs()

    adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls(runTime)

    CoNum, meanCoNum = ref.compressibleCourantNo(mesh, phi, rho, runTime)

    runTime = ref.setInitialDeltaT(runTime, adjustTimeStep, maxCo, CoNum)

    pimple = man.pimpleControl(mesh)

    # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    ref.ext_Info() << "\nStarting time loop\n" << ref.nl

    while runTime.run():

        adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls(runTime)
        CoNum, meanCoNum = ref.compressibleCourantNo(mesh, phi, rho, runTime)

        runTime = ref.setDeltaT(runTime, adjustTimeStep, maxCo, maxDeltaT,
                                CoNum)
        runTime.increment()

        ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl

        ref.rhoEqn(rho, phi)

        # --- Pressure-velocity PIMPLE corrector loop
        while pimple.loop():

            UEqn = fun_Ueqn(pimple, mesh, rho, U, phi, turbulence, ghf, p_rgh,
                            K)
            fun_hEqn(thermo, rho, p, h, phi, turbulence, dpdt, K)

            # --- Pressure corrector loop
            while pimple.correct():
                cumulativeContErr = fun_pEqn(mesh, runTime, pimple, thermo,
                                             rho, p, h, psi, U, phi,
                                             turbulence, gh, ghf, p_rgh, UEqn,
                                             dpdt, K, cumulativeContErr)
                pass
            if pimple.turbCorr():
                turbulence.correct()
                pass

            pass
        rho << thermo.rho()

        runTime.write()

        ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \
                       << "  ClockTime = " << runTime.elapsedClockTime() << " s" \
                       << ref.nl << ref.nl
    ref.ext_Info() << "End\n" << ref.nl

    import os
    return os.EX_OK