Skip to content

Commit b9d74f8

Browse files
committed
Initial Commit
0 parents  commit b9d74f8

5 files changed

+1678
-0
lines changed

CO2_interpolation.py

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
"""
2+
@author: Jalal Alali
3+
"""
4+
5+
import numpy as np
6+
import matplotlib.pyplot as plt
7+
8+
p_spann=np.array([150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,
9+
310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,
10+
500,510,520,530,540,550,560,570,580,590,600])
11+
12+
den=np.array([339.2598818,371.5183818,403.317185,434.0160957,463.1216168,
13+
490.3323815,515.5301064,538.7369052,560.0634069,579.6650226,597.7122246,
14+
614.3729516,629.8032612,644.1431781,657.5157308,670.0278043,681.7718488,
15+
692.8278309,703.265095,713.1439957,722.5172736,731.431196,739.9265001,
16+
748.0391761,755.8011209,763.2406882,770.3831547,777.2511161,783.864826,
17+
790.2424864,796.4004982,802.3536764,808.1154374,813.6979602,819.1123271,
18+
824.368646,829.4761569,834.4433252,839.2779231,843.9871012,848.5774518,
19+
853.0550638,857.4255722,861.694201,865.8658017,869.9448878])
20+
21+
fvf=np.array([0.00551745,0.005038376,0.004641135,0.004312857,0.004041809,
22+
0.003817511,0.003630921,0.003474515,0.00334221,0.003229191,0.00313169,
23+
0.003046764,0.002972118,0.002905952,0.002846851,0.002793689,0.002745566,
24+
0.002701753,0.002661655,0.002624785,0.002590733,0.00255916,0.002529777,
25+
0.002502341,0.002476643,0.002452502,0.002429764,0.002408294,0.002387975,
26+
0.002368702,0.002350387,0.002332948,0.002316314,0.002300423,0.002285217,
27+
0.002270646,0.002256664,0.002243231,0.002230309,0.002217865,0.002205867,
28+
0.002194289,0.002183104,0.00217229,0.002161824,0.002151687])
29+
30+
#CO2 Density at STD (1.01325 bar, 15 °C)
31+
den_co2_sc=1.87184934007942 #kg/m3
32+
33+
# Define the point where we want to interpolate
34+
p_target=350 #bar
35+
36+
# Perform linear interpolation
37+
fvf_interp = np.interp(p_target, p_spann, fvf)
38+
# Print the interpolated values
39+
print("FVF at "+str(p_target)+" bar= ", fvf_interp)
40+
41+
42+
# Perform linear interpolation
43+
den_interp = np.interp(p_target, p_spann, den)
44+
# Print the interpolated values
45+
print("CO2 Density at Standard Condition (SC)= ", den_co2_sc, "kg/m3")
46+
print("CO2 Density at "+str(p_target)+" bar= ", den_interp, "kg/m3")
47+
48+
# # Create figure and axes
49+
# fig, ax1 = plt.subplots(1)
50+
51+
# # Plot data for "p" on the first y-axis
52+
# ax1.plot(p_spann, den, 'r-', label='Density')
53+
# # ax1.scatter(p_target,den_interp, color='black')
54+
# # ax1.annotate("Density at "+str(p_target)+" bar:\n"+str(den_interp), xy=(p_target,den_interp), xytext=(10,20),
55+
# # textcoords='offset points', ha='left', va='bottom')
56+
# ax1.set_xlabel('Pressure (bar)')
57+
# ax1.set_ylabel('Density (kg/m3)', color='r')
58+
# ax1.tick_params('y', colors='r')
59+
60+
# # # Create a second y-axis
61+
# ax2 = ax1.twinx()
62+
63+
# # # Plot data for "fvf" on the second y-axis
64+
# ax2.plot(p_spann, fvf, 'b-', label='FVF')
65+
# # ax2.scatter(p_target,fvf_interp, color='black')
66+
# # ax2.annotate("FVF at "+str(p_target)+" bar:\n"+str(fvf_interp), xy=(p_target,fvf_interp), xytext=(10,20),
67+
# # textcoords='offset points', ha='left', va='bottom')
68+
# ax2.set_xlabel('Pressure (bar)')
69+
# ax2.set_ylabel('FVF', color='b')
70+
# ax2.tick_params('y', colors='b')
71+
72+
# # # Add legend
73+
# lines = ax1.get_lines() + ax2.get_lines()
74+
# labels = [line.get_label() for line in lines]
75+
# ax1.set_title('CO2 Density & FVF Vs. Pressure')
76+
# ax1.legend(lines, labels, loc='best')
77+
78+
# #Adjust the figure size to fit the page
79+
# fig=plt.gcf()
80+
# fig.set_size_inches(8, 6)
81+
# plt.subplots_adjust(left=0.2, right=0.8, bottom=0.2, top=0.8)
82+
83+
# # # Show the plot
84+
# # plt.show()
85+
# plt.savefig('FVF Original.pdf')
86+
87+
88+
89+
90+
91+
92+
93+
94+

0 commit comments

Comments
 (0)