Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-ideal capabilities for 1-D flame model #1079

Merged
merged 19 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions data/h2o2.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
description: |-
Hydrogen-Oxygen submechanism extracted from GRI-Mech 3.0.
Modified from the original to include N2.

Redlich-Kwong coefficients are based on tabulated critical properties or
estimated according to the method of Joback and Reid, "Estimation of pure-
component properties from group-contributions," Chem. Eng. Comm. 57 (1987)
233-243

generator: ck2yaml
input-files: [h2o2.inp, gri30_tran.dat]
Expand All @@ -18,6 +23,14 @@ phases:
transport: mixture-averaged
state: {T: 300.0, P: 1 atm}

- name: ohmech-RK
thermo: Redlich-Kwong
elements: [O, H, Ar, N]
species: [H2, H, O, O2, OH, H2O, HO2, H2O2, AR, N2]
kinetics: gas
transport: mixture-averaged
state: {T: 300.0, P: 1 atm}

species:
- name: H2
composition: {H: 2}
Expand All @@ -37,6 +50,10 @@ species:
diameter: 2.92
polarizability: 0.79
rotational-relaxation: 280.0
equation-of-state:
model: Redlich-Kwong
a: 1.43319e+11
b: 18.42802577
- name: H
composition: {H: 1}
thermo:
Expand All @@ -53,6 +70,10 @@ species:
geometry: atom
well-depth: 145.0
diameter: 2.05
equation-of-state:
model: Redlich-Kwong
a: 1.32125e+11
b: 17.63395812
- name: O
composition: {O: 1}
thermo:
Expand All @@ -69,6 +90,10 @@ species:
geometry: atom
well-depth: 80.0
diameter: 2.75
equation-of-state:
model: Redlich-Kwong
a: 4.74173e+11
b: 10.69952492
- name: O2
composition: {O: 2}
thermo:
Expand All @@ -87,6 +112,10 @@ species:
diameter: 3.458
polarizability: 1.6
rotational-relaxation: 3.8
equation-of-state:
model: Redlich-Kwong
a: 1.74102e+12
b: 22.08100907
- name: OH
composition: {O: 1, H: 1}
thermo:
Expand All @@ -103,6 +132,10 @@ species:
geometry: linear
well-depth: 80.0
diameter: 2.75
equation-of-state:
model: Redlich-Kwong
a: 4.77552e+11
b: 10.72986231
- name: H2O
composition: {H: 2, O: 1}
thermo:
Expand All @@ -121,6 +154,10 @@ species:
diameter: 2.605
dipole: 1.844
rotational-relaxation: 4.0
equation-of-state:
model: Redlich-Kwong
a: 1.42674e+13
b: 21.12705912
- name: HO2
composition: {H: 1, O: 2}
thermo:
Expand All @@ -139,6 +176,10 @@ species:
diameter: 3.458
rotational-relaxation: 1.0
note: '*'
equation-of-state:
model: Redlich-Kwong
a: 1.46652e+12
b: 21.27344867
- name: H2O2
composition: {H: 2, O: 2}
thermo:
Expand All @@ -156,6 +197,10 @@ species:
well-depth: 107.4
diameter: 3.458
rotational-relaxation: 3.8
equation-of-state:
model: Redlich-Kwong
a: 1.46652e+12
b: 21.27344867
- name: AR
composition: {Ar: 1}
thermo:
Expand All @@ -170,6 +215,10 @@ species:
geometry: atom
well-depth: 136.5
diameter: 3.33
equation-of-state:
model: Redlich-Kwong
a: 1.69466E+12
b: 22.30627035
- name: N2
composition: {N: 2}
thermo:
Expand All @@ -188,6 +237,10 @@ species:
diameter: 3.621
polarizability: 1.76
rotational-relaxation: 4.0
equation-of-state:
model: Redlich-Kwong
a: 1.55976e+12
b: 26.81724983

