Ejemplo n.º 1
0
 def plot_Ts():
     pp = PropertyPlot('HEOS::R134a', 'TS', unit_system='EUR', tp_limits='ACHP')
     pp.calc_isolines()
     cycle = SimpleCompressionCycle('HEOS::R134a', 'TS', unit_system='EUR', tp_limits='ACHP')
     cycle.simple_solve_dt(Te=T_K_sat_evaporating ,Tc=T_K_sat_condensing, dT_sh=superheat, dT_sc=subcooling, eta_com= Isentropic_Efficiency/100, SI=True)
     cycle.steps = 50
     sc = cycle.get_state_changes()
     plt.close(cycle.figure)
     pp.draw_process(sc)
     pp.savefig('T-s.svg')
     pp.show()
Ejemplo n.º 2
0
    def getPHdata(self):
        ncurves = 10
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            plot = PropertyPlot('R134a', 'ph')
            plot.calc_isolines(num=ncurves)
            #plot.show()

            #extract the isolines from coolprop, and plot them with pyplot
            for i in range(0, 10):
                xi = (plot.isolines[21])[i].x / 1000
                yi = (plot.isolines[21])[i].y / 1000
                if self.xPH is None:
                    self.xPH = np.array(xi)
                    self.yPH = np.array(yi)
                else:
                    self.xPH = np.vstack((self.xPH, xi))
                    self.yPH = np.vstack((self.yPH, yi))

                xi = (plot.isolines[19])[i].x / 1000
                yi = (plot.isolines[19])[i].y / 1000
                self.xPH = np.vstack((self.xPH, xi))
                self.yPH = np.vstack((self.yPH, yi))

                xi = (plot.isolines[34])[i].x / 1000
                yi = (plot.isolines[34])[i].y / 1000
                self.xPH = np.vstack((self.xPH, xi))
                self.yPH = np.vstack((self.yPH, yi))

                xi = (plot.isolines[36])[i].x / 1000
                yi = (plot.isolines[36])[i].y / 1000
                self.xPH = np.vstack((self.xPH, xi))
                self.yPH = np.vstack((self.yPH, yi))
            #next i
        #end with
        return
Ejemplo n.º 3
0
def create_ts_plot(states: list, fluid: str):
    cycle_states = StateContainer()

    # plot only displays a dot for the state if it occurs twice
    merged_states = []
    for state in states:
        merged_states.append(state['data'])
        if state['marker']:
            merged_states.append(state['data'])

    states = merged_states

    i = 0
    for state in states:
        cycle_states[i, 'P'] = state['P']
        cycle_states[i]['T'] = state['T']
        cycle_states[i]['S'] = state['S']
        cycle_states[i]['H'] = state['H']
        i += 1

    plot = PropertyPlot(fluid, 'TS', tp_limits='ORC')
    plot.calc_isolines(CP.iQ, num=2)
    plot.calc_isolines(CP.iP)

    style = {}
    '''
    style = {
        'marker': 'o',
        'markerfacecolor': 'blue',
        'markeredgecolor': 'blue',
        'color': matplotlib.colors.to_rgba('#ff0000'),
    }
    '''

    plot.draw_process(cycle_states, line_opts=style)

    return plot
Ejemplo n.º 4
0
def plot_cycle(s, T):
    # End calculation

    # Plotting T-S
    label = ('1', '2', '3a', '3b', '4a', '4b', '5', '6', '7', '8', 'cab')

    _, ax = plt.subplots()
    ax.plot(s, T, 'b-s', linewidth=.8)

    for idx, (s_, T_) in enumerate(zip(s, T)):
        ax.annotate('   ' + label[idx], (s_, T_))

    ax.set_xlabel('s')
    ax.set_ylabel('T')

    plot = PropertyPlot('Air', 'TS', unit_system='KSI', tp_limits='ACHP', axis=ax)
    plot.calc_isolines(CoolProp.iP, iso_range=s, num=(len(s) - 4))

    ax.set_xlim([np.min(s) * 0.97, np.max(s) * 1.03])
    ax.set_ylim([np.min(T) * 0.97, np.max(T) * 1.03])

    plot.show()
