31typedef Cabinet<ThermoPhase> ThermoPhaseCabinet;
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 ThermoPhaseCabinet::as<Phase>(handle)->nElements();
87 return 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 (xLen < obj->nSpecies()) {
202 throw ArraySizeError(
"thermo_getMoleFractions", xLen, obj->nSpecies());
204 obj->getMoleFractions(x);
215 auto obj = ThermoPhaseCabinet::as<Phase>(handle);
216 if (yLen < obj->nSpecies()) {
217 throw ArraySizeError(
"thermo_getMassFractions", yLen, obj->nSpecies());
219 obj->getMassFractions(y);
230 auto obj = ThermoPhaseCabinet::as<Phase>(handle);
231 if (xLen != obj->nSpecies()) {
232 throw ArraySizeError(
"thermo_setMoleFractions", xLen, obj->nSpecies());
234 obj->setMoleFractions(x);
245 auto obj = ThermoPhaseCabinet::as<Phase>(handle);
246 if (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 (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 (weightsLen < obj->nSpecies()) {
300 throw ArraySizeError(
"thermo_getMolecularWeights", weightsLen, obj->nSpecies());
302 obj->getMolecularWeights(weights);
313 auto obj = ThermoPhaseCabinet::as<Phase>(handle);
314 if (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;
352 return ThermoPhaseCabinet::as<Phase>(handle)->elementIndex(name);
362 return ThermoPhaseCabinet::as<Phase>(handle)->speciesIndex(name);
372 return ThermoPhaseCabinet::as<Phase>(handle)->nAtoms(k, m);
378 int32_t
thermo_addElement(int32_t handle,
const char* symbol,
double weight, int32_t atomicNumber,
double entropy298, int32_t elem_type)
382 return ThermoPhaseCabinet::as<Phase>(handle)->addElement(symbol, weight, atomicNumber, entropy298, elem_type);
392 return ThermoPhaseCabinet::at(handle)->refPressure();
402 return ThermoPhaseCabinet::at(handle)->minTemp(k);
412 return ThermoPhaseCabinet::at(handle)->maxTemp(k);
422 return ThermoPhaseCabinet::at(handle)->enthalpy_mole();
432 return ThermoPhaseCabinet::at(handle)->enthalpy_mass();
442 return ThermoPhaseCabinet::at(handle)->entropy_mole();
452 return ThermoPhaseCabinet::at(handle)->entropy_mass();
462 return ThermoPhaseCabinet::at(handle)->intEnergy_mole();
472 return ThermoPhaseCabinet::at(handle)->intEnergy_mass();
482 return ThermoPhaseCabinet::at(handle)->gibbs_mole();
492 return ThermoPhaseCabinet::at(handle)->gibbs_mass();
502 return ThermoPhaseCabinet::at(handle)->cp_mole();
512 return ThermoPhaseCabinet::at(handle)->cp_mass();
522 return ThermoPhaseCabinet::at(handle)->cv_mole();
532 return ThermoPhaseCabinet::at(handle)->cv_mass();
542 auto& obj = ThermoPhaseCabinet::at(handle);
544 obj->getChemPotentials(mu);
555 auto& obj = ThermoPhaseCabinet::at(handle);
557 obj->getElectrochemPotentials(mu);
568 return ThermoPhaseCabinet::at(handle)->electricPotential();
578 ThermoPhaseCabinet::at(handle)->setElectricPotential(v);
589 return ThermoPhaseCabinet::at(handle)->thermalExpansionCoeff();
599 return ThermoPhaseCabinet::at(handle)->isothermalCompressibility();
609 auto& obj = ThermoPhaseCabinet::at(handle);
611 obj->getPartialMolarEnthalpies(hbar);
622 auto& obj = ThermoPhaseCabinet::at(handle);
624 obj->getPartialMolarEntropies(sbar);
635 auto& obj = ThermoPhaseCabinet::at(handle);
637 obj->getPartialMolarIntEnergies(ubar);
648 auto& obj = ThermoPhaseCabinet::at(handle);
650 obj->getPartialMolarCp(cpbar);
661 auto& obj = ThermoPhaseCabinet::at(handle);
663 obj->getPartialMolarVolumes(vbar);
674 ThermoPhaseCabinet::at(handle)->setState_TPX(t, p, x);
685 ThermoPhaseCabinet::at(handle)->setState_TPY(t, p, y);
696 ThermoPhaseCabinet::at(handle)->setState_TP(t, p);
707 ThermoPhaseCabinet::as<Phase>(handle)->setState_TD(t, rho);
718 ThermoPhaseCabinet::at(handle)->setState_DP(rho, p);
729 ThermoPhaseCabinet::at(handle)->setState_HP(h, p);
740 ThermoPhaseCabinet::at(handle)->setState_UV(u, v);
751 ThermoPhaseCabinet::at(handle)->setState_SV(s, v);
762 ThermoPhaseCabinet::at(handle)->setState_SP(s, p);
773 ThermoPhaseCabinet::at(handle)->setState_ST(s, t);
784 ThermoPhaseCabinet::at(handle)->setState_TV(t, v);
795 ThermoPhaseCabinet::at(handle)->setState_PV(p, v);
806 ThermoPhaseCabinet::at(handle)->setState_UP(u, p);
817 ThermoPhaseCabinet::at(handle)->setState_VH(v, h);
828 ThermoPhaseCabinet::at(handle)->setState_TH(t, h);
839 ThermoPhaseCabinet::at(handle)->setState_SH(s, h);
846 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)
850 ThermoPhaseCabinet::at(handle)->equilibrate(XY, solver, rtol, max_steps, max_iter, estimate_equil);
861 return ThermoPhaseCabinet::at(handle)->critTemperature();
871 return ThermoPhaseCabinet::at(handle)->critPressure();
881 return ThermoPhaseCabinet::at(handle)->critDensity();
891 return ThermoPhaseCabinet::at(handle)->vaporFraction();
901 return ThermoPhaseCabinet::at(handle)->satTemperature(p);
911 return ThermoPhaseCabinet::at(handle)->satPressure(t);
921 ThermoPhaseCabinet::at(handle)->setState_Psat(p, x);
932 ThermoPhaseCabinet::at(handle)->setState_Tsat(t, x);
943 auto obj = ThermoPhaseCabinet::as<SurfPhase>(handle);
945 obj->getCoverages(theta);
956 auto obj = ThermoPhaseCabinet::as<SurfPhase>(handle);
958 obj->setCoverages(theta);
969 auto obj = ThermoPhaseCabinet::as<Phase>(handle);
971 obj->getConcentrations(c);
982 auto obj = ThermoPhaseCabinet::as<Phase>(handle);
984 obj->setConcentrations(conc);
995 return ThermoPhaseCabinet::as<SurfPhase>(handle)->siteDensity();
1005 ThermoPhaseCabinet::as<SurfPhase>(handle)->setSiteDensity(n0);
1016 ThermoPhaseCabinet::as<SurfPhase>(handle)->setCoveragesByName(cov);
1023 int32_t
thermo_report(int32_t handle, int32_t show_thermo,
double threshold, int32_t bufLen,
char* buf)
1027 bool show_thermo_ = (show_thermo != 0);
1028 string out = ThermoPhaseCabinet::at(handle)->report(show_thermo_, threshold);
1030 return int(out.size()) + 1;
1041 bool show = (showThermo != 0);
1042 writelog(ThermoPhaseCabinet::at(handle)->report(show, threshold));
1061 return ThermoPhaseCabinet::size();
1073 return ThermoPhaseCabinet::parent(handle);
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...
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)
Destructor; required by some APIs although object is managed by Solution.
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.
double thermo_critDensity(int32_t handle)
Critical density (kg/m3).
int32_t thermo_parentHandle(int32_t handle)
Return handle to parent of ThermoPhase object.
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_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_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.
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.