32template<> ThermoPhaseCabinet* ThermoPhaseCabinet::s_storage = 0;
38 int32_t
thermo_name(int32_t handle, int32_t bufLen,
char* buf)
42 string out = ThermoPhaseCabinet::as<Phase>(handle)->name();
44 return int(out.size()) + 1;
54 ThermoPhaseCabinet::as<Phase>(handle)->setName(nm);
61 int32_t
thermo_type(int32_t handle, int32_t bufLen,
char* buf)
65 string out = ThermoPhaseCabinet::at(handle)->type();
67 return int(out.size()) + 1;
77 return static_cast<int32_t
>(ThermoPhaseCabinet::as<Phase>(handle)->nElements());
87 return static_cast<int32_t
>(ThermoPhaseCabinet::as<Phase>(handle)->nSpecies());
97 return ThermoPhaseCabinet::as<Phase>(handle)->temperature();
107 ThermoPhaseCabinet::as<Phase>(handle)->setTemperature(temp);
118 return ThermoPhaseCabinet::as<Phase>(handle)->pressure();
128 ThermoPhaseCabinet::as<Phase>(handle)->setPressure(p);
139 return ThermoPhaseCabinet::as<Phase>(handle)->density();
149 ThermoPhaseCabinet::as<Phase>(handle)->setDensity(density_);
160 return ThermoPhaseCabinet::as<Phase>(handle)->molarDensity();
170 return ThermoPhaseCabinet::as<Phase>(handle)->meanMolecularWeight();
180 return ThermoPhaseCabinet::as<Phase>(handle)->moleFraction(k);
190 return ThermoPhaseCabinet::as<Phase>(handle)->massFraction(k);
200 auto obj = ThermoPhaseCabinet::as<Phase>(handle);
201 if (
static_cast<size_t>(xLen) < obj->nSpecies()) {
202 throw ArraySizeError(
"thermo_getMoleFractions", xLen, obj->nSpecies());
204 obj->getMoleFractions(x);
215 auto obj = ThermoPhaseCabinet::as<Phase>(handle);
216 if (
static_cast<size_t>(yLen) < obj->nSpecies()) {
217 throw ArraySizeError(
"thermo_getMassFractions", yLen, obj->nSpecies());
219 obj->getMassFractions(y);
230 auto obj = ThermoPhaseCabinet::as<Phase>(handle);
231 if (
static_cast<size_t>(xLen) < obj->nSpecies()) {
232 throw ArraySizeError(
"thermo_setMoleFractions", xLen, obj->nSpecies());
234 obj->setMoleFractions(x);
245 auto obj = ThermoPhaseCabinet::as<Phase>(handle);
246 if (
static_cast<size_t>(yLen) < obj->nSpecies()) {
247 throw ArraySizeError(
"thermo_setMassFractions", yLen, obj->nSpecies());
249 obj->setMassFractions(y);
260 ThermoPhaseCabinet::as<Phase>(handle)->setMoleFractionsByName(x);
271 ThermoPhaseCabinet::as<Phase>(handle)->setMassFractionsByName(x);
282 auto obj = ThermoPhaseCabinet::as<Phase>(handle);
283 if (
static_cast<size_t>(bufLen) < obj->nElements()) {
284 throw ArraySizeError(
"thermo_atomicWeights", bufLen, obj->nElements());
286 const vector<double>& out = obj->atomicWeights();
287 std::copy(out.begin(), out.end(), buf);
288 return int(out.size());
298 auto obj = ThermoPhaseCabinet::as<Phase>(handle);
299 if (
static_cast<size_t>(weightsLen) < obj->nSpecies()) {
300 throw ArraySizeError(
"thermo_getMolecularWeights", weightsLen, obj->nSpecies());
302 obj->getMolecularWeights(weights);
313 auto obj = ThermoPhaseCabinet::as<Phase>(handle);
314 if (
static_cast<size_t>(chargesLen) < obj->nElements()) {
315 throw ArraySizeError(
"thermo_getCharges", chargesLen, obj->nElements());
317 obj->getCharges(charges);
328 string out = ThermoPhaseCabinet::as<Phase>(handle)->elementName(m);
330 return int(out.size()) + 1;
340 string out = ThermoPhaseCabinet::as<Phase>(handle)->speciesName(k);
342 return int(out.size()) + 1;
353 return static_cast<int32_t
>(ThermoPhaseCabinet::as<Phase>(handle)->elementIndex(name,
true));
365 return static_cast<int32_t
>(ThermoPhaseCabinet::as<Phase>(handle)->speciesIndex(name,
true));
376 return ThermoPhaseCabinet::as<Phase>(handle)->nAtoms(k, m);
382 int32_t
thermo_addElement(int32_t handle,
const char* symbol,
double weight, int32_t atomicNumber,
double entropy298, int32_t elem_type)
386 return static_cast<int32_t
>(ThermoPhaseCabinet::as<Phase>(handle)->addElement(symbol, weight, atomicNumber, entropy298, elem_type));
396 return ThermoPhaseCabinet::at(handle)->refPressure();
406 return ThermoPhaseCabinet::at(handle)->minTemp(k);
416 return ThermoPhaseCabinet::at(handle)->maxTemp(k);
426 return ThermoPhaseCabinet::at(handle)->enthalpy_mole();
436 return ThermoPhaseCabinet::at(handle)->enthalpy_mass();
446 return ThermoPhaseCabinet::at(handle)->entropy_mole();
456 return ThermoPhaseCabinet::at(handle)->entropy_mass();
466 return ThermoPhaseCabinet::at(handle)->intEnergy_mole();
476 return ThermoPhaseCabinet::at(handle)->intEnergy_mass();
486 return ThermoPhaseCabinet::at(handle)->gibbs_mole();
496 return ThermoPhaseCabinet::at(handle)->gibbs_mass();
506 return ThermoPhaseCabinet::at(handle)->cp_mole();
516 return ThermoPhaseCabinet::at(handle)->cp_mass();
526 return ThermoPhaseCabinet::at(handle)->cv_mole();
536 return ThermoPhaseCabinet::at(handle)->cv_mass();
546 auto& obj = ThermoPhaseCabinet::at(handle);
548 obj->getChemPotentials(mu);
559 auto& obj = ThermoPhaseCabinet::at(handle);
561 obj->getElectrochemPotentials(mu);
572 return ThermoPhaseCabinet::at(handle)->electricPotential();
582 ThermoPhaseCabinet::at(handle)->setElectricPotential(v);
593 return ThermoPhaseCabinet::at(handle)->thermalExpansionCoeff();
603 return ThermoPhaseCabinet::at(handle)->isothermalCompressibility();
613 auto& obj = ThermoPhaseCabinet::at(handle);
615 obj->getPartialMolarEnthalpies(hbar);
626 auto& obj = ThermoPhaseCabinet::at(handle);
628 obj->getPartialMolarEntropies(sbar);
639 auto& obj = ThermoPhaseCabinet::at(handle);
641 obj->getPartialMolarIntEnergies(ubar);
652 auto& obj = ThermoPhaseCabinet::at(handle);
654 obj->getPartialMolarCp(cpbar);
665 auto& obj = ThermoPhaseCabinet::at(handle);
667 obj->getPartialMolarVolumes(vbar);
678 ThermoPhaseCabinet::at(handle)->setState_TPX(t, p, x);
689 ThermoPhaseCabinet::at(handle)->setState_TPX(t, p, x);
700 ThermoPhaseCabinet::at(handle)->setState_TPY(t, p, y);
711 ThermoPhaseCabinet::at(handle)->setState_TPY(t, p, y);
722 ThermoPhaseCabinet::at(handle)->setState_TP(t, p);
733 ThermoPhaseCabinet::as<Phase>(handle)->setState_TD(t, rho);
744 ThermoPhaseCabinet::at(handle)->setState_DP(rho, p);
755 ThermoPhaseCabinet::at(handle)->setState_HP(h, p);
766 ThermoPhaseCabinet::at(handle)->setState_UV(u, v);
777 ThermoPhaseCabinet::at(handle)->setState_SV(s, v);
788 ThermoPhaseCabinet::at(handle)->setState_SP(s, p);
799 ThermoPhaseCabinet::at(handle)->setState_ST(s, t);
810 ThermoPhaseCabinet::at(handle)->setState_TV(t, v);
821 ThermoPhaseCabinet::at(handle)->setState_PV(p, v);
832 ThermoPhaseCabinet::at(handle)->setState_UP(u, p);
843 ThermoPhaseCabinet::at(handle)->setState_VH(v, h);
854 ThermoPhaseCabinet::at(handle)->setState_TH(t, h);
865 ThermoPhaseCabinet::at(handle)->setState_SH(s, h);
872 int32_t
thermo_equilibrate(int32_t handle,
const char* XY,
const char* solver,
double rtol, int32_t max_steps, int32_t max_iter, int32_t estimate_equil)
876 ThermoPhaseCabinet::at(handle)->equilibrate(XY, solver, rtol, max_steps, max_iter, estimate_equil);
887 return ThermoPhaseCabinet::at(handle)->critTemperature();
897 return ThermoPhaseCabinet::at(handle)->critPressure();
907 return ThermoPhaseCabinet::at(handle)->critDensity();
917 return ThermoPhaseCabinet::at(handle)->vaporFraction();
927 return ThermoPhaseCabinet::at(handle)->satTemperature(p);
937 return ThermoPhaseCabinet::at(handle)->satPressure(t);
947 ThermoPhaseCabinet::at(handle)->setState_Psat(p, x);
958 ThermoPhaseCabinet::at(handle)->setState_Tsat(t, x);
969 auto obj = ThermoPhaseCabinet::as<SurfPhase>(handle);
971 obj->getCoverages(theta);
982 auto obj = ThermoPhaseCabinet::as<SurfPhase>(handle);
984 obj->setCoverages(theta);
995 auto obj = ThermoPhaseCabinet::as<Phase>(handle);
997 obj->getConcentrations(c);
1008 auto obj = ThermoPhaseCabinet::as<Phase>(handle);
1010 obj->setConcentrations(conc);
1021 return ThermoPhaseCabinet::as<SurfPhase>(handle)->siteDensity();
1031 ThermoPhaseCabinet::as<SurfPhase>(handle)->setSiteDensity(n0);
1042 ThermoPhaseCabinet::as<SurfPhase>(handle)->setCoveragesByName(cov);
1053 ThermoPhaseCabinet::at(handle)->setEquivalenceRatio(phi, fuelComp, oxComp);
1060 int32_t
thermo_report(int32_t handle, int32_t show_thermo,
double threshold, int32_t bufLen,
char* buf)
1064 bool show_thermo_ = (show_thermo != 0);
1065 string out = ThermoPhaseCabinet::at(handle)->report(show_thermo_, threshold);
1067 return int(out.size()) + 1;
1078 bool show = (showThermo != 0);
1079 writelog(ThermoPhaseCabinet::at(handle)->report(show, threshold));
1091 ThermoPhaseCabinet::del(handle);
1103 return ThermoPhaseCabinet::size();
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase,...
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
Template for classes to hold pointers to objects.
CTTHERMO - Generated CLib Cantera interface library.
double thermo_satTemperature(int32_t handle, double p)
Return the saturation temperature given the pressure.
int32_t thermo_setState_VH(int32_t handle, double v, double h)
Set the specific volume (m^3/kg) and the specific enthalpy (J/kg)
int32_t surf_setCoveragesByName(int32_t handle, const char *cov)
Set the coverages from a string of colon-separated name:value pairs.
int32_t thermo_speciesIndex(int32_t handle, const char *name)
Returns the index of a species named 'name' within the Phase object.
int32_t thermo_speciesName(int32_t handle, int32_t k, int32_t bufLen, char *buf)
Name of the species with index k.
double thermo_cv_mole(int32_t handle)
Molar heat capacity at constant volume.
int32_t thermo_setState_TD(int32_t handle, double t, double rho)
Set the internally stored temperature (K) and density (kg/m^3)
double thermo_intEnergy_mass(int32_t handle)
Specific internal energy.
int32_t thermo_getConcentrations(int32_t handle, int32_t cLen, double *c)
Get the species concentrations (kmol/m^3).
int32_t thermo_getMoleFractions(int32_t handle, int32_t xLen, double *x)
Get the species mole fraction vector.
int32_t surf_setCoverages(int32_t handle, int32_t thetaLen, const double *theta)
Set the surface site fractions to a specified state.
int32_t thermo_print(int32_t handle, int32_t showThermo, double threshold)
Print a summary of the state of the phase to the logger.
double thermo_cp_mass(int32_t handle)
Specific heat at constant pressure.
int32_t thermo_setMassFractions(int32_t handle, int32_t yLen, const double *y)
Set the mass fractions to the specified values and normalize them.
int32_t thermo_setState_ST(int32_t handle, double s, double t)
Set the specific entropy (J/kg/K) and temperature (K).
int32_t thermo_setTemperature(int32_t handle, double temp)
Set the internally stored temperature of the phase (K).
double thermo_maxTemp(int32_t handle, int32_t k)
Maximum temperature for which the thermodynamic data for the species are valid.
double thermo_pressure(int32_t handle)
Return the thermodynamic pressure (Pa).
double thermo_density(int32_t handle)
Density (kg/m^3).
int32_t thermo_getElectrochemPotentials(int32_t handle, int32_t muLen, double *mu)
Get the species electrochemical potentials.
double thermo_enthalpy_mole(int32_t handle)
Molar enthalpy.
int32_t thermo_setState_SH(int32_t handle, double s, double h)
Set the specific entropy (J/kg/K) and the specific enthalpy (J/kg)
int32_t thermo_setMoleFractionsByName(int32_t handle, const char *x)
Set the mole fractions of a group of species by name.
double thermo_cv_mass(int32_t handle)
Specific heat at constant volume.
int32_t thermo_report(int32_t handle, int32_t show_thermo, double threshold, int32_t bufLen, char *buf)
returns a summary of the state of the phase as a string
int32_t thermo_setState_TH(int32_t handle, double t, double h)
Set the temperature (K) and the specific enthalpy (J/kg)
int32_t thermo_del(int32_t handle)
Delete ThermoPhase object.
int32_t thermo_setState_SP(int32_t handle, double s, double p)
Set the specific entropy (J/kg/K) and pressure (Pa).
int32_t thermo_setState_TV(int32_t handle, double t, double v)
Set the temperature (K) and specific volume (m^3/kg).
double thermo_vaporFraction(int32_t handle)
Return the fraction of vapor at the current conditions.
int32_t thermo_addElement(int32_t handle, const char *symbol, double weight, int32_t atomicNumber, double entropy298, int32_t elem_type)
Add an element.
int32_t thermo_getPartialMolarIntEnergies(int32_t handle, int32_t ubarLen, double *ubar)
Return an array of partial molar internal energies for the species in the mixture.
double thermo_massFraction(int32_t handle, int32_t k)
Return the mass fraction of a single species.
double thermo_gibbs_mole(int32_t handle)
Molar Gibbs function.
int32_t surf_getCoverages(int32_t handle, int32_t thetaLen, double *theta)
Return a vector of surface coverages.
int32_t thermo_setState_TPX_byName(int32_t handle, double t, double p, const char *x)
Set the temperature (K), pressure (Pa), and mole fractions.
double thermo_critDensity(int32_t handle)
Critical density (kg/m3).
int32_t thermo_nElements(int32_t handle)
Number of elements.
double thermo_meanMolecularWeight(int32_t handle)
The mean molecular weight.
int32_t thermo_setState_Tsat(int32_t handle, double t, double x)
Set the state to a saturated system at a particular temperature.
int32_t thermo_setState_PV(int32_t handle, double p, double v)
Set the pressure (Pa) and specific volume (m^3/kg).
double thermo_enthalpy_mass(int32_t handle)
Specific enthalpy.
int32_t thermo_elementIndex(int32_t handle, const char *name)
Return the index of element named 'name'.
int32_t thermo_type(int32_t handle, int32_t bufLen, char *buf)
String indicating the thermodynamic model implemented.
int32_t thermo_nSpecies(int32_t handle)
Returns the number of species in the phase.
double surf_siteDensity(int32_t handle)
Returns the site density.
double thermo_entropy_mass(int32_t handle)
Specific entropy.
int32_t thermo_setName(int32_t handle, const char *nm)
Sets the string name for the phase.
int32_t thermo_getCharges(int32_t handle, int32_t chargesLen, double *charges)
Copy the vector of species charges into array charges.
int32_t thermo_setState_HP(int32_t handle, double h, double p)
Set the internally stored specific enthalpy (J/kg) and pressure (Pa) of the phase.
int32_t thermo_setState_TPY(int32_t handle, double t, double p, int32_t yLen, const double *y)
Set the internally stored temperature (K), pressure (Pa), and mass fractions of the phase.
int32_t thermo_equilibrate(int32_t handle, const char *XY, const char *solver, double rtol, int32_t max_steps, int32_t max_iter, int32_t estimate_equil)
Equilibrate a ThermoPhase object.
double thermo_intEnergy_mole(int32_t handle)
Molar internal energy.
double thermo_critTemperature(int32_t handle)
Critical temperature (K).
int32_t thermo_name(int32_t handle, int32_t bufLen, char *buf)
Return the name of the phase.
int32_t thermo_setState_TPX(int32_t handle, double t, double p, int32_t xLen, const double *x)
Set the temperature (K), pressure (Pa), and mole fractions.
int32_t thermo_getChemPotentials(int32_t handle, int32_t muLen, double *mu)
Get the species chemical potentials.
double thermo_electricPotential(int32_t handle)
Returns the electric potential of this phase (V).
int32_t thermo_getPartialMolarEnthalpies(int32_t handle, int32_t hbarLen, double *hbar)
Returns an array of partial molar enthalpies for the species in the mixture.
int32_t thermo_setState_Psat(int32_t handle, double p, double x)
Set the state to a saturated system at a particular pressure.
double thermo_refPressure(int32_t handle)
Returns the reference pressure in Pa.
int32_t thermo_cabinetSize()
Return size of ThermoPhase storage.
double thermo_isothermalCompressibility(int32_t handle)
Returns the isothermal compressibility.
int32_t thermo_setPressure(int32_t handle, double p)
Set the internally stored pressure (Pa) at constant temperature and composition.
double thermo_gibbs_mass(int32_t handle)
Specific Gibbs function.
double thermo_moleFraction(int32_t handle, int32_t k)
Return the mole fraction of a single species.
int32_t thermo_getPartialMolarCp(int32_t handle, int32_t cpbarLen, double *cpbar)
Return an array of partial molar heat capacities for the species in the mixture.
int32_t thermo_setState_UP(int32_t handle, double u, double p)
Set the specific internal energy (J/kg) and pressure (Pa).
double thermo_molarDensity(int32_t handle)
Molar density (kmol/m^3).
double thermo_minTemp(int32_t handle, int32_t k)
Minimum temperature for which the thermodynamic data for the species or phase are valid.
int32_t thermo_setEquivalenceRatio(int32_t handle, double phi, const char *fuelComp, const char *oxComp)
Set the mixture composition according to the equivalence ratio.
int32_t thermo_setMassFractionsByName(int32_t handle, const char *x)
Set the species mass fractions by name.
double thermo_satPressure(int32_t handle, double t)
Return the saturation pressure given the temperature.
int32_t thermo_getPartialMolarVolumes(int32_t handle, int32_t vbarLen, double *vbar)
Return an array of partial molar volumes for the species in the mixture.
double thermo_thermalExpansionCoeff(int32_t handle)
Return the volumetric thermal expansion coefficient.
int32_t thermo_setState_DP(int32_t handle, double rho, double p)
Set the density (kg/m**3) and pressure (Pa) at constant composition.
int32_t thermo_setState_TP(int32_t handle, double t, double p)
Set the temperature (K) and pressure (Pa)
double thermo_critPressure(int32_t handle)
Critical pressure (Pa).
int32_t thermo_atomicWeights(int32_t handle, int32_t bufLen, double *buf)
Return a read-only reference to the vector of atomic weights.
int32_t thermo_setState_TPY_byName(int32_t handle, double t, double p, const char *y)
Set the internally stored temperature (K), pressure (Pa), and mass fractions of the phase.
int32_t thermo_setMoleFractions(int32_t handle, int32_t xLen, const double *x)
Set the mole fractions to the specified values.
int32_t thermo_getMassFractions(int32_t handle, int32_t yLen, double *y)
Get the species mass fractions.
int32_t thermo_elementName(int32_t handle, int32_t m, int32_t bufLen, char *buf)
Name of the element with index m.
double thermo_temperature(int32_t handle)
Temperature (K).
double thermo_cp_mole(int32_t handle)
Molar heat capacity at constant pressure.
int32_t thermo_setDensity(int32_t handle, const double density_)
Set the internally stored density (kg/m^3) of the phase.
int32_t thermo_getMolecularWeights(int32_t handle, int32_t weightsLen, double *weights)
Copy the vector of molecular weights into array weights.
int32_t surf_setSiteDensity(int32_t handle, double n0)
Set the site density of the surface phase (kmol m-2)
int32_t thermo_getPartialMolarEntropies(int32_t handle, int32_t sbarLen, double *sbar)
Returns an array of partial molar entropies of the species in the solution.
double thermo_entropy_mole(int32_t handle)
Molar entropy.
int32_t thermo_setElectricPotential(int32_t handle, double v)
Set the electric potential of this phase (V).
int32_t thermo_setState_UV(int32_t handle, double u, double v)
Set the specific internal energy (J/kg) and specific volume (m^3/kg).
int32_t thermo_setConcentrations(int32_t handle, int32_t concLen, const double *conc)
Set the concentrations to the specified values within the phase.
int32_t thermo_setState_SV(int32_t handle, double s, double v)
Set the specific entropy (J/kg/K) and specific volume (m^3/kg).
double thermo_nAtoms(int32_t handle, int32_t k, int32_t m)
Number of atoms of element m in species k.
size_t copyString(const string &source, char *dest, size_t length)
Copy the contents of a string into a char array of a given length.
void writelog(const string &fmt, const Args &... args)
Write a formatted message to the screen.
Namespace for the Cantera kernel.
T handleAllExceptions(T ctErrorCode, T otherErrorCode)
Exception handler used at language interface boundaries.
Contains declarations for string manipulation functions within Cantera.