Ejemplo n.º 5
0
def main():
    fluid_ref = 'n-Pentane'
    for plot_type in ['Ts']:  #['pt', 'ph', 'ps', 'ts', 'pt', 'prho', 'trho']:
        plt = PropertyPlot(fluid_ref, plot_type)
        plt.set_axis_limits([-0.5 * 1e3, 1.5 * 1e3, 300, 530])
        plt.draw_isolines('Q', [0.1, 0.9])
        plt.draw_isolines('P', [100 * 1e3, 2000 * 1e3])
        plt.draw_isolines('D', [2, 600])
        plt.show()
from CoolProp.Plots import PropertyPlot
from CoolProp.Plots.SimpleCycles import StateContainer
import pickle
import os

cache_plot = False
if cache_plot:
    filename = fluid + '.p'
    if os.path.isfile(filename):   # Load previously saved plot
        pp = pickle.load(open( filename, "rb" ) )
    else:
        states = StateContainer()
        states_hf = StateContainer()
        states_cf = StateContainer()
        pp = PropertyPlot('HEOS::'+fluid, 'TS')
        with NoStdStreams():
            pp.calc_isolines()
        with open(filename, 'wb') as f: 
            pickle.dump(pp, f) 
else:
    states = StateContainer()
    states_hf = StateContainer()
    states_cf = StateContainer()
    pp = PropertyPlot('HEOS::'+fluid, 'TS')
    with NoStdStreams():
        pp.calc_isolines()
        
    
for i in range(3):
    states[i,'T'] = T[i]
Ejemplo n.º 7
0
library = 'HEOS'
library = 'REFPROP'

limits = [0, 1.75, 250, 550]  # limits for plotting

cache_plot = False
if cache_plot:
    filename = fluid + '.p'
    if os.path.isfile(filename):  # Load previously saved plot
        pp = pickle.load(open(filename, "rb"))
    else:
        states = StateContainer()
        states_hf = StateContainer()
        states_cf = StateContainer()
        pp = PropertyPlot(library + '::' + fluid, 'TS')
        with NoStdStreams():
            pp.calc_isolines()
        with open(filename, 'wb') as f:
            pickle.dump(pp, f)
else:
    states = StateContainer()
    states_hf = StateContainer()
    states_cf = StateContainer()
    pp = PropertyPlot(library + '::' + fluid, 'TS')
    #    pp.set_axis_limits(limits)
    with NoStdStreams():
        pp.calc_isolines()

pp.figure.set_figheight(8)
pp.figure.set_figwidth(10)
Ejemplo n.º 8
0
h = HAPropsSI('H', 'T', 298.15, 'P', 101325, 'R', 0.5)
print(h)

# Temperature of saturated air at the previous enthalpy
T = HAPropsSI('T', 'P', 101325, 'H', h, 'R', 1.0)
print(T)

# Temperature of saturated air - order of inputs doesn't matter
T = HAPropsSI('T', 'H', h, 'R', 1.0, 'P', 101325)
print(T)

#%%

import CoolProp
from CoolProp.Plots import PropertyPlot
plot = PropertyPlot('R290', 'ph')
plot.calc_isolines()
plot.show()

#%%
import CoolProp
from CoolProp.Plots import PropertyPlot
ts_plot = PropertyPlot('R290', 'Ts', tp_limits='ORC')
ts_plot.calc_isolines(CoolProp.iQ, num=6)
ts_plot.show()

