Skip to content

Commit

Permalink
change program structure
Browse files Browse the repository at this point in the history
  • Loading branch information
chi86 committed Mar 17, 2019
1 parent 8d52edc commit 0aa3dff
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 115 deletions.
203 changes: 105 additions & 98 deletions PrintDia.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,146 +12,148 @@

import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.use("pgf")
#mpl.use("pgf")

import CoolProp.CoolProp as CP
from CoolProp.Plots import PropertyPlot
from CoolProp.Plots import SimpleCompressionCycle


fluid="R1234yf"
rrange=np.linspace(10,500,10).tolist()
prange=np.linspace(4E5,40E5,10).tolist()

rrange=[10,20,50,100,200,300,400,500]
prange=[1E5,2E5,4E5,6E5,8E5,10E5,12E5,16E5,20E5,25E5,30E5,40E5]
def main():
fluid="R1234yf"
rrange=[10,20,50,100,200,300,400,500]
prange=[1E5,2E5,4E5,6E5,8E5,10E5,12E5,16E5,20E5,25E5,30E5,40E5]

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)
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)

## 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.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)


ts.draw()
## 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)

axL=ts.get_axis_limits()

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

axL=ts.get_axis_limits()

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

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])
t1=axL[3]-25
t0=t1-5

# Calculate the angle of the line
dx, dy = pA-pB
x_min, x_max = axL[0:2]
y_min, y_max = axL[2:4]
for p in prange:
s1=CP.PropsSI("Smass","T",t1,"P",p,fluid)
s0=CP.PropsSI("Smass","T",t0,"P",p,fluid)

Dx = dx * fig_x / (x_max - x_min)
Dy = dy * fig_y / (y_max - y_min)
pA=np.array([s0,t0])
pB=np.array([s1,t1])

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
# 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')

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])
t1=axL[3]-10
t0=t1-5

# 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)
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')
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
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)
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])
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]
# 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)
Dx = dx * fig_x / (x_max - x_min)
Dy = dy * fig_y / (y_max - y_min)

angle = (180/np.pi)*np.arctan( Dy / Dx)
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.text(s0, t0, str(format(q,'.1f')), rotation = angle,
horizontalalignment='left',
verticalalignment='bottom', rotation_mode='anchor', color='gray')

ax.grid()
#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)

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")
#plt.show()
############### TS
fig.savefig('TS.eps')
fig.savefig("TS.pgf", bbox_inches="tight")
############### TS


# ############### ph
Expand Down Expand Up @@ -204,3 +206,8 @@


# plt.show()



if __name__== "__main__":
main()
2 changes: 1 addition & 1 deletion TS.eps

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions report.blg
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[0] Config.pm:354> INFO - This is Biber 2.7
[0] Config.pm:357> INFO - Logfile is 'report.blg'
[20] biber:302> INFO - === Sat Mar 16, 2019, 14:23:27
[30] Biber.pm:359> INFO - Reading 'report.bcf'
[20] biber:302> INFO - === Sun Mar 17, 2019, 20:14:39
[29] Biber.pm:359> INFO - Reading 'report.bcf'
[77] Biber.pm:835> INFO - Found 1 citekeys in bib section 0
[86] Biber.pm:3670> INFO - Processing section 0
[95] Biber.pm:3840> INFO - Looking for bibtex format file 'ref.bib' for section 0
[96] bibtex.pm:1422> INFO - Decoding LaTeX character macros into UTF-8
[96] Biber.pm:3840> INFO - Looking for bibtex format file 'ref.bib' for section 0
[97] bibtex.pm:1422> INFO - Decoding LaTeX character macros into UTF-8
[100] bibtex.pm:1279> INFO - Found BibTeX data source 'ref.bib'
[112] UCollate.pm:68> INFO - Overriding locale 'en-US' defaults 'normalization = NFD' with 'normalization = prenormalized'
[112] UCollate.pm:68> INFO - Overriding locale 'en-US' defaults 'variable = shifted' with 'variable = non-ignorable'
[112] Biber.pm:3499> INFO - Sorting list 'nyt/global/' of type 'entry' with scheme 'nyt' and locale 'en-US'
[112] Biber.pm:3505> INFO - No sort tailoring available for locale 'en-US'
[114] bbl.pm:608> INFO - Writing 'report.bbl' with encoding 'ascii'
[115] bbl.pm:712> INFO - Output to report.bbl
[113] UCollate.pm:68> INFO - Overriding locale 'en-US' defaults 'normalization = NFD' with 'normalization = prenormalized'
[113] UCollate.pm:68> INFO - Overriding locale 'en-US' defaults 'variable = shifted' with 'variable = non-ignorable'
[113] Biber.pm:3499> INFO - Sorting list 'nyt/global/' of type 'entry' with scheme 'nyt' and locale 'en-US'
[113] Biber.pm:3505> INFO - No sort tailoring available for locale 'en-US'
[115] bbl.pm:608> INFO - Writing 'report.bbl' with encoding 'ascii'
[116] bbl.pm:712> INFO - Output to report.bbl
12 changes: 6 additions & 6 deletions report.log
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=pdflatex 2019.3.1) 16 MAR 2019 14:23
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=pdflatex 2019.3.1) 17 MAR 2019 20:14
entering extended mode
\write18 enabled.
%&-line parsing enabled.
Expand Down Expand Up @@ -703,10 +703,10 @@ Package biblatex Info: Reference segment=0 on input line 41.
(./TS.pgf

LaTeX Font Warning: Font shape `OT1/cmss/m/n' in size <20> not available
(Font) size <20.74> substituted on input line 1807.
(Font) size <20.74> substituted on input line 2028.

)
Overfull \hbox (6.61455pt too wide) in paragraph at lines 1989--50
Overfull \hbox (14.12099pt too wide) in paragraph at lines 2210--50
[][]
[]

Expand All @@ -721,8 +721,8 @@ Package logreq Info: Writing requests to 'report.run.xml'.
)
Here is how much of TeX's memory you used:
16582 strings out of 494896
306984 string characters out of 6180318
724721 words of memory out of 5000000
306982 string characters out of 6180318
725721 words of memory out of 5000000
19629 multiletter control sequences out of 15000+600000
7799 words of font info for 29 fonts, out of 8000000 for 9000
36 hyphenation exceptions out of 8191
Expand All @@ -733,7 +733,7 @@ nts/type1/public/amsfonts/cm/cmr8.pfb></usr/share/texmf-dist/fonts/type1/public
/amsfonts/cm/cmss10.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/c
mss17.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmti8.pfb></usr
/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmtt8.pfb>
Output written on report.pdf (1 page, 79675 bytes).
Output written on report.pdf (1 page, 80821 bytes).
PDF statistics:
39 PDF objects out of 1000 (max. 8388607)
28 compressed objects within 1 object stream
Expand Down
Binary file modified report.pdf
Binary file not shown.

0 comments on commit 0aa3dff

Please sign in to comment.