combining a density-based compressible solver with a...
TRANSCRIPT
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Combining a density-based compressible solver with amultiphase model
Eleanor Harvey
CDT Fluid Dynamics,University of Leeds,
UK
January 18, 2021
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 1 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Introduction
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 2 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Contents
Introduction
rhoCentralFoam
Implementing a new solver, rhoCentralFoamHEM
Running a tutorial case
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 3 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Under-expanded jets
Under-expanded jets are observed in sudden releases from a high pressuresource.
They are often of interest in hazard modelling applications
The flows often exhibit highly compressible flow with shock features.
Figure: Typical under-expanded jet structure
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 4 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Compressible Computational Fluid Dynamics
Variable density
Compressibility variable, β, no longer assumed close to zero.
β =1
V
∂V
∂p
Can be solved with two approaches: pressure-based and density-based
Pressure-based Density-basedrhoSimpleFoam rhoCentralFoam
rhoPimpleFoam
rhoPimpleAdiabaticFoam
sonicFoam
Table: Core compressible OpenFOAM solvers
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 5 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Multi-phase compressible flow
A multiphase aspect is needed for liquid release which quickly undergoesphase change as pressure dramatically drops.
This flashing process is critical for predicting the flow.
OpenFOAM multiphase compressible solvers includecompressibleInterFoam and twoPhaseEulerFoam among others - they areall pressure based.
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 6 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
New multiphase density-based solver
Figure: New solver method
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 7 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Homogeneous Equilibrium Model
For the multiphase model, we include a very simplified model - the HomogeneousEquilibrium Mixture (HEM) modelThe model assumes both thermal and mechanical equilibrium between two phases- liquid and gas/vapour.most fields are weighted averages of their component phases:
e = αev + (1− α)el .
The phase fraction, α is calculated as
α =ρ− ρlρv − ρl
with the density ρ and the saturation densities (ρv and ρl).
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 8 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Sound speed compressibility modelling
One core difference in the two phase mixture is in the modelling of compressibilityand sound speed. These can be much lower in a two phase mixture than that ofeither component.
Figure: New solver method
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 9 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
rhoCentralFoam
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 10 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Governing equations
The governing equations solved by rhoCentralFoam are the continuity,momentum and energy equations
∂ρ
∂t+∇ · [Uρ] = 0,
∂(ρU)
∂t+∇· [U(ρU)] +∇p +∇ · σ = 0,
∂(ρE )
∂t+∇ · [U(ρE )] +∇ · [Up] +∇ · (σ · U) +∇ · j = 0,
for density, ρ, velocity, U, pressure, p, the total energy E = e + |U|2/2 with e thespecific internal energy or enthalpy, σ the viscous stress tensor,
σ = −µ[∇U + (∇U)T − 2/3(∇ · U)I
],
dynamic viscosity µ and j , the diffusive flux of heat with thermal conductivity k
j = −k∇T
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 11 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Discretisation of convective terms
Convective terms are integrated over a control volume and linearized inrhoCentralFoam.C for a generic dependent tensor field Ψ as,∫
V
∇ · [uΨ]dV =∫S
dS · [uΨ] ≈∑f
Sf · Uf Ψf =∑f
φf Ψf .
In compressible flow, wave propagation as well as velocity has an impact ontransport of fluid properties. Stabilisation must take into account that transportcan occur in any direction. Interpolation in both directions, f+, f−, is needed foreach cell face. A weighting factor, α, and a diffusive volumetric flux, ωf , based onmaximum speeds at any discontinuity are used to give the full discretisation:∑
f
φf Ψf =∑f
[αφf +Ψf + + (1− α)φf−Ψf− + ωf (Ψf− −Ψf +)]
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 12 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
createFields.H
Navigate to the solver directory and begin by looking at the createFields.H file.
OFv2006
cd $FOAM_SOLVERS/compressible/rhoCentralFoam
1 #include "createRDeltaT.H"
2
3 Info
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
createFields.H
The field for density is created from the thermo object and velocity is read in fromthe case.The solver implemented in OpenFOAM solves for density weighted fields, ρ,Û = ρU, Ê = ρE .
ea
40 volVectorField rhoU
41 (
42 IOobject
43 (
44 "rhoU",
45 runTime.timeName(),
46 mesh,
47 IOobject::NO_READ,
48 IOobject::NO_WRITE
49 ),
50 rho*U
51 );
ea
53 volScalarField rhoE
54 (
55 IOobject
56 (
57 "rhoE",
58 runTime.timeName(),
59 mesh,
60 IOobject::NO_READ,
61 IOobject::NO_WRITE
62 ),
63 rho*(e + 0.5*magSqr(U))
64 );
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 14 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
createFields.H
Surface scalar fields are created for the positive and negative directions which willbe used to interpolate different variables in the solver.
ea
66 surfaceScalarField pos
67 (
68 IOobject
69 (
70 "pos",
71 runTime.timeName(),
72 mesh
73 ),
74 mesh,
75 dimensionedScalar("pos", dimless, 1.0)
76 );
A turbulence model and phi variable are constructed at the end of thecreateFields.H file.
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 15 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
rhoCentralFoam.C
Looking into the main solver file rhoCentralFoam.C, the first step in the runtime loop is to interpolate the primitive variables in both directions.
ea
85 surfaceScalarField rho_pos(interpolate(rho, pos));
86 surfaceScalarField rho_neg(interpolate(rho, neg));
87
88 surfaceVectorField rhoU_pos(interpolate(rhoU, pos, U.name()));
89 surfaceVectorField rhoU_neg(interpolate(rhoU, neg, U.name()));
This is shown here for density, ρ and density weighted velocity, Û, but also codedfor the reciprocal compressibility, rPsi and internal energy/enthalpy, e.
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 16 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
rhoCentralFoam.C
Other variables which need interpolated surface fields are calculated from theseprimitive variables.
The velocity U is calculated from Û and ρ
Pressure is constructed from density and the reciprocal of compressibility,p = ρ/ψ
ea
98 surfaceVectorField U_pos("U_pos", rhoU_pos/rho_pos);
99 surfaceVectorField U_neg("U_neg", rhoU_neg/rho_neg);
100
101 surfaceScalarField p_pos("p_pos", rho_pos*rPsi_pos);
102 surfaceScalarField p_neg("p_neg", rho_neg*rPsi_neg);
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 17 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
rhoCentralFoam.C
Speed of sound, c is calculated on line 110 using specific heat capacities atconstant pressure, Cp and volume, Cv and the compressibility, ψ. The speed ofsound is critical in determining the propagation of waves through the fluid.
c2 =CpCvψ
ea
110 volScalarField c("c", sqrt(thermo.Cp()/thermo.Cv()*rPsi));
111 surfaceScalarField cSf_pos
112 (
113 "cSf_pos",
114 interpolate(c, pos, T.name())*mesh.magSf()
115 );
116
117 surfaceScalarField cSf_neg
118 (
119 "cSf_neg",
120 interpolate(c, neg, T.name())*mesh.magSf()
121 );
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 18 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
rhoCentralFoam.C
The surface scalar fields phiv_pos and phiv_neg are constructed for the velocitycomponents of the volumetric fluxes.
φf + = Uf + · Sfφf− = Uf− · Sf
ea104 surfaceScalarField phiv_pos("phiv_pos", U_pos & mesh.Sf());
ea107 surfaceScalarField phiv_neg("phiv_neg", U_neg & mesh.Sf());
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 19 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
rhoCentralFoam.C
Once these local speeds of propagation have been calculated, their associatedvolumetric fluxes, Φf± can be found.
Φf + = max(φf + + cf +|Sf |, φf− + cf−|Sf |, 0)
Φf− = min(φf + − cf +|Sf |, φf− − cf−|Sf |, 0)
ea
123 surfaceScalarField ap
124 (
125 "ap",
126 max(max(phiv_pos + cSf_pos, phiv_neg + cSf_neg), v_zero)
127 );
128
129 surfaceScalarField am
130 (
131 "am",
132 min(min(phiv_pos - cSf_pos, phiv_neg - cSf_neg), v_zero)
133 );
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 20 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
rhoCentralFoam.C
These fluxes are then used to calculate the weightings and diffusive term for thediscretisation,∑
f
φf Ψf =∑f
[αφf +Ψf + + (1− α)φf−Ψf− + ωf (Ψf− −Ψf +)]
Either a Tadmor central or Kurganov central-upwinding scheme is used,
α =
{12 , for the Tadmor flux scheme,
Φf +Φf +−Φf− , for the Kurganov flux scheme,
ωf =
{−α max(Φf +,Φf−), for the Tadmor flux scheme,−α(1− α)(Φf + − Φf−), for the Kurganov flux scheme,
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 21 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
rhoCentralFoam.C
The implementations of the weighting variable, α, as a_pos and the diffusive flux,ωf , as aSf are shown on lines 135-147.
ea
135 surfaceScalarField a_pos("a_pos", ap/(ap - am));
136
137 surfaceScalarField amaxSf("amaxSf", max(mag(am), mag(ap)));
138
139 surfaceScalarField aSf("aSf", am*a_pos);
140
141 if (fluxScheme == "Tadmor")
142 {
143 aSf = -0.5*amaxSf;
144 a_pos = 0.5;
145 }
146
147 surfaceScalarField a_neg("a_neg", 1.0 - a_pos);
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 22 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
rhoCentralFoam.C
Terms are collected together to acquire the fluxes in each direction, aphiv_posand aphiv_neg.
∑f
φf Ψf =∑f
[Ψf +[αφf + − ωf ] + Ψf−[(1− α)φf− + ωf ]]
ea
149 phiv_pos *= a_pos;
150 phiv_neg *= a_neg;
151
152 surfaceScalarField aphiv_pos("aphiv_pos", phiv_pos - aSf);
153 surfaceScalarField aphiv_neg("aphiv_neg", phiv_neg + aSf);
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 23 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
rhoCentralFoam.C
Finally the convective terms, Uρ, U(ρU), U(ρE ), Up are calculated.
ea
175 phi = aphiv_pos*rho_pos + aphiv_neg*rho_neg;
176
177 surfaceVectorField phiU(aphiv_pos*rhoU_pos + aphiv_neg*rhoU_neg);
Two terms in the momentum equation, ∇ · [U(ρU)] term and ∇p, are combinedinto variable phiUp. From the energy equation, U(ρE ) and Up are similarlycombined into phiEp.
ea
182 surfaceVectorField phiUp(phiU + (a_pos*p_pos + a_neg*p_neg)*mesh.Sf());
183
184 surfaceScalarField phiEp
185 (
186 "phiEp",
187 aphiv_pos*(rho_pos*(e_pos + 0.5*magSqr(U_pos)) + p_pos)
188 + aphiv_neg*(rho_neg*(e_neg + 0.5*magSqr(U_neg)) + p_neg)
189 + aSf*p_pos - aSf*p_neg
190 );
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 24 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
rhoCentralFoam.C
Finally the solver begins to solve the governing equations, beginning with thedensity equation,
∂ρ
∂t+∇ · [Uρ] = 0.
All the equations in rhoCentralFoam are solved in the main .C file.
ea
195 // --- Solve density
196 solve(fvm::ddt(rho) + fvc::div(phi));
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 25 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
rhoCentralFoam.C
Next - the momentum equation is solved in two steps.
The diffusive terms are functions of U and T for the momentum and heatdiffusion respectively cannot be evaluated implicitly with the other terms due tothe working variables, Û, Ê being density weighted.
They are applied as implicit corrections to the original inviscid equations:
The inviscid momentum equation is solved for Û
U is updated from the solution and then both the U and Û boundaryconditions are corrected in turn
If a non zero viscosity value was read in for the case then the diffusive termsare solved for, with variable U
Finally, Û is recalculated again in the non inviscid case
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 26 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
rhoCentralFoam.C
Solving the momentum equation in two stages:
ea
198 // --- Solve momentum
199 solve(fvm::ddt(rhoU) + fvc::div(phiUp));
200
201 U.ref() =
202 rhoU()
203 /rho();
204 U.correctBoundaryConditions();
205 rhoU.boundaryFieldRef() == rho.boundaryField()*U.
boundaryField();
206
207 if (!inviscid)
208 {
209 solve
210 (
211 fvm::ddt(rho, U) - fvc::ddt(rho, U)
212 - fvm::laplacian(muEff, U)
213 - fvc::div(tauMC)
214 );
215 rhoU = rho*U;
216 }
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 27 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
rhoCentralFoam.C
The energy equation is solved in two steps similarly to the momentum.Finally the pressure is updated as p = ρ/ψThe boundary conditions for p are then used to update those for ρ
ea
256 p.ref() =
257 rho()
258 /psi();
259 p.correctBoundaryConditions();
260 rho.boundaryFieldRef() == psi.boundaryField()*p.boundaryField();
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 28 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Implementing rhoCentralFoamHEM
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 29 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Copy and compile solver
Copy the solver rhoCentralFoam to our own working directory.
foamcp -r --parents applications/solvers/compressible/rhoCentralFoam $WM_PROJECT_USER_DIR
In our work space move the solver to a modified name - rhoCentralFoamHEM andchange the names in other files as needed:
usol
cd compressible/
mv rhoCentralFoam rhoCentralFoamHEM
cd rhoCentralFoamHEM
mv rhoCentralFoam.C rhoCentralFoamHEM.C
rm -r rhoCentralDyMFoam
sed -i s/rhoCentralFoam/rhoCentralFoamHEM/g rhoCentralFoamHEM.C
sed -i s/rhoCentralFoam/rhoCentralFoamHEM/g Make/files
sed -i s/FOAM_APPBIN/FOAM_USER_APPBIN/g Make/files
sed -i s/FOAM_LIBBIN/FOAM_USER_LIBBIN/g BCs/Make/files
wmake libso BCs
wmake
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 30 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Copying a multiphase thermophysical library
We need to include the structure for two different thermophysical models. A twophase library from the solver compressibleInterFoam is copied to the directoryand will be modified.
cp -r $FOAM_SOLVERS/multiphase/compressibleInterFoam/twoPhaseMixtureThermo \MytwoPhaseMixtureThermo
cd MytwoPhaseMixtureThermo
mv twoPhaseMixtureThermo.C MytwoPhaseMixtureThermo.C
mv twoPhaseMixtureThermo.H MytwoPhaseMixtureThermo.H
sed -i s/FOAM_LIBBIN/FOAM_USER_LIBBIN/g Make/files
sed -i s/twoPhaseMixtureThermo/MytwoPhaseMixtureThermo/g Make/files
sed -i s/twoPhaseMixtureThermo/MytwoPhaseMixtureThermo/g MytwoPhaseMixture*
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 31 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Modify the constructor
Next the phi variable is removed or commented out in theMytwoPhaseMixtureThermo.C and .H file constructors so the only input is thefield U.
44 Foam::MytwoPhaseMixtureThermo::MytwoPhaseMixtureThermo
45 (
46 const volVectorField& U
47 )
Modified MytwoPhaseMixtureThermo.C constructor
71 // Constructors
72
73 //- Construct from components
74 MytwoPhaseMixtureThermo
75 (
76 const volVectorField& U
77 );
Modified MytwoPhaseMixtureThermo.H constructor
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 32 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Remove the interface components
Remove the functions associated with the interface between the phases present.
Remove #include "interfaceProperties" from the header file.
Remove public interfaceProperties on line 57, and the comma beforeit on line 56.
Remove interfaceProperties(alpha1(), U, *this) from line 51 inMytwoPhaseMixtureThermo.C.
Remove accompanying functions from the .C file such as theinterfaceProperties::correct(); from line 104 in the correct() function
Remove the following function from the bottom of .C file
bool Foam::MytwoPhaseMixtureThermo::read()
{
if (psiThermo::read())
{
return interfaceProperties::read();
}
return false;
}
Remove declaration in the .H file virtual bool read();Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 33 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Compile the library and link to solver
Library is now ready to compile
wmake libso
Now link to the solver -In rhoCentralFoam.C add the line #include "MytwoPhaseMixtureThermo.H"Add two lines to the EXE_INC and three to the EXE_LIBS sections inMake/options.
1 -I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \2 -IMytwoPhaseMixtureThermo \
Make/options EXE INC additions
1 -L$(FOAM_USER_LIBBIN) \2 -ltwoPhaseMixture \
3 -lMytwoPhaseMixtureThermo \
Make/options EXE LIB additions
Compiling the solver with wmake now has the library linked to it.
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 34 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Adding the new library
To use the new library:In createFields.H replace the old thermophysical model initialisation increateFields and energy variable initialisation (lines 3-11) with the new thermomodel:
Info
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Setting up thermo variables
As part of the HEM model quantities are calculated as weighted averages acrossthe domain using the phase fraction fields. The energy field e is initialised herethen set up as
e = αev + (1− α)el .
Add these lines after the definition of the phase fractions alpha1, alpha2.
volScalarField& e = mixture.thermo1().he();
e = alpha1*mixture.thermo1().he()+alpha2*mixture.thermo2().he();
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 36 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Setting up thermo variables
Density is created also as a weighted average.
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
alpha1*mixture.thermo1().rho() + alpha2*(mixture.thermo2().rho())
);
Next in createFields.H the setup of the turbulence model is modified so thatthermo is replaced with mixture.
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 37 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Correct reference variables
In the createFieldRefs.H change thermo to mixture and the definition of T .The compressibility, psi, is removed from the file too since this will be definedlater in createFields.H.Modify mu so that if both mu values in thermo properties are 0 - then simulationruns as inviscid.
volScalarField& p = mixture.p();
volScalarField& T = mixture.T();
const volScalarField& mu = alpha1*mixture.thermo1().mu()+ alpha2*mixture.thermo2
().mu();
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 38 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Correct reference variables
In the HEM model, the phase fraction is calculated as
α =ρ− ρlρv − ρl
with the density ρ and the saturation densities( ρv , rhovSat and ρl , rholSat).In createFields.H, add the liquid and vapour saturation density fields and afield for the difference between them, ρv − ρl .volScalarField rhovSat
(
IOobject
(
"rhovSat",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("rhovSat", dimDensity, 1.0)
);
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 39 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Correct reference variables
Saturation densities calculated in each time-step as the temperature is updatedusing a lookup data table provided in the constant directory for the simulationcase files. Add these lines of code which can be placed underneath the definitionsof the saturation densities.
interpolationTable tempSeriesRhovSat
(
runTime.path()/runTime.caseConstant()/"rhovSat.dat"
);
interpolationTable tempSeriesRholSat
(
runTime.path()/runTime.caseConstant()/"rholSat.dat"
);
Include the line #include "interpolationTable.H" in the header files at thetop of the rhoCentralFoamHEM.C file.
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 40 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Correct reference variables
The tables need to contain the data for densities along the saturation line betweenthe critical point and triple point. The minimum and maximum temperaturevalues are read in to limit any extrapolation of the data later on in the calculationof α. Add these lines to createFields.H to read in these values
Info
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Calculating phase fraction
We continue and add the calculation of the phase fraction. Create short filecalcAlpha.H to do this
1 forAll ( mesh.C(), celli) //loop through cell centres2 { if(T[celli]>TmaxSat)3 { rhovSat[celli] = rho[celli];4 rholSat[celli] = rhovSat[celli]*2;5 rhoDiffSat[celli] = rhovSat[celli] - rholSat[celli]; }6 else { if(T[celli]
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Adding the barotropicCompressibilityModel
In the main solver directory, copy down the barotropic library as follows.
cp -r $FOAM_SRC/thermophysicalModels/barotropicCompressibilityModel .cd barotropicCompressibilityModel
sed -i s/FOAM_LIBBIN/FOAM_USER_LIBBIN/g Make/files
sed -i s/libbarotropicCompressibilityModel/libMybarotropicCompressibilityModel/g
\ Make/files
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 43 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Adding the barotropicCompressibilityModel
Modify the barotropicCompressibilityModel.C file and other files in thelibrary with addition of the volScalarFields rhovSat and rholSat as inputs.
Foam::barotropicCompressibilityModel::barotropicCompressibilityModel( const dictionary& compressibilityProperties,
const volScalarField& gamma,const volScalarField& rhovSat,const volScalarField& rholSat,const word& psiName
):
compressibilityProperties_(compressibilityProperties),psi_( IOobject
(psiName,gamma.mesh().time().timeName(),gamma.mesh()
),gamma.mesh(),dimensionedScalar(dimensionSet(0, -2, 2, 0, 0), Zero)
),gamma_(gamma),rhovSat_(rhovSat),rholSat_(rholSat)
{}
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 44 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Modifying the barotropicCompressibilityModel
sed -i ’s/const volScalarField& gamma,/&\n const volScalarField\& rholSat,\n \const volScalarField\& rhovSat,/’ barotropicCompressibilityModel/b* Chung/C* Wallis/W* \
linear/l*sed -i ’s/const volScalarField& gamma_;/&\n const volScalarField\& rholSat_;\n \const volScalarField\& rhovSat_;/’ barotropicCompressibilityModel/b* Chung/C* Wallis/W*sed -i ’s/gamma_(gamma)/&,\n rholSat_(rholSat),\n rhovSat_(rhovSat)/’ \
barotropicCompressibilityModel/b* Chung/C* Wallis/W*
sed -i ’/readEntry("pSat"/d’ Chung/C* Wallis/W*sed -i ’/readEntry("rholSat"/d’ Chung/C* Wallis/W*sed -i ’/dimensionedScalar pSat_;/d’ Chung/C* Wallis/W*sed -i ’/dimensionedScalar rhovSat_;/d’ Chung/C* Wallis/W*sed -i ’/dimensionedScalar rholSat_;/d’ Chung/C* Wallis/W*sed -i ’/rhovSat_ = psiv_/d’ Chung/C* Wallis/W*
Delete the pSat, rholSat, rhovSat read ins from the constructors in Chung.Cand Wallis.C
sed -i ’s/pSat_/(rhovSat_\/psiv_)/g’ Chung/C* Wallis/W*sed -i ’s/(compressibilityProperties, gamma, psiName)/(compressibilityProperties, gamma, \
rholSat, rhovSat, psiName)/g’ \linear/l* Chung/C* Wallis/W* barotropicCompressibilityModel/b*sed -i ’s/(dict, gamma, psiName)/(dict, gamma, rholSat, rhovSat, psiName)/g’ \
barotropicCompressibilityModel/*
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 45 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Compile and link the library
wmake libso
Return to the main solver directory and add the line#include "barotropicCompressibilityModel.H" with the other headers atthe top of rhoCentralFoamHEM.C. Also modify the Make/options file with theseadditions.
EXE_INC = \
.
.
-IbarotropicCompressibilityModel/lnInclude \
.
EXE_LIBS = \
.
.
-lMybarotropicCompressibilityModel \
.
Additions to the solver Make/options file
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 46 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Set up the compressibility model
Once the library is linked to the solver we can now use it to create thecompressibility model for psi. Add the following code to the createFields.H
Infocorrect();. This corrects the compressibility field when the phasefraction is recalculated here.
#include "calcAlpha.H"
psiModel->correct();
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 47 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Speed of sound in liquids
The speed of sound for the liquid phase requires the bulk modulus, K. In thecreateFields.H add to the bottom of the file the following code which allowsthe solver to read in the thermophysicalProperties.liquid file in theconstant directory and then read in the bulk modulus, K.
IOdictionary thermophysicalPropertiesLiquid
(
IOobject
(
"thermophysicalProperties.liquid",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
dimensionedScalar K(dimPressure,readScalar(thermophysicalPropertiesLiquid.lookup
("K")));
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 48 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Mixture speed of sound
Using this the speeds of sound in both the vapour and liquid can be added to thesolver code. At the location in the code where the speed of sound, c, is created ineach time step, we rename this to cv and modify it to use the mixture fields.Then a similar field is created for speed of sound in the liquid using the relation
c2l =K
ρ.
Finally the speed of sound of the mixture is initialised as a weighted average ofthe two values.
1
ρc2=
α
ρvc2v+
(1− α)ρlc2l
.
volScalarField cv("cv", sqrt(mixture.thermo1().Cp()/mixture.thermo1().Cv()/
mixture.thermo1().psi()));
volScalarField cl("cl", sqrt(K/rholSat));
volScalarField c("c", 1/sqrt((alpha1*rhovSat + alpha2*rholSat)*(alpha1/rhovSat/
sqr(cv) + alpha2/rholSat/sqr(cl))));
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 49 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Set up the compressibility model
In the twoPhaseMixtureThermo model we have used here we can see on line 164that the THE function is not implemented and will simply return the oldtemperature and therefore not update it.
164 Foam::tmp Foam::MytwoPhaseMixtureThermo::THE
165 (
166 const scalarField& h,
167 const scalarField& p,
168 const scalarField& T0,
169 const labelList& cells
170 ) const
171 {
172 NotImplemented;
173 return T0;
174 }
MytwoPhaseMixtureThermo.C
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 50 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Set up the compressibility model
Create a function calcT.H file to update the temperature for the two phasemixture.
1 Info
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Set up the compressibility model
Continuation of file..
25
26
27 #include "calcAlpha.H"28
29 mixture.correctThermo();30 mixture.correct();31
32 if (iter++ > 200)33 {34 FatalErrorInFunction35
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Tutorial case
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 53 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Multiphase jet tutorial
Here a simple tutorial case will be studied for the rhoCentralFoamHEM solver.The case chosen is a supersonic jet problem, largely based on the tutorial locatedin the directory:\$FOAM_TUTORIALS/compressible/rhoCentralFoam/LadenburgJet60psi.
A high pressure tank source is discharged into atmospheric pressure conditionsthrough a circular nozzle and the resulting flow is supersonic with Mach discfeatures produced which are often difficult to predict correctly using numericalmethods. Here the jet release is a vapour-liquid mixtureIn the accompanying case files navigate to the HEMcase directory
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 54 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Case setup
Axisymmetric case with wedgeboundary conditions
High pressure inlet (1.8MPa) into0.3MPa conditions.
50% liquid phase fraction inlet into100% vapour conditions
Case geometry
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 55 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Modified case files
Several files are modified for the multiphase case from the original structure.These can be inspected to see where the additions for the new solver have beenmade.
Thermophysical properties are now found in three files - one each for the twophases and a general file.
Saturation data files are needed in the constant directory
A volume fraction file for initial and boundary conditions is needed for one ofthe phases.
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 56 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Modified case files
Saturation density data has been taken from the NIST database. The data forCO2 is used here.
Liquid and vapour densities for CO2 along the saturation line. The data for thecase is included in the constant directory in rhovSat.dat, rholSat.dat
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 57 / 58
-
Introduction rhoCentralFoam Implementing rhoCentralFoamHEM Tutorial case
Modified case files
Run the case from the accompanying files directory HEMcase. Results for
Eleanor Harvey Combining a density-based compressible solver with a multiphase model January 18, 2021 58 / 58
IntroductionrhoCentralFoamcreateFields.HrhoCentralFoam.C
Implementing rhoCentralFoamHEMMultiphase
Tutorial case