# Untitled

a guest
Sep 11th, 2018
89
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import numpy as np
2. import matplotlib.pyplot as plt
3.
4.
5. def Rho_dtic(TC):
6.     """ valid between -45C and +25C"""
7.
8.     return 0.7987 - 0.0036*(TC - 25.)
9.
10. def C2K(C):
11.     return C + 273.15
12. def K2C(K):
13.     return K - 273.15
14.
15. def C2F(C):
16.     return (9./5.)*C + 32.
17. def F2C(F):
18.     return (5./9.)*(F-32.)
19.
20. def C2R(C):
21.     return (9./5.)*(C+273.15)
22. def R2C(R):
23.     return (5./9.)*R - 273.15
24.
25. def F2K(F):
26.     return (5./9.)*(F-32.) + 273.15
27. def K2F(K):
28.     return  (9./5.)*(K-273.15) + 32.
29.
30.
31.
32. C = 5. * np.arange(15) -45.
33.
34. C_lowextrap = -85.
35. C_ext = np.linspace(C_lowextrap, C[0], 5)
36.
37. print "rho at -30F: ", Rho_dtic((-30.-32.)*(5./9.))
38.
39. rho = Rho_dtic(C)
40. rho_ext  = Rho_dtic(C_ext)
41.
42. K, K_ext = C2K(C), C2K(C_ext)
43. F, F_ext = C2F(C), C2F(C_ext)
44. R, R_ext = C2R(C), C2R(C_ext)
45.
46. K_limits = np.array([50, 300])
47. C_limits = K2C(K_limits)
48. F_limits = K2F(K_limits)
49. R_limits = C2R(K2C(K_limits))
50.
51. put_rat = 0.03
52. K_put = K_limits.max() - put_rat*(K_limits.max()-K_limits.min())
53. C_put = C_limits.max() - put_rat*(C_limits.max()-C_limits.min())
54. F_put = F_limits.max() - put_rat*(F_limits.max()-F_limits.min())
55. R_put = R_limits.max() - put_rat*(R_limits.max()-R_limits.min())
56.
57. R_info = np.array([302, 335, 350, 355, 380, 420])
58. C_info = R2C(R_info)
59. K_info = C2K(R2C(R_info))
60. F_info = C2F(R2C(R_info))
61. info = ['hard wax', 'solid wax', 'soft wax', 'gel',
62.         'gel, thick liquid', 'liquid w/ some solids']
63.
64. # NOW LOX!!!!!!
65.
66. """
67. # A10.....
68. R_A10 = np.array([98.0, 110, 120, 130, 140, 150, 160, 165])  # R is absolute Farenheit
69. C_A10 = R2C(R_A18)
70. K_A10 = C2K(R2C(R_A18))
71. F_A10 = C2F(R2C(R_A18))
72. lb_A10 = np.array([81.5, 79.5, 78.2, 76.7, 74.9, 73.2, 71.5, 70.8])
73. f = 0.01602  # g/cm^3 per lb/ft^3
74. rho_A10 = f*lb_A18
75. """
76.
77. # A02.....
78. K_A02 = np.array([68.0, 70, 74, 78, 80, 82, 86, 89])
79. C_A02 = K2C(K_A02)
80. F_A02 = K2F(K_A02)
81. R_A02 = C2R(K2C(K_A02))
82. rho_A02 = np.array([1.2489, 1.2393, 1.2200, 1.2008,
83.                    1.1911,1.1815, 1.1623, 1.1479 ])
84.
85. # A18.....
86. A, B, n = 0.43533, 0.28772, 0.29240
87. Tc, Tmin, Tmax = 154.58, 54.35, 154.58
88.
89. K_A18 = 55. + 5.*np.arange(8)
90. C_A18 = K2C(K_A18)
91. F_A18 = K2F(K_A18)
92. R_A18 = C2R(K2C(K_A18))
93.
94. def Rho_L(T):
95.     return A * (B**(-(1 - T/Tc)**n))
96.
97. rho_A18 = Rho_L(K_A18)
98.
99. F_NK33_LOX = -310.
100. F_NK33_RP1 =  -30.
101.
102. C_NK33_LOX = F2C(F_NK33_LOX)
103. K_NK33_LOX = C2K(F2C(F_NK33_LOX))
104. R_NK33_LOX = C2R(F2C(F_NK33_LOX))
105.
106. C_NK33_RP1 = F2C(F_NK33_RP1)
107. K_NK33_RP1 = C2K(F2C(F_NK33_RP1))
108. R_NK33_RP1 = C2R(F2C(F_NK33_RP1))
109.
110. rho_NK33_LOX = Rho_L(C2K(F2C(F_NK33_LOX)))
111. rho_NK33_RP1 = Rho_dtic(F2C(F_NK33_RP1))
112.
113. NK33_LOX_label = "NK-33  LOX  -310F"
114. NK33_RP1_label = "NK-33  RP1   -30F"
115. C_NK33_LOXlabel   = -180.
116. C_NK33_RP1label   =  -70.
117. F_NK33_LOXlabel   = C2F(C_NK33_LOXlabel)
118. F_NK33_RP1label   = C2F(C_NK33_RP1label)
119. K_NK33_LOXlabel   = C2K(C_NK33_LOXlabel)
120. K_NK33_RP1label   = C2K(C_NK33_RP1label)
121. R_NK33_LOXlabel   = C2R(C_NK33_LOXlabel)
122. R_NK33_RP1label   = C2R(C_NK33_RP1label)
123.
124.
125. fig = plt.figure(figsize=[9,10])
126.
127. rho_limits = np.array([0.75, 1.35])
128. h = rho_limits.min() + 0.01
129. h_put = rho_limits.max() - 0.02
130. #bbox = {'fc': '0.8', 'pad': 0}
131. thing     = {'ha': 'center', 'va': 'bottom', 'bbox': None,
132.              'fontsize':15}
133. thing_put = {'ha': 'right',  'va': 'top', 'bbox': None,
134.              'fontsize':18}
135. thing_LOX = {'ha': 'left',  'va': 'bottom', 'bbox': None,
136.              'fontsize':14}
137. thing_RP1 = {'ha': 'right',  'va': 'bottom', 'bbox': None,
138.              'fontsize':14}
139. ticklab_fontsize = 15
140. lws, lwd, lwn = 2, 1.5, 1.0
141.
142. # plt.subplot(4,1,1)
143. ax = plt.subplot(4, 1, 1)
144. for item in (ax.get_xticklabels() + ax.get_yticklabels()):
145.     item.set_fontsize(ticklab_fontsize)
146. plt.plot(C, rho, lw=lws)
147. plt.plot(C_ext, rho_ext, '--r', lw=lwd)
148. plt.xlim(C_limits)
149. plt.ylim(rho_limits)
150. plt.minorticks_on()
151. plt.text(C_put, h_put, "Centigrade", thing_put)
152. for a, b in zip(C_info, info):
153.     plt.text(a, h, b, thing, rotation=90)
154. plt.plot(C_A02, rho_A02, 'or')
155. plt.plot(C_A18, rho_A18, lw=lws)
156. plt.plot(C_limits, [rho_NK33_LOX]*2, '-k', lw=lwn)
157. plt.plot(C_limits, [rho_NK33_RP1]*2, '--k', lw=lwn)
158. plt.text(C_NK33_LOXlabel, rho_NK33_LOX+0.02, NK33_LOX_label, thing_LOX)
159. plt.text(C_NK33_RP1label, rho_NK33_RP1+0.02, NK33_RP1_label, thing_RP1)
160.
161.
162.
163.
164.
165.
166. ax = plt.subplot(4, 1, 2)
167. for item in (ax.get_xticklabels() + ax.get_yticklabels()):
168.     item.set_fontsize(ticklab_fontsize)
169. plt.plot(K, rho, lw=lws)
170. plt.plot(K_ext, rho_ext, '--r', lw=lwd)
171. plt.xlim(K_limits)
172. plt.ylim(rho_limits)
173. plt.minorticks_on()
174. plt.text(K_put, h_put, "Kelvin", thing_put)
175. for a, b in zip(K_info, info):
176.     plt.text(a, h, b, thing, rotation=90)
177. plt.plot(K_A02, rho_A02, 'or')
178. plt.plot(K_A18, rho_A18, lw=lws)
179. plt.plot(K_limits, [rho_NK33_LOX]*2, '-k', lw=lwn)
180. plt.plot(K_limits, [rho_NK33_RP1]*2, '--k', lw=lwn)
181. plt.text(K_NK33_LOXlabel, rho_NK33_LOX+0.02, NK33_LOX_label, thing_LOX)
182. plt.text(K_NK33_RP1label, rho_NK33_RP1+0.02, NK33_RP1_label, thing_RP1)
183.
184.
185.
186. ax = plt.subplot(4, 1, 3)
187. for item in (ax.get_xticklabels() + ax.get_yticklabels()):
188.     item.set_fontsize(ticklab_fontsize)
189. plt.plot(F, rho, lw=lws)
190. plt.plot(F_ext, rho_ext, '--r', lw=lwd)
191. plt.xlim(F_limits)
192. plt.ylim(rho_limits)
193. plt.minorticks_on()
194. plt.text(F_put, h_put, "Farenheit", thing_put)
195. for a, b in zip(F_info, info):
196.     plt.text(a, h, b, thing, rotation=90)
197. plt.plot(F_A02, rho_A02, 'or')
198. plt.plot(F_A18, rho_A18, lw=lws)
199. plt.plot(F_limits, [rho_NK33_LOX]*2, '-k', lw=lwn)
200. plt.plot(F_limits, [rho_NK33_RP1]*2, '--k', lw=lwn)
201. plt.text(F_NK33_LOXlabel, rho_NK33_LOX+0.02, NK33_LOX_label, thing_LOX)
202. plt.text(F_NK33_RP1label, rho_NK33_RP1+0.02, NK33_RP1_label, thing_RP1)
203.
204.
205.
206. ax = plt.subplot(4, 1, 4)
207. for item in (ax.get_xticklabels() + ax.get_yticklabels()):
208.     item.set_fontsize(ticklab_fontsize)
209. plt.plot(R, rho, lw=lws)
210. plt.plot(R_ext, rho_ext, '--r', lw=lwd)
211. plt.xlim(R_limits)
212. plt.ylim(rho_limits)
213. plt.minorticks_on()
214. plt.text(R_put, h_put, "Rankine", thing_put)
215. for a, b in zip(R_info, info):
216.     plt.text(a, h, b, thing, rotation=90)
217. plt.plot(R_A02, rho_A02, 'or')
218. plt.plot(R_A18, rho_A18, lw=lws)
219. plt.plot(R_limits, [rho_NK33_LOX]*2, '-k', lw=lwn)
220. plt.plot(R_limits, [rho_NK33_RP1]*2, '--k', lw=lwn)
221. plt.text(R_NK33_LOXlabel, rho_NK33_LOX+0.02, NK33_LOX_label, thing_LOX)
222. plt.text(R_NK33_RP1label, rho_NK33_RP1+0.02, NK33_RP1_label, thing_RP1)
223.
224.
225.