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
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
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
Exemple #4
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