#%%problem
import CoolProp
from CoolProp.Plots import PropertyPlot
plot = PropertyPlot('HEOS::R134a', 'PH', unit_system='EUR', tp_limits='ACHP')
plot.calc_isolines(CoolProp.iQ, num=11)
Ejemplo n.º 9
0
def SimpleRankineCycle(T3, p3, p1, epsilon_e, epsilon_p, fluid='water'):
    h1 = PropsSI('H', 'P', p1, 'Q', 0., fluid)
    s1 = PropsSI('S', 'P', p1, 'Q', 0., fluid)
    T1 = PropsSI('T', 'P', p1, 'Q', 0., fluid)
    
    p2 = p3
    h2 = h1 + (PropsSI('H', 'P', p2, 'S', s1, fluid) - h1) / epsilon_p
    s2 = PropsSI('S', 'H', h2, 'P', p2, fluid)
    T2 = PropsSI('T', 'H', h2, 'P', p2, fluid)
    
    h3 = PropsSI('H', 'P', p3, 'T', T3, fluid)
    s3 = PropsSI('S', 'H', h3, 'P', p3, fluid)
    
    p4 = p1
    h4 = h3 - epsilon_e * (h3 - PropsSI('H', 'P', p4, 'S', s3, fluid))
    s4 = PropsSI('S', 'H', h4, 'P', p4, fluid)
    T4 = PropsSI('T', 'H', h4, 'P', p4, fluid)
    
    w_net = h3 - h4
    q_boiler = h3 - h2
    eta_c = w_net / q_boiler
    
    Ts = PropertyPlot(fluid, 'Ts', 'KSI')
    Ts.set_axis_limits([0., 12., 200., 900.])    
    Ts.calc_isolines(CoolProp.iP, [Ts.system.P.from_SI(p1), Ts.system.P.from_SI(p3)], num=10)
    Ts.calc_isolines(CoolProp.iQ, [Ts.system.Q.from_SI(0.), Ts.system.Q.from_SI(1.)], num=11)
    Ts.draw_isolines()
    
    states = zip(Ts.system.S.from_SI(array([s1,s2,s3,s4,s1])),Ts.system.T.from_SI(array([T1,T2,T3,T4,T1])))
    Ts.draw_process(states, iso_types=None, line_opts={'color':'red', 'lw':1.5})
    isot = [
      None, # non-isentropic pumping from 1 to 2
      CoolProp.iP, # p2=p3
      None,
      CoolProp.iP, # p4=p1
      ]
    Ts.draw_process(states, iso_types=isot, line_opts={'color':'green', 'lw':1.5})
    
    
    ax = Ts.axis
    ax.text(Ts.system.S.from_SI(s1), Ts.system.T.from_SI(T1), ' 1', fontsize=10, rotation=0, color='r')
    ax.text(Ts.system.S.from_SI(s2), Ts.system.T.from_SI(T2), ' 2', fontsize=10, rotation=0, color='r')
    ax.text(Ts.system.S.from_SI(s3), Ts.system.T.from_SI(T3), ' 3', fontsize=10, rotation=0, color='r')
    ax.text(Ts.system.S.from_SI(s4), Ts.system.T.from_SI(T4), ' 4', fontsize=10, rotation=0, color='r')
    ax.text(Ts.system.S.from_SI(8e3),Ts.system.T.from_SI(850),"Efficiency: %.1f%%" %(eta_c*100.))
    ax.text(Ts.system.S.from_SI(8e3),Ts.system.T.from_SI(800),"Net work: %d kJ/kg" %(w_net/1000))
    ax.text(Ts.system.S.from_SI(8e3),Ts.system.T.from_SI(750),"Heat input: %d kJ/kg" %(q_boiler/1000))
    return Ts
