Пример #1
0
#%%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)
plot.calc_isolines(CoolProp.iT, num=25)
plot.calc_isolines(CoolProp.iSmass, num=15)
plot.show()

#%%
import CoolProp
from CoolProp.Plots import PropertyPlot
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()

#%%

import CoolProp
from CoolProp.Plots import PropertyPlot
ts_plot = PropertyPlot('Water', 'Ts')
ts_plot.calc_isolines(CoolProp.iQ, num=11)
ts_plot.title(r'$T,s$ Graph for Water')
ts_plot.xlabel(r'$s$ [kJ/kg K]')
ts_plot.ylabel(r'$T$ [K]')
Пример #2
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)
Пример #3
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")
Пример #4
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)
Пример #5
0
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)
ph_plot_R407C.calc_isolines(CoolProp.iT, num=25)
ph_plot_R407C.draw()
ph_plot_R407C.isolines.clear()

ph_plot_R410A.props[CoolProp.iQ]['color'] = 'green'
ph_plot_R410A.calc_isolines(CoolProp.iQ, num=11)
ph_plot_R410A.draw()

ph_plot_R407C.xlabel(r'$h$ $[\mathrm{kJ/kg}]$')
ph_plot_R407C.ylabel(r'$P$ $[\mathrm{kPa}]$')
#ph_plot_R407C.grid()
plt.plot(h_60k,P_60k,'b-', label='60K ECU')
#plt.errorbar(h_60k,P_60k, yerr=0.08*P_60k)
plt.plot(h_36k,P_36k,'g:', label='36K ECU')
plt.plot(h_18k,P_18k,'r--', label='18K ECU')

plt.ylim(500,5000)