reactions:
- equation: 2 O + M <=> O2 + M # Reaction 1
Expand Down
19 changes: 14 additions & 5 deletions include/cantera/oneD/StFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "Domain1D.h"
#include "cantera/base/Array.h"
#include "cantera/base/Solution.h"
#include "cantera/thermo/IdealGasPhase.h"
#include "cantera/thermo/ThermoPhase.h"
#include "cantera/kinetics/Kinetics.h"

namespace Cantera
Expand Down Expand Up @@ -81,12 +81,11 @@ class StFlow : public Domain1D
}

/**
* Set the thermo manager. Note that the flow equations assume
* the ideal gas equation.
* Set the thermo manager.
*
* @deprecated To be removed after Cantera 3.0 (unused)
*/
void setThermo(IdealGasPhase& th);
void setThermo(ThermoPhase& th);

virtual void setKinetics(shared_ptr<Kinetics> kin);

Expand Down Expand Up @@ -330,6 +329,7 @@ class StFlow : public Domain1D
m_rho[j] = m_thermo->density();
m_wtm[j] = m_thermo->meanMolecularWeight();
m_cp[j] = m_thermo->cp_mass();
m_thermo->getPartialMolarEnthalpies(&m_hk(0, j));
}
}

Expand Down Expand Up @@ -425,6 +425,9 @@ class StFlow : public Domain1D
//! Update the diffusive mass fluxes.
virtual void updateDiffFluxes(const doublereal* x, size_t j0, size_t j1);

//! Get the gradient of species specific molar enthalpies
virtual void grad_hk(const double* x, size_t j);

//---------------------------------------------------------
// member data
//---------------------------------------------------------
Expand All @@ -450,12 +453,18 @@ class StFlow : public Domain1D
Array2D m_dthermal;
Array2D m_flux;

//! Array of size #m_nsp by #m_points for saving molar enthalpies
Array2D m_hk;

//! Array of size #m_nsp by #m_points -1 for saving enthalpy fluxes
Array2D m_dhk_dz;

// production rates
Array2D m_wdot;

size_t m_nsp;

IdealGasPhase* m_thermo = nullptr;
ThermoPhase* m_thermo = nullptr;
Kinetics* m_kin = nullptr;
Transport* m_trans = nullptr;