Ejemplo n.º 10
0
    print MCE.OutputList(), '\n', '=' * 20

    csv_file = "Evaporator_MCE.csv"
    print "\n demonstrating write to csv", csv_file, '\n'
    Write2CSV(MCE, open(csv_file, 'w'), append=False)

    print "check MCE capacity summation", MCE.hin_r * MCE.mdot_r[-1],
    print np.sum([
        MCE.Evaps[i].hin_r * MCE.Evaps[i].mdot_r
        for i in range(MCE.Fins.Tubes.Ncircuits)
    ])

    # plot maldistribution
    h = np.array([MCE.Evaps[i].hout_r for i in range(len(MCE.Evaps))])
    p = MCE.psat_r * (1 + 0 * h)
    plot = PropertyPlot('HEOS::R410A', 'PH', unit_system='KSI')
    plot.calc_isolines(CoolProp.iQ, num=2)
    plot.axis.plot(MCE.hin_r / 1000, MCE.psat_r / 1000, '>', label='Inlet')
    plot.axis.plot(h / 1000, p / 1000, 'x', label='Individual circuit exits')
    plot.axis.plot(MCE.hout_r / 1000,
                   MCE.psat_r / 1000,
                   'o',
                   label='Overall exit')
    plt.legend(loc='best', numpoints=1)
    plot.savefig('MultiCircuitEvaporator_py_example.pdf')
    #plot.figure.show()
    plt.close(plot.figure)

    print "outlet enthalpies", [
        MCE.Evaps[i].hout_r for i in range(len(MCE.Evaps))
    ], MCE.hout_r, PropsSI('H', 'T', MCE.Evaps[-1].Tdew_r, 'Q', 1,
Ejemplo n.º 11
0
def plot_TS(fluid, rrange, prange):
    ############### TS
    fig_x, fig_y = 14, 9
    fig = plt.figure(figsize=(fig_x, fig_y))
    ax = fig.gca()
    ax.set_ylim(240, 400)
    ax.set_xlim(800, 2000)

    qrange = np.linspace(0, 1, 10).tolist()
    ts = PropertyPlot(fluid, 'TS', unit_system='SI', tp_limits='ORC',
                      axis=ax)  #,reciprocal_density=True)
    ts.calc_isolines(CP.iQ, iso_range=qrange, num=10)

    ts.props[CP.iDmass]['color'] = 'red'
    ts.props[CP.iDmass]['lw'] = '0.5'
    ts.calc_isolines(CP.iDmass,
                     iso_range=rrange,
                     num=len(rrange),
                     rounding=False)

    ## isobaric
    ts.props[CP.iP]['color'] = 'green'
    ts.props[CP.iP]['lw'] = '0.5'
    ts.calc_isolines(CP.iP, iso_range=prange, num=len(prange), rounding=False)

    ts.draw()

    axL = ts.get_axis_limits()

    ax.text(axL[0] + 20, axL[3] - 7, fluid, size=20)

    t1 = axL[3] - 25
    t0 = t1 - 5

    for p in prange:
        s1 = CP.PropsSI("Smass", "T", t1, "P", p, fluid)
        s0 = CP.PropsSI("Smass", "T", t0, "P", p, fluid)

        pA = np.array([s0, t0])
        pB = np.array([s1, t1])

        # Calculate the angle of the line
        dx, dy = pA - pB
        x_min, x_max = axL[0:2]
        y_min, y_max = axL[2:4]

        Dx = dx * fig_x / (x_max - x_min)
        Dy = dy * fig_y / (y_max - y_min)

        angle = (180 / np.pi) * np.arctan(Dy / Dx)

        ax.text(s0,
                t0,
                str(format(p / 1E5, '.0f')) + 'bar',
                rotation=angle,
                horizontalalignment='left',
                verticalalignment='bottom',
                rotation_mode='anchor',
                color='green')

    t1 = axL[3] - 10
    t0 = t1 - 5

    for r in rrange:
        s1 = CP.PropsSI("Smass", "T", t1, "Dmass", r, fluid)
        s0 = CP.PropsSI("Smass", "T", t0, "Dmass", r, fluid)

        pA = np.array([s0, t0])
        pB = np.array([s1, t1])

        # Calculate the angle of the line
        dx, dy = pA - pB
        x_min, x_max = axL[0:2]
        y_min, y_max = axL[2:4]

        Dx = dx * fig_x / (x_max - x_min)
        Dy = dy * fig_y / (y_max - y_min)

        angle = (180 / np.pi) * np.arctan(Dy / Dx)

        ax.text(s0,
                t0,
                str(format(r, '.0f')) + 'kg/m3',
                rotation=angle,
                horizontalalignment='left',
                verticalalignment='bottom',
                rotation_mode='anchor',
                color='red')

    t1 = axL[2]
    t0 = t1 + 8

    for q in qrange:
        s1 = CP.PropsSI("Smass", "T", t1, "Q", q, fluid)
        s0 = CP.PropsSI("Smass", "T", t0, "Q", q, fluid)

        pA = np.array([s0, t0])
        pB = np.array([s1, t1])

        # Calculate the angle of the line
        dx, dy = pA - pB
        x_min, x_max = axL[0:2]
        y_min, y_max = axL[2:4]

        Dx = dx * fig_x / (x_max - x_min)
        Dy = dy * fig_y / (y_max - y_min)

        angle = (180 / np.pi) * np.arctan(Dy / Dx)

        ax.text(s0,
                t0,
                str(format(q, '.1f')),
                rotation=angle,
                horizontalalignment='left',
                verticalalignment='bottom',
                rotation_mode='anchor',
                color='gray')

    #fig.plot([s0,s1],[t0,t1],'ro')
    ## isobaric

    ax.grid()

    pgf_with_pdflatex = {
        "pgf.texsystem":
        "pdflatex",
        "pgf.preamble": [
            r"\usepackage[utf8x]{inputenc}",
            r"\usepackage[T1]{fontenc}",
        ]
    }
    mpl.rcParams.update(pgf_with_pdflatex)

    fig.savefig('TS.eps')
    fig.savefig("TS.pgf", bbox_inches="tight")
#%%

from CoolProp.Plots import PropertyPlot
from CoolProp.Plots.SimpleCycles import StateContainer

# for the property plot, the composition needs to be embedded in the fluid name:
if '&' in fluid:
    fluid_full = library+'::'+fluid1 + '[' + str(x_molar) + ']&' + fluid2 + '[' + str(1-x_molar) + ']'
else:
    fluid_full =  library+'::'+fluid

states = StateContainer()
states_hf = StateContainer()
states_cf = StateContainer()
pp = PropertyPlot(fluid_full, 'TS')
if len(limits)>0:
    pp.set_axis_limits(limits)
with NoStdStreams():
    pass
    pp.calc_isolines()
        
    
for i in range(3):
    states[i,'T'] = T[i]
    states[i,"S"] = s[i]
    
for i,Tx in enumerate(T_cd):
    states.append({'T':Tx,'S':s_cd[i]})

for i in range(5,len(T)):
Ejemplo n.º 13
0
from CoolProp.Plots import PropertyPlot

#plot = PropertyPlot("HEOS::ISOBUTAN[0.8]&PROPANE[0.2]", 'PH', unit_system='EUR', tp_limits='ACHP')
# plot.calc_isolines()
# plot.show()

#plot = PropertyPlot("HEOS::ISOBUTAN[0.8]&PROPANE[0.2]", 'TS', unit_system='EUR', tp_limits='ORC')
# plot.calc_isolines()
# plot.show()

plot = PropertyPlot("REFPROP::ISOBUTAN[0.8]&PROPANE[0.2]", 'PH', unit_system='EUR', tp_limits='ACHP')
plot.calc_isolines()
plot.show()

#plot = PropertyPlot("REFPROP::ISOBUTAN[0.8]&PROPANE[0.2]", 'TS', unit_system='EUR', tp_limits='ORC')
# plot.calc_isolines()
# plot.show()

plot = PropertyPlot("HEOS::R134a", 'PH', unit_system='EUR', tp_limits='ACHP')
plot.calc_isolines()
plot.show()
Ejemplo n.º 14
0
from CoolProp.Plots import PropertyPlot

#plot = PropertyPlot("HEOS::ISOBUTAN[0.8]&PROPANE[0.2]", 'PH', unit_system='EUR', tp_limits='ACHP')
#plot.calc_isolines()
#plot.show()

#plot = PropertyPlot("HEOS::ISOBUTAN[0.8]&PROPANE[0.2]", 'TS', unit_system='EUR', tp_limits='ORC')
#plot.calc_isolines()
#plot.show()

plot = PropertyPlot("REFPROP::ISOBUTAN[0.8]&PROPANE[0.2]", 'PH', unit_system='EUR', tp_limits='ACHP')
plot.calc_isolines()
plot.show()

#plot = PropertyPlot("REFPROP::ISOBUTAN[0.8]&PROPANE[0.2]", 'TS', unit_system='EUR', tp_limits='ORC')
#plot.calc_isolines()
#plot.show()

plot = PropertyPlot("HEOS::R134a", 'PH', unit_system='EUR', tp_limits='ACHP')
plot.calc_isolines()
plot.show()
Ejemplo n.º 15
0
import CoolProp
from CoolProp.Plots import PropertyPlot

fluids = CoolProp.CoolProp.FluidsList()

for i, fluid in enumerate(fluids):
    plot = PropertyPlot(fluid, 'ph')
    plot.calc_isolines()
    plot.show()

    if i > 3:
        break
Ejemplo n.º 16
0
from CoolProp.Plots.Common import process_fluid_state, get_critical_point
state = process_fluid_state(
    "HEOS::R32[0.381109419953993]&R125[0.179558888662016]&R134A[0.439331691383991]"
)
cstate = get_critical_point(state)
print(cstate.T())

import matplotlib.pyplot as plt
from CoolProp.Plots import PropertyPlot

fluid = "R407C"
fluid = "R32[0.381109419953993]&R125[0.179558888662016]&R134A[0.439331691383991]"
#fluid = "R32[0.40]&R125[0.15]&R134A[0.45]"

plot_RP = PropertyPlot("REFPROP::" + fluid,
                       'PH',
                       unit_system='EUR',
                       tp_limits='ACHP')
plot_RP.calc_isolines()
plot_RP.draw()

plot_CP = PropertyPlot("HEOS::" + fluid,
                       'PH',
                       unit_system='EUR',
                       tp_limits='ACHP')
plot_CP.calc_isolines()
plot_CP.draw()

plt.show(block=True)
Ejemplo n.º 17
0
                                label='Temperature',
                                symbol=u'T',
                                unit=u'R')
        self._U = BaseDimension(add_SI=0.0,
                                mul_SI=0.000429923,
                                off_SI=0.0,
                                label='Specific Internal Energy',
                                symbol=u'u',
                                unit=u'BTU/lbm')
        self._Q = BaseDimension(add_SI=0.0,
                                mul_SI=1.0,
                                off_SI=0.0,
                                label='Vapour Quality',
                                symbol=u'x',
                                unit=u'')


BasePlot.UNIT_SYSTEMS['ENG'] = ENGunits()  # ['EUR','KSI','SI']

ec = EC_Fluid(symbol)
ec.printCriticalProps()

# Plot Types: 'PS', 'PT', 'HS', 'TS', 'PD', 'TD', 'PH'
# tp_limits:  'NONE', 'DEF','ACHP','ORC'
plot = PropertyPlot(symbol, 'TD', unit_system='ENG', tp_limits='DEF')
plot.calc_isolines(CP.iHmass, num=11)
plot.calc_isolines(CP.iQ, num=11)
plot.title('%s (%s)' % (ec.name, ec.symbol))
plot.grid()
plot.show()
Ejemplo n.º 18
0
def SimpleRankineCycle(T3, p3, p1, epsilon_e, epsilon_p, fluid='water'):
    h1 = PropsSI('H', 'P', p1, 'Q', 0., fluid)
    s1 = PropsSI('S', 'P', p1, 'Q', 0., fluid)
    T1 = PropsSI('T', 'P', p1, 'Q', 0., fluid)

    p2 = p3
    h2 = h1 + (PropsSI('H', 'P', p2, 'S', s1, fluid) - h1) / epsilon_p
    s2 = PropsSI('S', 'H', h2, 'P', p2, fluid)
    T2 = PropsSI('T', 'H', h2, 'P', p2, fluid)

    h3 = PropsSI('H', 'P', p3, 'T', T3, fluid)
    s3 = PropsSI('S', 'H', h3, 'P', p3, fluid)

    p4 = p1
    h4 = h3 - epsilon_e * (h3 - PropsSI('H', 'P', p4, 'S', s3, fluid))
    s4 = PropsSI('S', 'H', h4, 'P', p4, fluid)
    T4 = PropsSI('T', 'H', h4, 'P', p4, fluid)

    w_net = h3 - h4
    q_boiler = h3 - h2
    eta_c = w_net / q_boiler

    Ts = PropertyPlot(fluid, 'Ts', 'KSI')
    Ts.set_axis_limits([0., 12., 200., 900.])
    Ts.calc_isolines(CoolProp.iP, [Ts.system.P.from_SI(p1), Ts.system.P.from_SI(p3)], num=10)
    Ts.calc_isolines(CoolProp.iQ, [Ts.system.Q.from_SI(0.), Ts.system.Q.from_SI(1.)], num=11)
    Ts.draw_isolines()

    states = zip(Ts.system.S.from_SI(array([s1,s2,s3,s4,s1])),Ts.system.T.from_SI(array([T1,T2,T3,T4,T1])))
    Ts.draw_process(states, iso_types=None, line_opts={'color':'red', 'lw':1.5})
    isot = [
      None, # non-isentropic pumping from 1 to 2
      CoolProp.iP, # p2=p3
      None,
      CoolProp.iP, # p4=p1
      ]
    Ts.draw_process(states, iso_types=isot, line_opts={'color':'green', 'lw':1.5})

    ax = Ts.axis
    ax.text(Ts.system.S.from_SI(s1), Ts.system.T.from_SI(T1), ' 1', fontsize=10, rotation=0, color='r')
    ax.text(Ts.system.S.from_SI(s2), Ts.system.T.from_SI(T2), ' 2', fontsize=10, rotation=0, color='r')
    ax.text(Ts.system.S.from_SI(s3), Ts.system.T.from_SI(T3), ' 3', fontsize=10, rotation=0, color='r')
    ax.text(Ts.system.S.from_SI(s4), Ts.system.T.from_SI(T4), ' 4', fontsize=10, rotation=0, color='r')
    ax.text(Ts.system.S.from_SI(8e3),Ts.system.T.from_SI(850),"Efficiency: %.1f%%" %(eta_c*100.))
    ax.text(Ts.system.S.from_SI(8e3),Ts.system.T.from_SI(800),"Net work: %d kJ/kg" %(w_net/1000))
    ax.text(Ts.system.S.from_SI(8e3),Ts.system.T.from_SI(750),"Heat input: %d kJ/kg" %(q_boiler/1000))
    return Ts
Ejemplo n.º 19
0
from __future__ import print_function
import CoolProp
import CoolProp.CoolProp as CP
from CoolProp.Plots import PropertyPlot
import numpy as np


print ("I'm testing python")
print (' ')

rho = CP.PropsSI('D', 'T', 298.15, 'P', 101325, 'Nitrogen')
print ('rho of Nirogen= ', rho)
print (' ')

ph_plot = PropertyPlot('Water', 'PH')
ph_plot.calc_isolines()
#ph_plot.show()
#ph_plot.savefig('images/enthalpy_pressure_graph_for_Water.pdf')

fluid = 'Water'
pressure_at_critical_point = CP.PropsSI(fluid,'pcrit')
# Massic volume (in m^3/kg) is the inverse of density
# (or volumic mass in kg/m^3). Let's compute the massic volume of liquid
# at 1bar (1e5 Pa) of pressure
vL = 1/CP.PropsSI('D','P',1e5,'Q',0,fluid)
# Same for saturated vapor
vG = 1/CP.PropsSI('D','P',1e5,'Q',1,fluid)

print ('vL = ', vL)
print ('vG = ', vG)
Ejemplo n.º 20
0
def main():
    fluid_ref = 'n-Pentane'
    for plot_type in ['Ts']:  # ['pt', 'ph', 'ps', 'ts', 'pt', 'prho', 'trho']:
        plt = PropertyPlot(fluid_ref, plot_type)
        plt.set_axis_limits([-0.5 * 1e3, 1.5 * 1e3, 300, 530])
        plt.draw_isolines('Q', [0.1, 0.9])
        plt.draw_isolines('P', [100 * 1e3, 2000 * 1e3])
        plt.draw_isolines('D', [2, 600])
        plt.show()
