Skip to content

Commit

Permalink
added explicit eig_eps_key assignment in implicit 'M' case, updated t…
Browse files Browse the repository at this point in the history
…hrow error msgs
  • Loading branch information
pjsingal committed Oct 21, 2024
1 parent 2e93c1f commit 5a2c7f8
Showing 1 changed file with 41 additions and 25 deletions.
66 changes: 41 additions & 25 deletions src/kinetics/LinearBurkeRate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,22 @@ void LinearBurkeRate::setParameters(const AnyMap& node, const UnitStack& rate_un
" pressure-dependent-Arrhenius (PLOG), falloff (Troe form), or Chebyshev"
" format.", eqn);
}
string eig_eps_key;
// If using eig0 for all colliders, then it is mandatory to specify an eig0 value
// for the reference collider
if (colliders[0].hasKey("eig0")){
eig_eps_key = "eig0";
}
AnyMap params;
params["A"] = 1.0;
params["b"] = 0.0;
params["Ea"] = 0.0;
m_epsObj_M = ArrheniusRate(AnyValue(params), colliders[0].units(), eps_units);
m_colliderInfo["M"] = colliders[0];
string eig_eps_key;
// If using eig0 for all colliders, then it is mandatory to specify an eig0 value
// for the reference collider
if (colliders[0].hasKey("eig0")){
eig_eps_key = "eig0";
}
else {
eig_eps_key = "efficiency";
colliders[0][eig_eps_key] = params;
}
// Start at 1 because index 0 is for "M"
for (size_t i = 1; i < colliders.size(); i++){
if (!colliders[i].hasKey("name")) {
Expand All @@ -127,29 +131,41 @@ void LinearBurkeRate::setParameters(const AnyMap& node, const UnitStack& rate_un
" has no 'name' defined.", i, eqn);
}
auto nm = colliders[i]["name"].asString();
if (!colliders[i].hasKey("efficiency") && !colliders[0].hasKey("eig0")) {
throw InputFileError("LinearBurkeRate::setParameters", m_input,
"Collider '{}' in reaction '{}' lacks an 'efficiency' or 'eig0' key.",
nm, eqn);
}
if (eig_eps_key.empty()) {
if (colliders[i].hasKey("efficiency") && !colliders[i].hasKey("eig0")) {
eig_eps_key = "efficiency";
} else if (colliders[i].hasKey("eig0") && !colliders[i].hasKey("efficiency")) {
if (eig_eps_key == "eig0"){ // 'M' has 'eig0'
if (!colliders[i].hasKey("eig0") && !colliders[i].hasKey("efficiency")){
throw InputFileError("LinearBurkeRate::setParameters", m_input,
"Collider '{}' in reaction '{}' lacks an 'eig0' key.",
nm, eqn);
} else if (!colliders[i].hasKey("eig0") && colliders[i].hasKey("efficiency")){
throw InputFileError("LinearBurkeRate::setParameters", m_input,
"'eig0' must be specified for 'M' in reaction '{}', since the other"
" colliders are specified according to the same parameter.", eqn);
} else{
"Since 'M' has been explicitly given 'eig0', all other "
"colliders must receive 'eig0' as well. No mixing and matching "
"of 'eig0' and 'efficiency' is allowed.", eqn);
} else if (colliders[i].hasKey("eig0") && colliders[i].hasKey("efficiency")){
throw InputFileError("LinearBurkeRate::setParameters", m_input,
"Collider '{}' in reaction '{}' cannot contain both 'efficiency'"
" and 'eig0'. Any additional colliders must also make same choice"
" as that of M.", nm, eqn);
" and 'eig0'. All additional colliders must also make the"
" same choice as that of 'M'.", nm, eqn);
}
}
else { // 'M' has 'efficiency'
if (!colliders[i].hasKey("efficiency") && !colliders[i].hasKey("eig0")){
throw InputFileError("LinearBurkeRate::setParameters", m_input,
"Collider '{}' in reaction '{}' lacks an 'efficiency' key.",
nm, eqn);
} else if (!colliders[i].hasKey("efficiency") && colliders[i].hasKey("eig0")){
throw InputFileError("LinearBurkeRate::setParameters", m_input,
"Since 'M' has been (implicitly) given 'efficiency', all other "
"colliders must also receive an 'efficiency'. No mixing and matching "
"of 'efficiency' and 'eig0' is allowed.\nIf you wish to define all "
"colliders according to 'eig0' instead, then an 'eig0' value must "
"be explicitly provided for 'M' as well.", eqn);
} else if (colliders[i].hasKey("efficiency") && colliders[i].hasKey("eig0")){
throw InputFileError("LinearBurkeRate::setParameters", m_input,
"Collider '{}' in reaction '{}' cannot contain both 'eig0'"
" and 'efficiency'. All additional colliders must also make the"
" same choice as that of 'M'.", nm, eqn);
}
} else if (!colliders[i].hasKey(eig_eps_key)) {
throw InputFileError("LinearBurkeRate::setParameters", m_input,
"All collision efficiencies in reaction '{}' must be defined uniformly"
" as either 'eig0' or 'efficiency'. No mixing and matching is allowed.",
eqn);
}
// Save data to m_colliderInfo, which will make it accessible by getParameters
m_colliderInfo[colliders[i]["name"].asString()] = colliders[i];
Expand Down

0 comments on commit 5a2c7f8

Please sign in to comment.