|
| 1 | +import CLIMAParameters |
| 2 | +import CloudMicrophysics as CM |
| 3 | +import CloudMicrophysics.P3Scheme as P3 |
| 4 | +import CloudMicrophysics.Parameters as CMP |
| 5 | +import CairoMakie as Plt |
| 6 | + |
| 7 | +const PSP3 = CMP.ParametersP3 |
| 8 | + |
| 9 | +FT = Float64 |
| 10 | + |
| 11 | +p3 = CMP.ParametersP3(FT) |
| 12 | + |
| 13 | +function get_values( |
| 14 | + p3::PSP3, |
| 15 | + Chen2022::CMP.Chen2022VelTypeSnowIce, |
| 16 | + q::FT, |
| 17 | + N::FT, |
| 18 | + ρ_a::FT, |
| 19 | + x_resolution::Int, |
| 20 | + y_resolution::Int, |
| 21 | +) where {FT} |
| 22 | + F_rs = range(FT(0), stop = FT(1 - eps(FT)), length = x_resolution) |
| 23 | + ρ_rs = range(FT(25), stop = FT(975), length = y_resolution) |
| 24 | + |
| 25 | + V_m = zeros(x_resolution, y_resolution) |
| 26 | + D_m = zeros(x_resolution, y_resolution) |
| 27 | + |
| 28 | + for i in 1:x_resolution |
| 29 | + for j in 1:y_resolution |
| 30 | + F_r = F_rs[i] |
| 31 | + ρ_r = ρ_rs[j] |
| 32 | + |
| 33 | + V_m[i, j] = |
| 34 | + P3.terminal_velocity_mass(p3, Chen2022, q, N, ρ_r, F_r, ρ_a) |
| 35 | + # get D_m in mm for plots |
| 36 | + D_m[i, j] = 1e3 * P3.D_m(p3, q, N, ρ_r, F_r) |
| 37 | + end |
| 38 | + end |
| 39 | + return (; F_rs, ρ_rs, V_m, D_m) |
| 40 | +end |
| 41 | + |
| 42 | +function figure_2() |
| 43 | + Chen2022 = CMP.Chen2022VelType(FT) |
| 44 | + # density of air in kg/m^3 |
| 45 | + ρ_a = FT(1.2) #FT(1.293) |
| 46 | + |
| 47 | + f = Plt.Figure() |
| 48 | + xres = 100 |
| 49 | + yres = 100 |
| 50 | + min = FT(0) |
| 51 | + max = FT(10) |
| 52 | + |
| 53 | + # small D_m |
| 54 | + q_s = FT(0.0008) |
| 55 | + N_s = FT(1e6) |
| 56 | + |
| 57 | + # medium D_m |
| 58 | + q_m = FT(0.22) |
| 59 | + N_m = FT(1e6) |
| 60 | + |
| 61 | + # large D_m |
| 62 | + q_l = FT(0.7) |
| 63 | + N_l = FT(1e6) |
| 64 | + |
| 65 | + # get V_m and D_m |
| 66 | + (F_rs, ρ_rs, V_ms, D_ms) = |
| 67 | + get_values(p3, Chen2022.snow_ice, q_s, N_s, ρ_a, xres, yres) |
| 68 | + (F_rm, ρ_rm, V_mm, D_mm) = |
| 69 | + get_values(p3, Chen2022.snow_ice, q_m, N_m, ρ_a, xres, yres) |
| 70 | + (F_rl, ρ_rl, V_ml, D_ml) = |
| 71 | + get_values(p3, Chen2022.snow_ice, q_l, N_l, ρ_a, xres, yres) |
| 72 | + |
| 73 | + ax1 = Plt.Axis( |
| 74 | + f[1, 1], |
| 75 | + xlabel = "F_r", |
| 76 | + ylabel = "ρ_r", |
| 77 | + title = "Small Dₘ", |
| 78 | + width = 350, |
| 79 | + height = 350, |
| 80 | + limits = (0, 1.0, 25, 975), |
| 81 | + xticks = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0], |
| 82 | + yticks = [200, 400, 600, 800], |
| 83 | + ) |
| 84 | + |
| 85 | + Plt.contourf!( |
| 86 | + F_rs, |
| 87 | + ρ_rs, |
| 88 | + V_ms, |
| 89 | + colormap = Plt.reverse(Plt.cgrad(:Spectral)), |
| 90 | + ) |
| 91 | + Plt.contour!(F_rs, ρ_rs, D_ms, color = :black, labels = true, levels = 3) |
| 92 | + Plt.Colorbar( |
| 93 | + f[2, 1], |
| 94 | + limits = ( |
| 95 | + minimum(v for v in V_ms if !isnan(v)), |
| 96 | + maximum(v for v in V_ms if !isnan(v)), |
| 97 | + ), |
| 98 | + colormap = Plt.reverse(Plt.cgrad(:Spectral)), |
| 99 | + flipaxis = true, |
| 100 | + vertical = false, |
| 101 | + ) |
| 102 | + |
| 103 | + ax2 = Plt.Axis( |
| 104 | + f[1, 2], |
| 105 | + xlabel = "F_r", |
| 106 | + ylabel = "ρ_r", |
| 107 | + title = "Medium Dₘ", |
| 108 | + width = 350, |
| 109 | + height = 350, |
| 110 | + limits = (0, 1.0, 25, 975), |
| 111 | + xticks = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0], |
| 112 | + yticks = [200, 400, 600, 800], |
| 113 | + ) |
| 114 | + |
| 115 | + Plt.contourf!( |
| 116 | + F_rm, |
| 117 | + ρ_rm, |
| 118 | + V_mm, |
| 119 | + colormap = Plt.reverse(Plt.cgrad(:Spectral)), |
| 120 | + ) |
| 121 | + Plt.contour!(F_rm, ρ_rm, D_mm, color = :black, labels = true, levels = 3) |
| 122 | + Plt.Colorbar( |
| 123 | + f[2, 2], |
| 124 | + limits = ( |
| 125 | + minimum(v for v in V_mm if !isnan(v)), |
| 126 | + maximum(v for v in V_mm if !isnan(v)), |
| 127 | + ), |
| 128 | + colormap = Plt.reverse(Plt.cgrad(:Spectral)), |
| 129 | + flipaxis = true, |
| 130 | + vertical = false, |
| 131 | + ) |
| 132 | + |
| 133 | + ax3 = Plt.Axis( |
| 134 | + f[1, 3], |
| 135 | + xlabel = "F_r", |
| 136 | + ylabel = "ρ_r", |
| 137 | + title = "Large Dₘ", |
| 138 | + width = 350, |
| 139 | + height = 350, |
| 140 | + limits = (0, 1.0, 25, 975), |
| 141 | + xticks = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0], |
| 142 | + yticks = [200, 400, 600, 800], |
| 143 | + ) |
| 144 | + |
| 145 | + Plt.contourf!( |
| 146 | + F_rl, |
| 147 | + ρ_rl, |
| 148 | + V_ml, |
| 149 | + colormap = Plt.reverse(Plt.cgrad(:Spectral)), |
| 150 | + ) |
| 151 | + Plt.contour!(F_rl, ρ_rl, D_ml, color = :black, labels = true, levels = 3) |
| 152 | + Plt.Colorbar( |
| 153 | + f[2, 3], |
| 154 | + limits = ( |
| 155 | + minimum(v for v in V_ml if !isnan(v)), |
| 156 | + maximum(v for v in V_ml if !isnan(v)), |
| 157 | + ), |
| 158 | + colormap = Plt.reverse(Plt.cgrad(:Spectral)), |
| 159 | + flipaxis = true, |
| 160 | + vertical = false, |
| 161 | + ) |
| 162 | + |
| 163 | + Plt.linkxaxes!(ax1, ax2) |
| 164 | + Plt.linkxaxes!(ax2, ax3) |
| 165 | + Plt.linkyaxes!(ax1, ax2) |
| 166 | + Plt.linkyaxes!(ax2, ax3) |
| 167 | + |
| 168 | + # Plot D_m as second row of comparisons |
| 169 | + |
| 170 | + ax4 = Plt.Axis( |
| 171 | + f[3, 1], |
| 172 | + height = 350, |
| 173 | + width = 350, |
| 174 | + xlabel = "F_r", |
| 175 | + ylabel = "ρ_r", |
| 176 | + title = "Small Dₘ vs F_r and ρ_r", |
| 177 | + ) |
| 178 | + Plt.contourf!( |
| 179 | + F_rs, |
| 180 | + ρ_rs, |
| 181 | + D_ms, |
| 182 | + colormap = Plt.reverse(Plt.cgrad(:Spectral)), |
| 183 | + ) |
| 184 | + Plt.Colorbar( |
| 185 | + f[4, 1], |
| 186 | + limits = ( |
| 187 | + minimum(d for d in D_ms if !isnan(d)), |
| 188 | + maximum(d for d in D_ms if !isnan(d)), |
| 189 | + ), |
| 190 | + colormap = Plt.reverse(Plt.cgrad(:Spectral)), |
| 191 | + flipaxis = true, |
| 192 | + vertical = false, |
| 193 | + ) |
| 194 | + ax5 = Plt.Axis( |
| 195 | + f[3, 2], |
| 196 | + height = 350, |
| 197 | + width = 350, |
| 198 | + xlabel = "F_r", |
| 199 | + ylabel = "ρ_r", |
| 200 | + title = "Medium Dₘ vs F_r and ρ_r", |
| 201 | + ) |
| 202 | + Plt.contourf!( |
| 203 | + F_rm, |
| 204 | + ρ_rm, |
| 205 | + D_mm, |
| 206 | + colormap = Plt.reverse(Plt.cgrad(:Spectral)), |
| 207 | + ) |
| 208 | + Plt.Colorbar( |
| 209 | + f[4, 2], |
| 210 | + limits = ( |
| 211 | + minimum(d for d in D_mm if !isnan(d)), |
| 212 | + maximum(d for d in D_mm if !isnan(d)), |
| 213 | + ), |
| 214 | + colormap = Plt.reverse(Plt.cgrad(:Spectral)), |
| 215 | + flipaxis = true, |
| 216 | + vertical = false, |
| 217 | + ) |
| 218 | + ax6 = Plt.Axis( |
| 219 | + f[3, 3], |
| 220 | + height = 350, |
| 221 | + width = 350, |
| 222 | + xlabel = "F_r", |
| 223 | + ylabel = "ρ_r", |
| 224 | + title = "Large Dₘ vs F_r and ρ_r", |
| 225 | + ) |
| 226 | + Plt.contourf!( |
| 227 | + F_rl, |
| 228 | + ρ_rl, |
| 229 | + D_ml, |
| 230 | + colormap = Plt.reverse(Plt.cgrad(:Spectral)), |
| 231 | + ) |
| 232 | + Plt.Colorbar( |
| 233 | + f[4, 3], |
| 234 | + limits = ( |
| 235 | + minimum(d for d in D_ml if !isnan(d)), |
| 236 | + maximum(d for d in D_ml if !isnan(d)), |
| 237 | + ), |
| 238 | + colormap = Plt.reverse(Plt.cgrad(:Spectral)), |
| 239 | + flipaxis = true, |
| 240 | + vertical = false, |
| 241 | + ) |
| 242 | + |
| 243 | + Plt.linkxaxes!(ax1, ax4) |
| 244 | + Plt.linkxaxes!(ax4, ax5) |
| 245 | + Plt.linkxaxes!(ax5, ax6) |
| 246 | + Plt.linkyaxes!(ax1, ax4) |
| 247 | + Plt.linkyaxes!(ax4, ax5) |
| 248 | + Plt.linkyaxes!(ax5, ax6) |
| 249 | + |
| 250 | + Plt.resize_to_layout!(f) |
| 251 | + Plt.save("MorrisonandMilbrandtFig2.svg", f) |
| 252 | +end |
| 253 | + |
| 254 | +# Terminal Velocity figure |
| 255 | +figure_2() |
0 commit comments