Ejemplo n.º 21
0
cycle_states[4, 'H'] = h4
cycle_states[4]['S'] = s4
cycle_states[4][CoolProp.iP] = P4
cycle_states[4, CoolProp.iT] = T4

cycle_states[5, 'H'] = h5
cycle_states[5]['S'] = s5
cycle_states[5][CoolProp.iP] = P5
cycle_states[5, CoolProp.iT] = T5

cycle_states[6, 'H'] = h6
cycle_states[6]['S'] = s6
cycle_states[6][CoolProp.iP] = P6
cycle_states[6, CoolProp.iT] = T6

cycle_states[7, 'H'] = h1
cycle_states[7]['S'] = s1
cycle_states[7][CoolProp.iP] = P1
cycle_states[7, CoolProp.iT] = T1

print(cycle_states)

pp = PropertyPlot(gas, 'PH', unit_system='EUR', tp_limits='ACHP')
pp.calc_isolines()
pp.draw_process(cycle_states)
pp.show()

#plot = PropertyPlot('R290', 'ph')
#plot.calc_isolines()
#plot.show()
Ejemplo n.º 22
0
#         new_state.set_mass_fractions(masses) # Uses mass fraction to work with incompressibles
#     if np.isfinite(crit_state.p) and np.isfinite(crit_state.T):
#         new_state.specify_phase(CoolProp.iphase_critical_point)
#         new_state.update(CoolProp.PT_INPUTS, crit_state.p, crit_state.T)
#         #new_state.update(CoolProp.DmolarT_INPUTS, crit_state.rhomolar, crit_state.T)
#         return new_state
#     raise ValueError("Could not calculate the critical point data.")

from CoolProp.Plots.Common import process_fluid_state, get_critical_point
state = process_fluid_state("HEOS::R32[0.381109419953993]&R125[0.179558888662016]&R134A[0.439331691383991]")
cstate = get_critical_point(state)
print(cstate.T())


import matplotlib.pyplot as plt
from CoolProp.Plots import PropertyPlot

fluid = "R407C"
fluid = "R32[0.381109419953993]&R125[0.179558888662016]&R134A[0.439331691383991]"
#fluid = "R32[0.40]&R125[0.15]&R134A[0.45]"

plot_RP = PropertyPlot("REFPROP::"+fluid, 'PH', unit_system='EUR', tp_limits='ACHP')
plot_RP.calc_isolines()
plot_RP.draw()

plot_CP = PropertyPlot("HEOS::"+fluid, 'PH', unit_system='EUR', tp_limits='ACHP')
plot_CP.calc_isolines()
plot_CP.draw()

plt.show(block=True)
Ejemplo n.º 23
0
cycle_states[7,'H'] = h1
cycle_states[7]['S'] = s1
cycle_states[7][CoolProp.iP] = P1
cycle_states[7,CoolProp.iT] = T1

#Qdot_condensor_calculated = (h2-h4)*massflow

print(cycle_states)
print(Qdot_condensor_expected)
#print(Qdot_condensor_calculated)
print(Expected_COP)
#print(Qdot_condensor_calculated/compressor_power)


pp = PropertyPlot(gas, 'PH', unit_system='KSI',tp_limits='ACHP')
pp.calc_isolines(CoolProp.iQ, num=11)
pp.set_axis_limits([300,700,400,2500])
pp.draw_process(cycle_states)
pp.show()

pp = PropertyPlot(gas, 'TS', unit_system='KSI',tp_limits='ACHP')
pp.calc_isolines(CoolProp.iQ, num=15)
pp.set_axis_limits([1.2,2.6,250,360])
pp.draw_process(cycle_states)
pp.show()

pp = PropertyPlot(gas, 'PH', unit_system='KSI',tp_limits='ACHP')
pp.calc_isolines(CoolProp.iQ, num=11)
pp.set_axis_limits([300,700,400,2500])
pp.draw_process(cycle_states)
Ejemplo n.º 24
0
h_36k = np.array([435.1,492.6,471.5,403.6,323.9,302.3,302.4,302.4,423.9,434.5,435.1]) #in kJ/kg



# plot = PropertyPlot('HEOS::R245fa', 'TS', unit_system='EUR', tp_limits='ORC')
# plot.calc_isolines(CoolProp.iQ, num=11)
# plot.calc_isolines(CoolProp.iP, iso_range=[1,50], num=10, rounding=True)
# plot.draw()
# plot.isolines.clear()
# plot.props[CoolProp.iP]['color'] = 'green'
# plot.props[CoolProp.iP]['lw'] = '0.5'
# plot.calc_isolines(CoolProp.iP, iso_range=[1,50], num=10, rounding=False)
# plot.show()


ph_plot_R410A = PropertyPlot('R410A', 'PH',unit_system='KSI',tp_limits='ACHP')

ph_plot_R410A.calc_isolines(CoolProp.iQ, num=11)

plt.plot(h_36k,P_36k,'g:', label='36K ECU')
plt.ylim(500,5000)
plt.xlim(250,500)
plt.yticks([500, 1000, 5000],
               [r'500', r'$1000$', r'$5000$'])
ph_plot_R410A.show()

#Plot P-h diagram
ph_plot_R407C = PropertyPlot('R407C', 'PH',unit_system='KSI',tp_limits='ACHP')
ph_plot_R407C.props[CoolProp.iQ]['color'] = 'black'

ph_plot_R407C.calc_isolines(CoolProp.iQ, num=11)