changeset 2596:34360f7d6679

lib/cfpylib/gasdyn: fixed bug in cea2_gas.py Code had been using the perfect gas Cp value if transport properties were turned on for the calculation (which was the default). This occured as the code would go through line by line and look for the Cp line and then set the value. The issue was that when transport properties are turned on, Cp is in the file three times, with the last one being a frozen value. This has been fixed by making the code state when it has found Cp and not set it again for that calculation.
author Chris James (c.james4@uq.edu.au)
date Wed, 26 Feb 2020 13:42:03 +1000
parents 52ad264b6c49
children 6231b8dd7e79
files lib/cfpylib/gasdyn/cea2_gas.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lib/cfpylib/gasdyn/cea2_gas.py	Sat Feb 01 14:08:50 2020 +1000
+++ b/lib/cfpylib/gasdyn/cea2_gas.py	Wed Feb 26 13:42:03 2020 +1000
@@ -31,6 +31,7 @@
    28-Fed-08: Major changes to allow proper calculation at high temps.
    11-Dec-08: Addition of basic incident Shock function
    19-Feb-12: some refactoring, simplification and general clean-up
+   26-Feb-20: Fixed bug with perfect gas Cp value accidentally being grabbed if transport properties are calculated - Chris James
 """
 
 import sys, string, math, os, subprocess, re
@@ -421,6 +422,7 @@
         thermo_props_found = False
         conductivity_found = False
         incident_shock_data = False
+        Cp_found = False
         for line in lines:
             if line=="\n": continue
             if line.find("PRODUCTS WHICH WERE CONSIDERED BUT WHOSE")>=0: break
@@ -438,9 +440,10 @@
                     self.e = get_cea2_float(tokens[2:]) * 1.0e3
                 elif line.find("S, KJ/(KG)(K)")>=0:
                     self.s = get_cea2_float(tokens[2:]) * 1.0e3
-                elif line.find("Cp, KJ/(KG)(K)")>=0:
+                elif not Cp_found and line.find("Cp, KJ/(KG)(K)")>=0:
                     self.cp = get_cea2_float(tokens[2:]) * 1.0e3
                     self.C_p = self.cp
+                    Cp_found = True
                 elif line.find("GAMMAs")>=0:
                     self.gam = get_cea2_float(tokens[1:])
                 elif line.find("M, (1/n)")>=0: