cantera/docs/doxyinput/thermodemo.cpp
Ray Speth a6f939c2fe Applied consistent formatting to all C++ code
Done using astyle:
astyle --style=kr --add-brackets --indent=spaces=4 --indent-col1-comments --unpad-paren --pad-header --align-pointer=type --lineend=linux
2012-02-10 17:24:00 +00:00

41 lines
1,008 B
C++

#include <cantera/Cantera.h>
void thermo_demo(string file, string phase)
{
ThermoPhase* gas = newPhase(file, phase);
gas->setState_TPX(1500.0, 2.0*OneAtm, "O2:1.0, H2:3.0, AR:1.0");
// temperature, pressure, and density
cout << gas->temperature() << endl;
cout << gas->pressure() << endl;
cout << gas->density() << endl;
// molar thermodynamic properties
cout << gas->enthalpy_mole() << endl;
cout << gas->entropy_mole() << endl;
// specific (per unit mass) thermodynamic properties
cout << gas->enthalpy_mass() << endl;
cout << gas->entropy_mass() << endl;
// chemical potentials of the species
int numSpecies = gas->nSpecies();
vector_fp mu(numSpecies);
gas->getChemPotentials(mu.begin());
int n;
for (n = 0; n < numSpecies; n++) {
cout << gas->speciesName(n) << " " << mu[n] << endl;
}
}
int main()
{
try {
thermo_demo("h2o2.cti","ohmech");
} catch (CanteraError) {
showErrors();
}
}