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

Inconsistency of MW/iMW precisions in CEPTR #560

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
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
162 changes: 81 additions & 81 deletions Mechanisms/IonizedAir/mechanism.H
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,19 @@ const amrex::Real h_global_imw[5] = {
// molecular weights
#ifdef AMREX_USE_GPU
AMREX_GPU_CONSTANT const amrex::Real global_mw[5] = {
31.998000, // O2
28.014000, // N2
0.000549, // E
15.999549, // On
31.998549, // O2n
31.9980000000000011, // O2
28.0139999999999993, // N2
0.0005485799088728, // E
15.9995485799088737, // On
31.9985485799088742, // O2n
};
#endif
const amrex::Real h_global_mw[5] = {
31.998000, // O2
28.014000, // N2
0.000549, // E
15.999549, // On
31.998549, // O2n
31.9980000000000011, // O2
28.0139999999999993, // N2
0.0005485799088728, // E
15.9995485799088737, // On
31.9985485799088742, // O2n
};

// inverse molecular weights
Expand Down Expand Up @@ -139,11 +139,11 @@ imw(const int n)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void
get_mw(amrex::Real* mw_new)
{
mw_new[0] = 31.998000; // O2
mw_new[1] = 28.014000; // N2
mw_new[2] = 0.000549; // E
mw_new[3] = 15.999549; // On
mw_new[4] = 31.998549; // O2n
mw_new[0] = 31.9980000000000011; // O2
mw_new[1] = 28.0139999999999993; // N2
mw_new[2] = 0.0005485799088728; // E
mw_new[3] = 15.9995485799088737; // On
mw_new[4] = 31.9985485799088742; // O2n
}

// molecular weight
Expand Down Expand Up @@ -944,11 +944,11 @@ CKSBMS(
YOW += y[i] * imw(i);
}
// Now compute y to x conversion
x[0] = y[0] / (31.998000 * YOW);
x[1] = y[1] / (28.014000 * YOW);
x[2] = y[2] / (0.000549 * YOW);
x[3] = y[3] / (15.999549 * YOW);
x[4] = y[4] / (31.998549 * YOW);
x[0] = y[0] / (31.9980000000000011 * YOW);
x[1] = y[1] / (28.0139999999999993 * YOW);
x[2] = y[2] / (0.0005485799088728 * YOW);
x[3] = y[3] / (15.9995485799088737 * YOW);
x[4] = y[4] / (31.9985485799088742 * YOW);
speciesEntropy(sor, T);
// Perform computation in Eq 42 and 43
for (int i = 0; i < 5; i++) {
Expand Down Expand Up @@ -1071,11 +1071,11 @@ CKPX(
amrex::Real& P)
{
amrex::Real XW = 0; // To hold mean molecular wt
XW += x[0] * 31.998000; // O2
XW += x[1] * 28.014000; // N2
XW += x[2] * 0.000549; // E
XW += x[3] * 15.999549; // On
XW += x[4] * 31.998549; // O2n
XW += x[0] * 31.9980000000000011; // O2
XW += x[1] * 28.0139999999999993; // N2
XW += x[2] * 0.0005485799088728; // E
XW += x[3] * 15.9995485799088737; // On
XW += x[4] * 31.9985485799088742; // O2n
P = rho * 8.31446261815324e+07 * T / XW; // P = rho*R*T/W
}

Expand Down Expand Up @@ -1106,11 +1106,11 @@ CKPC(
// See Eq 5 in CK Manual
amrex::Real W = 0;
amrex::Real sumC = 0;
W += c[0] * 31.998000; // O2
W += c[1] * 28.014000; // N2
W += c[2] * 0.000549; // E
W += c[3] * 15.999549; // On
W += c[4] * 31.998549; // O2n
W += c[0] * 31.9980000000000011; // O2
W += c[1] * 28.0139999999999993; // N2
W += c[2] * 0.0005485799088728; // E
W += c[3] * 15.9995485799088737; // On
W += c[4] * 31.9985485799088742; // O2n

for (int id = 0; id < 5; ++id) {
sumC += c[id];
Expand All @@ -1127,11 +1127,11 @@ CKRHOX(
amrex::Real& rho)
{
amrex::Real XW = 0; // To hold mean molecular wt
XW += x[0] * 31.998000; // O2
XW += x[1] * 28.014000; // N2
XW += x[2] * 0.000549; // E
XW += x[3] * 15.999549; // On
XW += x[4] * 31.998549; // O2n
XW += x[0] * 31.9980000000000011; // O2
XW += x[1] * 28.0139999999999993; // N2
XW += x[2] * 0.0005485799088728; // E
XW += x[3] * 15.9995485799088737; // On
XW += x[4] * 31.9985485799088742; // O2n
rho = P * XW / (8.31446261815324e+07 * T); // rho = P*W/(R*T)
}

Expand Down Expand Up @@ -1163,11 +1163,11 @@ CKRHOC(
// See Eq 5 in CK Manual
amrex::Real W = 0;
amrex::Real sumC = 0;
W += c[0] * 31.998000; // O2
W += c[1] * 28.014000; // N2
W += c[2] * 0.000549; // E
W += c[3] * 15.999549; // On
W += c[4] * 31.998549; // O2n
W += c[0] * 31.9980000000000011; // O2
W += c[1] * 28.0139999999999993; // N2
W += c[2] * 0.0005485799088728; // E
W += c[3] * 15.9995485799088737; // On
W += c[4] * 31.9985485799088742; // O2n

for (int id = 0; id < 5; ++id) {
sumC += c[id];
Expand Down Expand Up @@ -1201,12 +1201,12 @@ CKMMWY(const amrex::Real y[], amrex::Real& wtm)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void
CKMMWX(const amrex::Real x[], amrex::Real& wtm)
{
amrex::Real XW = 0; // see Eq 4 in CK Manual
XW += x[0] * 31.998000; // O2
XW += x[1] * 28.014000; // N2
XW += x[2] * 0.000549; // E
XW += x[3] * 15.999549; // On
XW += x[4] * 31.998549; // O2n
amrex::Real XW = 0; // see Eq 4 in CK Manual
XW += x[0] * 31.9980000000000011; // O2
XW += x[1] * 28.0139999999999993; // N2
XW += x[2] * 0.0005485799088728; // E
XW += x[3] * 15.9995485799088737; // On
XW += x[4] * 31.9985485799088742; // O2n
wtm = XW;
}

Expand All @@ -1218,11 +1218,11 @@ CKMMWC(const amrex::Real c[], amrex::Real& wtm)
// See Eq 5 in CK Manual
amrex::Real W = 0;
amrex::Real sumC = 0;
W += c[0] * 31.998000; // O2
W += c[1] * 28.014000; // N2
W += c[2] * 0.000549; // E
W += c[3] * 15.999549; // On
W += c[4] * 31.998549; // O2n
W += c[0] * 31.9980000000000011; // O2
W += c[1] * 28.0139999999999993; // N2
W += c[2] * 0.0005485799088728; // E
W += c[3] * 15.9995485799088737; // On
W += c[4] * 31.9985485799088742; // O2n

for (int id = 0; id < 5; ++id) {
sumC += c[id];
Expand Down Expand Up @@ -1320,18 +1320,18 @@ CKXTY(const amrex::Real x[], amrex::Real y[])
{
amrex::Real XW = 0; // See Eq 4, 9 in CK Manual
// Compute mean molecular wt first
XW += x[0] * 31.998000; // O2
XW += x[1] * 28.014000; // N2
XW += x[2] * 0.000549; // E
XW += x[3] * 15.999549; // On
XW += x[4] * 31.998549; // O2n
XW += x[0] * 31.9980000000000011; // O2
XW += x[1] * 28.0139999999999993; // N2
XW += x[2] * 0.0005485799088728; // E
XW += x[3] * 15.9995485799088737; // On
XW += x[4] * 31.9985485799088742; // O2n
// Now compute conversion
amrex::Real XWinv = 1.0 / XW;
y[0] = x[0] * 31.998000 * XWinv;
y[1] = x[1] * 28.014000 * XWinv;
y[2] = x[2] * 0.000549 * XWinv;
y[3] = x[3] * 15.999549 * XWinv;
y[4] = x[4] * 31.998549 * XWinv;
y[0] = x[0] * 31.9980000000000011 * XWinv;
y[1] = x[1] * 28.0139999999999993 * XWinv;
y[2] = x[2] * 0.0005485799088728 * XWinv;
y[3] = x[3] * 15.9995485799088737 * XWinv;
y[4] = x[4] * 31.9985485799088742 * XWinv;
}

// convert x[species] (mole fracs) to c[species] (molar conc)
Expand Down Expand Up @@ -1361,11 +1361,11 @@ CKXTCR(
amrex::Real XW = 0; // See Eq 4, 11 in CK Manual
amrex::Real ROW;
// Compute mean molecular wt first
XW += x[0] * 31.998000; // O2
XW += x[1] * 28.014000; // N2
XW += x[2] * 0.000549; // E
XW += x[3] * 15.999549; // On
XW += x[4] * 31.998549; // O2n
XW += x[0] * 31.9980000000000011; // O2
XW += x[1] * 28.0139999999999993; // N2
XW += x[2] * 0.0005485799088728; // E
XW += x[3] * 15.9995485799088737; // On
XW += x[4] * 31.9985485799088742; // O2n
ROW = rho / XW;

// Compute conversion, see Eq 11
Expand Down Expand Up @@ -1398,18 +1398,18 @@ CKCTY(const amrex::Real c[], amrex::Real y[])
{
amrex::Real CW = 0; // See Eq 12 in CK Manual
// compute denominator in eq 12 first
CW += c[0] * 31.998000; // O2
CW += c[1] * 28.014000; // N2
CW += c[2] * 0.000549; // E
CW += c[3] * 15.999549; // On
CW += c[4] * 31.998549; // O2n
CW += c[0] * 31.9980000000000011; // O2
CW += c[1] * 28.0139999999999993; // N2
CW += c[2] * 0.0005485799088728; // E
CW += c[3] * 15.9995485799088737; // On
CW += c[4] * 31.9985485799088742; // O2n
// Now compute conversion
amrex::Real CWinv = 1.0 / CW;
y[0] = c[0] * 31.998000 * CWinv;
y[1] = c[1] * 28.014000 * CWinv;
y[2] = c[2] * 0.000549 * CWinv;
y[3] = c[3] * 15.999549 * CWinv;
y[4] = c[4] * 31.998549 * CWinv;
y[0] = c[0] * 31.9980000000000011 * CWinv;
y[1] = c[1] * 28.0139999999999993 * CWinv;
y[2] = c[2] * 0.0005485799088728 * CWinv;
y[3] = c[3] * 15.9995485799088737 * CWinv;
y[4] = c[4] * 31.9985485799088742 * CWinv;
}

// get specific heat at constant volume as a function
Expand Down Expand Up @@ -1688,11 +1688,11 @@ CKWXR(
amrex::Real XW = 0; // See Eq 4, 11 in CK Manual
amrex::Real ROW;
// Compute mean molecular wt first
XW += x[0] * 31.998000; // O2
XW += x[1] * 28.014000; // N2
XW += x[2] * 0.000549; // E
XW += x[3] * 15.999549; // On
XW += x[4] * 31.998549; // O2n
XW += x[0] * 31.9980000000000011; // O2
XW += x[1] * 28.0139999999999993; // N2
XW += x[2] * 0.0005485799088728; // E
XW += x[3] * 15.9995485799088737; // On
XW += x[4] * 31.9985485799088742; // O2n
// Extra 1e6 factor to take c to SI
ROW = 1e6 * rho / XW;

Expand Down
30 changes: 15 additions & 15 deletions Support/ceptr/ceptr/ck.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ def cksbms(fstream, mechanism, species_info):
species = species_info.nonqssa_species[spec_idx]
cw.writer(
fstream,
f"x[{spec_idx}] = y[{spec_idx}]/({species.weight:f}*YOW); ",
f"x[{spec_idx}] = y[{spec_idx}]/({species.weight:.16f}*YOW); ",
)

# call routine
Expand Down Expand Up @@ -684,7 +684,7 @@ def ckgbms(fstream, mechanism, species_info):
species = species_info.nonqssa_species[spec_idx]
cw.writer(
fstream,
f"x[{spec_idx}] = y[{spec_idx}]/({species.weight:f}*YOW); ",
f"x[{spec_idx}] = y[{spec_idx}]/({species.weight:.16f}*YOW); ",
)

# call routine
Expand Down Expand Up @@ -822,7 +822,7 @@ def ckabms(fstream, mechanism, species_info):
species = species_info.nonqssa_species[spec_idx]
cw.writer(
fstream,
f"x[{spec_idx}] = y[{spec_idx}]/({species.weight:f}*YOW); ",
f"x[{spec_idx}] = y[{spec_idx}]/({species.weight:.16f}*YOW); ",
)

# call routine
Expand Down Expand Up @@ -868,7 +868,7 @@ def ckpx(fstream, mechanism, species_info):
species = species_info.nonqssa_species[spec_idx]
cw.writer(
fstream,
f"XW += x[{spec_idx}]*{species.weight:f}; " + cw.comment(f"{species.name}"),
f"XW += x[{spec_idx}]*{species.weight:.16f}; " + cw.comment(f"{species.name}"),
)

cw.writer(
Expand Down Expand Up @@ -948,7 +948,7 @@ def ckpc(fstream, mechanism, species_info):
species = species_info.nonqssa_species[spec_idx]
cw.writer(
fstream,
f"W += c[{spec_idx}]*{species.weight:f}; " + cw.comment(f"{species.name}"),
f"W += c[{spec_idx}]*{species.weight:.16f}; " + cw.comment(f"{species.name}"),
)

cw.writer(fstream)
Expand Down Expand Up @@ -993,7 +993,7 @@ def ckrhox(fstream, mechanism, species_info):
species = species_info.nonqssa_species[spec_idx]
cw.writer(
fstream,
f"XW += x[{spec_idx}]*{species.weight:f}; " + cw.comment(f"{species.name}"),
f"XW += x[{spec_idx}]*{species.weight:.16f}; " + cw.comment(f"{species.name}"),
)

cw.writer(
Expand Down Expand Up @@ -1063,7 +1063,7 @@ def ckrhoc(fstream, mechanism, species_info):
species = species_info.nonqssa_species[spec_idx]
cw.writer(
fstream,
f"W += c[{spec_idx}]*{species.weight:f}; " + cw.comment(f"{species.name}"),
f"W += c[{spec_idx}]*{species.weight:.16f}; " + cw.comment(f"{species.name}"),
)

cw.writer(fstream)
Expand Down Expand Up @@ -1144,7 +1144,7 @@ def ckmmwx(fstream, mechanism, species_info):
species = species_info.nonqssa_species[spec_idx]
cw.writer(
fstream,
f"XW += x[{spec_idx}]*{species.weight:f}; " + cw.comment(f"{species.name}"),
f"XW += x[{spec_idx}]*{species.weight:.16f}; " + cw.comment(f"{species.name}"),
)
cw.writer(fstream, "wtm = XW;")
cw.writer(fstream)
Expand Down Expand Up @@ -1174,7 +1174,7 @@ def ckmmwc(fstream, mechanism, species_info):
species = species_info.nonqssa_species[spec_idx]
cw.writer(
fstream,
f"W += c[{spec_idx}]*{species.weight:f}; " + cw.comment(f"{species.name}"),
f"W += c[{spec_idx}]*{species.weight:.16f}; " + cw.comment(f"{species.name}"),
)
cw.writer(fstream)
cw.writer(fstream, f"for (int id = 0; id < {n_species}; ++id) {{")
Expand Down Expand Up @@ -1374,7 +1374,7 @@ def ckxty(fstream, mechanism, species_info):
species = species_info.nonqssa_species[spec_idx]
cw.writer(
fstream,
f"XW += x[{spec_idx}]*{species.weight:f}; " + cw.comment(f"{species.name}"),
f"XW += x[{spec_idx}]*{species.weight:.16f}; " + cw.comment(f"{species.name}"),
)

# now compute conversion
Expand All @@ -1385,7 +1385,7 @@ def ckxty(fstream, mechanism, species_info):
species = species_info.nonqssa_species[spec_idx]
cw.writer(
fstream,
f"y[{spec_idx}] = x[{spec_idx}]*{species.weight:f}*XWinv; ",
f"y[{spec_idx}] = x[{spec_idx}]*{species.weight:.16f}*XWinv; ",
)

cw.writer(fstream)
Expand Down Expand Up @@ -1457,7 +1457,7 @@ def ckxtcr(fstream, mechanism, species_info):
species = species_info.nonqssa_species[sp]
cw.writer(
fstream,
f"XW += x[{species.idx}]*{species.weight:f}; "
f"XW += x[{species.idx}]*{species.weight:.16f}; "
+ cw.comment(f"{species.name}"),
)

Expand Down Expand Up @@ -1535,7 +1535,7 @@ def ckcty(fstream, mechanism, species_info):
species = species_info.nonqssa_species[sp]
cw.writer(
fstream,
f"CW += c[{species.idx}]*{species.weight:f}; "
f"CW += c[{species.idx}]*{species.weight:.16f}; "
+ cw.comment(f"{species.name}"),
)

Expand All @@ -1546,7 +1546,7 @@ def ckcty(fstream, mechanism, species_info):
species = species_info.nonqssa_species[sp]
cw.writer(
fstream,
f"y[{species.idx}] = c[{species.idx}]*{species.weight:f}*CWinv; ",
f"y[{species.idx}] = c[{species.idx}]*{species.weight:.16f}*CWinv; ",
)

cw.writer(fstream)
Expand Down Expand Up @@ -2227,7 +2227,7 @@ def ckwxr(fstream, mechanism, species_info):
species = species_info.nonqssa_species[sp]
cw.writer(
fstream,
f"XW += x[{species.idx}]*{species.weight:f}; "
f"XW += x[{species.idx}]*{species.weight:.16f}; "
+ cw.comment(f"{species.name}"),
)

Expand Down
Loading
Loading