Example #1
0
def alphaEqn( mesh, phi, alpha1, rhoPhi, rho1, rho2, interface, nAlphaCorr ):
    from Foam.OpenFOAM import word 
    alphaScheme = word( "div(phi,alpha)" )
    alpharScheme = word( "div(phirb,alpha)" )
    
    from Foam.finiteVolume import surfaceScalarField
    phic = surfaceScalarField( ( phi / mesh.magSf() ).mag() )
    phic.ext_assign( ( interface.cAlpha() * phic ).ext_min( phic.ext_max() ) )
    phir = phic * interface.nHatf()
    
    from Foam import fvc
    from Foam import MULES

    for aCorr in range( nAlphaCorr ):
       phiAlpha = fvc.flux( phi, alpha1, alphaScheme ) + fvc.flux( -fvc.flux( -phir, 1.0 - alpha1, alpharScheme ), alpha1, alpharScheme )
       MULES.explicitSolve( alpha1, phi, phiAlpha, 1.0, 0.0 )
       
       rhoPhi.ext_assign( phiAlpha * ( rho1 - rho2 ) + phi * rho2 )

       pass
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Liquid phase volume fraction = " << alpha1.weightedAverage( mesh.V() ).value() \
               << "  Min(alpha1) = " << alpha1.ext_min().value() \
               << "  Max(alpha1) = " << alpha1.ext_max().value() << nl
    pass
Example #2
0
def alphaEqn(mesh, phi, alpha1, rhoPhi, rho1, rho2, interface, nAlphaCorr):
    from Foam.OpenFOAM import word
    alphaScheme = word("div(phi,alpha)")
    alpharScheme = word("div(phirb,alpha)")

    from Foam.finiteVolume import surfaceScalarField
    phic = surfaceScalarField((phi / mesh.magSf()).mag())
    phic.ext_assign((interface.cAlpha() * phic).ext_min(phic.ext_max()))
    phir = phic * interface.nHatf()

    from Foam import fvc
    from Foam import MULES

    for aCorr in range(nAlphaCorr):
        phiAlpha = fvc.flux(phi, alpha1, alphaScheme) + fvc.flux(
            -fvc.flux(-phir, 1.0 - alpha1, alpharScheme), alpha1, alpharScheme)
        MULES.explicitSolve(alpha1, phi, phiAlpha, 1.0, 0.0)

        rhoPhi.ext_assign(phiAlpha * (rho1 - rho2) + phi * rho2)

        pass
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Liquid phase volume fraction = " << alpha1.weightedAverage( mesh.V() ).value() \
               << "  Min(alpha1) = " << alpha1.ext_min().value() \
               << "  Max(alpha1) = " << alpha1.ext_max().value() << nl
    pass
Example #3
0
def alphaEqns( runTime, mesh, rho1, rho2, rhoPhi, phic, dgdt, divU, alpha1, alpha2, phi, interface, nAlphaCorr ):

    from Foam.OpenFOAM import word 
    alphaScheme = word( "div(phi,alpha)" )
    alpharScheme = word( "div(phirb,alpha)" )

    phir = phic*interface.nHatf()
    
    from Foam.finiteVolume import volScalarField
    from Foam.OpenFOAM import IOobject, word, fileName, dimensionedScalar, scalar, ext_Info, nl
    for gCorr in range( nAlphaCorr ):
        Sp = volScalarField.DimensionedInternalField( IOobject( word( "Sp" ),
                                                                fileName( runTime.timeName() ),
                                                                mesh ),
                                                      mesh,
                                                      dimensionedScalar( word( "Sp" ), dgdt.dimensions(), 0.0 ) )

        Su = volScalarField.DimensionedInternalField( IOobject( word( "Su" ),
                                                                fileName( runTime.timeName() ),
                                                                mesh ),
                                                      # Divergence term is handled explicitly to be
                                                      # consistent with the explicit transport solution
                                                      divU * alpha1.ext_min( scalar( 1 ) ) )
        for celli in range( dgdt.size() ):
            if dgdt[ celli ] > 0.0 and alpha1[ celli ] > 0.0:
                Sp[ celli ] -= dgdt[ celli ] * alpha1[ celli ]
                Su[ celli ] += dgdt[ celli ] * alpha1[ celli ]
                pass
            elif dgdt[ celli ] < 0.0 and alpha1[ celli ] < 1.0:
                Sp[ celli ] += dgdt[ celli ] * ( 1.0 - alpha1[ celli ] )
                pass
            pass

        from Foam import fvc
        phiAlpha1 = fvc.flux( phi, alpha1, alphaScheme ) + fvc.flux( - fvc.flux( -phir, alpha2, alpharScheme ), alpha1, alpharScheme )
        
        from Foam import MULES
        from Foam.OpenFOAM import geometricOneField
        MULES.explicitSolve( geometricOneField(), alpha1, phi, phiAlpha1, Sp, Su, 1.0, 0.0 )
        
        rho1f = fvc.interpolate( rho1 )
        rho2f = fvc.interpolate( rho2 )
        rhoPhi.ext_assign( phiAlpha1 * ( rho1f - rho2f ) + phi * rho2f )

        alpha2.ext_assign( scalar( 1 ) - alpha1 )

        pass

    
    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Liquid phase volume fraction = " << alpha1.weightedAverage( mesh.V() ).value() \
               << "  Min(alpha1) = " << alpha1.ext_min().value() << "  Min(alpha2) = " << alpha2.ext_min().value() << nl
    pass