mirror of
https://github.com/Cantera/cantera.git
synced 2026-08-09 12:38:22 -05:00
[test-problems] Replace legacy factory methods
This commit is contained in:
@@ -14,18 +14,18 @@ void testProblem(int printLvl)
|
||||
VCS_SOLVE::disableTiming();
|
||||
|
||||
// Create the phases
|
||||
std::unique_ptr<ThermoPhase> LiSi_solid(newPhase("Li7Si3_latsol.yaml",
|
||||
"Li7Si3_and_Interstitials(S)"));
|
||||
std::unique_ptr<ThermoPhase> Li_liq(newPhase("Li7Si3_latsol.yaml", "Li(L)"));
|
||||
std::unique_ptr<ThermoPhase> LiFixed(newPhase("Li7Si3_latsol.yaml", "LiFixed"));
|
||||
MargulesVPSSTP salt("Li7Si3_latsol.yaml", "MoltenSalt_electrolyte");
|
||||
auto LiSi_solid = newThermo("Li7Si3_latsol.yaml", "Li7Si3_and_Interstitials(S)");
|
||||
auto Li_liq = newThermo("Li7Si3_latsol.yaml", "Li(L)");
|
||||
auto LiFixed = newThermo("Li7Si3_latsol.yaml", "LiFixed");
|
||||
shared_ptr<ThermoPhase> salt(new MargulesVPSSTP(
|
||||
"Li7Si3_latsol.yaml", "MoltenSalt_electrolyte"));
|
||||
|
||||
// set states
|
||||
vector_fp x(salt.nSpecies(), 0);
|
||||
vector_fp x(salt->nSpecies(), 0);
|
||||
x[0] = 0.7;
|
||||
x[1] = 1.0 - x[0];
|
||||
|
||||
salt.setState_TPX(T, OneAtm, &x[0]);
|
||||
salt->setState_TPX(T, OneAtm, &x[0]);
|
||||
LiSi_solid->setState_TP(T, OneAtm);
|
||||
|
||||
int ee = static_cast<int>(LiSi_solid->nElements());
|
||||
@@ -51,7 +51,7 @@ void testProblem(int printLvl)
|
||||
|
||||
MultiPhase mmm;
|
||||
|
||||
mmm.addPhase(&salt, 10.);
|
||||
mmm.addPhase(salt.get(), 10.);
|
||||
mmm.addPhase(LiSi_solid.get(), 1.);
|
||||
mmm.addPhase(LiFixed.get(), 100.);
|
||||
|
||||
|
||||
@@ -85,15 +85,16 @@ int main(int argc, char** argv)
|
||||
|
||||
// Initialize the individual phases
|
||||
|
||||
HMWSoln hmw(inputFile, "NaCl_electrolyte_complex_shomate");
|
||||
hmw.setName("NaCl_electrolyte");
|
||||
size_t kk = hmw.nSpecies();
|
||||
shared_ptr<ThermoPhase> hmw(new HMWSoln(
|
||||
inputFile, "NaCl_electrolyte_complex_shomate"));
|
||||
hmw->setName("NaCl_electrolyte");
|
||||
size_t kk = hmw->nSpecies();
|
||||
vector_fp Xmol(kk, 0.0);
|
||||
size_t iH2OL = hmw.speciesIndex("H2O(L)");
|
||||
size_t iH2OL = hmw->speciesIndex("H2O(L)");
|
||||
Xmol[iH2OL] = 1.0;
|
||||
hmw.setState_TPX(T, pres, Xmol.data());
|
||||
hmw->setState_TPX(T, pres, Xmol.data());
|
||||
|
||||
ThermoPhase* gas = newPhase("NaCl_gas.yaml");
|
||||
auto gas = newThermo("NaCl_gas.yaml");
|
||||
|
||||
kk = gas->nSpecies();
|
||||
Xmol.resize(kk, 0.0);
|
||||
@@ -105,16 +106,16 @@ int main(int argc, char** argv)
|
||||
gas->setState_TPX(T, pres, Xmol.data());
|
||||
|
||||
|
||||
StoichSubstance ss("NaCl_Solid.yaml");
|
||||
ss.setState_TP(T, pres);
|
||||
shared_ptr<ThermoPhase> ss(new StoichSubstance("NaCl_Solid.yaml"));
|
||||
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);
|
||||
mp->addPhase(hmw.get(), 2.0);
|
||||
mp->addPhase(gas.get(), 4.0);
|
||||
mp->addPhase(ss.get(), 5.0);
|
||||
|
||||
|
||||
try {
|
||||
|
||||
@@ -22,7 +22,7 @@ int main(int argc, char** argv)
|
||||
double Cp0_R[20], pmCp[20];
|
||||
|
||||
HMWSoln* HMW = new HMWSoln(iFile, "NaCl_electrolyte");
|
||||
ThermoPhase* solid = newPhase("NaCl_Solid.yaml", "NaCl(S)");
|
||||
auto solid = newThermo("NaCl_Solid.yaml", "NaCl(S)");
|
||||
|
||||
size_t nsp = HMW->nSpecies();
|
||||
double mf[100];
|
||||
@@ -219,8 +219,6 @@ int main(int argc, char** argv)
|
||||
|
||||
delete HMW;
|
||||
HMW = 0;
|
||||
delete solid;
|
||||
solid = 0;
|
||||
Cantera::appdelete();
|
||||
return retn;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ int main(int argc, char** argv)
|
||||
*/
|
||||
string nacl_s = "NaCl_Solid.yaml";
|
||||
string id = "NaCl(S)";
|
||||
Cantera::ThermoPhase* solid = Cantera::newPhase(nacl_s, id);
|
||||
auto solid = Cantera::newThermo(nacl_s, id);
|
||||
|
||||
size_t nsp = HMW->nSpecies();
|
||||
double acMol[100];
|
||||
@@ -212,8 +212,6 @@ int main(int argc, char** argv)
|
||||
|
||||
delete HMW;
|
||||
HMW = 0;
|
||||
delete solid;
|
||||
solid = 0;
|
||||
Cantera::appdelete();
|
||||
|
||||
return retn;
|
||||
|
||||
@@ -27,7 +27,7 @@ int main(int argc, char** argv)
|
||||
/*
|
||||
* Load in and initialize the
|
||||
*/
|
||||
Cantera::ThermoPhase* solid = newPhase("NaCl_Solid.yaml","NaCl(S)");
|
||||
auto solid = newThermo("NaCl_Solid.yaml","NaCl(S)");
|
||||
|
||||
|
||||
size_t nsp = HMW->nSpecies();
|
||||
@@ -218,8 +218,6 @@ int main(int argc, char** argv)
|
||||
|
||||
delete HMW;
|
||||
HMW = 0;
|
||||
delete solid;
|
||||
solid = 0;
|
||||
Cantera::appdelete();
|
||||
return retn;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ int main(int argc, char** argv)
|
||||
/*
|
||||
* Load in and initialize the
|
||||
*/
|
||||
Cantera::ThermoPhase* solid = newPhase("NaCl_Solid.yaml","NaCl(S)");
|
||||
auto solid = newThermo("NaCl_Solid.yaml", "NaCl(S)");
|
||||
|
||||
|
||||
size_t nsp = HMW->nSpecies();
|
||||
@@ -222,8 +222,6 @@ int main(int argc, char** argv)
|
||||
|
||||
delete HMW;
|
||||
HMW = 0;
|
||||
delete solid;
|
||||
solid = 0;
|
||||
Cantera::appdelete();
|
||||
return retn;
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ int main()
|
||||
#endif
|
||||
double pres;
|
||||
try {
|
||||
ThermoPhase* w = newPhase("liquidvapor.yaml", "liquid-water-IAPWS95");
|
||||
(dynamic_cast<WaterSSTP*>(w))->_allowGasPhase(true);
|
||||
auto w = newThermo("liquidvapor.yaml", "liquid-water-IAPWS95");
|
||||
(std::dynamic_pointer_cast<WaterSSTP>(w))->_allowGasPhase(true);
|
||||
|
||||
/*
|
||||
* Print out the triple point conditions
|
||||
@@ -302,8 +302,6 @@ int main()
|
||||
printf("Critical Temp = %10.3g K\n", w->critTemperature());
|
||||
printf("Critical Pressure = %10.3g atm\n", w->critPressure()/OneAtm);
|
||||
printf("Critical Dens = %10.3g kg/m3\n", w->critDensity());
|
||||
|
||||
delete w;
|
||||
} catch (CanteraError& err) {
|
||||
std::cout << err.what() << std::endl;
|
||||
Cantera::appdelete();
|
||||
|
||||
@@ -18,20 +18,20 @@ int main(int argc, char** argv)
|
||||
int i, k;
|
||||
|
||||
try {
|
||||
shared_ptr<ThermoPhase> gas(newPhase("diamond.yaml", "gas"));
|
||||
auto gas = newThermo("diamond.yaml", "gas");
|
||||
size_t nsp = gas->nSpecies();
|
||||
cout.precision(4);
|
||||
cout << "Number of species = " << nsp << endl;
|
||||
|
||||
shared_ptr<ThermoPhase> diamond(newPhase("diamond.yaml", "diamond"));
|
||||
auto diamond = newThermo("diamond.yaml", "diamond");
|
||||
size_t nsp_diamond = diamond->nSpecies();
|
||||
cout << "Number of species in diamond = " << nsp_diamond << endl;
|
||||
|
||||
shared_ptr<ThermoPhase> diamond100(newPhase("diamond.yaml", "diamond_100"));
|
||||
auto diamond100 = newThermo("diamond.yaml", "diamond_100");
|
||||
size_t nsp_d100 = diamond100->nSpecies();
|
||||
cout << "Number of species in diamond_100 = " << nsp_d100 << endl;
|
||||
|
||||
auto kin = newKinetics({gas.get(), diamond.get(), diamond100.get()},
|
||||
auto kin = newKinetics({gas, diamond, diamond100},
|
||||
"diamond.yaml", "diamond_100");
|
||||
InterfaceKinetics& ikin = dynamic_cast<InterfaceKinetics&>(*kin);
|
||||
size_t nr = kin->nReactions();
|
||||
|
||||
@@ -10,11 +10,9 @@ using namespace Cantera;
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
try {
|
||||
int log_level = 0;
|
||||
|
||||
unique_ptr<ThermoPhase> g(newPhase("h2o2.yaml"));
|
||||
auto trRef = newTransport(g.get(), "DustyGas");
|
||||
DustyGasTransport* tranDusty = dynamic_cast<DustyGasTransport*>(tran.get());
|
||||
auto g = newThermo("h2o2.yaml");
|
||||
auto tran = newTransport(g, "DustyGas");
|
||||
auto tranDusty = std::dynamic_pointer_cast<DustyGasTransport>(tran);
|
||||
|
||||
size_t nsp = g->nSpecies();
|
||||
vector_fp multiD(nsp*nsp);
|
||||
|
||||
@@ -24,7 +24,7 @@ int main()
|
||||
double pres;
|
||||
try {
|
||||
|
||||
unique_ptr<ThermoPhase> w(newPhase("liquidvapor.yaml", "water"));
|
||||
auto w = newThermo("liquidvapor.yaml", "water");
|
||||
|
||||
/*
|
||||
* Print out the triple point conditions
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
using namespace std;
|
||||
using namespace Cantera;
|
||||
|
||||
void printGas(ostream& oooo, ThermoPhase* gasTP, InterfaceKinetics* iKin_ptr, double* src)
|
||||
void printGas(ostream& oooo, shared_ptr<ThermoPhase> gasTP,
|
||||
shared_ptr<InterfaceKinetics> iKin_ptr, double* src)
|
||||
{
|
||||
double x[MSSIZE];
|
||||
double C[MSSIZE];
|
||||
@@ -53,7 +54,8 @@ void printGas(ostream& oooo, ThermoPhase* gasTP, InterfaceKinetics* iKin_ptr, do
|
||||
|
||||
}
|
||||
|
||||
void printBulk(ostream& oooo,ThermoPhase* bulkPhaseTP, InterfaceKinetics* iKin_ptr, double* src)
|
||||
void printBulk(ostream& oooo, shared_ptr<ThermoPhase> bulkPhaseTP,
|
||||
shared_ptr<InterfaceKinetics> iKin_ptr, double* src)
|
||||
{
|
||||
double x[MSSIZE];
|
||||
double C[MSSIZE];
|
||||
@@ -96,8 +98,8 @@ void printBulk(ostream& oooo,ThermoPhase* bulkPhaseTP, InterfaceKinetics* iKin_p
|
||||
oooo << endl;
|
||||
}
|
||||
|
||||
void printSurf(ostream& oooo, ThermoPhase* surfPhaseTP,
|
||||
InterfaceKinetics* iKin_ptr, double* src)
|
||||
void printSurf(ostream& oooo, shared_ptr<ThermoPhase> surfPhaseTP,
|
||||
shared_ptr<InterfaceKinetics> iKin_ptr, double* src)
|
||||
{
|
||||
double x[MSSIZE];
|
||||
oooo.precision(3);
|
||||
@@ -136,23 +138,23 @@ int main(int argc, char** argv)
|
||||
int ioflag = 1;
|
||||
|
||||
try {
|
||||
ThermoPhase* gasTP = newPhase(infile, gasPhaseName);
|
||||
auto gasTP = newThermo(infile, gasPhaseName);
|
||||
size_t nspGas = gasTP->nSpecies();
|
||||
cout << "Number of species = " << nspGas << endl;
|
||||
|
||||
ThermoPhase* bulkPhaseTP = newPhase(infile, bulkParticlePhaseName);
|
||||
auto bulkPhaseTP = newThermo(infile, bulkParticlePhaseName);
|
||||
size_t nspBulk = bulkPhaseTP->nSpecies();
|
||||
cout << "Number of species in bulk phase named " <<
|
||||
bulkParticlePhaseName << " = " << nspBulk << endl;
|
||||
|
||||
ThermoPhase* surfPhaseTP = newPhase(infile, surfParticlePhaseName);
|
||||
auto surfPhaseTP = newThermo(infile, surfParticlePhaseName);
|
||||
size_t nsp_d100 = surfPhaseTP->nSpecies();
|
||||
cout << "Number of species in surface phase, " << surfParticlePhaseName
|
||||
<< " = " << nsp_d100 << endl;
|
||||
|
||||
auto kin = newKinetics({gasTP, bulkPhaseTP, surfPhaseTP},
|
||||
infile, surfParticlePhaseName);
|
||||
InterfaceKinetics* iKin_ptr = dynamic_cast<InterfaceKinetics*>(kin.get());
|
||||
auto iKin_ptr = dynamic_pointer_cast<InterfaceKinetics>(kin);
|
||||
size_t nr = iKin_ptr->nReactions();
|
||||
cout << "Number of reactions = " << nr << endl;
|
||||
|
||||
@@ -160,7 +162,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// create a second copy of the same surface phase
|
||||
// (this is a made up problem btw to check the software capability)
|
||||
ThermoPhase* surfPhaseTP2 = newPhase(infile, surfParticlePhaseName);
|
||||
auto surfPhaseTP2 = newThermo(infile, surfParticlePhaseName);
|
||||
size_t nsp2 = surfPhaseTP2->nSpecies();
|
||||
string pname = surfPhaseTP2->name();
|
||||
cout << "Number of species in 2nd surface phase, " << pname
|
||||
@@ -170,7 +172,7 @@ int main(int argc, char** argv)
|
||||
// second surface phase.
|
||||
auto kin2 = newKinetics({gasTP, bulkPhaseTP, surfPhaseTP2},
|
||||
infile, surfParticlePhaseName);
|
||||
InterfaceKinetics* iKin2_ptr = dynamic_cast<InterfaceKinetics*>(kin2.get());
|
||||
auto iKin2_ptr = dynamic_pointer_cast<InterfaceKinetics>(kin2);
|
||||
nr = iKin_ptr->nReactions();
|
||||
cout << "Number of reactions = " << nr << endl;
|
||||
|
||||
@@ -180,7 +182,7 @@ int main(int argc, char** argv)
|
||||
* Set-up the Surface Problem
|
||||
* This problem will consist of 2 identical InterfaceKinetics objects
|
||||
*/
|
||||
vector<InterfaceKinetics*> vecKinPtrs { iKin_ptr, iKin2_ptr };
|
||||
vector<InterfaceKinetics*> vecKinPtrs { iKin_ptr.get(), iKin2_ptr.get() };
|
||||
|
||||
// Create the ImplicitSurfChem problem
|
||||
// Initialize it and call the pseudo steadystate capability.
|
||||
@@ -268,14 +270,6 @@ int main(int argc, char** argv)
|
||||
surfaceProb = 0;
|
||||
iKin_ptr = 0;
|
||||
iKin2_ptr = 0;
|
||||
delete gasTP;
|
||||
gasTP = 0;
|
||||
delete bulkPhaseTP;
|
||||
bulkPhaseTP = 0;
|
||||
delete surfPhaseTP;
|
||||
surfPhaseTP = 0;
|
||||
delete surfPhaseTP2;
|
||||
surfPhaseTP2 = 0;
|
||||
appdelete();
|
||||
} catch (CanteraError& err) {
|
||||
std::cout << err.what() << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user