cantera/test_problems/cathermo/testWaterTP/testWaterSSTP.cpp
Ray Speth 7c171631af Merge branch 'scons' into 'trunk'
Conflicts:
	Cantera/Makefile.in
	Cantera/clib/src/clib_defs.h
	Cantera/clib/src/ctreactor.cpp
	Cantera/clib/src/ctstagn.cpp
	Cantera/clib/src/ctstagn.h
	Cantera/cxx/Makefile.in
	Cantera/cxx/demos/combustor/combustor.cpp
	Cantera/cxx/demos/flamespeed/flamespeed.cpp
	Cantera/cxx/demos/kinetics1/example_utils.h
	Cantera/cxx/demos/kinetics1/kinetics1.cpp
	Cantera/cxx/include/Cantera.h
	Cantera/cxx/include/Cantera.mak.in
	Cantera/cxx/include/Cantera_bt.mak.in
	Cantera/cxx/include/Edge.h
	Cantera/cxx/include/GRI30.h
	Cantera/cxx/include/Interface.h
	Cantera/cxx/include/zerodim.h
	Cantera/fortran/f77demos/Makefile.in
	Cantera/fortran/src/Makefile.in
	Cantera/fortran/src/fct.cpp
	Cantera/fortran/src/fctxml.cpp
	Cantera/fortran/src/flib_defs.h
	Cantera/matlab/Makefile.in
	Cantera/matlab/cantera/Contents.m
	Cantera/matlab/setup_winmatlab.py
	Cantera/matlab/src/ctfunctions.cpp
	Cantera/matlab/src/ctmatutils.h
	Cantera/matlab/src/mixturemethods.cpp
	Cantera/matlab/src/mllogger.h
	Cantera/matlab/src/phasemethods.cpp
	Cantera/matlab/src/reactormethods.cpp
	Cantera/matlab/src/reactornetmethods.cpp
	Cantera/matlab/src/thermomethods.cpp
	Cantera/matlab/src/wallmethods.cpp
	Cantera/matlab/src/xmlmethods.cpp
	Cantera/python/Cantera/Edge.py
	Cantera/python/Cantera/Interface.py
	Cantera/python/Cantera/Phase.py
	Cantera/python/Cantera/importFromFile.py
	Cantera/python/Makefile.in
	Cantera/python/ctml_writer.py
	Cantera/python/setup.py.in
	Cantera/python/src/Makefile.in
	Cantera/python/src/ctkinetics_methods.cpp
	Cantera/python/src/ctonedim_methods.cpp
	Cantera/python/src/pylogger.h
	Cantera/src/Makefile.in
	Cantera/src/base/config.h.in
	Cantera/src/base/ctml.cpp
	Cantera/src/base/ctml.h
	Cantera/src/base/mdp_allo.cpp
	Cantera/src/base/mdp_allo.h
	Cantera/src/base/vec_functions.h
	Cantera/src/base/xml.cpp
	Cantera/src/base/xml.h
	Cantera/src/converters/CKParser.h
	Cantera/src/converters/Element.h
	Cantera/src/converters/Reaction.h
	Cantera/src/converters/RxnSpecies.h
	Cantera/src/converters/Species.h
	Cantera/src/converters/ckr_defs.h
	Cantera/src/converters/ckr_utils.h
	Cantera/src/equil/BasisOptimize.cpp
	Cantera/src/equil/Makefile.in
	Cantera/src/equil/MultiPhase.cpp
	Cantera/src/equil/vcs_MultiPhaseEquil.cpp
	Cantera/src/equil/vcs_VolPhase.cpp
	Cantera/src/equil/vcs_VolPhase.h
	Cantera/src/equil/vcs_linmaxc.cpp
	Cantera/src/equil/vcs_phaseStability.cpp
	Cantera/src/equil/vcs_rxnadj.cpp
	Cantera/src/equil/vcs_solve.cpp
	Cantera/src/equil/vcs_solve.h
	Cantera/src/equil/vcs_solve_TP.cpp
	Cantera/src/equil/vcs_util.cpp
	Cantera/src/equil/vcs_xerror.c
	Cantera/src/kinetics/GasKinetics.cpp
	Cantera/src/kinetics/GasKinetics.h
	Cantera/src/kinetics/InterfaceKinetics.cpp
	Cantera/src/kinetics/InterfaceKinetics.h
	Cantera/src/kinetics/Kinetics.h
	Cantera/src/kinetics/ReactionStoichMgr.h
	Cantera/src/kinetics/RxnRates.h
	Cantera/src/kinetics/StoichManager.h
	Cantera/src/numerics/BandMatrix.cpp
	Cantera/src/numerics/BandMatrix.h
	Cantera/src/numerics/DAE_Solver.h
	Cantera/src/numerics/DAE_solvers.cpp
	Cantera/src/numerics/DenseMatrix.cpp
	Cantera/src/numerics/DenseMatrix.h
	Cantera/src/numerics/FuncEval.h
	Cantera/src/numerics/IDA_Solver.cpp
	Cantera/src/numerics/IDA_Solver.h
	Cantera/src/numerics/Integrator.h
	Cantera/src/numerics/Makefile.in
	Cantera/src/numerics/NonlinearSolver.cpp
	Cantera/src/numerics/NonlinearSolver.h
	Cantera/src/numerics/ResidEval.h
	Cantera/src/numerics/ResidJacEval.cpp
	Cantera/src/numerics/ResidJacEval.h
	Cantera/src/numerics/SquareMatrix.cpp
	Cantera/src/numerics/SquareMatrix.h
	Cantera/src/numerics/ctlapack.h
	Cantera/src/oneD/Domain1D.h
	Cantera/src/oneD/OneDim.cpp
	Cantera/src/oneD/OneDim.h
	Cantera/src/oneD/Resid1D.h
	Cantera/src/oneD/Solid1D.cpp
	Cantera/src/oneD/Solid1D.h
	Cantera/src/oneD/StFlow.cpp
	Cantera/src/oneD/Surf1D.h
	Cantera/src/spectra/LineBroadener.h
	Cantera/src/thermo/Constituents.cpp
	Cantera/src/thermo/GibbsExcessVPSSTP.cpp
	Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp
	Cantera/src/thermo/IonsFromNeutralVPSSTP.h
	Cantera/src/thermo/LatticePhase.cpp
	Cantera/src/thermo/LatticeSolidPhase.cpp
	Cantera/src/thermo/LatticeSolidPhase.h
	Cantera/src/thermo/Makefile.in
	Cantera/src/thermo/MargulesVPSSTP.cpp
	Cantera/src/thermo/MargulesVPSSTP.h
	Cantera/src/thermo/NasaThermo.h
	Cantera/src/thermo/PDSS_IonsFromNeutral.cpp
	Cantera/src/thermo/PDSS_IonsFromNeutral.h
	Cantera/src/thermo/PDSS_SSVol.cpp
	Cantera/src/thermo/Phase.cpp
	Cantera/src/thermo/PseudoBinaryVPSSTP.cpp
	Cantera/src/thermo/PseudoBinaryVPSSTP.h
	Cantera/src/thermo/PureFluidPhase.cpp
	Cantera/src/thermo/ShomateThermo.h
	Cantera/src/thermo/SimpleThermo.h
	Cantera/src/thermo/SpeciesThermoFactory.cpp
	Cantera/src/thermo/State.h
	Cantera/src/thermo/StoichSubstance.h
	Cantera/src/thermo/ThermoFactory.cpp
	Cantera/src/thermo/ThermoPhase.cpp
	Cantera/src/thermo/ThermoPhase.h
	Cantera/src/transport/AqueousTransport.cpp
	Cantera/src/transport/AqueousTransport.h
	Cantera/src/transport/DustyGasTransport.cpp
	Cantera/src/transport/DustyGasTransport.h
	Cantera/src/transport/L_matrix.h
	Cantera/src/transport/LiquidTransport.cpp
	Cantera/src/transport/LiquidTransport.h
	Cantera/src/transport/LiquidTransportData.h
	Cantera/src/transport/MMCollisionInt.cpp
	Cantera/src/transport/MMCollisionInt.h
	Cantera/src/transport/Makefile.in
	Cantera/src/transport/MixTransport.cpp
	Cantera/src/transport/MixTransport.h
	Cantera/src/transport/MultiTransport.cpp
	Cantera/src/transport/MultiTransport.h
	Cantera/src/transport/SimpleTransport.cpp
	Cantera/src/transport/SimpleTransport.h
	Cantera/src/transport/SolidTransport.cpp
	Cantera/src/transport/SolidTransport.h
	Cantera/src/transport/TransportBase.h
	Cantera/src/transport/TransportFactory.cpp
	Cantera/src/transport/TransportFactory.h
	Cantera/src/transport/TransportParams.h
	Cantera/src/transport/WaterTransport.h
	Cantera/src/zeroD/FlowDevice.h
	Cantera/src/zeroD/Reactor.h
	Cantera/src/zeroD/ReactorBase.cpp
	Cantera/src/zeroD/ReactorBase.h
	Cantera/src/zeroD/ReactorNet.h
	Cantera/src/zeroD/Wall.h
	Cantera/user/Makefile.in
	License.rtf
	Makefile.in
	apps/bvp/stagnation.cpp
	configure
	configure.in
	data/transport/misc_tran.dat
	docs/Makefile.in
	docs/install_examples/README.txt
	docs/install_examples/cygwin_gcc434_dbg_f2c_numpy.sh
	docs/install_examples/linux_64_gcc424_dbg_python252_numpy
	docs/install_examples/linux_64_gcc424_opt_python252_numpy
	docs/install_examples/mac_gcc401_python251_numpy
	docs/python/.cvsignore
	ext/Makefile.in
	ext/blas/Makefile.in
	ext/cvode/Makefile.in
	ext/f2c_blas/Makefile.in
	ext/f2c_lapack/Makefile.in
	ext/f2c_math/Makefile.in
	ext/f2c_math/xersve.c
	ext/f2c_recipes/Makefile.in
	ext/lapack/Makefile.in
	ext/math/Makefile.in
	ext/recipes/Makefile.in
	ext/tpx/CarbonDioxide.cpp
	ext/tpx/Makefile.in
	ext/tpx/Sub.cpp
	ext/tpx/utils.cpp
	preconfig
	test_problems/ChemEquil_gri_matrix/gri_matrix.cpp
	test_problems/ChemEquil_gri_pairs/gri_pairs.cpp
	test_problems/ChemEquil_ionizedGas/ionizedGasEquil.cpp
	test_problems/ChemEquil_ionizedGas/runtest
	test_problems/ChemEquil_red1/basopt_red1.cpp
	test_problems/CpJump/CpJump.cpp
	test_problems/Makefile.in
	test_problems/VCSnonideal/Makefile.in
	test_problems/VCSnonideal/NaCl_equil/HMW_NaCl.xml
	test_problems/VCSnonideal/NaCl_equil/nacl_equil.cpp
	test_problems/VPsilane_test/silane_equil.cpp
	test_problems/cathermo/DH_graph_1/DH_graph_1.cpp
	test_problems/cathermo/DH_graph_NM/DH_graph_1.cpp
	test_problems/cathermo/DH_graph_Pitzer/DH_graph_1.cpp
	test_problems/cathermo/DH_graph_acommon/DH_graph_1.cpp
	test_problems/cathermo/DH_graph_bdotak/DH_graph_1.cpp
	test_problems/cathermo/HMW_dupl_test/HMW_NaCl_sp1977_alt.xml
	test_problems/cathermo/HMW_dupl_test/HMW_dupl_test.cpp
	test_problems/cathermo/HMW_dupl_test/TemperatureTable.h
	test_problems/cathermo/HMW_dupl_test/sortAlgorithms.cpp
	test_problems/cathermo/HMW_dupl_test/sortAlgorithms.h
	test_problems/cathermo/HMW_graph_CpvT/HMW_NaCl_sp1977_alt.xml
	test_problems/cathermo/HMW_graph_CpvT/HMW_graph_CpvT.cpp
	test_problems/cathermo/HMW_graph_CpvT/TemperatureTable.h
	test_problems/cathermo/HMW_graph_CpvT/sortAlgorithms.cpp
	test_problems/cathermo/HMW_graph_CpvT/sortAlgorithms.h
	test_problems/cathermo/HMW_graph_GvI/HMW_NaCl.xml
	test_problems/cathermo/HMW_graph_GvI/HMW_graph_GvI.cpp
	test_problems/cathermo/HMW_graph_GvI/TemperatureTable.h
	test_problems/cathermo/HMW_graph_GvI/sortAlgorithms.cpp
	test_problems/cathermo/HMW_graph_GvI/sortAlgorithms.h
	test_problems/cathermo/HMW_graph_GvT/HMW_NaCl_sp1977_alt.xml
	test_problems/cathermo/HMW_graph_GvT/HMW_graph_GvT.cpp
	test_problems/cathermo/HMW_graph_GvT/TemperatureTable.h
	test_problems/cathermo/HMW_graph_GvT/sortAlgorithms.cpp
	test_problems/cathermo/HMW_graph_GvT/sortAlgorithms.h
	test_problems/cathermo/HMW_graph_HvT/HMW_NaCl_sp1977_alt.xml
	test_problems/cathermo/HMW_graph_HvT/HMW_graph_HvT.cpp
	test_problems/cathermo/HMW_graph_HvT/TemperatureTable.h
	test_problems/cathermo/HMW_graph_HvT/sortAlgorithms.cpp
	test_problems/cathermo/HMW_graph_HvT/sortAlgorithms.h
	test_problems/cathermo/HMW_graph_VvT/HMW_NaCl_sp1977_alt.xml
	test_problems/cathermo/HMW_graph_VvT/HMW_graph_VvT.cpp
	test_problems/cathermo/HMW_graph_VvT/TemperatureTable.h
	test_problems/cathermo/HMW_graph_VvT/sortAlgorithms.cpp
	test_problems/cathermo/HMW_graph_VvT/sortAlgorithms.h
	test_problems/cathermo/HMW_test_1/HMW_test_1.cpp
	test_problems/cathermo/HMW_test_3/HMW_test_3.cpp
	test_problems/cathermo/Makefile.in
	test_problems/cathermo/VPissp/ISSPTester.cpp
	test_problems/cathermo/ims/IMSTester.cpp
	test_problems/cathermo/issp/ISSPTester.cpp
	test_problems/cathermo/stoichSubSSTP/TemperatureTable.h
	test_problems/cathermo/stoichSubSSTP/sortAlgorithms.cpp
	test_problems/cathermo/stoichSubSSTP/sortAlgorithms.h
	test_problems/cathermo/stoichSubSSTP/stoichSubSSTP.cpp
	test_problems/cathermo/testIAPWS/testIAPWSphi.cpp
	test_problems/cathermo/testWaterPDSS/testWaterPDSS.cpp
	test_problems/cathermo/testWaterTP/testWaterSSTP.cpp
	test_problems/cathermo/wtWater/wtWater.cpp
	test_problems/ck2cti_test/Makefile.in
	test_problems/ck2cti_test/runtest.in
	test_problems/cxx_ex/Makefile.in
	test_problems/cxx_ex/equil_example1.cpp
	test_problems/cxx_ex/example_utils.h
	test_problems/cxx_ex/kinetics_example1.cpp
	test_problems/cxx_ex/kinetics_example2.cpp
	test_problems/cxx_ex/kinetics_example3.cpp
	test_problems/cxx_ex/runtest
	test_problems/cxx_ex/rxnpath_example1.cpp
	test_problems/cxx_ex/transport_example1.cpp
	test_problems/cxx_ex/transport_example2.cpp
	test_problems/min_python/Makefile.in
	test_problems/min_python/minDiamond/Makefile.in
	test_problems/min_python/negATest/negATest.cpp
	test_problems/mixGasTransport/runtest
	test_problems/nasa9_reader/Makefile.in
	test_problems/nasa9_reader/runtest.in
	test_problems/negATest/negATest.cpp
	test_problems/printUtilUnitTest/pUtest.cpp
	test_problems/pureFluidTest/testPureWater.cpp
	test_problems/silane_equil/silane_equil.cpp
	test_problems/surfkin/surfdemo.cpp
	tools/Makefile.in
	tools/bin/cvs2cl.pl
	tools/src/ck2cti.cpp
	tools/templates/f77/demo_ftnlib.cpp
	win32/vc7/Sundials/sundials/sundials_config.h
	win32/vc9/Sundials/SUNDIALS_SHARED/sundials_config.h
	winconfig.h
