Compare commits
No commits in common. "trunk" and "sutherland" have entirely different histories.
trunk
...
sutherland
2 changed files with 40 additions and 99 deletions
129
ct2foam.C
129
ct2foam.C
|
|
@ -33,7 +33,6 @@ Description
|
|||
|
||||
#include <cantera/transport.h>
|
||||
#include <cantera/IdealGasMix.h>
|
||||
#include <cantera/thermo/speciesThermoTypes.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
|
|
@ -59,7 +58,7 @@ std::string stringNASACoefs (doublereal *coef)
|
|||
|
||||
void calculateSutherland (Cantera::IdealGasMix *gas_, doublereal As[], doublereal C[])
|
||||
{
|
||||
std::shared_ptr<Cantera::Transport> tr_ ( Cantera::newTransportMgr("Mix", gas_) );
|
||||
Cantera::Transport *tr_ = Cantera::newTransportMgr("Mix", gas_);
|
||||
|
||||
doublereal mu0[gas_->nSpecies()];
|
||||
doublereal muRatio[gas_->nSpecies()];
|
||||
|
|
@ -117,63 +116,11 @@ void calculateSutherland (Cantera::IdealGasMix *gas_, doublereal As[], doublerea
|
|||
As[j] = mu0[j] * (T0 + C[j]) / pow(T0, 3./2.);
|
||||
}
|
||||
|
||||
delete tr_;
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
std::string ofReactionString (const std::shared_ptr<Cantera::Reaction> r)
|
||||
{
|
||||
|
||||
std::ostringstream reaction;
|
||||
|
||||
|
||||
for (auto iter = r->reactants.begin(); iter != r->reactants.end(); ++iter)
|
||||
{
|
||||
if (iter != r->reactants.begin())
|
||||
{
|
||||
reaction << " + ";
|
||||
}
|
||||
if (iter->second != 1.0)
|
||||
{
|
||||
reaction << iter->second;
|
||||
}
|
||||
reaction << iter->first;
|
||||
if (iter->second != r->orders[iter->first] && r->orders[iter->first] != 0.0 )
|
||||
{
|
||||
reaction << "^" << r->orders[iter->first];
|
||||
}
|
||||
}
|
||||
|
||||
reaction << " = ";
|
||||
|
||||
for (Cantera::Composition::iterator iter = r->products.begin(); iter != r->products.end(); ++iter)
|
||||
{
|
||||
if (iter != r->products.begin())
|
||||
{
|
||||
reaction << " + ";
|
||||
}
|
||||
if (iter->second != 1.0)
|
||||
{
|
||||
reaction << iter->second;
|
||||
}
|
||||
reaction << iter->first;
|
||||
if (iter->second != r->orders[iter->first] && r->orders[iter->first] != 0.0)
|
||||
{
|
||||
reaction << "^" << r->orders[iter->first];
|
||||
}
|
||||
}
|
||||
|
||||
return reaction.str();
|
||||
}
|
||||
|
||||
|
||||
bool is_file_exist(const std::string &fileName)
|
||||
{
|
||||
std::ifstream infile(fileName);
|
||||
return infile.good();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
|
|
@ -187,9 +134,9 @@ int main(int argc, char *argv[])
|
|||
std::ofstream fthermo;
|
||||
std::ofstream frxn;
|
||||
|
||||
|
||||
options.add_options()
|
||||
("name", "Name of ideal gas mix in CTI file", cxxopts::value(sgas))
|
||||
("w,overwrite", "Overwrite exsisting files")
|
||||
("h,help", "print help message")
|
||||
;
|
||||
|
||||
|
|
@ -226,26 +173,9 @@ int main(int argc, char *argv[])
|
|||
|
||||
Cantera::IdealGasMix gas_(scti, sgas);
|
||||
|
||||
bool overwrite = result["overwrite"].as<bool>();
|
||||
|
||||
if (is_file_exist(sthermo) && (!overwrite))
|
||||
{
|
||||
throw std::system_error(EEXIST, std::system_category(), sthermo);
|
||||
}
|
||||
else
|
||||
{
|
||||
fthermo.open(sthermo);
|
||||
}
|
||||
|
||||
if (is_file_exist(srxn) && (!overwrite))
|
||||
{
|
||||
throw std::system_error(EEXIST, std::system_category(), srxn);
|
||||
}
|
||||
else
|
||||
{
|
||||
frxn.open(srxn);
|
||||
}
|
||||
fthermo.open(sthermo);
|
||||
|
||||
frxn.open(srxn);
|
||||
|
||||
// Thermo Part =============================================================
|
||||
|
||||
|
|
@ -255,6 +185,17 @@ int main(int argc, char *argv[])
|
|||
|
||||
calculateSutherland (&gas_, As, C);
|
||||
|
||||
for (size_t n = 0; n < gas_.nSpecies(); n++)
|
||||
{
|
||||
std::cout << As[n] << std::endl;
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
for (size_t n = 0; n < gas_.nSpecies(); n++)
|
||||
{
|
||||
std::cout << C[n] << std::endl;
|
||||
}
|
||||
|
||||
// these constants define the location of coefficient "a6" in the
|
||||
// cofficient array c. The c array contains Tmid in the first
|
||||
|
|
@ -267,14 +208,7 @@ int main(int argc, char *argv[])
|
|||
doublereal minTemp, maxTemp, refPressure;
|
||||
|
||||
// get the NASA coefficients in array c
|
||||
switch(gas_.speciesThermo().reportType(n))
|
||||
{
|
||||
case NASA2:
|
||||
gas_.speciesThermo().reportParams(n, type, c, minTemp, maxTemp, refPressure);
|
||||
break;
|
||||
default:
|
||||
throw std::domain_error(gas_.speciesName(n) + " has a non-NASA2-type thermodynamics interpolator");
|
||||
}
|
||||
gas_.speciesThermo().reportParams(n, type, c, minTemp, maxTemp, refPressure);
|
||||
|
||||
fthermo<<(
|
||||
fmt::format(
|
||||
|
|
@ -336,11 +270,14 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
case Cantera::ELEMENTARY_RXN:
|
||||
|
||||
frxn<<( fmt::format( rxnTypeFormat, irn + rate + rxn));
|
||||
|
||||
frxn<<( fmt::format( rxnEqnFormat,
|
||||
r->Reaction::reactantString() + " = " + r->Reaction::productString()));
|
||||
|
||||
frxn<<(
|
||||
fmt::format(
|
||||
rxnTypeFormat + rxnEqnFormat + arrheniusFormat,
|
||||
irn + rate + rxn,
|
||||
ofReactionString(r),
|
||||
arrheniusFormat,
|
||||
std::dynamic_pointer_cast<Cantera::ElementaryReaction>(r)->rate.preExponentialFactor(),
|
||||
std::dynamic_pointer_cast<Cantera::ElementaryReaction>(r)->rate.temperatureExponent(),
|
||||
std::dynamic_pointer_cast<Cantera::ElementaryReaction>(r)->rate.activationEnergy_R()
|
||||
|
|
@ -352,11 +289,14 @@ int main(int argc, char *argv[])
|
|||
|
||||
rate = "thirdBody" + rate;
|
||||
|
||||
frxn<<( fmt::format( rxnTypeFormat, irn + rate + rxn));
|
||||
|
||||
frxn<<( fmt::format( rxnEqnFormat,
|
||||
r->Reaction::reactantString() + " = " + r->Reaction::productString()));
|
||||
|
||||
frxn<<(
|
||||
fmt::format(
|
||||
rxnTypeFormat + rxnEqnFormat + arrheniusFormat,
|
||||
irn + rate + rxn,
|
||||
ofReactionString(r),
|
||||
arrheniusFormat,
|
||||
std::dynamic_pointer_cast<Cantera::ElementaryReaction>(r)->rate.preExponentialFactor(),
|
||||
std::dynamic_pointer_cast<Cantera::ElementaryReaction>(r)->rate.temperatureExponent(),
|
||||
std::dynamic_pointer_cast<Cantera::ElementaryReaction>(r)->rate.activationEnergy_R()
|
||||
|
|
@ -407,11 +347,14 @@ int main(int argc, char *argv[])
|
|||
break;
|
||||
}
|
||||
|
||||
frxn<<( fmt::format( rxnTypeFormat, irn + rate + rxn));
|
||||
|
||||
frxn<<( fmt::format( rxnEqnFormat,
|
||||
r->Reaction::reactantString() + " = " + r->Reaction::productString()));
|
||||
|
||||
frxn<<(
|
||||
fmt::format(
|
||||
rxnTypeFormat + rxnEqnFormat + falloffFormat,
|
||||
irn + rate + rxn,
|
||||
ofReactionString(r),
|
||||
falloffFormat,
|
||||
std::dynamic_pointer_cast<Cantera::FalloffReaction>(r)->low_rate.preExponentialFactor(),
|
||||
std::dynamic_pointer_cast<Cantera::FalloffReaction>(r)->low_rate.temperatureExponent(),
|
||||
std::dynamic_pointer_cast<Cantera::FalloffReaction>(r)->low_rate.activationEnergy_R(),
|
||||
|
|
|
|||
10
ofFormats.h
10
ofFormats.h
|
|
@ -28,12 +28,6 @@ std::string thermoFormat = std::string() +
|
|||
"}}\n"
|
||||
;
|
||||
|
||||
std::string rxnTypeFormat =
|
||||
" type {};\n";
|
||||
|
||||
std::string rxnEqnFormat =
|
||||
" reaction \"{}\";\n";
|
||||
|
||||
std::string arrheniusFormat = std::string() +
|
||||
" A {};\n" +
|
||||
" beta {};\n" +
|
||||
|
|
@ -86,4 +80,8 @@ std::string sriFormat = std::string() +
|
|||
;
|
||||
|
||||
|
||||
std::string rxnTypeFormat = " type {};\n";
|
||||
|
||||
std::string rxnEqnFormat = " reaction \"{}\";\n";
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue