本文整理汇总了C++中ThermoPhase类的典型用法代码示例。如果您正苦于以下问题:C++ ThermoPhase类的具体用法?C++ ThermoPhase怎么用?C++ ThermoPhase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ThermoPhase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: phase_setmassfractionsbyname_
status_t phase_setmassfractionsbyname_(const integer* n, char* y, ftnlen leny)
{
try {
ThermoPhase* p = _fph(n);
p->setMassFractionsByName(f2string(y, leny));
} catch (...) {
return handleAllExceptions(-1, ERR);
}
return 0;
}
开发者ID:Cantera,项目名称:cantera-svn,代码行数:10,代码来源:fct.cpp
示例2: phase_getmassfractions_
status_t phase_getmassfractions_(const integer* n, doublereal* y)
{
try {
ThermoPhase* p = _fph(n);
p->getMassFractions(y);
} catch (...) {
return handleAllExceptions(-1, ERR);
}
return 0;
}
开发者ID:anujg1991,项目名称:cantera,代码行数:10,代码来源:fct.cpp
示例3: phase_setmolefractionsbyname_
status_t phase_setmolefractionsbyname_(const integer* n, char* x, ftnlen lx)
{
try {
ThermoPhase* p = _fph(n);
p->setMoleFractionsByName(f2string(x, lx));
} catch (...) {
return handleAllExceptions(-1, ERR);
}
return 0;
}
开发者ID:Cantera,项目名称:cantera-svn,代码行数:10,代码来源:fct.cpp
示例4: phase_setmassfractionsbyname_
status_t phase_setmassfractionsbyname_(const integer* n, char* y, ftnlen leny)
{
try {
ThermoPhase* p = _fph(n);
compositionMap yy = parseCompString(f2string(y, leny), p->speciesNames());
p->setMassFractionsByName(yy);
} catch (...) {
return handleAllExceptions(-1, ERR);
}
return 0;
}
开发者ID:anujg1991,项目名称:cantera,代码行数:11,代码来源:fct.cpp
示例5: phase_getmolecularweights_
status_t phase_getmolecularweights_(const integer* n, doublereal* mw)
{
try {
ThermoPhase* p = _fph(n);
const vector_fp& wt = p->molecularWeights();
copy(wt.begin(), wt.end(), mw);
} catch (...) {
return handleAllExceptions(-1, ERR);
}
return 0;
}
开发者ID:anujg1991,项目名称:cantera,代码行数:11,代码来源:fct.cpp
示例6: phase_setmolefractionsbyname_
status_t phase_setmolefractionsbyname_(const integer* n, char* x, ftnlen lx)
{
try {
ThermoPhase* p = _fph(n);
compositionMap xx = parseCompString(f2string(x, lx), p->speciesNames());
p->setMoleFractionsByName(xx);
} catch (...) {
return handleAllExceptions(-1, ERR);
}
return 0;
}
开发者ID:anujg1991,项目名称:cantera,代码行数:11,代码来源:fct.cpp
示例7: phase_setmolefractionsbyname_
status_t DLL_EXPORT phase_setmolefractionsbyname_(const integer* n, char* x, ftnlen lx) {
try {
ThermoPhase* p = _fph(n);
compositionMap xx;
int nsp = p->nSpecies();
for (int nn = 0; nn < nsp; nn++) {
xx[p->speciesName(nn)] = -1;
}
parseCompString(f2string(x, lx), xx);
p->setMoleFractionsByName(xx);
return 0;
}
catch (CanteraError) {handleError(); return -1;}
}
开发者ID:hkmoffat,项目名称:cantera,代码行数:14,代码来源:fct.cpp
示例8: CanteraError
//====================================================================================================================
void Kinetics::assignShallowPointers(const std::vector<thermo_t*> & tpVector) {
size_t ns = tpVector.size();
if (ns != m_thermo.size()) {
throw CanteraError(" Kinetics::assignShallowPointers",
" Number of ThermoPhase objects arent't the same");
}
for (size_t i = 0; i < ns; i++) {
ThermoPhase *ntp = tpVector[i];
ThermoPhase *otp = m_thermo[i];
if (ntp->id() != otp->id()) {
throw CanteraError(" Kinetics::assignShallowPointers",
" id() of the ThermoPhase objects isn't the same");
}
if (ntp->eosType() != otp->eosType()) {
throw CanteraError(" Kinetics::assignShallowPointers",
" eosType() of the ThermoPhase objects isn't the same");
}
if (ntp->nSpecies() != otp->nSpecies()) {
throw CanteraError(" Kinetics::assignShallowPointers",
" Number of ThermoPhase objects isn't the same");
}
m_thermo[i] = tpVector[i];
}
}
开发者ID:hkmoffat,项目名称:cantera,代码行数:27,代码来源:Kinetics.cpp
示例9: phase_setmolefractions_
status_t phase_setmolefractions_(const integer* n, double* x, const integer* norm)
{
try {
ThermoPhase* p = _fph(n);
if (*norm) {
p->setMoleFractions(x);
} else {
p->setMoleFractions_NoNorm(x);
}
} catch (...) {
return handleAllExceptions(-1, ERR);
}
return 0;
}
开发者ID:anujg1991,项目名称:cantera,代码行数:14,代码来源:fct.cpp
示例10: phase_setmassfractionsbyname_
status_t DLL_EXPORT phase_setmassfractionsbyname_(const integer* n, char* y, ftnlen leny) {
try {
ThermoPhase* p = _fph(n);
compositionMap yy;
int nsp = p->nSpecies();
for (int nn = 0; nn < nsp; nn++) {
yy[p->speciesName(nn)] = -1;
}
parseCompString(f2string(y, leny), yy);
p->setMassFractionsByName(yy);
return 0;
}
catch (CanteraError) {handleError(); return -1;}
}
开发者ID:hkmoffat,项目名称:cantera,代码行数:14,代码来源:fct.cpp
示例11: phase_setmassfractions_
status_t phase_setmassfractions_(const integer* n, doublereal* y, const integer* norm)
{
try {
ThermoPhase* p = _fph(n);
if (*norm) {
p->setMassFractions(y);
} else {
p->setMassFractions_NoNorm(y);
}
} catch (...) {
return handleAllExceptions(-1, ERR);
}
return 0;
}
开发者ID:anujg1991,项目名称:cantera,代码行数:14,代码来源:fct.cpp
示例12: simple_demo
// The actual code is put into a function that
// can be called from the main program.
void simple_demo() {
// Create a new phase
ThermoPhase* gas = newPhase("h2o2.cti","ohmech");
// Set its state by specifying T (500 K) P (2 atm) and the mole
// fractions. Note that the mole fractions do not need to sum to
// 1.0 - they will be normalized internally. Also, the values for
// any unspecified species will be set to zero.
gas->setState_TPX(500.0, 2.0*OneAtm, "H2O:1.0, H2:8.0, AR:1.0");
// Print a summary report of the state of the gas
cout << report(*gas) << endl;
// Clean up
delete gas;
}
开发者ID:anujg1991,项目名称:cantera,代码行数:19,代码来源:demo1a.cpp
示例13: setThermoMgr
void IdealGasReactor::setThermoMgr(ThermoPhase& thermo)
{
//! @TODO: Add a method to ThermoPhase that indicates whether a given
//! subclass is compatible with this reactor model
if (thermo.eosType() != cIdealGas) {
throw CanteraError("IdealGasReactor::setThermoMgr",
"Incompatible phase type provided");
}
Reactor::setThermoMgr(thermo);
}
开发者ID:goldmanm,项目名称:cantera,代码行数:10,代码来源:IdealGasReactor.cpp
示例14: main
int main(int argc, char** argv)
{
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
try {
IdealSolnGasVPSS gg("silane.xml", "silane");
ThermoPhase* g = ≫
cout.precision(4);
g->setState_TPX(1500.0, 100.0, "SIH4:0.01, H2:0.99");
g->equilibrate("TP");
cout << g->report(true, 0.0) << endl;
return 0;
} catch (CanteraError& err) {
std::cerr << err.what() << std::endl;
cerr << "program terminating." << endl;
return -1;
}
}
开发者ID:gitnmr,项目名称:cantera,代码行数:19,代码来源:silane_equil.cpp
示例15: main
int main(int argc, char **argv)
{
int retn = 0;
int i;
try {
char iFile[80];
strcpy(iFile, "HMW_NaCl.xml");
if (argc > 1) {
strcpy(iFile, argv[1]);
}
double Cp0_R[20], pmCp[20];
//fileLog *fl = new fileLog("HMW_graph_1.log");
//setLogger(fl);
HMWSoln *HMW = new HMWSoln(iFile, "NaCl_electrolyte");
/*
* Load in and initialize the
*/
Cantera::ThermoPhase *solid = newPhase("NaCl_Solid.xml","NaCl(S)");
int nsp = HMW->nSpecies();
double acMol[100];
double act[100];
double mf[100];
double moll[100];
for (i = 0; i < 100; i++) {
acMol[i] = 1.0;
act[i] = 1.0;
mf[i] = 0.0;
act[i] = 0.0;
}
HMW->getMoleFractions(mf);
string sName;
TemperatureTable TTable(15, false, 273.15, 25., 0, 0);
HMW->setState_TP(298.15, 1.01325E5);
int i1 = HMW->speciesIndex("Na+");
int i2 = HMW->speciesIndex("Cl-");
//int i3 = HMW->speciesIndex("H2O(L)");
for (i = 0; i < nsp; i++) {
moll[i] = 0.0;
}
HMW->setMolalities(moll);
double ISQRT;
double Is = 0.0;
/*
* Set the Pressure
*/
double pres = OneAtm;
/*
* Fix the molality
*/
Is = 6.146;
ISQRT = sqrt(Is);
moll[i1] = Is;
moll[i2] = Is;
HMW->setState_TPM(298.15, pres, moll);
double Xmol[30];
HMW->getMoleFractions(Xmol);
ThermoPhase *hmwtb = (ThermoPhase *)HMW;
ThermoPhase *hmwtbDupl = hmwtb->duplMyselfAsThermoPhase();
//ThermoPhase *hmwtbDupl = 0;
HMWSoln *HMW1 = HMW;
HMWSoln *HMW2 = dynamic_cast<HMWSoln *>(hmwtbDupl);
for (int itherms = 0; itherms < 2; itherms++) {
if (itherms ==0) {
HMW = HMW1;
} else {
HMW = HMW2;
}
/*
* ThermoUnknowns
*/
double T;
double Cp0_NaCl = 0.0, Cp0_Naplus = 0.0, Cp0_Clminus = 0.0, Delta_Cp0s = 0.0, Cp0_H2O = 0.0;
double Cp_NaCl = 0.0, Cp_Naplus = 0.0, Cp_Clminus = 0.0, Cp_H2O = 0.0;
double molarCp0;
#ifdef DEBUG_HKM
FILE *ttt;
if (itherms ==0) {
ttt = fopen("table1.csv","w");
//.........这里部分代码省略.........
开发者ID:hkmoffat,项目名称:cantera,代码行数:101,代码来源:HMW_dupl_test.cpp
示例16: main
int main(int argc, char** argv)
{
string infile;
int i, k;
int ioflag = 1;
// look for command-line options
if (argc > 1) {
string tok;
for (int j = 1; j < argc; j++) {
tok = string(argv[j]);
if (tok[0] == '-') {
int nopt = static_cast<int>(tok.size());
for (int n = 1; n < nopt; n++) {
if (tok[n] == 'h') {
printUsage();
exit(0);
} else if (tok[n] == 'd') {
int lvl = 0;
if (j < (argc - 1)) {
string tokla = string(argv[j+1]);
if (strlen(tokla.c_str()) > 0) {
lvl = atoi(tokla.c_str());
n = nopt - 1;
j += 1;
ioflag = lvl;
}
}
} else {
printUsage();
exit(1);
}
}
} else if (infile == "") {
infile = tok;
} else {
printUsage();
exit(1);
}
}
}
if (infile == "") {
infile = "diamond.cti";
}
try {
/*************************************************************/
/*
* FILL IN THESE NAMES FOR EACH PROBLEM
*/
/*
* ProblemNumber = 0 : diamond.cti
* = 1 : haca.cti
*/
int ProblemNumber = 1;
string gasPhaseName = "gas";
string bulkParticlePhaseName = "diamond";
string surfParticlePhaseName = "diamond_100";
if (ProblemNumber == 1) {
gasPhaseName = "gas";
bulkParticlePhaseName = "soot";
surfParticlePhaseName = "soot_interface";
}
/************************************************************/
XML_Node* xc = new XML_Node();
string path = findInputFile(infile);
ctml::get_CTML_Tree(xc, path);
XML_Node* const xg = (XML_Node*) findXMLPhase(xc, gasPhaseName);
if (!xg) {
printf("ERROR: Could not find gas phase named, %s, in file\n",
gasPhaseName.c_str());
exit(-1);
}
ThermoPhase* gasTP = newPhase(*xg);
size_t nspGas = gasTP->nSpecies();
cout << "Number of species = " << nspGas << endl;
XML_Node* const xd =
(XML_Node*) findXMLPhase(xc, bulkParticlePhaseName);
if (!xd) {
printf("ERROR: Could not find bulk phase named, %s, in file\n",
bulkParticlePhaseName.c_str());
exit(-1);
}
ThermoPhase* bulkPhaseTP = newPhase(*xd);
size_t nspBulk = bulkPhaseTP->nSpecies();
cout << "Number of species in bulk phase named " <<
bulkParticlePhaseName << " = " << nspBulk << endl;
XML_Node* const xs =
(XML_Node*) findXMLPhase(xc, surfParticlePhaseName);
if (!xs) {
printf("ERROR: Could not find surf Particle phase named,"
"%s, in file\n",
surfParticlePhaseName.c_str());
exit(-1);
}
//.........这里部分代码省略.........
开发者ID:anujg1991,项目名称:cantera,代码行数:101,代码来源:surfaceSolver2.cpp
示例17: main
int main(int argc, char** argv)
{
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
suppress_deprecation_warnings();
int numSucc = 0;
int numFail = 0;
int printLvl = 1;
string inputFile = "HMW_NaCl.xml";
VCS_SOLVE::disableTiming();
/*
* Process the command line arguments
*/
if (argc > 1) {
string tok;
for (int j = 1; j < argc; j++) {
tok = string(argv[j]);
if (tok[0] == '-') {
int nopt = static_cast<int>(tok.size());
for (int n = 1; n < nopt; n++) {
if (!strcmp(tok.c_str() + 1, "help_cmdfile")) {
} else if (tok[n] == 'h') {
printUsage();
exit(1);
} else if (tok[n] == 'd') {
printLvl = 2;
int lvl = 2;
if (j < (argc - 1)) {
string tokla = string(argv[j+1]);
if (strlen(tokla.c_str()) > 0) {
lvl = atoi(tokla.c_str());
n = nopt - 1;
j += 1;
if (lvl >= 0) {
printLvl = lvl;
}
}
}
} else {
printUsage();
exit(1);
}
}
} else if (inputFile == "HMW_NaCl.xml") {
inputFile = tok;
} else {
printUsage();
exit(1);
}
}
}
try {
int estimateEquil = -1;
double T = 298.15;
double pres = OneAtm;
// Initialize the individual phases
HMWSoln hmw(inputFile, "");
size_t kk = hmw.nSpecies();
vector_fp Xmol(kk, 0.0);
size_t iH2OL = hmw.speciesIndex("H2O(L)");
Xmol[iH2OL] = 1.0;
hmw.setState_TPX(T, pres, Xmol.data());
ThermoPhase* gas = newPhase("gas.xml");
kk = gas->nSpecies();
Xmol.resize(kk, 0.0);
for (size_t i = 0; i < kk; i++) {
Xmol[i] = 0.0;
}
size_t iN2 = gas->speciesIndex("N2");
Xmol[iN2] = 1.0;
gas->setState_TPX(T, pres, Xmol.data());
StoichSubstance ss("NaCl_Solid.xml", "");
ss.setState_TP(T, pres);
// Construct the multiphase object
MultiPhase* mp = new MultiPhase();
mp->addPhase(&hmw, 2.0);
mp->addPhase(gas, 4.0);
mp->addPhase(&ss, 5.0);
try {
mp->equilibrate("TP", "vcs", 1e-9, 50000, 100, estimateEquil, printLvl);
cout << *mp;
numSucc++;
} catch (CanteraError& err) {
cout << *mp;
//.........这里部分代码省略.........
开发者ID:CSM-Offenburg,项目名称:cantera,代码行数:101,代码来源:nacl_equil.cpp
示例18: phase_getmolecularweights_
status_t DLL_EXPORT phase_getmolecularweights_(const integer* n, doublereal* mw) {
ThermoPhase* p = _fph(n);
const vector_fp& wt = p->molecularWeights();
copy(wt.begin(), wt.end(), mw);
return 0;
}
开发者ID:hkmoffat,项目名称:cantera,代码行数:6,代码来源:fct.cpp
示例19: phase_getatomicweights_
status_t DLL_EXPORT phase_getatomicweights_(const integer* n, doublereal* atw) {
ThermoPhase* p = _fph(n);
const vector_fp& wt = p->atomicWeights();
copy(wt.begin(), wt.end(), atw);
return 0;
}
开发者ID:hkmoffat,项目名称:cantera,代码行数:6,代码来源:fct.cpp
示例20: main
int main(int argc, char** argv) {
int i, k;
string infile = "diamond.xml";
try {
XML_Node *xc = new XML_Node();
string path = findInputFile(infile);
ctml::get_CTML_Tree(xc, path);
XML_Node * const xg = xc->findNameID("phase", "gas");
ThermoPhase *gasTP = newPhase(*xg);
int nsp = gasTP->nSpecies();
cout << "Number of species = " << nsp << endl;
XML_Node * const xd = xc->findNameID("phase", "diamond");
ThermoPhase *diamondTP = newPhase(*xd);
int nsp_diamond = diamondTP->nSpecies();
cout << "Number of species in diamond = " << nsp_diamond << endl;
XML_Node * const xs = xc->findNameID("phase", "diamond_100");
ThermoPhase *diamond100TP = newPhase(*xs);
//SurfPhase *diamond100TP = new SurfPhase(*xs);
int nsp_d100 = diamond100TP->nSpecies();
cout << "Number of species in diamond_100 = " << nsp_d100 << endl;
vector<ThermoPhase *> phaseList;
phaseList.push_back(gasTP);
phaseList.push_back(diamondTP);
phaseList.push_back(diamond100TP);
InterfaceKinetics *iKin_ptr = new InterfaceKinetics();
importKinetics(*xs, phaseList, iKin_ptr);
int nr = iKin_ptr->nReactions();
cout << "Number of reactions = " << nr << endl;
double x[20];
for (i = 0; i < 20; i++) x[i] = 0.0;
x[0] = 0.0010;
x[1] = 0.9888;
x[2] = 0.0002;
x[3] = 0.0100;
double p = 20.0*OneAtm/760.0;
gasTP->setState_TPX(1200., p, x);
for (i = 0; i < 20; i++) x[i] = 0.0;
int i0 = diamond100TP->speciesIndex("c6H*");
x[i0] = 0.1;
int i1 = diamond100TP->speciesIndex("c6HH");
x[i1] = 0.9;
diamond100TP->setState_TX(1200., x);
for (i = 0; i < 20; i++) x[i] = 0.0;
x[0] = 1.0;
diamondTP->setState_TPX(1200., p, x);
iKin_ptr->advanceCoverages(100.);
// Throw some asserts in here to test that they compile
AssertTrace(p == p);
AssertThrow(p == p, "main");
AssertThrowMsg(i == 20, "main", "are you kidding");
double src[20];
for (i = 0; i < 20; i++) src[i] = 0.0;
iKin_ptr->getNetProductionRates(src);
double sum = 0.0;
double naH = 0.0;
for (k = 0; k < 13; k++) {
if (k < 4) {
naH = gasTP->nAtoms(k, 0);
} else if (k == 4) {
naH = 0;
} else if (k > 4) {
int itp = k - 5;
naH = diamond100TP->nAtoms(itp, 0);
}
cout << k << " " << naH << " " ;
printDbl(src[k]);
cout << endl;
sum += naH * src[k];
}
cout << "sum = ";
printDbl(sum);
cout << endl;
double mwd = diamondTP->molecularWeight(0);
double dens = diamondTP->density();
double gr = src[4] * mwd / dens;
gr *= 1.0E6 * 3600.;
cout << "growth rate = " << gr << " microns per hour" << endl;
diamond100TP->getMoleFractions(x);
cout << "Coverages:" << endl;
for (k = 0; k < 8; k++) {
cout << k << " " << diamond100TP->speciesName(k)
<< " "
<< x[k] << endl;
//.........这里部分代码省略.........
开发者ID:anujg1991,项目名称:cantera,代码行数:101,代码来源:runDiamond.cpp
注:本文中的ThermoPhase类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论