Numpy 拒绝显示向量化函数
Numpy refuses to display vectorized function
我有一个代码运行如下:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import pyXSteam.XSteam
from pyXSteam.XSteam import XSteam
steamTable = XSteam(XSteam.UNIT_SYSTEM_MKS) # m/kg/sec/°C/bar/W
A = 3000 #define the heat exchange area
d_in = 20 #define the inner diameter of HE tubes
CF = 0.85 #define the cleanliness factor of SC.
w = 2.26 #define the water velocity within the tubes
Dk=np.arange(27.418,301.598,27.418) #define the range of steam loads
dk = (Dk * 1000 / (A * 3.600)) #calculate the relative steam load
Tcwin=20
def Cp():
return steamTable.CpL_t(Tcwin)
Gw = 13000 #define the flow of CW, t/hr
e = 2.718281828
f_velocity = w * 1.1 / (20 ** 0.25)
f_w=0.12 * CF * (1 + 0.15 * Tcwin)
Ф_в = f_velocity ** f_w
K = CF * 4070 * ((1.1 * w / (d_in ** 0.25)) ** (0.12 * CF * (1 + 0.15 * Tcwin))) * (1 - (((35 - Tcwin) ** 2) * (0.52 - 0.0072 * dk) * (CF ** 0.5)) / 1000)
n = (K * A) / (Cp() * Gw * 1000)
Tcwout_theor = Tcwin + (Dk * 2225 / (Cp() * Gw))
Subcooling_theor = (Tcwout_theor - Tcwin) / (e ** (K * A / (Cp() * (Gw * 1000 / 3600) * 1000)))
TR_theor = (Tcwout_theor - Tcwin)
Tsat_theor = (Tcwout_theor + Subcooling_theor)
def Ts():
return np.vectorize(Tsat_theor)
def Psat_theor():
return steamTable.psat_t(Tsat_theor)
print(Dk)
print(Tsat_theor)
print(Psat_theor)
虽然它确实计算 Tsat_theor,但无法打印 Psat_theor。
输出如下:
<函数 Psat_theor 在 0x000002A7C29F0D30>
如何获取Psat_theor的实际值?
您需要调用上述功能,更改
print(Psat_theor)
至
print(Psat_theor())
我有一个代码运行如下:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import pyXSteam.XSteam
from pyXSteam.XSteam import XSteam
steamTable = XSteam(XSteam.UNIT_SYSTEM_MKS) # m/kg/sec/°C/bar/W
A = 3000 #define the heat exchange area
d_in = 20 #define the inner diameter of HE tubes
CF = 0.85 #define the cleanliness factor of SC.
w = 2.26 #define the water velocity within the tubes
Dk=np.arange(27.418,301.598,27.418) #define the range of steam loads
dk = (Dk * 1000 / (A * 3.600)) #calculate the relative steam load
Tcwin=20
def Cp():
return steamTable.CpL_t(Tcwin)
Gw = 13000 #define the flow of CW, t/hr
e = 2.718281828
f_velocity = w * 1.1 / (20 ** 0.25)
f_w=0.12 * CF * (1 + 0.15 * Tcwin)
Ф_в = f_velocity ** f_w
K = CF * 4070 * ((1.1 * w / (d_in ** 0.25)) ** (0.12 * CF * (1 + 0.15 * Tcwin))) * (1 - (((35 - Tcwin) ** 2) * (0.52 - 0.0072 * dk) * (CF ** 0.5)) / 1000)
n = (K * A) / (Cp() * Gw * 1000)
Tcwout_theor = Tcwin + (Dk * 2225 / (Cp() * Gw))
Subcooling_theor = (Tcwout_theor - Tcwin) / (e ** (K * A / (Cp() * (Gw * 1000 / 3600) * 1000)))
TR_theor = (Tcwout_theor - Tcwin)
Tsat_theor = (Tcwout_theor + Subcooling_theor)
def Ts():
return np.vectorize(Tsat_theor)
def Psat_theor():
return steamTable.psat_t(Tsat_theor)
print(Dk)
print(Tsat_theor)
print(Psat_theor)
虽然它确实计算 Tsat_theor,但无法打印 Psat_theor。 输出如下:
<函数 Psat_theor 在 0x000002A7C29F0D30>
如何获取Psat_theor的实际值?
您需要调用上述功能,更改
print(Psat_theor)
至
print(Psat_theor())