-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfigure_1.py
196 lines (157 loc) · 5.68 KB
/
figure_1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from collections import defaultdict
SPEAKING_DATA_FILE = "data/heads-data-speaking.csv"
BREATHING_DATA_FILE = "data/heads-data-breathing.csv"
def get_cunningham_corr_factor(diameter):
λ = 6.4e-8 # mean free path
d = diameter # particle diameter
A1, A2, A3 = 1.257, 0.400, 0.55 # experimentally derived coefficients
corr_factor = 1 + ((2 * λ) / d) * (A1 + A2 * np.exp((-A3 * d) / λ))
return corr_factor
def get_terminal_velocity(diameter):
g = 9.81 # m/s^2, gravitation
p = 997 # kg/m^3, density of water (aerosol)
e = 1.825e-5 # dynamic viscosity of air at 20°C
Cc = get_cunningham_corr_factor(diameter)
terminal_velocity = (diameter**2 * g * p * Cc) / (18 * e)
return terminal_velocity
def get_settling_time():
diameters = np.logspace(-7.9, -3, num=50)
residence_times = []
for diameter in diameters:
terminal_velocity = get_terminal_velocity(diameter)
residence_time_s = 1.5 / terminal_velocity
residence_times.append(residence_time_s)
diameters_um = diameters * 1e6
settling_df = pd.DataFrame(
{
"Aerosol diameter (um)": diameters_um,
"Residence time (seconds)": residence_times,
}
)
return settling_df
def return_bagheri_dfs():
# Data extracted from Figure 6 of Bagheri et. al. 2023 (Breathing + Speaking (normal))
# https://doi.org/10.1016/j.jaerosci.2022.106102
df_speaking = pd.read_csv(SPEAKING_DATA_FILE)
df_breathing = pd.read_csv(BREATHING_DATA_FILE)
CONCENTRATION_CUT_OFF = 1e-4
# Based on the underlying data, plotted in Figure 6 of this paper: https://doi.org/10.1016/j.jaerosci.2022.106102 I do not trust the data
# for the lower concentrations.
df_speaking = df_speaking[df_speaking["concentration"] > CONCENTRATION_CUT_OFF]
df_breathing = df_breathing[df_breathing["concentration"] > CONCENTRATION_CUT_OFF]
return df_breathing, df_speaking
def return_figure_1():
df_pivot_breathing, df_pivot_speaking = return_bagheri_dfs()
fig, axs = plt.subplots(
2, 1, figsize=(8, 5.8), height_ratios=[2, 2], dpi=600, sharex=True
)
sns_colors = sns.color_palette()
axs[0].plot(
df_pivot_breathing["particle-diameter"],
df_pivot_breathing["concentration"],
"o",
color=sns_colors[0],
label="Breathing",
markersize=4,
)
axs[0].text(
0.44,
0.3,
"Breathing",
transform=axs[0].transAxes,
ha="left",
va="bottom",
fontsize=10,
color=sns_colors[0],
)
axs[0].plot(
df_pivot_speaking["particle-diameter"],
df_pivot_speaking["concentration"],
"o",
color=sns_colors[1],
label="Speaking",
markersize=4,
)
axs[0].text(
0.68,
0.74,
"Speaking",
transform=axs[0].transAxes,
ha="left",
va="bottom",
fontsize=10,
color=sns_colors[1],
)
axs[0].set_title("a", loc="left", fontsize=12, fontweight="bold", x=-0.095, y=1.05)
axs[0].set_yscale("log")
axs[0].set_xscale("log")
axs[0].set_xlabel("Aerosol diameter (μm)", fontsize=9)
axs[0].xaxis.set_major_formatter(plt.FuncFormatter(lambda x, _: "{:.2f}".format(x)))
axs[0].tick_params(axis="x", which="major", labelbottom=True, labelsize=8)
axs[0].tick_params(axis="y", which="major", labelsize=8)
axs[0].set_ylabel(
r"Particle concentration (log) / $\mathregular{cm^{-3}}$", fontsize=9
)
axs[0].set_title("")
settling_df = get_settling_time()
settling_df_sorted = settling_df.sort_values(by="Aerosol diameter (um)")
settling_df_dashed = settling_df_sorted[
settling_df_sorted["Aerosol diameter (um)"] <= 0.51
]
settling_df_solid = settling_df_sorted[
settling_df_sorted["Aerosol diameter (um)"] >= 0.5
]
# Plot the dashed line
sns.lineplot(
data=settling_df_dashed,
x="Aerosol diameter (um)",
y="Residence time (seconds)",
ax=axs[1],
color=sns_colors[4],
linestyle="--",
)
# Plot the solid line
sns.lineplot(
data=settling_df_solid,
x="Aerosol diameter (um)",
y="Residence time (seconds)",
ax=axs[1],
color=sns_colors[4],
linestyle="-",
)
y_min, y_max = axs[1].get_ylim()
print(y_min, y_max)
# axs[1].set_ylim(y_min, y_max * 10)
axs[1].set_title("b", loc="left", fontsize=12, fontweight="bold", x=-0.095, y=0.95)
axs[1].set_yscale("log")
axs[1].xaxis.set_major_formatter(plt.FuncFormatter(lambda x, _: "{:.2f}".format(x)))
axs[1].set_xlabel("Aerosol diameter (μm)", fontsize=9)
axs[1].set_ylabel("Theoretical residence time", fontsize=9)
tick_values = [
1,
60,
3600,
86400,
] # Values in seconds for 1 second, 1 minute, 1 hour, and 1 day
tick_labels = ["1s", "1m", "1h", "24h"]
axs[1].set_yticks(tick_values)
axs[1].set_yticklabels(tick_labels)
axs[1].set_title("")
axs[1].tick_params(axis="x", which="major", bottom=False, labelsize=8)
axs[1].tick_params(axis="y", which="major", labelsize=8)
for ax in axs:
ax.tick_params(
axis="both", which="minor", left=False, right=False, top=False, bottom=False
)
ax.grid(True, which="major", color="gray", linewidth=0.2)
ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False)
plt.tight_layout()
plt.savefig("fig/aerosol_size_distribution.png", dpi=600)
plt.savefig("fig/aerosol_size_distribution.pdf")
if __name__ == "__main__":
return_figure_1()