From 64ec9d2c3f57ffc00fc0b64c9ca94a08606a14ef Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Thu, 19 Mar 2009 20:05:03 +0000 Subject: [PATCH] Added a new dir. --- .../examples/reactors/functors_sim/.cvsignore | 5 + .../reactors/functors_sim/Makefile.in | 15 +++ .../examples/reactors/functors_sim/cleanup | 5 + .../reactors/functors_sim/functors.py | 19 ++++ .../functors_sim/output_blessed_0.txt | 102 ++++++++++++++++++ .../examples/reactors/functors_sim/runtest.in | 46 ++++++++ 6 files changed, 192 insertions(+) create mode 100644 Cantera/python/examples/reactors/functors_sim/.cvsignore create mode 100644 Cantera/python/examples/reactors/functors_sim/Makefile.in create mode 100755 Cantera/python/examples/reactors/functors_sim/cleanup create mode 100644 Cantera/python/examples/reactors/functors_sim/functors.py create mode 100644 Cantera/python/examples/reactors/functors_sim/output_blessed_0.txt create mode 100755 Cantera/python/examples/reactors/functors_sim/runtest.in diff --git a/Cantera/python/examples/reactors/functors_sim/.cvsignore b/Cantera/python/examples/reactors/functors_sim/.cvsignore new file mode 100644 index 000000000..ee46f1d22 --- /dev/null +++ b/Cantera/python/examples/reactors/functors_sim/.cvsignore @@ -0,0 +1,5 @@ +Makefile +runtest +ct2ctml.log +diff_out_0.txt +output_0.txt diff --git a/Cantera/python/examples/reactors/functors_sim/Makefile.in b/Cantera/python/examples/reactors/functors_sim/Makefile.in new file mode 100644 index 000000000..d464af79a --- /dev/null +++ b/Cantera/python/examples/reactors/functors_sim/Makefile.in @@ -0,0 +1,15 @@ +#!/bin/sh + +PYTHON_CMD = @PYTHON_CMD@ + +run: + $(PYTHON_CMD) functors.py + +test: + ./runtest +clean: + rm -f *.log *.csv *.xml + ./cleanup + +# end of file + diff --git a/Cantera/python/examples/reactors/functors_sim/cleanup b/Cantera/python/examples/reactors/functors_sim/cleanup new file mode 100755 index 000000000..e17708780 --- /dev/null +++ b/Cantera/python/examples/reactors/functors_sim/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 \ + output_0.txt diff* diff --git a/Cantera/python/examples/reactors/functors_sim/functors.py b/Cantera/python/examples/reactors/functors_sim/functors.py new file mode 100644 index 000000000..c3c08f3a4 --- /dev/null +++ b/Cantera/python/examples/reactors/functors_sim/functors.py @@ -0,0 +1,19 @@ +# This example shows how to create 'functors' - objects that evaluate +# functions. These are useful for specifying the expansion rate or +# heat flux at a wall. + +from Cantera.Func import * + +# create f1(t) = 4 + 6t + 8t^2 + t^3 +f1 = Polynomial([4.0, 6.0, 8.0, 1.0]) + +# create sin(t) +f2 = Fourier(1.0, [(0.0, 0.0), (0.0, 1.0)]) + +# functors can be combined by +,*,or / to create new functors +f3 = f2*f2 + +xpts = 0.1*array(range(100)) + +for x in xpts: + print x, f1(x), f2(x), f3(x) diff --git a/Cantera/python/examples/reactors/functors_sim/output_blessed_0.txt b/Cantera/python/examples/reactors/functors_sim/output_blessed_0.txt new file mode 100644 index 000000000..34d8a5233 --- /dev/null +++ b/Cantera/python/examples/reactors/functors_sim/output_blessed_0.txt @@ -0,0 +1,102 @@ +DUPL ERR: ID = 0 +DUPL ERR: ID = 0 +0.0 4.0 0.0 0.0 +0.1 4.681 0.0998334166468 0.0 +0.2 5.528 0.198669330795 0.0 +0.3 6.547 0.295520206661 0.0 +0.4 7.744 0.389418342309 0.0 +0.5 9.125 0.479425538604 0.0 +0.6 10.696 0.564642473395 0.0 +0.7 12.463 0.644217687238 0.0 +0.8 14.432 0.7173560909 0.0 +0.9 16.609 0.783326909627 0.0 +1.0 19.0 0.841470984808 0.0 +1.1 21.611 0.891207360061 0.0 +1.2 24.448 0.932039085967 0.0 +1.3 27.517 0.963558185417 0.0 +1.4 30.824 0.985449729988 0.0 +1.5 34.375 0.997494986604 0.0 +1.6 38.176 0.999573603042 0.0 +1.7 42.233 0.991664810452 0.0 +1.8 46.552 0.973847630878 0.0 +1.9 51.139 0.946300087687 0.0 +2.0 56.0 0.909297426826 0.0 +2.1 61.141 0.863209366649 0.0 +2.2 66.568 0.80849640382 0.0 +2.3 72.287 0.745705212177 0.0 +2.4 78.304 0.675463180551 0.0 +2.5 84.625 0.598472144104 0.0 +2.6 91.256 0.515501371821 0.0 +2.7 98.203 0.427379880234 0.0 +2.8 105.472 0.334988150156 0.0 +2.9 113.069 0.239249329214 0.0 +3.0 121.0 0.14112000806 0.0 +3.1 129.271 0.0415806624333 0.0 +3.2 137.888 -0.0583741434276 0.0 +3.3 146.857 -0.157745694143 0.0 +3.4 156.184 -0.255541102027 0.0 +3.5 165.875 -0.35078322769 0.0 +3.6 175.936 -0.442520443295 0.0 +3.7 186.373 -0.529836140908 0.0 +3.8 197.192 -0.611857890943 0.0 +3.9 208.399 -0.687766159184 0.0 +4.0 220.0 -0.756802495308 0.0 +4.1 232.001 -0.818277111064 0.0 +4.2 244.408 -0.871575772414 0.0 +4.3 257.227 -0.916165936749 0.0 +4.4 270.464 -0.95160207389 0.0 +4.5 284.125 -0.977530117665 0.0 +4.6 298.216 -0.993691003633 0.0 +4.7 312.743 -0.999923257564 0.0 +4.8 327.712 -0.996164608836 0.0 +4.9 343.129 -0.982452612624 0.0 +5.0 359.0 -0.958924274663 0.0 +5.1 375.331 -0.925814682328 0.0 +5.2 392.128 -0.88345465572 0.0 +5.3 409.397 -0.832267442224 0.0 +5.4 427.144 -0.772764487556 0.0 +5.5 445.375 -0.70554032557 0.0 +5.6 464.096 -0.631266637872 0.0 +5.7 483.313 -0.550685542598 0.0 +5.8 503.032 -0.464602179414 0.0 +5.9 523.259 -0.37387666483 0.0 +6.0 544.0 -0.279415498199 0.0 +6.1 565.261 -0.182162504272 0.0 +6.2 587.048 -0.0830894028175 0.0 +6.3 609.367 0.0168139004844 0.0 +6.4 632.224 0.11654920485 0.0 +6.5 655.625 0.215119988088 0.0 +6.6 679.576 0.311541363513 0.0 +6.7 704.083 0.404849920617 0.0 +6.8 729.152 0.494113351139 0.0 +6.9 754.789 0.578439764388 0.0 +7.0 781.0 0.656986598719 0.0 +7.1 807.791 0.728969040126 0.0 +7.2 835.168 0.793667863849 0.0 +7.3 863.137 0.850436620629 0.0 +7.4 891.704 0.898708095812 0.0 +7.5 920.875 0.937999976775 0.0 +7.6 950.656 0.967919672031 0.0 +7.7 981.053 0.988168233877 0.0 +7.8 1012.072 0.998543345375 0.0 +7.9 1043.719 0.99894134184 0.0 +8.0 1076.0 0.989358246623 0.0 +8.1 1108.921 0.969889810845 0.0 +8.2 1142.488 0.94073055668 0.0 +8.3 1176.707 0.902171833756 0.0 +8.4 1211.584 0.854598908088 0.0 +8.5 1247.125 0.798487112623 0.0 +8.6 1283.336 0.734397097874 0.0 +8.7 1320.223 0.662969230082 0.0 +8.8 1357.792 0.584917192892 0.0 +8.9 1396.049 0.501020856458 0.0 +9.0 1435.0 0.412118485242 0.0 +9.1 1474.651 0.319098362349 0.0 +9.2 1515.008 0.2228899141 0.0 +9.3 1556.077 0.124454423507 0.0 +9.4 1597.864 0.0247754254534 0.0 +9.5 1640.375 -0.0751511204618 0.0 +9.6 1683.616 -0.174326781223 0.0 +9.7 1727.593 -0.271760626411 0.0 +9.8 1772.312 -0.366479129252 0.0 +9.9 1817.779 -0.457535893775 0.0 diff --git a/Cantera/python/examples/reactors/functors_sim/runtest.in b/Cantera/python/examples/reactors/functors_sim/runtest.in new file mode 100755 index 000000000..c863c97a1 --- /dev/null +++ b/Cantera/python/examples/reactors/functors_sim/runtest.in @@ -0,0 +1,46 @@ +#!/bin/sh +# +# +temp_success="1" +/bin/rm -f output_0.txt diff_csv.txt diff_out_0.txt + +########################################################################## +PYTHON_CMD=@PYTHON_CMD@ +prog=functors.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=$? + +retnTotal=1 +if test $retnStat_0 = "0" +then + retnTotal=0 +fi + +if test $retnTotal = "0" +then + echo "Successful test comparison on "`pwd` +else + echo "Unsuccessful test comparison of csv files on "`pwd` " test" + echo " ASCII files are different - see diff_test*.txt" +fi