From 4a1c7d04d404098225fd851b14d43a1172e18263 Mon Sep 17 00:00:00 2001 From: DongWangChina Date: Thu, 31 Aug 2023 17:42:19 +0800 Subject: [PATCH 01/10] update install document: df-notorch python=3.8 --- docs/source/qs/install.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/qs/install.rst b/docs/source/qs/install.rst index 096afe463..e3b0f0e3d 100644 --- a/docs/source/qs/install.rst +++ b/docs/source/qs/install.rst @@ -147,7 +147,7 @@ Then you can pass your own libtorch path to DeepFlame. .. code-block:: bash - conda create -n df-notorch + conda create -n df-notorch python=3.8 conda activate df-notorch conda install -c cantera libcantera-devel From 2f53c730e27e439148e57a41658e3dc15b7ec8fb Mon Sep 17 00:00:00 2001 From: DongWangChina Date: Mon, 18 Dec 2023 21:37:37 +0800 Subject: [PATCH 02/10] update flareFGM for 2-phase combustion & 6D table --- .../solvers/dfHighSpeedFoam/createFields.H | 11 +- .../solvers/dfLowMachFoam/createFields.H | 7 +- .../solvers/dfSprayFoam/createFields.H | 40 +- .../solvers/dfSprayFoam/dfSprayFoam.C | 14 +- src/dfChemistryModel/dfChemistryModel.H | 2 + .../FGMLiquidEvaporationBoil.C | 228 ++++++ .../FGMLiquidEvaporationBoil.H | 169 ++++ .../FGMLiquidEvaporationBoils.C | 38 + src/dfCombustionModels/FGM/baseFGM/baseFGM.C | 575 +++++++++++--- src/dfCombustionModels/FGM/baseFGM/baseFGM.H | 60 +- .../flameletTableSolver/readThermChemTables.H | 226 +----- .../FGM/flameletTableSolver/tableSolver.C | 552 ++++++++++++- .../FGM/flameletTableSolver/tableSolver.H | 98 ++- .../FGM/flareFGM/flareFGM.C | 745 ++++++++++++------ src/dfCombustionModels/Make/files | 4 + src/dfCombustionModels/Make/options | 22 +- 16 files changed, 2179 insertions(+), 612 deletions(-) create mode 100644 src/dfCombustionModels/FGM/FGMLiquidEvaporationBoil/FGMLiquidEvaporationBoil.C create mode 100644 src/dfCombustionModels/FGM/FGMLiquidEvaporationBoil/FGMLiquidEvaporationBoil.H create mode 100644 src/dfCombustionModels/FGM/FGMLiquidEvaporationBoil/FGMLiquidEvaporationBoils.C diff --git a/applications/solvers/dfHighSpeedFoam/createFields.H b/applications/solvers/dfHighSpeedFoam/createFields.H index 852122f45..4d5e8b4c4 100644 --- a/applications/solvers/dfHighSpeedFoam/createFields.H +++ b/applications/solvers/dfHighSpeedFoam/createFields.H @@ -186,8 +186,15 @@ volScalarField rhoE rho*(ea + 0.5*magSqr(U)) ); -chemistry->correctThermo(); -Info<< "At initial time, min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; +const word combModelName(mesh.objectRegistry::lookupObject("combustionProperties").lookup("combustionModel")); +Info << "Combustion Model Name is confirmed as "<< combModelName << endl; + + +if (combModelName != "flareFGM") +{ + chemistry->correctThermo(); + Info<< "At initial time, min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; +} forAll(Y, i) { diff --git a/applications/solvers/dfLowMachFoam/createFields.H b/applications/solvers/dfLowMachFoam/createFields.H index 9e750c334..15413d462 100644 --- a/applications/solvers/dfLowMachFoam/createFields.H +++ b/applications/solvers/dfLowMachFoam/createFields.H @@ -93,8 +93,11 @@ chemistry->setEnergyName("ha"); chemistry->updateEnergy(); -chemistry->correctThermo(); -Info<< "At initial time, min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; +if (combModelName != "flareFGM") +{ + chemistry->correctThermo(); + Info<< "At initial time, min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; +} //for dpdt diff --git a/applications/solvers/dfSprayFoam/createFields.H b/applications/solvers/dfSprayFoam/createFields.H index 3c33fce70..7506f74b8 100644 --- a/applications/solvers/dfSprayFoam/createFields.H +++ b/applications/solvers/dfSprayFoam/createFields.H @@ -78,11 +78,30 @@ autoPtr turbulence const word turbName(mesh.objectRegistry::lookupObject("turbulenceProperties").lookup("simulationType")); +Info<< "Creating field dpdt\n" << endl; +volScalarField dpdt +( + IOobject + ( + "dpdt", + runTime.timeName(), + mesh + ), + mesh, + dimensionedScalar(p.dimensions()/dimTime, 0) +); + Info<< "Creating reaction model\n" << endl; autoPtr> combustion ( CombustionModel::New(thermo, turbulence()) ); + +const word combModelName(mesh.objectRegistry::lookupObject +("combustionProperties").lookup("combustionModel")); +Info << "Combustion Model Name is confirmed as "<< combModelName << endl; + + Info<< "end Creating reaction model\n" << endl; dfChemistryModel* chemistry = combustion->chemistry(); PtrList& Y = chemistry->Y(); @@ -91,23 +110,12 @@ const label inertIndex(chemistry->species()[inertSpecie]); chemistry->setEnergyName("ha"); chemistry->updateEnergy(); +if (combModelName != "flareFGM") +{ + chemistry->correctThermo(); + Info<< "At initial time, min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; +} -chemistry->correctThermo(); -Info<< "At initial time, min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; - - -Info<< "Creating field dpdt\n" << endl; -volScalarField dpdt -( - IOobject - ( - "dpdt", - runTime.timeName(), - mesh - ), - mesh, - dimensionedScalar(p.dimensions()/dimTime, 0) -); Info<< "Creating field kinetic energy K\n" << endl; volScalarField K("K", 0.5*magSqr(U)); diff --git a/applications/solvers/dfSprayFoam/dfSprayFoam.C b/applications/solvers/dfSprayFoam/dfSprayFoam.C index ff044db6d..363508475 100644 --- a/applications/solvers/dfSprayFoam/dfSprayFoam.C +++ b/applications/solvers/dfSprayFoam/dfSprayFoam.C @@ -153,9 +153,17 @@ int main(int argc, char *argv[]) while (pimple.loop()) { #include "UEqn.H" - #include "YEqn.H" - #include "EEqn.H" - chemistry->correctThermo(); + + if(combModelName!="ESF" && combModelName!="flareFGM" ) + { + #include "YEqn.H" + #include "EEqn.H" + chemistry->correctThermo(); + } + else + { + combustion->correct(); + } Info<< "T gas min/max " << min(T).value() << ", " << max(T).value() << endl; diff --git a/src/dfChemistryModel/dfChemistryModel.H b/src/dfChemistryModel/dfChemistryModel.H index f514f91c2..fbb916af7 100644 --- a/src/dfChemistryModel/dfChemistryModel.H +++ b/src/dfChemistryModel/dfChemistryModel.H @@ -311,6 +311,8 @@ public: const volScalarField& hai(const label i) {return hai_[i];} + const scalar & hci(const label i) {return hc_[i];} + // update T, psi, mu, alpha, rhoD, hai (if needed) void correctThermo(); diff --git a/src/dfCombustionModels/FGM/FGMLiquidEvaporationBoil/FGMLiquidEvaporationBoil.C b/src/dfCombustionModels/FGM/FGMLiquidEvaporationBoil/FGMLiquidEvaporationBoil.C new file mode 100644 index 000000000..bedb12220 --- /dev/null +++ b/src/dfCombustionModels/FGM/FGMLiquidEvaporationBoil/FGMLiquidEvaporationBoil.C @@ -0,0 +1,228 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "FGMLiquidEvaporationBoil.H" +// #include "specie.H" +#include "mathematicalConstants.H" + + +using namespace Foam::constant::mathematical; + +// // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +// template +// Foam::tmp Foam::LiquidEvaporationBoil::calcXc +// ( +// const label celli +// ) const +// { +// scalarField Xc(this->owner().thermo().carrier().Y().size()); + +// forAll(Xc, i) +// { +// Xc[i] = +// this->owner().thermo().carrier().Y()[i][celli] +// /this->owner().thermo().carrier().Wi(i); +// } + +// return Xc/sum(Xc); +// } + + +// template +// Foam::scalar Foam::LiquidEvaporationBoil::Sh +// ( +// const scalar Re, +// const scalar Sc +// ) const +// { +// return 2.0 + 0.6*Foam::sqrt(Re)*cbrt(Sc); +// } + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::FGMLiquidEvaporationBoil::FGMLiquidEvaporationBoil +( + const dictionary& dict, + CloudType& owner +) +: + LiquidEvaporationBoil(dict, owner), + W_(this->owner().mesh().objectRegistry::lookupObject("Wt")) +{ + +} + + +template +Foam::FGMLiquidEvaporationBoil::FGMLiquidEvaporationBoil +( + const FGMLiquidEvaporationBoil& pcm +) +: + LiquidEvaporationBoil(pcm), + + W_(this->owner().mesh().objectRegistry::lookupObject("Wt")) +{ + +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::FGMLiquidEvaporationBoil::~FGMLiquidEvaporationBoil() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::FGMLiquidEvaporationBoil::calculate +( + const scalar dt, + const label celli, + const scalar Re, + const scalar Pr, + const scalar d, + const scalar nu, + const scalar T, + const scalar Ts, + const scalar pc, + const scalar Tc, + const scalarField& X, + scalarField& dMassPC +) const +{ + // immediately evaporate mass that has reached critical condition + if ((this->liquids_.Tc(X) - T) < small) + { + if (debug) + { + WarningInFunction + << "Parcel reached critical conditions: " + << "evaporating all available mass" << endl; + } + + forAll(this->activeLiquids_, i) + { + const label lid = this->liqToLiqMap_[i]; + dMassPC[lid] = great; + } + + return; + } + + // droplet surface pressure assumed to surface vapour pressure + scalar ps = this->liquids_.pv(pc, Ts, X); + + // vapour density at droplet surface [kg/m^3] + const scalar RR = 1000.0*constant::physicoChemical::R.value(); // J/(kmol·k) + // vapour density at droplet surface [kg/m3] + scalar rhos = ps*this->liquids_.W(X)/(RR*Ts); + + // // construct carrier phase species volume fractions for cell, celli + // const scalarField XcMix(calcXc(celli)); + + // // carrier thermo properties + // scalar Hsc = 0.0; + // scalar Hc = 0.0; + // scalar Cpc = 0.0; + // scalar kappac = 0.0; + // this->owner().thermo().carrier().calcH(Tc, pc); + // forAll(this->owner().thermo().carrier().Y(), i) + // { + // const scalar Yc = this->owner().thermo().carrier().Y()[i][celli]; + // Hc += Yc*this->owner().thermo().carrier().Ha(i, pc, Tc); + // } + + // this->owner().thermo().carrier().calcH(Ts, ps); + // this->owner().thermo().carrier().calcCp(Ts, ps); + // this->owner().thermo().carrier().calcMu(Ts, ps); + // forAll(this->owner().thermo().carrier().Y(), i) + // { + // const scalar Yc = this->owner().thermo().carrier().Y()[i][celli]; + // Hsc += Yc*this->owner().thermo().carrier().Ha(i, ps, Ts); + // Cpc += Yc*this->owner().thermo().carrier().Cp(i, ps, Ts); + // kappac += Yc*this->owner().thermo().carrier().kappa(i, ps, Ts); + // } + + // calculate mass transfer of each specie in liquid + forAll(this->activeLiquids_, i) + { + const label gid = this->liqToCarrierMap_[i]; + const label lid = this->liqToLiqMap_[i]; + + // boiling temperature at cell pressure for liquid species lid [K] + const scalar TBoil = this->liquids_.properties()[lid].pvInvert(pc); + // limit droplet temperature to boiling/critical temperature + const scalar Td = min(T, 0.999*TBoil); + // saturation pressure for liquid species lid [Pa] + const scalar pSat = this->liquids_.properties()[lid].pv(pc, Td); + // surface molar fraction - Raoult's Law + const scalar Xs = X[lid]*pSat/pc; + + + // if (Xc*pc > pSat) + // { + // // saturated vapour - no phase change + // } + // else + { + // vapour diffusivity [m2/s] + const scalar Dab = this->liquids_.properties()[lid].D(ps, Ts); + + // Schmidt number + const scalar Sc = nu/(Dab + rootVSmall); + + // Sherwood number + const scalar Sh = this->Sh(Re, Sc); + + // mixture molar weight + scalar W_gas = W_[celli];//FGMmodel_.getValue(celli, "W"); + + // carrier phase concentration-fuel + const scalar Yc = this->owner().thermo().carrier().Y()[gid][celli]; + + // fuel molar weight [kg/kmol] + const scalar W_fuel = this->liquids_.properties()[lid].W(); + const scalar Ys = Xs*W_fuel/W_gas/(1. + Xs*W_fuel/W_gas - Xs); // ref Hu.2017, Spalding.1953 + const scalar Bm = (Ys - Yc)/max(small, 1. - Ys); + + if (Bm > 0) + { + // mass transfer [kg] + dMassPC[lid] += pi*d*Sh*Dab*rhos*log(1.0 + Bm)*dt; + } + } + } +} + + + + +// ************************************************************************* // diff --git a/src/dfCombustionModels/FGM/FGMLiquidEvaporationBoil/FGMLiquidEvaporationBoil.H b/src/dfCombustionModels/FGM/FGMLiquidEvaporationBoil/FGMLiquidEvaporationBoil.H new file mode 100644 index 000000000..699177630 --- /dev/null +++ b/src/dfCombustionModels/FGM/FGMLiquidEvaporationBoil/FGMLiquidEvaporationBoil.H @@ -0,0 +1,169 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::FGMLiquidEvaporationBoil + +Description + Liquid evaporation model + - uses ideal gas assumption + - includes boiling model based on: + + \verbatim + "Studies of Superheated Fuel Spray Structures and Vaporization in + GDI Engines" + + Zuo, B., Gomes, A. M. and Rutland C. J. + + International Journal of Engine Research, 2000, Vol. 1(4), pp. 321-336 + \endverbatim + +\*---------------------------------------------------------------------------*/ + +#ifndef FGMLiquidEvaporationBoil_H +#define FGMLiquidEvaporationBoil_H + +#include "LiquidEvaporationBoil.H" +#include "liquidMixtureProperties.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +/*---------------------------------------------------------------------------*\ + Class FGMLiquidEvaporationBoil Declaration +\*---------------------------------------------------------------------------*/ + +template +class FGMLiquidEvaporationBoil +: + public LiquidEvaporationBoil +{ +protected: + + // Protected data + + // //- Global liquid properties data + // const liquidMixtureProperties& liquids_; + + // //- List of active liquid names + // List activeLiquids_; + + // //- Mapping between liquid and carrier species + // List