From aec61bea67f92d63628fee4ad972970045efb28d Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Tue, 24 Mar 2009 20:35:35 +0000 Subject: [PATCH] Completed the example problem. --- Cantera/python/examples/fuel_cells/.cvsignore | 9 ++ .../python/examples/fuel_cells/Makefile.in | 9 +- Cantera/python/examples/fuel_cells/cleanup | 5 + .../examples/fuel_cells/output_blessed_0.txt | 37 +++++++ Cantera/python/examples/fuel_cells/runtest.in | 64 +++++++++++ .../examples/fuel_cells/sofc_blessed_0.csv | 101 ++++++++++++++++++ 6 files changed, 220 insertions(+), 5 deletions(-) create mode 100755 Cantera/python/examples/fuel_cells/cleanup create mode 100644 Cantera/python/examples/fuel_cells/output_blessed_0.txt create mode 100755 Cantera/python/examples/fuel_cells/runtest.in create mode 100644 Cantera/python/examples/fuel_cells/sofc_blessed_0.csv diff --git a/Cantera/python/examples/fuel_cells/.cvsignore b/Cantera/python/examples/fuel_cells/.cvsignore index f3c7a7c5d..bc9fea132 100644 --- a/Cantera/python/examples/fuel_cells/.cvsignore +++ b/Cantera/python/examples/fuel_cells/.cvsignore @@ -1 +1,10 @@ Makefile +runtest +ct2ctml.log +diff_csv.txt +diff_out_0.txt +h2o2.xml +output_0.txt +sofc.csv +sofc.xml +transport_log.xml diff --git a/Cantera/python/examples/fuel_cells/Makefile.in b/Cantera/python/examples/fuel_cells/Makefile.in index a23f543ec..09e11854d 100644 --- a/Cantera/python/examples/fuel_cells/Makefile.in +++ b/Cantera/python/examples/fuel_cells/Makefile.in @@ -1,16 +1,15 @@ #!/bin/sh -PY_DEMOS = sofc.py PYTHON_CMD = @PYTHON_CMD@ run: - @(for py in $(PY_DEMOS) ; do \ - echo "running $${py}..."; \ - $(PYTHON_CMD) "$${py}"; \ - done) + $(PYTHON_CMD) sofc.py +test: + ./runtest clean: rm -f *.log *.csv *.xml + ./cleanup # end of file diff --git a/Cantera/python/examples/fuel_cells/cleanup b/Cantera/python/examples/fuel_cells/cleanup new file mode 100755 index 000000000..40e1dbd9e --- /dev/null +++ b/Cantera/python/examples/fuel_cells/cleanup @@ -0,0 +1,5 @@ +#!/bin/sh +# +/bin/rm -rf equilibrate_log*.html +/bin/rm -rf .cttmp* ct2ctml.log transport_log.xml vcs_equilibrate_res*.csv \ + catcomb.csv output_0.txt diff* diff --git a/Cantera/python/examples/fuel_cells/output_blessed_0.txt b/Cantera/python/examples/fuel_cells/output_blessed_0.txt new file mode 100644 index 000000000..39c725a87 --- /dev/null +++ b/Cantera/python/examples/fuel_cells/output_blessed_0.txt @@ -0,0 +1,37 @@ + + anode surface + + (m) 0.6187 + H(m) 0.3811 + O(m) 8.63e-05 + OH(m) 2.593e-06 + H2O(m) 5.057e-05 + + anode-side oxide surface + + (ox) 0.04994 + O''(ox) 0.9489 + OH'(ox) 0.001128 + H2O(ox) 3.359e-08 + + cathode surface + + (m) 1.482e-07 + H(m) 7.573e-14 + O(m) 1 + OH(m) 2.492e-08 + H2O(m) 4.033e-13 + + cathode-side oxide surface + + (ox) 0.04999 + O''(ox) 0.9498 + OH'(ox) 0.0002061 + H2O(ox) 1.12e-09 + +ocv from zero current is: 1.1375780672 +OCV from thermo equil is: 1.1375780672 +Ea0 = -0.733444291655 +Ec0 = 0.404133775541 + +polarization curve data written to file sofc.csv diff --git a/Cantera/python/examples/fuel_cells/runtest.in b/Cantera/python/examples/fuel_cells/runtest.in new file mode 100755 index 000000000..e615d43cf --- /dev/null +++ b/Cantera/python/examples/fuel_cells/runtest.in @@ -0,0 +1,64 @@ +#!/bin/sh +# +# +temp_success="1" +/bin/rm -f output_0.txt sofc.csv diff_csv.txt diff_out_0.txt + +########################################################################## +PYTHON_CMD=@PYTHON_CMD@ +prog=sofc.py +if test ! -f $prog ; then + echo $prog ' does not exist' + exit -1 +fi +################################################################# +# +CANTERA_DATA=${CANTERA_DATA:=../../../data/inputs}; export CANTERA_DATA +CANTERA_BIN=${CANTERA_BIN:=../../../bin} + +################################################################# + +$PYTHON_CMD $prog > output_0.txt <<+ +1.0 ++ +retnStat=$? +if [ $retnStat != "0" ] +then + temp_success="0" + echo "$prog returned with bad status, $retnStat, check output" +fi + +diff -w output_blessed_0.txt output_0.txt > diff_out_0.txt +retnStat_0=$? + +csvdiff -a 1.0E-50 sofc_blessed_0.csv sofc.csv > diff_csv.txt +retnStat_csv_0=$? + +retnTotal=1 +if test $retnStat_0 = "0" +then + retnTotal=0 +fi + +retnCSVTotal=1 +if test $retnStat_csv_0 = "1" +then + retnCSVTotal=0 +fi + +if test $retnCSVTotal = "0" +then + echo "Successful test comparison on "`pwd` + if test $retnTotal = "1" + then + echo " But text files show differences. See diff_out_0.txt" + fi +else + echo "Unsuccessful test comparison of csv files on "`pwd` " test" + echo " see diff_csv.txt " + if test $retnTotal != "0" + then + echo " ASCII files are different too - see diff_test*.txt" + fi +fi + diff --git a/Cantera/python/examples/fuel_cells/sofc_blessed_0.csv b/Cantera/python/examples/fuel_cells/sofc_blessed_0.csv new file mode 100644 index 000000000..e56eb6596 --- /dev/null +++ b/Cantera/python/examples/fuel_cells/sofc_blessed_0.csv @@ -0,0 +1,101 @@ +i (mA/cm2), eta_a, eta_c, eta_ohmic, Eload, +-1379.8727404477677, -0.25, 0.52790789464995425, -0.34496818511194188, 2.2604541469580886, +-1308.5936677595089, -0.245, 0.52300318943292878, -0.32714841693987723, 2.2327296735689988, +-1240.9507124396077, -0.23999999999999999, 0.51809507709580627, -0.31023767810990188, 2.2059108224019006, +-1176.751942053203, -0.23499999999999999, 0.5131828635981931, -0.29418798551330078, 2.1799489163076866, +-1115.8153602379441, -0.22999999999999998, 0.50826577298544739, -0.27895384005948604, 2.1547976802411259, +-1057.9683787270083, -0.22499999999999998, 0.50334293814461339, -0.26449209468175205, 2.1304131000225581, +-1003.0473167860237, -0.21999999999999997, 0.49841339045467503, -0.25076182919650591, 2.1067532868473737, +-950.8969266032409, -0.21499999999999997, 0.49347604818236179, -0.23772423165081025, 2.0837783470293645, +-901.36994324809666, -0.20999999999999996, 0.48852970345119306, -0.22534248581202415, 2.0614502564594099, +-854.32665788509894, -0.20499999999999996, 0.48357300758344202, -0.21358166447127475, 2.0397327392509093, +-809.63451299790074, -0.19999999999999996, 0.47860445458123801, -0.20240862824947517, 2.0185911500269058, +-767.1677184427341, -0.19499999999999995, 0.47362236247291811, -0.19179192961068353, 1.9979923592797943, +-726.80688721120407, -0.18999999999999995, 0.46862485220230521, -0.18170172180280103, 1.9779046412012988, +-688.43868984001131, -0.18500000000000005, 0.4636098236800118, -0.17210967246000283, 1.9582975633362074, +-651.95552645967075, -0.17999999999999994, 0.45857492854444237, -0.1629888816149177, 1.9391418773555527, +-617.25521552579244, -0.17500000000000004, 0.45351753909278947, -0.15431380388144811, 1.9204094101704303, +-584.24069832521434, -0.17000000000000004, 0.44843471273470792, -0.1460601745813036, 1.9020729545122044, +-552.81975839538188, -0.16500000000000004, 0.44332315118816379, -0.13820493959884547, 1.8841061579832021, +-522.9047550388849, -0.16000000000000003, 0.43817915347096548, -0.13072618875972122, 1.8664834094268794, +-494.41237015626484, -0.15500000000000003, 0.43299856153350302, -0.12360309253906622, 1.849179721268762, +-467.26336765910764, -0.15000000000000002, 0.42777669711565525, -0.11681584191477691, 1.832170606226625, +-441.38236476212944, -0.14500000000000002, 0.42250828807717888, -0.11034559119053236, 1.8154319464639039, +-416.69761448771652, -0.14000000000000001, 0.41718738202369776, -0.10417440362192913, 1.7989398528418197, +-393.14079874908748, -0.13500000000000001, 0.41180724449906314, -0.098285199687271868, 1.7826705113825279, +-370.6468314091519, -0.13, 0.40636023829737644, -0.092661707852287972, 1.7666000133458573, +-349.15367074127528, -0.125, 0.40083767950577198, -0.087288417685318823, 1.7507041643872836, +-328.60214074560082, -0.12, 0.39522966463999809, -0.082150535186400211, 1.7349582670225909, +-308.93576080045727, -0.11499999999999999, 0.38952486156173738, -0.077233940200114315, 1.7193368689580444, +-290.10058315271203, -0.10999999999999999, 0.38371025460066011, -0.072525145788178008, 1.7038134675850309, +-272.04503777381836, -0.10499999999999998, 0.37777083119846233, -0.068011259443454597, 1.6883601578381096, +-254.71978412981275, -0.099999999999999978, 0.37168919307988069, -0.063679946032453194, 1.6729472063085264, +-238.07756943371214, -0.094999999999999973, 0.36544506888355821, -0.059519392358428042, 1.6575425284381788, +-222.07309296768409, -0.089999999999999969, 0.35901469650317808, -0.055518273241921025, 1.6421110369412917, +-206.66287608008872, -0.084999999999999964, 0.3523700307643538, -0.051665719020022177, 1.6266138169805686, +-191.80513747905277, -0.07999999999999996, 0.34547771336289645, -0.047951284369763196, 1.6110070649288524, +-177.45967345971155, -0.074999999999999956, 0.33829771372158823, -0.044364918364927883, 1.5952406992827086, +-163.58774271665231, -0.070000000000000062, 0.33078150570995457, -0.040896935679163075, 1.5792565085853103, +-150.15195540647898, -0.064999999999999947, 0.32286957584483644, -0.037537988851619741, 1.5629856318926487, +-137.11616613783454, -0.060000000000000053, 0.31448794546685932, -0.034279041534458633, 1.5463450541975106, +-124.44537057766341, -0.054999999999999938, 0.30554319875698555, -0.031111342644415851, 1.529232608597594, +-112.10560537308905, -0.050000000000000044, 0.29591517517078447, -0.028026401343272261, 1.5115196437102494, +-100.0638510979181, -0.044999999999999929, 0.28544587692104173, -0.025015962774479525, 1.4930399068917137, +-88.28793794165432, -0.040000000000000036, 0.27392197698607212, -0.02207198448541358, 1.4735720286676783, +-76.746453866872528, -0.035000000000000031, 0.26104594594648167, -0.019186613466718131, 1.4528106266093925, +-65.408654968048907, -0.030000000000000027, 0.24638565912829768, -0.016352163742012225, 1.4303158900665025, +-54.244377771331443, -0.025000000000000022, 0.22928011779855484, -0.01356109444283286, 1.4054192794375804, +-43.223953220432634, -0.020000000000000018, 0.20864673303806058, -0.010805988305108158, 1.3770307885393613, +-32.318122098725098, -0.015000000000000013, 0.18253925318303621, -0.0080795305246812756, 1.3431968509039103, +-21.497951641830568, -0.010000000000000009, 0.14697091459643052, -0.0053744879104576423, 1.299923469703081, +-10.734753098454805, -0.0050000000000000044, 0.09231323307431788, -0.0026836882746137012, 1.2375749885451244, +9.255403119152559e-14, 0.0, -9.9920072216264089e-16, 2.3138507797881399e-17, 1.1375780671961917, +10.734753098454892, 0.0050000000000000044, -0.092313233074318268, 0.0026836882746137229, 1.0375811458472608, +21.497951641830351, 0.010000000000000009, -0.14697091459642964, 0.0053744879104575876, 0.97523266468930547, +32.318122098725006, 0.015000000000000013, -0.18253925318303599, 0.0080795305246812513, 0.93195928348847545, +43.223953220432556, 0.020000000000000018, -0.20864673303806042, 0.010805988305108139, 0.89812534585302406, +54.244377771331294, 0.025000000000000022, -0.22928011779855437, 0.013561094442832823, 0.86973685495480546, +65.408654968048211, 0.030000000000000027, -0.24638565912829663, 0.016352163742012052, 0.844840244325884, +76.746453866871832, 0.035000000000000031, -0.26104594594648067, 0.019186613466717958, 0.82234550778299398, +88.287937941653468, 0.040000000000000036, -0.27392197698607146, 0.022071984485413369, 0.80158410572470784, +100.06385109791724, 0.044999999999999929, -0.28544587692104073, 0.02501596277447931, 0.78211622750067267, +112.1056053730875, 0.050000000000000044, -0.29591517517078325, 0.028026401343271876, 0.76363649068213746, +124.44537057766134, 0.054999999999999938, -0.30554319875698405, 0.031111342644415334, 0.74592352579479337, +137.11616613783232, 0.060000000000000053, -0.31448794546685754, 0.034279041534458085, 0.72881108019487706, +150.15195540647633, 0.064999999999999947, -0.32286957584483472, 0.037537988851619082, 0.7121705024997389, +163.58774271664916, 0.070000000000000062, -0.33078150570995302, 0.040896935679162291, 0.69589962580707732, +177.45967345970769, 0.074999999999999956, -0.33829771372158618, 0.044364918364926925, 0.67991543510967967, +191.80513747904905, 0.080000000000000071, -0.3454777133628944, 0.047951284369762259, 0.66414906946353591, +206.66287608008406, 0.084999999999999964, -0.35237003076435192, 0.051665719020021018, 0.64854231741181978, +222.07309296767914, 0.09000000000000008, -0.35901469650317608, 0.055518273241919783, 0.63304509745109672, +238.07756943370575, 0.094999999999999973, -0.36544506888355555, 0.059519392358426439, 0.61761360595421078, +254.71978412980644, 0.10000000000000009, -0.37168919307987858, 0.063679946032451612, 0.60220892808386239, +272.04503777381086, 0.10499999999999998, -0.3777708311984595, 0.06801125944345271, 0.58679597655428051, +290.10058315270379, 0.10999999999999999, -0.38371025460065744, 0.07252514578817594, 0.57134266680735935, +308.9357608004475, 0.11499999999999999, -0.38952486156173421, 0.077233940200111872, 0.55581926543434668, +328.60214074559059, 0.12, -0.39522966463999532, 0.082150535186397644, 0.5401978673697998, +349.15367074126402, 0.125, -0.40083767950576893, 0.087288417685315992, 0.52445197000510779, +370.64683140913951, 0.13, -0.40636023829737339, 0.092661707852284877, 0.50855612104653447, +393.1407987490731, 0.13500000000000001, -0.4118072444990597, 0.098285199687268274, 0.4924856230098647, +416.6976144877018, 0.14000000000000001, -0.41718738202369415, 0.10417440362192545, 0.47621628155057305, +441.38236476211318, 0.14500000000000002, -0.4225082880771755, 0.11034559119052829, 0.4597241879284889, +467.26336765909014, 0.15000000000000002, -0.42777669711565164, 0.11681584191477253, 0.44298552816576853, +494.41237015624495, 0.15500000000000003, -0.43299856153349936, 0.12360309253906124, 0.4259764131236321, +522.9047550388633, 0.16000000000000003, -0.43817915347096159, 0.13072618875971584, 0.40867272496551521, +552.81975839535926, 0.16500000000000004, -0.44332315118815985, 0.13820493959883981, 0.39104997640919298, +584.24069832518887, 0.16999999999999993, -0.44843471273470414, 0.14606017458129722, 0.37308317988019146, +617.25521552576481, 0.17500000000000004, -0.45351753909278503, 0.1543138038814412, 0.35474672422196646, +651.95552645964119, 0.17999999999999994, -0.45857492854443821, 0.16298888161491029, 0.33601425703684429, +688.43868983998118, 0.18500000000000005, -0.46360982368000758, 0.17210967245999528, 0.31685857105618975, +726.80688721117087, 0.18999999999999995, -0.46862485220230088, 0.18170172180279273, 0.29725149319109911, +767.1677184426992, 0.19500000000000006, -0.47362236247291384, 0.19179192961067479, 0.27716377511260404, +809.63451299786084, 0.19999999999999996, -0.47860445458123357, 0.20240862824946521, 0.25656498436549396, +854.32665788505858, 0.20500000000000007, -0.48357300758343724, 0.21358166447126464, 0.23542339514149074, +901.36994324805278, 0.20999999999999996, -0.48852970345118879, 0.22534248581201319, 0.21370587793299078, +950.89692660319452, 0.21500000000000008, -0.49347604818235752, 0.23772423165079865, 0.19137778736303646, +1003.0473167859717, 0.21999999999999997, -0.49841339045467059, 0.25076182919649292, 0.16840284754502921, +1057.9683787269548, 0.22500000000000009, -0.50334293814460884, 0.26449209468173873, 0.14474303436984498, +1115.8153602378859, 0.22999999999999998, -0.50826577298544251, 0.27895384005947149, 0.12035845415127866, +1176.7519420531405, 0.23499999999999999, -0.5131828635981881, 0.29418798551328518, 0.095207218084719381, +1240.9507124395388, 0.23999999999999999, -0.51809507709580105, 0.31023767810988473, 0.069245311990506875, +1308.5936677594379, 0.245, -0.52300318943292379, 0.32714841693985947, 0.042426460823409451,