mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
Fixed the coefficients!!!! A minus was missing.
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
"coeffs": [
|
||||
[
|
||||
+9.60246658e+02,
|
||||
+1.29038391e+02,
|
||||
-1.29038391e+02,
|
||||
-1.61042520e+02,
|
||||
-1.96988800e+02,
|
||||
+1.13155900e+03,
|
||||
|
||||
@@ -58,23 +58,23 @@
|
||||
"density": {
|
||||
"coeffs": [
|
||||
[
|
||||
+0.00000000e+00,
|
||||
+0.00000000e+00,
|
||||
+0.00000000e+00,
|
||||
+0.00000000e+00,
|
||||
-2.39943098e+02,
|
||||
+1.25081590e+03,
|
||||
+4.23507367e+01,
|
||||
-1.81607263e+02,
|
||||
+3.78787879e+01
|
||||
],
|
||||
[
|
||||
+1.18577276e+01,
|
||||
-1.35013456e+01,
|
||||
+7.88854875e-01,
|
||||
+5.82010582e-01,
|
||||
+0.00000000e+00
|
||||
],
|
||||
[
|
||||
+0.00000000e+00,
|
||||
+0.00000000e+00,
|
||||
+0.00000000e+00,
|
||||
+0.00000000e+00,
|
||||
+0.00000000e+00
|
||||
],
|
||||
[
|
||||
+0.00000000e+00,
|
||||
+0.00000000e+00,
|
||||
+0.00000000e+00,
|
||||
-2.67448980e-02,
|
||||
+3.14002268e-02,
|
||||
-3.28798186e-03,
|
||||
+0.00000000e+00,
|
||||
+0.00000000e+00
|
||||
]
|
||||
|
||||
@@ -612,7 +612,7 @@ class IncompressibleData(object):
|
||||
|
||||
# TODO: Check for rows with only nan values
|
||||
x_num = len(x_in)
|
||||
y_num = len(y_in)
|
||||
y_num = len(y_in)
|
||||
|
||||
cols = len(xy_exp)
|
||||
eqns = x_num * y_num
|
||||
@@ -706,7 +706,7 @@ class SolutionData(object):
|
||||
else: return np.polynomial.polynomial.polyval2d(T-self.Tbase, x-self.xbase, c)
|
||||
|
||||
def c (self, T, p, x=0.0, c=None):
|
||||
if c==None: return np.polynomial.polynomial.polyval2d(T-self.Tbase, x-self.xbase, data.specific_heat.coeffs)
|
||||
if c==None: return np.polynomial.polynomial.polyval2d(T-self.Tbase, x-self.xbase, self.specific_heat.coeffs)
|
||||
else: return np.polynomial.polynomial.polyval2d(T-self.Tbase, x-self.xbase, c)
|
||||
|
||||
def cp (self, T, p, x=0.0, c=None):
|
||||
@@ -799,6 +799,10 @@ class CoefficientData(SolutionData):
|
||||
|
||||
|
||||
def convertMelinderArray(self, array):
|
||||
"""The same function as the SecCool converter,
|
||||
the original source code is slightly different though.
|
||||
That is why the implementation is in a transposed form..."""
|
||||
|
||||
if len(array)!=18:
|
||||
raise ValueError("The lenght is not equal to 18!")
|
||||
|
||||
@@ -894,7 +898,7 @@ class SecCoolExample(CoefficientData):
|
||||
self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL
|
||||
self.density.coeffs = self.convertSecCoolArray(np.array([
|
||||
960.24665800,
|
||||
1.2903839100,
|
||||
-1.2903839100,
|
||||
-0.0161042520,
|
||||
-0.0001969888,
|
||||
1.131559E-05,
|
||||
@@ -912,6 +916,8 @@ class SecCoolExample(CoefficientData):
|
||||
-1.346886E-06,
|
||||
4.141999E-08]))
|
||||
|
||||
|
||||
|
||||
self.specific_heat.type = self.density.INCOMPRESSIBLE_POLYNOMIAL
|
||||
self.specific_heat.coeffs = self.convertSecCoolArray(np.array([
|
||||
3822.9712300,
|
||||
@@ -1103,13 +1109,13 @@ class SolutionExample(SolutionData):
|
||||
[1032.3, 1025.3, 1018.5, 1011.7, 1005.1, 998.5, 992.0],
|
||||
[1021.5, 1015.3, 1009.2, 1003.1, 997.1, 991.2, 985.4]]) # kg/m3
|
||||
|
||||
self.density.data = np.array([
|
||||
[np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan],
|
||||
[np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan],
|
||||
[np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan],
|
||||
[np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan],
|
||||
[np.nan, np.nan, np.nan, np.nan, 1016.0, 1008.4, np.nan],
|
||||
[np.nan, 1033.2, np.nan, np.nan, np.nan, np.nan, np.nan],
|
||||
[np.nan, 1025.3, 1018.5, np.nan, np.nan, 998.5, 992.0],
|
||||
[np.nan, np.nan, 1009.2, np.nan, np.nan, np.nan, np.nan]]) # kg/m3
|
||||
# self.density.data = np.array([
|
||||
# [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan],
|
||||
# [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan],
|
||||
# [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan],
|
||||
# [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan],
|
||||
# [np.nan, np.nan, np.nan, np.nan, 1016.0, 1008.4, np.nan],
|
||||
# [np.nan, 1033.2, np.nan, np.nan, np.nan, np.nan, np.nan],
|
||||
# [np.nan, 1025.3, 1018.5, np.nan, np.nan, 998.5, 992.0],
|
||||
# [np.nan, np.nan, 1009.2, np.nan, np.nan, np.nan, np.nan]]) # kg/m3
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ class SolutionDataWriter(object):
|
||||
put in your data and add some documentation for where the
|
||||
information came from.
|
||||
"""
|
||||
#def __init__(self):
|
||||
# SolutionData.__init__(self)
|
||||
def __init__(self):
|
||||
self.verbose = False
|
||||
|
||||
def fitAll(self, data):
|
||||
T = data.temperature.data
|
||||
@@ -32,7 +32,7 @@ class SolutionDataWriter(object):
|
||||
data.density.type = data.density.INCOMPRESSIBLE_POLYNOMIAL
|
||||
data.density.fit(T,x,data.Tbase,data.xbase)
|
||||
except errList as ve:
|
||||
print "Could not fit density coefficients:", ve
|
||||
if self.verbose: print "Could not fit density coefficients:", ve
|
||||
pass
|
||||
|
||||
try:
|
||||
@@ -40,7 +40,7 @@ class SolutionDataWriter(object):
|
||||
data.specific_heat.type = data.specific_heat.INCOMPRESSIBLE_POLYNOMIAL
|
||||
data.specific_heat.fit(T,x,data.Tbase,data.xbase)
|
||||
except errList as ve:
|
||||
print "Could not fit specific heat coefficients:", ve
|
||||
if self.verbose: print "Could not fit specific heat coefficients:", ve
|
||||
pass
|
||||
|
||||
try:
|
||||
@@ -48,7 +48,7 @@ class SolutionDataWriter(object):
|
||||
data.viscosity.type = data.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL
|
||||
data.viscosity.fit(T,x,data.Tbase,data.xbase)
|
||||
except errList as ve:
|
||||
print "Could not fit viscosity coefficients:", ve
|
||||
if self.verbose: print "Could not fit viscosity coefficients:", ve
|
||||
pass
|
||||
|
||||
try:
|
||||
@@ -56,7 +56,7 @@ class SolutionDataWriter(object):
|
||||
data.conductivity.type = data.conductivity.INCOMPRESSIBLE_POLYNOMIAL
|
||||
data.conductivity.fit(T,x,data.Tbase,data.xbase)
|
||||
except errList as ve:
|
||||
print "Could not fit conductivity coefficients:", ve
|
||||
if self.verbose: print "Could not fit conductivity coefficients:", ve
|
||||
pass
|
||||
|
||||
try:
|
||||
@@ -64,7 +64,7 @@ class SolutionDataWriter(object):
|
||||
data.saturation_pressure.type = data.saturation_pressure.INCOMPRESSIBLE_EXPPOLYNOMIAL
|
||||
data.saturation_pressure.fit(T,x,data.Tbase,data.xbase)
|
||||
except errList as ve:
|
||||
print "Could not fit saturation pressure coefficients:", ve
|
||||
if self.verbose: print "Could not fit saturation pressure coefficients:", ve
|
||||
pass
|
||||
|
||||
try:
|
||||
@@ -72,7 +72,7 @@ class SolutionDataWriter(object):
|
||||
data.T_freeze.type = data.T_freeze.INCOMPRESSIBLE_POLYNOMIAL
|
||||
data.T_freeze.fit(T,x,data.Tbase,data.xbase)
|
||||
except errList as ve:
|
||||
print "Could not fit TFreeze coefficients:", ve
|
||||
if self.verbose: print "Could not fit TFreeze coefficients:", ve
|
||||
pass
|
||||
|
||||
try:
|
||||
@@ -80,7 +80,7 @@ class SolutionDataWriter(object):
|
||||
data.volume2mass.type = data.volume2mass.INCOMPRESSIBLE_POLYNOMIAL
|
||||
data.volume2mass.fit(T,x,data.Tbase,data.xbase)
|
||||
except errList as ve:
|
||||
print "Could not fit V2M coefficients:", ve
|
||||
if self.verbose: print "Could not fit V2M coefficients:", ve
|
||||
pass
|
||||
|
||||
try:
|
||||
@@ -88,7 +88,7 @@ class SolutionDataWriter(object):
|
||||
data.mass2mole.type = data.mass2mole.INCOMPRESSIBLE_POLYNOMIAL
|
||||
data.mass2mole.fit(T,x,data.Tbase,data.xbase)
|
||||
except errList as ve:
|
||||
print "Could not fit M2M coefficients:", ve
|
||||
if self.verbose: print "Could not fit M2M coefficients:", ve
|
||||
pass
|
||||
|
||||
|
||||
@@ -173,25 +173,31 @@ if __name__ == '__main__':
|
||||
|
||||
def printInfo(data):
|
||||
print "{0:s} : {1:.4e}, {2:.4e}".format(data.name, data.Tbase, data.xbase)
|
||||
|
||||
def printDens(data, T, p, x, fluid='', f=None):
|
||||
|
||||
def printValue(data, T, p, x, fluid='', f=None, dataFunc=None, dataLetter=''):
|
||||
if f!=None:
|
||||
try:
|
||||
print "{0:s} : {1:.4e}, {2:.4e}, {3:.4e}, inputs: {4:.4e}, {5:.4e}, {6:.4e} ".format(data.name, data.rho(T, p, x), CP.Props('D','T',T,'P',p,fluid), float(f(T,x)), T, p, x)
|
||||
print "{0:s} : {1:.4e}, {2:.4e}, {3:.4e}, inputs: {4:.4e}, {5:.4e}, {6:.4e} ".format(data.name, dataFunc(T, p, x), CP.Props(dataLetter,'T',T,'P',p,fluid), float(f(T,x)), T, p, x)
|
||||
except:
|
||||
print "{0:s} : {1:.4e}, {2:.4e}, {3:.4e}, inputs: {4:.4e}, {5:.4e}, {6:.4e} ".format(data.name, data.rho(T, p, x), CP.Props('D','T',T,'P',p,fluid), float(f(T)), T, p, x)
|
||||
print "{0:s} : {1:.4e}, {2:.4e}, {3:.4e}, inputs: {4:.4e}, {5:.4e}, {6:.4e} ".format(data.name, dataFunc(T, p, x), CP.Props(dataLetter,'T',T,'P',p,fluid), float(f(T)), T, p, x)
|
||||
else:
|
||||
print "{0:s} : {1:.4e}, {2:.4e}, {3:.4e}, inputs: {4:.4e}, {5:.4e}, {6:.4e} ".format(data.name, data.rho(T, p, x), CP.Props('D','T',T,'P',p,fluid), 0.0, T, p, x)
|
||||
print "{0:s} : {1:.4e}, {2:.4e}, {3:.4e}, inputs: {4:.4e}, {5:.4e}, {6:.4e} ".format(data.name, dataFunc(T, p, x), CP.Props(dataLetter,'T',T,'P',p,fluid), 0.0, T, p, x)
|
||||
|
||||
def printDens(data, T, p, x, fluid='', f=None):
|
||||
printValue(data, T, p, x, fluid=fluid, f=f, dataFunc=data.rho, dataLetter='D')
|
||||
|
||||
def printHeat(data, T, p, x, fluid='', f=None):
|
||||
printValue(data, T, p, x, fluid=fluid, f=f, dataFunc=data.c, dataLetter='C')
|
||||
|
||||
|
||||
# data = PureExample()
|
||||
# writer.fitAll(data)
|
||||
# writer.toJSON(data)
|
||||
# printInfo(data)
|
||||
# if test: T = data.Tbase+55+273.15
|
||||
# if test: x = 0.0
|
||||
# if test: f = interpolate.interp1d(data.temperature.data, data.density.data.T[0])
|
||||
# if test: printDens(data, T, p, x, fluid='TD12', f=f)
|
||||
data = PureExample()
|
||||
writer.fitAll(data)
|
||||
writer.toJSON(data)
|
||||
printInfo(data)
|
||||
if test: T = data.Tbase+55+273.15
|
||||
if test: x = 0.0
|
||||
if test: f = interpolate.interp1d(data.temperature.data, data.density.data.T[0])
|
||||
if test: printDens(data, T, p, x, fluid='TD12', f=f)
|
||||
|
||||
|
||||
data = SolutionExample()
|
||||
@@ -203,24 +209,40 @@ if __name__ == '__main__':
|
||||
if test: f = interpolate.interp2d(data.temperature.data, data.concentration.data, data.density.data.T)
|
||||
if test: printDens(data, T, p, x, fluid='IceEA-{0:.4f}%'.format(x*100.0), f=f)
|
||||
|
||||
#
|
||||
# data = SecCoolExample()
|
||||
# writer.toJSON(data)
|
||||
# printInfo(data)
|
||||
# if test: T = data.Tbase+0
|
||||
# if test: x = 0.1
|
||||
# if test: f = None #interpolate.interp2d(data.temperature.data, data.concentration.data, data.density.data.T)
|
||||
# if test: printDens(data, T, p, x, fluid='SecCoolSolution-{0:.4f}%'.format(x*100.0), f=f)
|
||||
#
|
||||
#
|
||||
#
|
||||
# data = MelinderExample()
|
||||
# writer.toJSON(data)
|
||||
# printInfo(data)
|
||||
# if test: T = data.Tbase+10
|
||||
# if test: x = 0.22
|
||||
# if test: f = None #interpolate.interp2d(data.temperature.data, data.concentration.data, data.density.data.T)
|
||||
# if test: printDens(data, T, p, x, fluid='MMA-22%', f=f)
|
||||
|
||||
data = SecCoolExample()
|
||||
writer.toJSON(data)
|
||||
printInfo(data)
|
||||
if test: T = data.Tbase+0
|
||||
if test: x = 0.3157
|
||||
if test: f = None #interpolate.interp2d(data.temperature.data, data.concentration.data, data.density.data.T)
|
||||
if test: printDens(data, T, p, x, fluid='SecCoolSolution-{0:.4f}%'.format(x*100.0), f=f)
|
||||
|
||||
print
|
||||
print "It works for temperature changes:"
|
||||
printDens(data, T-10, p, x, fluid='SecCoolSolution-{0:.4f}%'.format(x*100.0), f=f)
|
||||
printDens(data, T+10, p, x, fluid='SecCoolSolution-{0:.4f}%'.format(x*100.0), f=f)
|
||||
printHeat(data, T-10, p, x, fluid='SecCoolSolution-{0:.4f}%'.format(x*100.0), f=f)
|
||||
printHeat(data, T+10, p, x, fluid='SecCoolSolution-{0:.4f}%'.format(x*100.0), f=f)
|
||||
print "but not for concentration changes:"
|
||||
x = x-0.1
|
||||
printDens(data, T, p, x, fluid='SecCoolSolution-{0:.4f}%'.format(x*100.0), f=f)
|
||||
x = x+0.2
|
||||
printDens(data, T, p, x, fluid='SecCoolSolution-{0:.4f}%'.format(x*100.0), f=f)
|
||||
x = x-0.2
|
||||
printHeat(data, T, p, x, fluid='SecCoolSolution-{0:.4f}%'.format(x*100.0), f=f)
|
||||
x = x+0.2
|
||||
printHeat(data, T, p, x, fluid='SecCoolSolution-{0:.4f}%'.format(x*100.0), f=f)
|
||||
print
|
||||
|
||||
|
||||
data = MelinderExample()
|
||||
writer.toJSON(data)
|
||||
printInfo(data)
|
||||
if test: T = data.Tbase+10
|
||||
if test: x = 0.22
|
||||
if test: f = None #interpolate.interp2d(data.temperature.data, data.concentration.data, data.density.data.T)
|
||||
if test: printDens(data, T, p, x, fluid='MMA-22%', f=f)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user