StoichSubstanceSSTP.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "ct_defs.h"
00021 #include "mix_defs.h"
00022 #include "StoichSubstanceSSTP.h"
00023 #include "SpeciesThermo.h"
00024 #include "ThermoFactory.h"
00025
00026 #include <string>
00027
00028 namespace Cantera {
00029
00030
00031
00032
00033
00034
00035
00036
00037 StoichSubstanceSSTP::StoichSubstanceSSTP():
00038 SingleSpeciesTP()
00039 {
00040 }
00041
00042
00043
00044
00045
00046
00047
00048
00049 StoichSubstanceSSTP::StoichSubstanceSSTP(std::string infile, std::string id) :
00050 SingleSpeciesTP()
00051 {
00052 XML_Node* root = get_XML_File(infile);
00053 if (id == "-") id = "";
00054 XML_Node* xphase = get_XML_NameID("phase", std::string("#")+id, root);
00055 if (!xphase) {
00056 throw CanteraError("StoichSubstanceSSTP::StoichSubstanceSSTP",
00057 "Couldn't find phase name in file:" + id);
00058 }
00059
00060 const XML_Node& th = xphase->child("thermo");
00061 std::string model = th["model"];
00062 if (model != "StoichSubstance" && model != "StoichSubstanceSSTP") {
00063 throw CanteraError("StoichSubstanceSSTP::StoichSubstanceSSTP",
00064 "thermo model attribute must be StoichSubstance");
00065 }
00066 importPhase(*xphase, this);
00067 }
00068
00069
00070
00071
00072
00073
00074 StoichSubstanceSSTP::StoichSubstanceSSTP(XML_Node& xmlphase, std::string id) :
00075 SingleSpeciesTP()
00076 {
00077 if (id != "") {
00078 std::string idxml = xmlphase["id"];
00079 if (id != idxml) {
00080 throw CanteraError("StoichSubstanceSSTP::StoichSubstanceSSTP",
00081 "id's don't match");
00082 }
00083 }
00084 const XML_Node& th = xmlphase.child("thermo");
00085 std::string model = th["model"];
00086 if (model != "StoichSubstance" && model != "StoichSubstanceSSTP") {
00087 throw CanteraError("StoichSubstanceSSTP::StoichSubstanceSSTP",
00088 "thermo model attribute must be StoichSubstance");
00089 }
00090 importPhase(xmlphase, this);
00091 }
00092
00093
00094
00095
00096
00097 StoichSubstanceSSTP::StoichSubstanceSSTP(const StoichSubstanceSSTP &right) :
00098 SingleSpeciesTP()
00099 {
00100 *this = operator=(right);
00101 }
00102
00103
00104
00105
00106
00107 StoichSubstanceSSTP &
00108 StoichSubstanceSSTP::operator=(const StoichSubstanceSSTP & right) {
00109 if (&right != this) {
00110 SingleSpeciesTP::operator=(right);
00111 }
00112 return *this;
00113 }
00114
00115
00116
00117
00118
00119 StoichSubstanceSSTP::~StoichSubstanceSSTP()
00120 {
00121 }
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131 ThermoPhase *StoichSubstanceSSTP::duplMyselfAsThermoPhase() const {
00132 StoichSubstanceSSTP *stp = new StoichSubstanceSSTP(*this);
00133 return (ThermoPhase *) stp;
00134 }
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 int StoichSubstanceSSTP::eosType() const {
00146 return cStoichSubstance;
00147 }
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 doublereal StoichSubstanceSSTP::pressure() const {
00164 return m_press;
00165 }
00166
00167
00168
00169
00170
00171
00172
00173
00174 void StoichSubstanceSSTP::setPressure(doublereal p) {
00175 m_press = p;
00176 }
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188 doublereal StoichSubstanceSSTP::isothermalCompressibility() const {
00189 return 0.0;
00190 }
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203 doublereal StoichSubstanceSSTP::thermalExpansionCoeff() const {
00204 return 0.0;
00205 }
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216 void StoichSubstanceSSTP::
00217 getActivityConcentrations(doublereal* c) const {
00218 c[0] = 1.0;
00219 }
00220
00221
00222
00223
00224
00225
00226 doublereal StoichSubstanceSSTP::standardConcentration(int k) const {
00227 return 1.0;
00228 }
00229
00230
00231
00232
00233
00234 doublereal StoichSubstanceSSTP::logStandardConc(int k) const {
00235 return 0.0;
00236 }
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256 void StoichSubstanceSSTP::
00257 getUnitsStandardConc(doublereal *uA, int k, int sizeUA) const {
00258 for (int i = 0; i < 6; i++) {
00259 uA[i] = 0;
00260 }
00261 }
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283 void StoichSubstanceSSTP::
00284 getStandardChemPotentials(doublereal* mu0) const {
00285 getGibbs_RT(mu0);
00286 mu0[0] *= GasConstant * temperature();
00287 }
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299 void StoichSubstanceSSTP::getEnthalpy_RT(doublereal* hrt) const {
00300 getEnthalpy_RT_ref(hrt);
00301 doublereal RT = GasConstant * temperature();
00302 doublereal presCorrect = (m_press - m_p0) / molarDensity();
00303 hrt[0] += presCorrect / RT;
00304 }
00305
00306
00307
00308
00309
00310
00311 void StoichSubstanceSSTP::getEntropy_R(doublereal* sr) const {
00312 getEntropy_R_ref(sr);
00313 }
00314
00315
00316
00317
00318
00319
00320 void StoichSubstanceSSTP::getGibbs_RT(doublereal* grt) const {
00321 getEnthalpy_RT(grt);
00322 grt[0] -= m_s0_R[0];
00323 }
00324
00325
00326
00327
00328
00329 void StoichSubstanceSSTP::getCp_R(doublereal* cpr) const {
00330 _updateThermo();
00331 cpr[0] = m_cp0_R[0];
00332 }
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343 void StoichSubstanceSSTP::getIntEnergy_RT(doublereal* urt) const {
00344 _updateThermo();
00345 doublereal RT = GasConstant * temperature();
00346 doublereal PV = m_p0 / molarDensity();
00347 urt[0] = m_h0_RT[0] - PV / RT;
00348 }
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366 void StoichSubstanceSSTP::getIntEnergy_RT_ref(doublereal* urt) const {
00367 _updateThermo();
00368 doublereal RT = GasConstant * temperature();
00369 doublereal PV = m_p0 / molarDensity();
00370 urt[0] = m_h0_RT[0] - PV / RT;
00371 }
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396 void StoichSubstanceSSTP::initThermo() {
00397
00398
00399
00400 m_kk = nSpecies();
00401 if (m_kk != 1) {
00402 throw CanteraError("initThermo",
00403 "stoichiometric substances may only contain one species.");
00404 }
00405 doublereal tmin = m_spthermo->minTemp();
00406 doublereal tmax = m_spthermo->maxTemp();
00407 if (tmin > 0.0) m_tmin = tmin;
00408 if (tmax > 0.0) m_tmax = tmax;
00409
00410
00411
00412 m_p0 = refPressure();
00413
00414
00415
00416
00417 int leng = 1;
00418 m_h0_RT.resize(leng);
00419 m_cp0_R.resize(leng);
00420 m_s0_R.resize(leng);
00421
00422
00423
00424 SingleSpeciesTP::initThermo();
00425 }
00426
00427
00428 void StoichSubstanceSSTP::initThermoXML(XML_Node& phaseNode, std::string id) {
00429
00430
00431
00432 if (!phaseNode.hasChild("thermo")) {
00433 throw CanteraError("StoichSubstanceSSTP::initThermoXML",
00434 "no thermo XML node");
00435 }
00436 XML_Node &tnode = phaseNode.child("thermo");
00437 double dens = getFloatDefaultUnits(tnode, "density", "kg/m3");
00438 setDensity(dens);
00439 SingleSpeciesTP::initThermoXML(phaseNode, id);
00440 }
00441
00442
00443
00444
00445
00446
00447
00448
00449 void StoichSubstanceSSTP::setParameters(int n, doublereal * const c) {
00450 doublereal rho = c[0];
00451 setDensity(rho);
00452 }
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462 void StoichSubstanceSSTP::getParameters(int &n, doublereal * const c) const {
00463 doublereal rho = density();
00464 n = 1;
00465 c[0] = rho;
00466 }
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479 void StoichSubstanceSSTP::setParametersFromXML(const XML_Node& eosdata) {
00480 std::string model = eosdata["model"];
00481 if (model != "StoichSubstance" && model != "StoichSubstanceSSTP") {
00482 throw CanteraError("StoichSubstanceSSTP::setParametersFromXML",
00483 "thermo model attribute must be StoichSubstance");
00484 }
00485 doublereal rho = getFloat(eosdata, "density", "toSI");
00486 setDensity(rho);
00487 }
00488
00489
00490
00491
00492
00493
00494
00495
00496 electrodeElectron::electrodeElectron():
00497 StoichSubstanceSSTP()
00498 {
00499 }
00500
00501
00502
00503
00504
00505
00506
00507
00508 electrodeElectron::electrodeElectron(std::string infile, std::string id) :
00509 StoichSubstanceSSTP()
00510 {
00511 XML_Node* root = get_XML_File(infile);
00512 if (id == "-") id = "";
00513 XML_Node* xphase = get_XML_NameID("phase", std::string("#")+id, root);
00514 if (!xphase) {
00515 throw CanteraError("electrodeElectron::electrodeElectron",
00516 "Couldn't find phase name in file:" + id);
00517 }
00518
00519 const XML_Node& th = xphase->child("thermo");
00520 std::string model = th["model"];
00521 if (model != "electrodeElectron") {
00522 throw CanteraError("electrodeElectron::electrodeElectron",
00523 "thermo model attribute must be electrodeElectron");
00524 }
00525 importPhase(*xphase, this);
00526 }
00527
00528
00529
00530
00531
00532
00533 electrodeElectron::electrodeElectron(XML_Node& xmlphase, std::string id) :
00534 StoichSubstanceSSTP()
00535 {
00536 if (id != "") {
00537 std::string idxml = xmlphase["id"];
00538 if (id != idxml) {
00539 throw CanteraError("electrodeElectron::electrodeElectron",
00540 "id's don't match");
00541 }
00542 }
00543 const XML_Node& th = xmlphase.child("thermo");
00544 std::string model = th["model"];
00545 if (model != "electrodeElectron") {
00546 throw CanteraError("electrodeElectron::electrodeElectron",
00547 "thermo model attribute must be electrodeElectron");
00548 }
00549 importPhase(xmlphase, this);
00550 }
00551
00552
00553
00554
00555
00556 electrodeElectron::electrodeElectron(const electrodeElectron &right) :
00557 StoichSubstanceSSTP()
00558 {
00559 *this = operator=(right);
00560 }
00561
00562
00563
00564
00565
00566 electrodeElectron &
00567 electrodeElectron::operator=(const electrodeElectron & right) {
00568 if (&right != this) {
00569 StoichSubstanceSSTP::operator=(right);
00570 }
00571 return *this;
00572 }
00573
00574
00575
00576
00577
00578 electrodeElectron::~electrodeElectron()
00579 {
00580 }
00581
00582 void electrodeElectron::setParametersFromXML(const XML_Node& eosdata) {
00583 std::string model = eosdata["model"];
00584 if (model != "electrodeElectron") {
00585 throw CanteraError("electrodeElectron::setParametersFromXML",
00586 "thermo model attribute must be electrodeElectron");
00587 }
00588 }
00589
00590 void electrodeElectron::initThermoXML(XML_Node& phaseNode, std::string id) {
00591 doublereal rho = 10.0;
00592 setDensity(rho);
00593 SingleSpeciesTP::initThermoXML(phaseNode, id);
00594 }
00595
00596 void electrodeElectron::setParameters(int n, doublereal * const c) {
00597 doublereal rho = 10.0;
00598 setDensity(rho);
00599 }
00600
00601 }
00602
00603