2012-02-10 03:21:33 +00:00

336 lines
10 KiB
C++

#include "Cantera.h"
#include "thermo.h"
#include "kernel/WaterSSTP.h"
#include <cstdio>
#include <cmath>
#include <new>
using namespace std;
using namespace Cantera;
double tvalue(double val, double atol = 1.0E-9) {
double rval = val;
if (fabs(val) < atol) {
rval = 0.0;
}
return rval;
}
int main () {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
double pres;
try {
WaterSSTP *w = new WaterSSTP("waterTPphase.xml","");
delete w;
char iFile[80], file_ID[80];
strcpy(iFile, "waterTPphase.xml");
sprintf(file_ID,"%s#water", iFile);
XML_Node *xm = get_XML_NameID("phase", file_ID, 0);
w = new WaterSSTP(*xm);
delete w;
strcpy(iFile, "waterTPphase.xml");
sprintf(file_ID,"%s#water", iFile);
xm = get_XML_NameID("phase", file_ID, 0);
w = new WaterSSTP();
importPhase(*xm, w);
/*
* Print out the triple point conditions
*/
double temp = 273.16;
pres = w->satPressure(temp);
printf("psat(%g) = %g\n", temp, pres);
double presLow = 1.0E-2;
temp = 298.15;
double oneBar = 1.0E5;
double vol;
printf("Comparisons to NIST: (see http://webbook.nist.gov):\n\n");
w->setDensity(1.0E-8);
w->setState_TP(temp, presLow);
double h = w->enthalpy_mole();
printf("H0(298.15) = %g J/kmol\n", h);
double h298 = h;
double s = w->entropy_mole();
s -= GasConstant * log(oneBar/presLow);
printf("S0(298.15) = %g J/kmolK\n", s);
double T[20];
T[0] = 298.15;
T[1] = 500.;
T[2] = 600.;
T[3] = 1000.;
double Cp0, delh0, delg0, g;
double Cp0_ss;
printf("\nIdeal Gas Standard State:\n");
printf (" T Cp0 S0 "
" -(G0-H298)/T H0-H298\n");
printf (" (K) (J/molK) (J/molK) "
" (J/molK) (kJ/mol)\n");
for (int i = 0; i < 4; i++) {
temp = T[i];
w->setState_TP(temp, presLow);
h = w->enthalpy_mole();
delh0 = tvalue(h - h298, 1.0E-6);
g = w->gibbs_mole();
delg0 = (g - h298)/temp + GasConstant * log(oneBar/presLow);
Cp0 = w->cp_mole();
{
w->getCp_R(&Cp0_ss);
Cp0_ss *= GasConstant;
if (fabs(Cp0_ss - Cp0) > 1.0E-5) {
printf("Inconsistency!\n");
exit(-1);
}
}
s = w->entropy_mole();
s -= GasConstant * log(oneBar/presLow);
printf("%10g %10g %13g %13g %13g\n", temp, Cp0*1.0E-3, s*1.0E-3,
-delg0*1.0E-3, delh0*1.0E-6);
}
printf("\n\n");
temp = 298.15;
w->setDensity(1000.);
w->setState_TP(temp, oneBar);
h = w->enthalpy_mole();
printf("H_liq(298.15, onebar) = %g J/kmol\n", h);
double h298l = h;
s = w->entropy_mole();
printf("S_liq(298.15, onebar) = %g J/kmolK\n", s);
T[0] = 273.19;
T[1] = 298.15;
T[2] = 300.;
T[3] = 373.15;
T[4] = 400.;
T[5] = 500.;
printf("\nLiquid 1bar or psat Standard State\n");
printf (" T press psat Cp0 S0 "
" -(G0-H298)/T H0-H298\n");
printf (" (K) (bar) (bar) (J/molK) (J/molK)"
" (J/molK) (kJ/mol)\n");
for (int i = 0; i < 6; i++) {
temp = T[i];
double psat = w->satPressure(temp);
double press = oneBar;
if (psat > press) {
press = psat*1.002;
}
w->setState_TP(temp, press);
h = w->enthalpy_mole();
delh0 = tvalue(h - h298l, 1.0E-6);
g = w->gibbs_mole();
delg0 = (g - h298l)/temp;
Cp0 = w->cp_mole();
s = w->entropy_mole();
printf("%10g %10g %12g %13g %13g %13g %13g\n", temp, press*1.0E-5,
psat*1.0E-5,
Cp0*1.0E-3, s*1.0E-3,
-delg0*1.0E-3, delh0*1.0E-6);
}
printf("\nLiquid Densities:\n");
printf (" T press psat Density molarVol "
"\n");
printf (" (K) (bar) (bar) (kg/m3) (m3/kmol)"
"\n");
for (int i = 0; i < 6; i++) {
temp = T[i];
double psat = w->satPressure(temp);
double press = oneBar;
if (psat > press) {
press = psat*1.002;
}
w->setState_TP(temp, press);
double d = w->density();
double mw = w->molecularWeight(0);
double vbar = mw/d;
// not implemented
//w.getPartialMolarVolumes(&vbar);
printf("%10g %10g %12g %13g %13g\n", temp, press*1.0E-5,
psat*1.0E-5, d, vbar);
}
printf("\nLiquid 1bar or psat State: Partial Molar Quantities\n");
printf (" T press psat Cpbar Sbar "
" -(G0-H298)/T H0-H298 Volume\n");
printf (" (K) (bar) (bar) (J/molK) (J/molK)"
" (J/molK) (kJ/mol) m3/kmol\n");
for (int i = 0; i < 6; i++) {
temp = T[i];
double psat = w->satPressure(temp);
double press = oneBar;
if (psat > press) {
press = psat*1.002;
}
w->setState_TP(temp, press);
w->getPartialMolarEnthalpies(&h);
delh0 = tvalue(h - h298l, 1.0E-6);
w->getChemPotentials(&g);
delg0 = (g - h298l)/temp;
w->getPartialMolarCp(&Cp0);
w->getPartialMolarEntropies(&s);
w->getPartialMolarVolumes(&vol);
printf("%10g %10g %12g %13g %13g %13g %13g %13g\n", temp, press*1.0E-5,
psat*1.0E-5,
Cp0*1.0E-3, s*1.0E-3,
-delg0*1.0E-3, delh0*1.0E-6, vol);
}
printf("\nLiquid 1bar or psat State: Standard State Quantities\n");
printf (" T press psat Cpbar Sbar "
" -(G0-H298)/T H0-H298 Volume\n");
printf (" (K) (bar) (bar) (J/molK) (J/molK)"
" (J/molK) (kJ/mol) m3/kmol\n");
for (int i = 0; i < 6; i++) {
temp = T[i];
double psat = w->satPressure(temp);
double press = oneBar;
if (psat > press) {
press = psat*1.002;
}
w->setState_TP(temp, press);
w->getEnthalpy_RT(&h);
h *= temp * GasConstant;
delh0 = tvalue(h - h298l, 1.0E-6);
w->getStandardChemPotentials(&g);
delg0 = (g - h298l)/temp;
w->getCp_R(&Cp0);
Cp0 *= GasConstant;
w->getEntropy_R(&s);
s *= GasConstant;
w->getStandardVolumes(&vol);
printf("%10g %10g %12g %13g %13g %13g %13g %13g\n", temp, press*1.0E-5,
psat*1.0E-5,
Cp0*1.0E-3, s*1.0E-3,
-delg0*1.0E-3, delh0*1.0E-6, vol);
}
printf("\nLiquid 1bar or psat State: Reference State Quantities (Always 1 atm no matter what system pressure is)\n");
printf (" T press psat Cpbar Sbar "
" -(G0-H298)/T H0-H298 Volume\n");
printf (" (K) (bar) (bar) (J/molK) (J/molK)"
" (J/molK) (kJ/mol) m3/kmol\n");
for (int i = 0; i < 6; i++) {
temp = T[i];
double psat = w->satPressure(temp);
double press = oneBar;
if (psat > press) {
press = psat*1.002;
}
w->setState_TP(temp, press);
w->getEnthalpy_RT_ref(&h);
h *= temp * GasConstant;
delh0 = tvalue(h - h298l, 1.0E-6);
w->getGibbs_ref(&g);
delg0 = (g - h298l)/temp;
w->getCp_R_ref(&Cp0);
Cp0 *= GasConstant;
w->getEntropy_R_ref(&s);
s *= GasConstant;
w->getStandardVolumes_ref(&vol);
printf("%10g %10g %12g %13g %13g %13g %13g %13g\n", temp, press*1.0E-5,
psat*1.0E-5,
Cp0*1.0E-3, s*1.0E-3,
-delg0*1.0E-3, delh0*1.0E-6, vol);
}
printf("\nLiquid 1 atm: Standard State Quantities - Should agree with table above\n");
printf (" T press psat Cpbar Sbar "
" -(G0-H298)/T H0-H298 Volume\n");
printf (" (K) (bar) (bar) (J/molK) (J/molK)"
" (J/molK) (kJ/mol) m3/kmol\n");
for (int i = 0; i < 6; i++) {
temp = T[i];
double psat = w->satPressure(temp);
double press = OneAtm;
w->setState_TP(temp, press);
w->getEnthalpy_RT(&h);
h *= temp * GasConstant;
delh0 = tvalue(h - h298l, 1.0E-6);
w->getStandardChemPotentials(&g);
delg0 = (g - h298l)/temp;
w->getCp_R(&Cp0);
Cp0 *= GasConstant;
w->getEntropy_R(&s);
s *= GasConstant;
w->getStandardVolumes(&vol);
printf("%10g %10g %12g %13g %13g %13g %13g %13g\n", temp, press*1.0E-5,
psat*1.0E-5,
Cp0*1.0E-3, s*1.0E-3,
-delg0*1.0E-3, delh0*1.0E-6, vol);
}
printf("\n\nTable of increasing Enthalpy at 1 atm\n\n");
double dens;
printf(" Enthalpy, Temperature, x_Vapor, Density, Entropy_mass, Gibbs_mass\n");
w->setState_TP(298., OneAtm);
double Hset = w->enthalpy_mass();
double vapFrac = w->vaporFraction();
double Tcalc = w->temperature();
double Scalc = w->entropy_mass();
double Gcalc = w->gibbs_mass();
dens = w->density();
printf(" %10g, %10g, %10g, %11.5g, %11.5g, %11.5g\n", Hset , Tcalc, vapFrac, dens, Scalc, Gcalc);
w->setState_HP(Hset, OneAtm);
vapFrac = w->vaporFraction();
Tcalc = w->temperature();
dens = w->density();
Scalc = w->entropy_mass();
Gcalc = w->gibbs_mass();
printf(" %10g, %10g, %10g, %11.5g, %11.5g, %11.5g\n", Hset , Tcalc, vapFrac, dens, Scalc, Gcalc);
double deltaH = 100000.;
for (int i = 0; i < 40; i++) {
Hset += deltaH;
try {
w->setState_HP(Hset, OneAtm);
} catch (CanteraError) {
printf(" %10g, -> Failed to converge, beyond the spinodal probably \n\n", Hset);
popError();
break;
}
vapFrac = w->vaporFraction();
Tcalc = w->temperature();
dens = w->density();
Scalc = w->entropy_mass();
Gcalc = w->gibbs_mass();
printf(" %10g, %10g, %10g, %11.5g, %11.5g, %11.5g\n", Hset , Tcalc, vapFrac, dens, Scalc, Gcalc);
}
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) {
showErrors();
Cantera::appdelete();
return -1;
}
return 0;
}