From f8111bc15c9e80d43c3d869bcc5c6b13fae27912 Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Tue, 6 May 2003 14:20:09 +0000 Subject: [PATCH] fixed errors --- tools/templates/cxx/demo.cpp | 56 +++++++++++++++++++-------------- tools/templates/cxx/demo.mak.in | 2 +- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/tools/templates/cxx/demo.cpp b/tools/templates/cxx/demo.cpp index 808127bd7..c1bc1030d 100644 --- a/tools/templates/cxx/demo.cpp +++ b/tools/templates/cxx/demo.cpp @@ -5,41 +5,49 @@ #include "Cantera.h" #include "IdealGasMix.h" +#include "equilibrium.h" + using namespace Cantera; -main() { +int main() { IdealGasMix gas("h2o2.xml"); - gas.setState_TPX_String(1200.0, OneAtm, - "H2:2, O2:1, OH:0.01, H:0.01, O:0.01"); + double temp = 1200.0; + double pres = OneAtm; + gas.setState_TPX(temp, pres, "H2:2, O2:1, OH:0.01, H:0.01, O:0.01"); equilibrate(gas,"HP"); - printf("**** C++ Test Program ****\n\n"); + printf("\n\n**** C++ Test Program ****\n\n"); + + + // Thermodynamic properties + printf( - "Temperature: 14.5g K\n" - "Pressure: 14.5g Pa\n" - "Density: 14.5g kg/m3\n" - "Molar Enthalpy: 14.5g J/kmol\n" - "Molar Entropy: 14.5g J/kmol-K\n" - "Molar cp: 14.5g J/kmol-K\n", + "Temperature: %14.5g K\n" + "Pressure: %14.5g Pa\n" + "Density: %14.5g kg/m3\n" + "Molar Enthalpy: %14.5g J/kmol\n" + "Molar Entropy: %14.5g J/kmol-K\n" + "Molar cp: %14.5g J/kmol-K\n", gas.temperature(), gas.pressure(), gas.density(), gas.enthalpy_mole(), gas.entropy_mole(), gas.cp_mole()); + // Reaction information + + int irxns = gas.nReactions(); + double* qf = new double[irxns]; + double* qr = new double[irxns]; + double* q = new double[irxns]; + + gas.getFwdRatesOfProgress(qf); + gas.getRevRatesOfProgress(qr); + gas.getNetRatesOfProgress(q); + + for (int i = 0; i < irxns; i++) { + printf("%30s %14.5g %14.5g %14.5g \n", + gas.reactionString(i).c_str(), qf[i], qr[i], q[i]); + } -// c -// c Reaction information -// c -// irxns = nReactions() -// call getFwdRatesOfProgress(qf) -// call getRevRatesOfProgress(qr) -// call getNetRatesOfProgress(q) -// do i = 1,irxns -// call getReactionEqn(i,eq) -// write(*,20) eq,qf(i),qr(i),q(i) -// 20 format(a20,3g14.5,' kmol/m3/s') -// end do -// stop -// end } diff --git a/tools/templates/cxx/demo.mak.in b/tools/templates/cxx/demo.mak.in index 1b5225ea6..6c5838719 100644 --- a/tools/templates/cxx/demo.mak.in +++ b/tools/templates/cxx/demo.mak.in @@ -55,7 +55,7 @@ DEPENDS = $(OBJS:.o=.d) all: $(PROGRAM) $(PROGRAM): $(OBJS) - $(CXX) -o $(PROGRAM) $(OBJS) $(LCXX_FLAGS) $(CANTERA_LIBS) $(LINK_OPTIONS) $(EXT_LIBS) @LIBS@ + $(CXX) -o $(PROGRAM) $(OBJS) $(LCXX_FLAGS) $(CANTERA_LIBS) $(LINK_OPTIONS) $(EXT_LIBS) @LIBS@ @FLIBS@ %.d: g++ -MM $*.cpp > $*.d