Expand Down
45 changes: 26 additions & 19 deletions src/oneD/StFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,13 @@ StFlow::StFlow(ThermoPhase* ph, size_t nsp, size_t points) :
Domain1D(nsp+c_offset_Y, points),
m_nsp(nsp)
{
if (ph->type() == "ideal-gas") {
m_thermo = static_cast<IdealGasPhase*>(ph);
} else {
throw CanteraError("StFlow::StFlow",
"Unsupported phase type: need 'IdealGasPhase'");
}
m_type = cFlowType;
m_points = points;

if (ph == 0) {
return; // used to create a dummy object
gkogekar marked this conversation as resolved.
Show resolved Hide resolved
}
m_thermo = ph;

size_t nsp2 = m_thermo->nSpecies();
if (nsp2 != m_nsp) {
Expand Down Expand Up @@ -60,6 +55,8 @@ StFlow::StFlow(ThermoPhase* ph, size_t nsp, size_t points) :
m_multidiff.resize(m_nsp*m_nsp*m_points);
m_flux.resize(m_nsp,m_points);
m_wdot.resize(m_nsp,m_points, 0.0);
m_hk.resize(m_nsp, m_points, 0.0);
m_dhk_dz.resize(m_nsp, m_points - 1, 0.0);
m_ybar.resize(m_nsp);
m_qdotRadiation.resize(m_points, 0.0);

Expand Down Expand Up @@ -138,7 +135,7 @@ string StFlow::type() const {
return "unstrained-flow";
}

void StFlow::setThermo(IdealGasPhase& th) {
void StFlow::setThermo(ThermoPhase& th) {
warn_deprecated("StFlow::setThermo", "To be removed after Cantera 3.0.");
m_thermo = &th;
}
Expand Down Expand Up @@ -202,6 +199,8 @@ void StFlow::resize(size_t ncomponents, size_t points)
}
m_flux.resize(m_nsp,m_points);
m_wdot.resize(m_nsp,m_points, 0.0);
m_hk.resize(m_nsp, m_points, 0.0);
m_dhk_dz.resize(m_nsp, m_points - 1, 0.0);
m_do_energy.resize(m_points,false);
m_qdotRadiation.resize(m_points, 0.0);
m_fixedtemp.resize(m_points);
Expand Down Expand Up @@ -561,24 +560,20 @@ void StFlow::evalResidual(double* x, double* rsd, int* diag,
// - sum_k(J_k c_p_k / M_k) dT/dz
//-----------------------------------------------
if (m_do_energy[j]) {
setGas(x,j);

// heat release term
const vector_fp& h_RT = m_thermo->enthalpy_RT_ref();
const vector_fp& cp_R = m_thermo->cp_R_ref();
setGas(x,j);
double dtdzj = dTdz(x,j);
double sum = 0.0;
double sum2 = 0.0;

grad_hk(x, j);
for (size_t k = 0; k < m_nsp; k++) {
double flxk = 0.5*(m_flux(k,j-1) + m_flux(k,j));
sum += wdot(k,j)*h_RT[k];
sum2 += flxk*cp_R[k]/m_wt[k];
sum += wdot(k,j)*m_hk(k,j);
sum += flxk * m_dhk_dz(k,j) / m_wt[k];
}
sum *= GasConstant * T(x,j);
double dtdzj = dTdz(x,j);
sum2 *= GasConstant * dtdzj;


rsd[index(c_offset_T, j)] = - m_cp[j]*rho_u(x,j)*dtdzj
- divHeatFlux(x,j) - sum - sum2;
- divHeatFlux(x,j) - sum;
rsd[index(c_offset_T, j)] /= (m_rho[j]*m_cp[j]);
rsd[index(c_offset_T, j)] -= rdt*(T(x,j) - T_prev(j));
rsd[index(c_offset_T, j)] -= (m_qdotRadiation[j] / (m_rho[j] * m_cp[j]));
Expand Down Expand Up @@ -1052,4 +1047,16 @@ void StFlow::evalContinuity(size_t j, double* x, double* rsd, int* diag, double
}
}

void StFlow::grad_hk(const double* x, size_t j)
{
for(size_t k = 0; k < m_nsp; k++) {
if (u(x, j) > 0.0) {
m_dhk_dz(k,j) = (m_hk(k,j) - m_hk(k,j-1)) / m_dz[j - 1];
}
else {
m_dhk_dz(k,j) = (m_hk(k,j+1) - m_hk(k,j)) / m_dz[j];
}
}
}

} // namespace
43 changes: 43 additions & 0 deletions test/data/CounterflowPremixedFlame-h2-mix-RK.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
0.000000e+00, 1.020919e-02, 7.384260e-20, 3.730000e+02, 2.191279e-03, 1.064384e-16, 2.572413e-13, 6.618564e-02, 2.710575e-14, 4.792796e-02, 2.402200e-06, 3.523660e-05, 8.836575e-01, -4.666264e-22
9.375000e-05, 1.534743e-02, 8.362683e-01, 5.607403e+02, 1.765146e-03, 1.099816e-16, 2.911574e-13, 5.885237e-02, 3.075474e-14, 5.595727e-02, 2.912535e-06, 4.278107e-05, 8.833795e-01, -4.636066e-22
1.875000e-04, 2.017175e-02, 1.580880e+00, 7.453460e+02, 1.378485e-03, 1.294924e-13, 8.290854e-12, 5.135130e-02, 1.240518e-11, 6.357571e-02, 5.940113e-06, 4.927735e-05, 8.836393e-01, -4.607253e-22
2.812500e-04, 2.479282e-02, 2.258946e+00, 9.302398e+02, 1.022632e-03, 6.002642e-11, 5.663515e-10, 4.366378e-02, 3.735161e-09, 7.093020e-02, 1.368376e-05, 5.355533e-05, 8.843161e-01, -4.579306e-22
3.281250e-04, 2.703861e-02, 2.576242e+00, 1.023149e+03, 8.450821e-04, 8.018856e-10, 8.005828e-09, 3.953350e-02, 3.728762e-08, 7.472727e-02, 2.476298e-05, 5.199750e-05, 8.848173e-01, -4.564807e-22
3.515625e-04, 2.814460e-02, 2.729663e+00, 1.069669e+03, 7.567863e-04, 2.523975e-09, 2.669775e-08, 3.740220e-02, 1.046219e-07, 7.664870e-02, 3.341988e-05, 4.927142e-05, 8.851095e-01, -4.557352e-22
3.750000e-04, 2.923722e-02, 2.879686e+00, 1.116146e+03, 6.702649e-04, 6.994666e-09, 7.608054e-08, 3.526323e-02, 2.701971e-07, 7.855309e-02, 4.388335e-05, 4.492228e-05, 8.854243e-01, -4.549958e-22
3.984375e-04, 3.031160e-02, 3.026411e+00, 1.162389e+03, 5.857067e-04, 1.726729e-08, 1.917254e-07, 3.312586e-02, 6.472579e-07, 8.043436e-02, 5.521150e-05, 3.880530e-05, 8.857592e-01, -4.542529e-22
4.218750e-04, 3.135842e-02, 3.169946e+00, 1.208034e+03, 5.035751e-04, 3.770053e-08, 4.252521e-07, 3.100800e-02, 1.429119e-06, 8.227958e-02, 6.559536e-05, 3.120026e-05, 8.861102e-01, -4.535157e-22
4.453125e-04, 3.236219e-02, 3.310426e+00, 1.252477e+03, 4.247140e-04, 7.259495e-08, 8.287079e-07, 2.893900e-02, 2.897847e-06, 8.406630e-02, 7.294842e-05, 2.304303e-05, 8.864702e-01, -4.527648e-22
4.687500e-04, 3.330115e-02, 3.448021e+00, 1.294862e+03, 3.503712e-04, 1.239784e-07, 1.426022e-06, 2.695991e-02, 5.430291e-06, 8.576189e-02, 7.584380e-05, 1.566845e-05, 8.868293e-01, -4.520202e-22
4.921875e-04, 3.414943e-02, 3.582949e+00, 1.334168e+03, 2.820917e-04, 1.889878e-07, 2.180534e-06, 2.512037e-02, 9.477910e-06, 8.732661e-02, 7.396208e-05, 1.000630e-05, 8.871751e-01, -4.512401e-22
5.156250e-04, 3.488153e-02, 3.715472e+00, 1.369370e+03, 2.214708e-04, 2.569445e-07, 2.969519e-06, 2.347171e-02, 1.537707e-05, 8.871997e-02, 6.796187e-05, 6.180646e-06, 8.874941e-01, -4.504662e-22
5.390625e-04, 3.547844e-02, 3.845882e+00, 1.399685e+03, 1.697691e-04, 3.104803e-07, 3.609872e-06, 2.205561e-02, 2.299946e-05, 8.991016e-02, 5.920620e-05, 3.812508e-06, 8.877745e-01, -4.496299e-22
5.625000e-04, 3.593321e-02, 3.974486e+00, 1.424796e+03, 1.275068e-04, 3.342267e-07, 3.952752e-06, 2.089230e-02, 3.157762e-05, 9.088357e-02, 4.931234e-05, 2.418205e-06, 8.880090e-01, -4.487961e-22
5.859375e-04, 3.625238e-02, 4.101572e+00, 1.444910e+03, 9.429371e-05, 3.241411e-07, 3.964717e-06, 1.997556e-02, 3.996534e-05, 9.164839e-02, 3.963263e-05, 1.606671e-06, 8.881963e-01, -4.478879e-22
6.093750e-04, 3.645266e-02, 4.227392e+00, 1.460640e+03, 6.900982e-05, 2.881388e-07, 3.718914e-06, 1.927758e-02, 4.713769e-05, 9.223007e-02, 3.099395e-05, 1.123271e-06, 8.883401e-01, -4.469739e-22
6.328125e-04, 3.655538e-02, 4.352150e+00, 1.472793e+03, 5.018203e-05, 2.391976e-07, 3.328361e-06, 1.875938e-02, 5.252766e-05, 9.266237e-02, 2.373948e-05, 8.217372e-07, 8.884474e-01, -4.459949e-22
6.562500e-04, 3.658180e-02, 4.475999e+00, 1.482183e+03, 3.632678e-05, 1.886367e-07, 2.891729e-06, 1.838056e-02, 5.605012e-05, 9.297941e-02, 1.789891e-05, 6.232119e-07, 8.885261e-01, -4.450014e-22
7.031250e-04, 3.646223e-02, 4.721473e+00, 1.494845e+03, 1.964888e-05, 1.082872e-07, 2.099106e-06, 1.793379e-02, 5.786997e-05, 9.335739e-02, 1.011934e-05, 3.933023e-07, 8.886186e-01, -4.428999e-22
7.500000e-04, 3.621372e-02, 4.964300e+00, 1.503314e+03, 1.061219e-05, 5.771327e-08, 1.502630e-06, 1.770107e-02, 5.584767e-05, 9.355838e-02, 5.586384e-06, 2.627214e-07, 8.886667e-01, -4.406724e-22
8.437500e-04, 3.549736e-02, 5.442840e+00, 1.514237e+03, 3.871363e-06, 1.865298e-08, 8.510600e-07, 1.755089e-02, 4.788340e-05, 9.369677e-02, 2.032983e-06, 1.406856e-07, 8.886975e-01, -4.358626e-22
9.375000e-04, 3.464164e-02, 5.911552e+00, 1.523304e+03, 1.469626e-06, 6.190415e-09, 5.175109e-07, 1.751949e-02, 4.007558e-05, 9.373349e-02, 7.820674e-07, 8.123678e-08, 8.887041e-01, -4.305777e-22
1.125000e-03, 3.264636e-02, 6.816283e+00, 1.541149e+03, 4.099842e-07, 1.535312e-09, 2.914181e-07, 1.755687e-02, 3.204736e-05, 9.371338e-02, 2.481969e-07, 4.124202e-08, 8.886967e-01, -4.185656e-22
1.312500e-03, 3.033447e-02, 7.668582e+00, 1.561077e+03, 1.881339e-07, 7.758994e-10, 2.414939e-07, 1.762102e-02, 3.049228e-05, 9.366523e-02, 1.518659e-07, 3.020320e-08, 8.886826e-01, -4.045228e-22
1.500000e-03, 2.772605e-02, 8.455102e+00, 1.583570e+03, 1.575810e-07, 7.555325e-10, 2.664020e-07, 1.769728e-02, 3.336068e-05, 9.360456e-02, 1.436557e-07, 2.881722e-08, 8.886642e-01, -3.883503e-22
1.750000e-03, 2.381717e-02, 9.378066e+00, 1.617664e+03, 2.062794e-07, 1.170803e-09, 3.766639e-07, 1.781360e-02, 4.199234e-05, 9.351052e-02, 1.688219e-07, 3.246961e-08, 8.886331e-01, -3.635148e-22
2.000000e-03, 1.944968e-02, 1.012378e+01, 1.656070e+03, 3.110334e-07, 2.102693e-09, 5.798077e-07, 1.794491e-02, 5.536756e-05, 9.340380e-02, 2.119063e-07, 3.888095e-08, 8.885948e-01, -3.351501e-22
2.500000e-03, 9.656592e-03, 1.097391e+01, 1.743361e+03, 7.443896e-07, 7.263598e-09, 1.445878e-06, 1.823991e-02, 9.936539e-05, 9.315727e-02, 3.431069e-07, 5.713140e-08, 8.885009e-01, -2.702988e-22
3.000000e-03, -9.932050e-04, 1.076428e+01, 1.835358e+03, 1.721271e-06, 2.385191e-08, 3.475953e-06, 1.855155e-02, 1.738773e-04, 9.287074e-02, 5.457504e-07, 8.303262e-08, 8.883980e-01, -2.004709e-22
3.250000e-03, -6.325597e-03, 1.021392e+01, 1.879260e+03, 2.503871e-06, 4.057309e-08, 5.142740e-06, 1.870381e-02, 2.230622e-04, 9.271566e-02, 6.720620e-07, 9.825228e-08, 8.883490e-01, -1.662031e-22
3.500000e-03, -1.142100e-02, 9.385500e+00, 1.920781e+03, 3.512531e-06, 6.558411e-08, 7.330052e-06, 1.884956e-02, 2.793796e-04, 9.255547e-02, 8.114615e-07, 1.144339e-07, 8.883038e-01, -1.334923e-22
3.875000e-03, -1.825784e-02, 7.674717e+00, 1.977424e+03, 5.448847e-06, 1.223424e-07, 1.161646e-05, 1.905148e-02, 3.741256e-04, 9.231109e-02, 1.036929e-06, 1.395402e-07, 8.882449e-01, -8.861048e-23
4.062500e-03, -2.119235e-02, 6.635660e+00, 2.002727e+03, 6.578201e-06, 1.598996e-07, 1.415747e-05, 1.914401e-02, 4.240435e-04, 9.218977e-02, 1.152298e-06, 1.519677e-07, 8.882200e-01, -8.081601e-23
4.250000e-03, -2.372554e-02, 5.486297e+00, 2.026029e+03, 7.791863e-06, 2.034408e-07, 1.691620e-05, 1.923025e-02, 4.745845e-04, 9.207075e-02, 1.267128e-06, 1.640970e-07, 8.881981e-01, -7.361773e-23
4.437500e-03, -2.580906e-02, 4.238130e+00, 2.047381e+03, 9.068806e-06, 2.524922e-07, 1.984634e-05, 1.931009e-02, 5.249935e-04, 9.195510e-02, 1.379926e-06, 1.758014e-07, 8.881791e-01, -6.701084e-23
4.625000e-03, -2.740055e-02, 2.901957e+00, 2.066880e+03, 1.038708e-05, 3.063417e-07, 2.289850e-05, 1.938356e-02, 5.746220e-04, 9.184369e-02, 1.489446e-06, 1.869847e-07, 8.881629e-01, -6.097478e-23
4.718750e-03, -2.800064e-02, 2.203773e+00, 2.075970e+03, 1.105146e-05, 3.346612e-07, 2.444938e-05, 1.941792e-02, 5.989075e-04, 9.178989e-02, 1.542419e-06, 1.923365e-07, 8.881557e-01, -5.815779e-23
4.812500e-03, -2.846434e-02, 1.486709e+00, 2.084655e+03, 1.170346e-05, 3.632483e-07, 2.598881e-05, 1.945049e-02, 6.225427e-04, 9.173793e-02, 1.593224e-06, 1.974446e-07, 8.881492e-01, -5.547409e-23
4.859375e-03, -2.864418e-02, 1.121426e+00, 2.088872e+03, 1.200378e-05, 3.767706e-07, 2.671937e-05, 1.946580e-02, 6.337394e-04, 9.171335e-02, 1.616424e-06, 1.997839e-07, 8.881462e-01, -5.417950e-23
4.906250e-03, -2.878903e-02, 7.517834e-01, 2.093034e+03, 1.226234e-05, 3.886765e-07, 2.737730e-05, 1.948012e-02, 6.440190e-04, 9.169060e-02, 1.636419e-06, 2.018258e-07, 8.881434e-01, -5.291659e-23
4.953125e-03, -2.889927e-02, 3.779246e-01, 2.097206e+03, 1.243125e-05, 3.965227e-07, 2.784171e-05, 1.949310e-02, 6.520262e-04, 9.167163e-02, 1.649102e-06, 2.031952e-07, 8.881407e-01, -5.168463e-23
5.000000e-03, -2.897656e-02, 0.000000e+00, 2.101546e+03, 1.243388e-05, 3.966192e-07, 2.786987e-05, 1.950659e-02, 6.523619e-04, 9.166124e-02, 1.651031e-06, 2.033500e-07, 8.881373e-01, -5.048287e-23
Loading