Skip to content

Commit fe4618b

Browse files
committed
Add docstrings to remainder of utility functions
1 parent 57569da commit fe4618b

File tree

3 files changed

+59
-12
lines changed

3 files changed

+59
-12
lines changed

Diff for: examples/simple.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ for i in 1:nt
6969
end
7070

7171
println("End; press any key to close.")
72+
xxx = readline()
73+
7274
# using NPZ
7375
# for (i, g) in enumerate(g_plots)
7476
# file_fn = @sprintf "output_%03d.npy" i
@@ -77,7 +79,6 @@ println("End; press any key to close.")
7779
# npzwrite(file_pth, g)
7880
# end
7981
# npzwrite("output/r_grid.npy", model.rᵢ)
80-
# xxx = readline()
8182

8283
# using NPZ
8384
# for (i, g) in enumerate(g_diags)

Diff for: src/size_dists.jl

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
export ExponentialDist, nc
12

2-
const test = 1.0;
3+
"""
4+
ExponentialDist{FT} <: AbstractSizeDist{FT}
35
6+
Exponential size distribution defined by two moments: total water content, L̅ and
7+
mean droplet mass, x̅
8+
"""
49
struct ExponentialDist{FT} <: AbstractSizeDist{FT}
510
::FT # Total water content, kg/m3
611
::FT # Mean initial droplet mass, kg
@@ -15,6 +20,12 @@ function Base.show(io::IO, d::ExponentialDist{FT}) where {FT <: Real}
1520
print(io, "ExponentalDist(L̅=$(d.* 1e3) g/m³, x̅=$(d.x̅) kg)")
1621
end
1722

23+
"""
24+
nc(dist::ExponentialDist{FT}, x::FT) where {FT <: Real}
25+
26+
Compute the number concentration for droplets of the given mass for a
27+
specific size distribution.
28+
"""
1829
function nc(dist::ExponentialDist{FT}, x::FT) where {FT <: Real}
1930
return (dist./ dist.^2) * exp(-x / dist.x̅)
2031
end

Diff for: src/util.jl

+45-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,43 @@
11
const ρw = 1000.0 # Density of water, kg/m³
22
const golovin_b = (1500.0)*1e-3 # Golovin collision coefficient, input cm³/g/s to -> m³/kg/s
33

4+
"""
5+
mass_from_r(r; ρ=ρw)
6+
7+
Compute mass (kg) of a droplet with given radius (m) and density (kg/m³)
8+
"""
49
mass_from_r(r; ρ=ρw) = (4*π/3)*ρ*(r^3)
10+
11+
"""
12+
r_from_mass(x; ρ=ρw)
13+
14+
Compute radius (m) of a droplet with given mass (kg) and density (kg/m³)
15+
"""
516
r_from_mass(x; ρ=ρw) = (3*x/4/π/ρ)^(1/3)
617

718
# Initial cloud droplet distribution
8-
# nc(x; L=L, x̅=x̅) = (L / x̅^2) * exp(-x / x̅)
9-
# NOTE: this probably needs to be some sort of struct with an abstract type?
10-
# Exponential(x, L, x̅) = nc(x, L, x̅)
1119

1220
## Collision Kernels
1321

14-
# inputs in kg
22+
"""
23+
golovin_kernel(xᵢ, xⱼ)
24+
25+
Compute the Golovin collision kernel for droplets of two given masses (in kg)
26+
"""
1527
golovin_kernel(xᵢ, xⱼ) = golovin_b * (xᵢ + xⱼ)
1628

29+
1730
function _interior_hydro_kernel(E_coal, E_coll, r_sum, tv_diff)
1831
E_coal * E_coll * π * r_sum*r_sum * abs(tv_diff)
1932
end
2033

34+
35+
"""
36+
hydrodynamic_kernel(xᵢ, xⱼ)
37+
38+
Compute the hydrodynamic collision kernel for droplets of the two given masses
39+
(in kg) assuming unity collision and coalescence efficiency.
40+
"""
2141
function hydrodynamic_kernel(xᵢ, xⱼ)
2242
tvᵢ = terminal_v(xᵢ)
2343
tvⱼ = terminal_v(xⱼ)
@@ -26,6 +46,12 @@ function hydrodynamic_kernel(xᵢ, xⱼ)
2646
_interior_hydro_kernel(1.0, 1.0, r_sum, tv_diff)
2747
end
2848

49+
"""
50+
long_kernel(xᵢ, xⱼ)
51+
52+
Compute the hydrodynamic collision kernel with parameterization of collision
53+
efficiency from Long (1974) for two droplets of given masses (in kg)
54+
"""
2955
function long_kernel(xᵢ, xⱼ)
3056
rᵢ = r_from_mass(xᵢ)
3157
rⱼ = r_from_mass(xⱼ)
@@ -52,9 +78,13 @@ function long_kernel(xᵢ, xⱼ)
5278
_interior_hydro_kernel(1.0, E_coll, r_sum, tv_diff)
5379
end
5480

55-
# Other Functions
81+
"""
82+
terminal_v(x)
83+
84+
Compute terminal velocity of a droplet of given mass (in kg) following the
85+
parameterization of Beard (1976)
86+
"""
5687
function terminal_v(x)
57-
# Beard (1976)
5888
r = r_from_mass(x)
5989
d = 2 * r * 1e6 # diameter, m -> μm
6090
x = x * 1e3 # mass, kg -> g
@@ -76,12 +106,17 @@ function terminal_v(x)
76106
tv = 1e-2 * α * x_to_beta # cm/s -> m/s
77107
end
78108

79-
# Pre-compute collison kernels
80-
function kernels(x, kernel)
109+
"""
110+
kernels(x::AbstractArray{FT, 1}, kernel::Symbol) where {FT <: AbstractFloat}
111+
112+
Pre-compute and cache pair-wise collision kernels for a 1D binned discretization
113+
of mass space.
114+
"""
115+
function kernels(x::AbstractArray{FT, 1}, kernel::Symbol) where {FT <: AbstractFloat}
81116

82117
m = length(x)
83-
ck = zeros(Float64, m, m)
84-
cck = zeros(Float64, m, m)
118+
ck = zeros(FT, m, m)
119+
cck = zeros(FT, m, m)
85120

86121
# Compute collision kernel for all potential bin interactions
87122
for j 1:m

0 commit comments

Comments
 (0)