diff --git a/Cantera/src/equil/MultiPhase.cpp b/Cantera/src/equil/MultiPhase.cpp index 594e243a4..be7111f2f 100644 --- a/Cantera/src/equil/MultiPhase.cpp +++ b/Cantera/src/equil/MultiPhase.cpp @@ -533,7 +533,8 @@ namespace Cantera { int i; doublereal sum = 0; for (i = 0; i < int(m_np); i++) { - sum += m_moles[i]/m_phase[i]->molarDensity(); + double vol = 1.0/m_phase[i]->molarDensity(); + sum += m_moles[i] * vol; } return sum; } diff --git a/test_problems/VCSnonideal/NaCl_equil/runtest b/test_problems/VCSnonideal/NaCl_equil/runtest index 6397b25f6..489e71163 100755 --- a/test_problems/VCSnonideal/NaCl_equil/runtest +++ b/test_problems/VCSnonideal/NaCl_equil/runtest @@ -31,7 +31,7 @@ retnStat_txt=$? $BINDIR/csvdiff -a 1.0E-50 vcs_equilibrate_blessed.csv vcs_equilibrate_res.csv > diff_csv.txt retnStat_csv=$? -if test $retnStat_csv = "1" +if test $retnStat_csv = "0" then echo "Successful test comparison on "`pwd` if [ $retnStat_txt != "0" ] diff --git a/test_problems/VCSnonideal/NaCl_equil/runtestd b/test_problems/VCSnonideal/NaCl_equil/runtestd index b8b7da443..453ec1d11 100755 --- a/test_problems/VCSnonideal/NaCl_equil/runtestd +++ b/test_problems/VCSnonideal/NaCl_equil/runtestd @@ -42,7 +42,7 @@ retnStat_txt=$? $BINDIR/csvdiff -a 1.0E-50 vcs_equilibrate_blessed.csv vcs_equilibrate_res.csv > diff_csv.txt retnStat_csv=$? -if test $retnStat_csv = "1" +if test $retnStat_csv = "0" then echo "Successful test comparison on "`pwd` if [ $retnStat_txt != "0" ] diff --git a/test_problems/python/flame1/output_blessed.txt b/test_problems/python/flame1/output_blessed.txt index 4980f4802..57e085ca2 100644 --- a/test_problems/python/flame1/output_blessed.txt +++ b/test_problems/python/flame1/output_blessed.txt @@ -116,7 +116,17 @@ Problem solved on [13] point grid(s). ############################################################################## Refining grid in flame. - New points inserted after grid points 0 1 + New points inserted after grid points 0 + to resolve H2O2 HO2 +.............................................................................. + +Attempt Newton solution of steady-state problem... success. + +Problem solved on [14] point grid(s). + +############################################################################## +Refining grid in flame. + New points inserted after grid points 0 to resolve H2O2 HO2 .............................................................................. @@ -127,7 +137,62 @@ Problem solved on [15] point grid(s). ############################################################################## Refining grid in flame. New points inserted after grid points 0 - to resolve H2O2 HO2 + to resolve HO2 +.............................................................................. + +Attempt Newton solution of steady-state problem... success. + +Problem solved on [16] point grid(s). + +no new points needed in flame +.............................................................................. + +Attempt Newton solution of steady-state problem... failure. + +.............................................................................. +Take 1 timesteps 7.5e-06 5.055 +.............................................................................. + +Attempt Newton solution of steady-state problem... failure. + +.............................................................................. +Take 2 timesteps 8.438e-06 5.05 +.............................................................................. + +Attempt Newton solution of steady-state problem... failure. + +.............................................................................. +Take 5 timesteps 3.204e-05 5.045 +.............................................................................. + +Attempt Newton solution of steady-state problem... failure. + +.............................................................................. +Take 10 timesteps 0.0002309 4.993 +.............................................................................. + +Attempt Newton solution of steady-state problem... failure. + +.............................................................................. +Take 10 timesteps 0.0008323 4.76 +.............................................................................. + +Attempt Newton solution of steady-state problem... failure. + +.............................................................................. +Take 10 timesteps 0.0007499 4.434 +.............................................................................. + +Attempt Newton solution of steady-state problem... failure. + +.............................................................................. +Take 10 timesteps 0.002703 4.143 +.............................................................................. + +Attempt Newton solution of steady-state problem... failure. + +.............................................................................. +Take 10 timesteps 0.002435 3.937 .............................................................................. Attempt Newton solution of steady-state problem... success. @@ -136,107 +201,48 @@ Problem solved on [16] point grid(s). ############################################################################## Refining grid in flame. - New points inserted after grid points 0 - to resolve HO2 -.............................................................................. - -Attempt Newton solution of steady-state problem... success. - -Problem solved on [17] point grid(s). - -no new points needed in flame -.............................................................................. - -Attempt Newton solution of steady-state problem... failure. - -.............................................................................. -Take 1 timesteps 7.5e-06 5.054 -.............................................................................. - -Attempt Newton solution of steady-state problem... failure. - -.............................................................................. -Take 2 timesteps 8.438e-06 5.049 -.............................................................................. - -Attempt Newton solution of steady-state problem... failure. - -.............................................................................. -Take 5 timesteps 3.204e-05 5.044 -.............................................................................. - -Attempt Newton solution of steady-state problem... failure. - -.............................................................................. -Take 10 timesteps 0.0002309 4.991 -.............................................................................. - -Attempt Newton solution of steady-state problem... failure. - -.............................................................................. -Take 10 timesteps 0.0008323 4.751 -.............................................................................. - -Attempt Newton solution of steady-state problem... failure. - -.............................................................................. -Take 10 timesteps 0.0015 4.747 -.............................................................................. - -Attempt Newton solution of steady-state problem... failure. - -.............................................................................. -Take 10 timesteps 0.001351 4.316 -.............................................................................. - -Attempt Newton solution of steady-state problem... success. - -Problem solved on [17] point grid(s). - -############################################################################## -Refining grid in flame. - New points inserted after grid points 0 1 2 3 4 5 6 7 8 9 10 11 12 13 + New points inserted after grid points 0 1 2 3 4 5 6 7 8 9 10 11 12 to resolve H H2 H2O H2O2 HO2 O O2 OH T u .............................................................................. Attempt Newton solution of steady-state problem... success. -Problem solved on [31] point grid(s). +Problem solved on [29] point grid(s). ############################################################################## Refining grid in flame. - New points inserted after grid points 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 22 23 26 27 + New points inserted after grid points 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 20 21 24 25 to resolve H H2 H2O H2O2 HO2 O O2 OH T u .............................................................................. Attempt Newton solution of steady-state problem... success. -Problem solved on [54] point grid(s). +Problem solved on [50] point grid(s). ############################################################################## Refining grid in flame. - New points inserted after grid points 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 47 + New points inserted after grid points 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 43 to resolve H H2 H2O H2O2 HO2 O O2 OH T u .............................................................................. Attempt Newton solution of steady-state problem... success. -Problem solved on [74] point grid(s). +Problem solved on [71] point grid(s). ############################################################################## Refining grid in flame. - New points inserted after grid points 0 1 2 3 5 6 7 8 9 10 11 12 13 14 16 17 24 25 26 27 28 29 30 31 32 33 - to resolve H H2 H2O H2O2 HO2 O O2 + New points inserted after grid points 0 1 2 3 5 6 7 8 9 10 11 12 13 14 16 17 24 25 26 27 28 29 30 31 32 33 34 + to resolve H H2 H2O H2O2 HO2 O O2 OH .............................................................................. Attempt Newton solution of steady-state problem... success. -Problem solved on [100] point grid(s). +Problem solved on [98] point grid(s). ############################################################################## Refining grid in flame. - New points inserted after grid points 0 1 2 - to resolve H2O2 HO2 + New points inserted after grid points 0 1 2 56 57 + to resolve H2O2 HO2 O .............................................................................. Attempt Newton solution of steady-state problem... success. diff --git a/test_problems/python/flame1/runtest b/test_problems/python/flame1/runtest index 3b635d12d..2b9e597c1 100755 --- a/test_problems/python/flame1/runtest +++ b/test_problems/python/flame1/runtest @@ -67,7 +67,7 @@ retnStat_txt=$? $BINDIR/csvdiff -a 1.0E-10 flame1_blessed.csv flame1.csv > diff_csv.txt retnStat_csv=$? -if test $retnStat_csv = "1" +if test $retnStat_csv = "0" then echo " Successful test comparison on "`pwd` if [ $retnStat_txt != "0" ] diff --git a/tools/testtools/csvdiff.cpp b/tools/testtools/csvdiff.cpp index fd03fb734..3ea8e1183 100644 --- a/tools/testtools/csvdiff.cpp +++ b/tools/testtools/csvdiff.cpp @@ -71,6 +71,11 @@ int Debug_Flag = TRUE; double grtol = 1.0E-3; double gatol = 1.0E-9; +#define RT_PASSED 0 +#define RT_FAILED_COL 1 +#define RT_FAILED_HDR 2 +#define RT_FAILED_OTHER 3 + /* * First iteration towards getting this variable */ @@ -646,7 +651,7 @@ int main(int argc, char *argv[]) int mixed_var = 0; int i, j, ndiff, jmax, i1, i2, k, found; double max_diff, rel_diff; - int testPassed = 1; + int testPassed = RT_PASSED; double atol_j, atol_arg = 0.0, rtol_arg = 0.0; /********************** BEGIN EXECUTION ************************************/ @@ -751,37 +756,37 @@ int main(int argc, char *argv[]) get_sizes(fp1, nTitleLines1, nColTitleLines1, nCol1, nDataRows1, &ColIsFloat1); if (nCol1 == 0) { printf("Number of columns in file %s is zero\n", fileName1); - testPassed = -1; - exit (-1); + testPassed = RT_FAILED_OTHER; + exit(RT_FAILED_OTHER); } if (nDataRows1 == 0) { printf("Number of data rows in file %s is zero\n", fileName1); - testPassed = -1; - exit (-1); + testPassed = RT_FAILED_OTHER; + exit(RT_FAILED_OTHER); } get_sizes(fp2, nTitleLines2, nColTitleLines2, nCol2, nDataRows2, &ColIsFloat2); if (nCol2 == 0) { printf("Number of columns in file %s is zero\n", fileName2); - testPassed = -1; - exit (-1); + testPassed = RT_FAILED_OTHER; + exit(RT_FAILED_OTHER); } if (nDataRows2 == 0) { printf("Number of data rows in file %s is zero\n", fileName2); - testPassed = -1; - exit (-1); + testPassed = RT_FAILED_OTHER; + exit(RT_FAILED_OTHER); } if (nTitleLines1 != nTitleLines2) { - printf("Number o Title Lines differ:, %d %d\n",nTitleLines1, nTitleLines2); - testPassed = 0; + printf("Number of Title Lines differ:, %d %d\n",nTitleLines1, nTitleLines2); + testPassed = RT_FAILED_OTHER; } else if (Debug_Flag) { printf("Number of Title Lines in each file = %d\n", nTitleLines1); } if (nColTitleLines1 != nColTitleLines2) { printf("Number of Column title lines differ:, %d %d\n", nColTitleLines1, nColTitleLines2); - testPassed = 0; + testPassed = RT_FAILED_OTHER; } else if (Debug_Flag) { printf("Number of column title lines in each file = %d\n", nColTitleLines1); } @@ -809,27 +814,27 @@ int main(int argc, char *argv[]) for (i = 0; i < n; i++) { if (strcmp(title1[i], title2[i]) != 0) { printf("Title Line %d differ:\n\t\"%s\"\n\t\"%s\"\n", i, title1[i], title2[i]); - testPassed = 0; + testPassed = RT_FAILED_HDR; } else if (Debug_Flag) { printf("Title Line %d for each file: \"%s\"\n", i, title1[i]); } } if (nTitleLines1 != nTitleLines2) { printf("Number of Title Lines differ: %d %d\n", nTitleLines1, nTitleLines2); - testPassed = -1; + testPassed = RT_FAILED_HDR;; } } else { if (nTitleLines1 != nTitleLines2) { if (nTitleLines1) { printf("Titles differ: title for first file: \"%s\"\n", title1[0]); - testPassed = 0; + testPassed = RT_FAILED_HDR; } if (nTitleLines2) { printf("Titles differ: title for second file: \"%s\"\n", title2[0]); } - testPassed = -1; + testPassed = RT_FAILED_HDR; } } @@ -842,7 +847,7 @@ int main(int argc, char *argv[]) printf("Number of column variables differ:, %d %d\n", nCol1, nCol2); mixed_var = TRUE; - testPassed = 0; + testPassed = RT_FAILED_OTHER; } else if (Debug_Flag) { printf("Number of column variables in both files = %d\n", nCol1); @@ -879,7 +884,7 @@ int main(int argc, char *argv[]) if (!found) { printf("csvdiff WARNING Variable %s (%d) in first file not found" " in second file\n", ColNames1[i], i); - testPassed = 0; + testPassed = RT_FAILED_OTHER; } } for (j = 0; j < nCol2; j++) { @@ -891,7 +896,7 @@ int main(int argc, char *argv[]) printf("csvdiff WARNING Variable %s (%d) in second file " "not found in first file\n", ColNames2[j], j); - testPassed = 0; + testPassed = RT_FAILED_OTHER; } } @@ -1024,7 +1029,7 @@ int main(int argc, char *argv[]) printf(" Largest difference was at data row %d ", jmax + 1); printf(": %g %g\n", curVarValues1[jmax], curVarValues2[jmax]); } - testPassed = 0; + testPassed = RT_FAILED_COL; } else if (Debug_Flag) { printf("Column variable %s passed\n", ColNames1[i1]); }