mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
Added gas phase and verbosity switches to the test script for #882
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
# coding: utf-8
|
||||
|
||||
import msgpack, zlib, StringIO
|
||||
import matplotlib.pyplot as plt, numpy as np, CoolProp
|
||||
|
||||
# Modify path as necessary
|
||||
with open(r'C:\Users\Belli\.CoolProp\Tables\HelmholtzEOSBackend(Water[1.0000000000])/single_phase_logpT.bin.z','rb') as fp:
|
||||
user_paths = [r'C:\Users\Belli',r'C:\Users\jowr']
|
||||
with open(user_paths[1]+r'\.CoolProp\Tables\HelmholtzEOSBackend(Water[1.0000000000])/single_phase_logpT.bin.z','rb') as fp:
|
||||
ph = zlib.decompress(fp.read())
|
||||
values = msgpack.load(StringIO.StringIO(ph))
|
||||
revision, matrices = values[0:2]
|
||||
@@ -12,9 +15,11 @@ with open(r'C:\Users\Belli\.CoolProp\Tables\HelmholtzEOSBackend(Water[1.00000000
|
||||
Ts = np.linspace(Tt, Tc)
|
||||
ps = CoolProp.CoolProp.PropsSI('P','T',Ts,'Q',0,'Water')
|
||||
|
||||
plt.plot(T, p, '.')
|
||||
plt.plot(T, p, '.', color='gray')
|
||||
plt.plot(Ts, ps, 'k', lw = 2)
|
||||
plt.yscale('log')
|
||||
plt.xlabel('Temperature / K')
|
||||
plt.ylabel('Pressure / Pa')
|
||||
plt.show()
|
||||
|
||||
|
||||
@@ -28,30 +33,45 @@ print AS.rhomolar_critical()
|
||||
pt = AS.keyed_output(CoolProp.iP_triple)
|
||||
pc = AS.p_critical()
|
||||
|
||||
verbose = False
|
||||
dTs = np.power(10.0,-np.arange(-1,4))
|
||||
|
||||
for p in np.logspace(np.log10(pt*1.05),np.log10(pc*0.95)):
|
||||
AS.update(CoolProp.PQ_INPUTS, p, 0)
|
||||
rhoL = AS.rhomolar()
|
||||
Ts = AS.T()
|
||||
# Liquid side
|
||||
for specify_phase in [True]:
|
||||
for specify_phase in [False,True]:
|
||||
if specify_phase:
|
||||
AS.specify_phase(CoolProp.iphase_liquid)
|
||||
else:
|
||||
AS.unspecify_phase()
|
||||
for dT in [10,1,0.01,0.001]:
|
||||
print p, Ts-dT
|
||||
for dT in dTs:
|
||||
if verbose: print p, Ts-dT
|
||||
try:
|
||||
AS.update(CoolProp.PT_INPUTS, p, Ts-dT)
|
||||
print p, Ts-dT, AS.rhomolar()
|
||||
if verbose: print p, Ts-dT, AS.rhomolar()
|
||||
except BaseException as BE:
|
||||
print 'ERROR:', BE
|
||||
print p, Ts, rhoL
|
||||
print ' '
|
||||
if specify_phase: print 'Liquid error:', BE
|
||||
else: print 'Liquid issue:', BE
|
||||
if verbose: print p, Ts, rhoL
|
||||
# Gaseous side
|
||||
for specify_phase in [False,True]:
|
||||
if specify_phase:
|
||||
AS.specify_phase(CoolProp.iphase_gas)
|
||||
else:
|
||||
AS.unspecify_phase()
|
||||
for dT in dTs:
|
||||
if verbose: print p, Ts+dT
|
||||
try:
|
||||
AS.update(CoolProp.PT_INPUTS, p, Ts+dT)
|
||||
if verbose: print p, Ts+dT, AS.rhomolar()
|
||||
except BaseException as BE:
|
||||
if specify_phase: print ' Gas error:', BE
|
||||
else: print ' Gas issue:', BE
|
||||
if verbose: print p, Ts, rhoL
|
||||
|
||||
|
||||
|
||||
|
||||
# In[ ]:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user