def LMPressureGradientAvg(x_min,x_max,Ref,G,D,Tbubble,Tdew,C=None,satTransport=None):
"""
Returns the average pressure gradient between qualities of x_min and x_max.
To obtain the pressure gradient for a given value of x, pass it in as x_min and x_max
Required parameters:
* x_min : The minimum quality for the range [-]
* x_max : The maximum quality for the range [-]
* Ref : String with the refrigerant name
* G : Mass flux [kg/m^2/s]
* D : Diameter of tube [m]
* Tbubble : Bubblepoint temperature of refrigerant [K]
* Tdew : Dewpoint temperature of refrigerant [K]
Optional parameters:
* C : The coefficient in the pressure drop
* satTransport : A dictionary with the keys 'mu_f','mu_g,'v_f','v_g' for the saturation properties. So they can be calculated once and passed in for a slight improvement in efficiency
"""
def LMFunc(x):
dpdz,alpha=LockhartMartinelli(Ref,G,D,x,Tbubble,Tdew,C,satTransport)
return dpdz
## Use Simpson's Rule to calculate the average pressure gradient
## Can't use adapative quadrature since function is not sufficiently smooth
## Not clear why not sufficiently smooth at x>0.9
if x_min==x_max:
return LMFunc(x_min)
else:
#Calculate the tranport properties once
satTransport={}
satTransport['v_f']=1/PropsSI('D','T',Tbubble,'Q',0.0,Ref)
satTransport['v_g']=1/PropsSI('D','T',Tdew,'Q',1.0,Ref)
satTransport['mu_f']=PropsSI('V','T',Tbubble,'Q',0.0,Ref)
satTransport['mu_g']=PropsSI('V','T',Tdew,'Q',1.0,Ref)
xx=np.linspace(x_min,x_max,30)
DP=np.zeros_like(xx)
for i in range(len(xx)):
DP[i]=LMFunc(xx[i])
return -simps(DP,xx)/(x_max-x_min)
评论列表
文章目录