[Input] Include more significant digits for Redlich-Kwong coefficients

ctml_writer was severely truncating Redlich-Kwong coefficients when converting
from CTI to XML formats, keeping only 5 significant digints in the "a"
coefficients and two decimal digits in the "b" coefficients, which is less than
what is used even in the example CTI files. The use of the "%f" format also
meant that the precision depended on input units.
This commit is contained in:
Ray Speth 2019-03-04 20:29:42 -05:00
parent 6c82b61c3d
commit ec7f779434
2 changed files with 31 additions and 31 deletions

View file

@ -845,11 +845,11 @@ class pureFluidParameters(activityCoefficients):
def build(self,a): def build(self,a):
f= a.addChild("pureFluidParameters") f= a.addChild("pureFluidParameters")
f['species'] = self._species f['species'] = self._species
s = '%10.4E, %10.4E \n' % (self._acoeff[0], self._acoeff[1]) s = '%.10g, %.10g\n' % (self._acoeff[0], self._acoeff[1])
ac = f.addChild("a_coeff",s) ac = f.addChild("a_coeff",s)
ac["units"] = _upres+'-'+_ulen+'6/'+_umol+'2' ac["units"] = _upres+'-'+_ulen+'6/'+_umol+'2'
ac["model"] = "linear_a" ac["model"] = "linear_a"
s = '%0.2f \n' % self._bcoeff s = '%.10g\n' % self._bcoeff
bc = f.addChild("b_coeff",s) bc = f.addChild("b_coeff",s)
bc["units"] = _ulen+'3/'+_umol bc["units"] = _ulen+'3/'+_umol
@ -864,12 +864,12 @@ class crossFluidParameters(activityCoefficients):
f= a.addChild("crossFluidParameters") f= a.addChild("crossFluidParameters")
f["species2"] = self._species2 f["species2"] = self._species2
f["species1"] = self._species1 f["species1"] = self._species1
s = '%10.4E, %10.4E \n' % (self._acoeff[0], self._acoeff[1]) s = '%.10g, %.10g\n' % (self._acoeff[0], self._acoeff[1])
ac = f.addChild("a_coeff",s) ac = f.addChild("a_coeff",s)
ac["units"] = _upres+'-'+_ulen+'6/'+_umol+'2' ac["units"] = _upres+'-'+_ulen+'6/'+_umol+'2'
ac["model"] = "linear_a" ac["model"] = "linear_a"
if self._bcoeff: if self._bcoeff:
s = '%0.2f \n' % self._bcoeff s = '%.10g\n' % self._bcoeff
bc = f.addChild("b_coeff",s) bc = f.addChild("b_coeff",s)
bc["units"] = _ulen+'3/'+_umol bc["units"] = _ulen+'3/'+_umol

View file

@ -38,15 +38,15 @@ TEST_F(RedlichKwongMFTP_Test, chem_potentials)
// where gamma_k is the activity coefficient. Run regression test against values calculated using // where gamma_k is the activity coefficient. Run regression test against values calculated using
// the model. // the model.
const double expected_result[9] = { const double expected_result[9] = {
-4.573578067074649e+008, -4.573578072583122e+008,
-4.573471163377696e+008, -4.573471168532005e+008,
-4.573375748803425e+008, -4.573375753640399e+008,
-4.573290065058332e+008, -4.573290069609340e+008,
-4.573212695326964e+008, -4.573212699618942e+008,
-4.573142485189869e+008, -4.573142489246118e+008,
-4.573078484551440e+008, -4.573078488392255e+008,
-4.573019904340246e+008, -4.573019907983406e+008,
-4.572966083775078e+008 -4.572966087236250e+008
}; };
double xmin = 0.6; double xmin = 0.6;
@ -125,30 +125,30 @@ TEST_F(RedlichKwongMFTP_Test, setTP)
// All sub-cooled liquid: // All sub-cooled liquid:
const double p1[6] = { const double p1[6] = {
1.587029921158317e+002, 1.587112190732014e+002,
1.541895558698696e+002, 1.541966713372675e+002,
1.501572815648243e+002, 1.501635359781652e+002,
1.465106359800041e+002, 1.465162036435630e+002,
1.431807662747959e+002, 1.431857735462774e+002,
1.401162435728261e+002 1.401207850479111e+002
}; };
// Phase change between temperatures 4 & 5: // Phase change between temperatures 4 & 5:
const double p2[6] = { const double p2[6] = {
6.265136821574670e+002, 6.267097216456422e+002,
5.991027079853330e+002, 5.993217207540168e+002,
5.656903533839055e+002, 5.659501111117172e+002,
5.196021189855490e+002, 5.199644273242080e+002,
3.384435863009947e+002, 3.393007538579040e+002,
2.755331531855265e+002 2.756259035569044e+002
}; };
// Supercritical; no discontinuity in rho values: // Supercritical; no discontinuity in rho values:
const double p3[6] = { const double p3[6] = {
6.839819449357851e+002, 6.841288400828764e+002,
6.667277456641792e+002, 6.668789423328959e+002,
6.483568057147166e+002, 6.485130892980700e+002,
6.286479753170340e+002, 6.288103574172300e+002,
6.073051275696215e+002, 6.074749284756613e+002,
5.839223896051005e+002 5.841013398471708e+002
}; };
for(int i=0; i<6; ++i) for(int i=0; i<6; ++i)