Skip to content

Commit

Permalink
Add wet deposition (#10)
Browse files Browse the repository at this point in the history
* Dry deposition

* Finish Unit Tests

* Modify Project.toml

* Modifying Project.toml

* remove ModelingToolkit dependency

* Add package for test files

* Add wet deposition

* Change Unit Test
  • Loading branch information
jialinl6 authored Jun 4, 2023
1 parent c312b3c commit eb22944
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/DepositionMTK.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ using StaticArrays

include("wesley1989.jl")
include("dry_deposition.jl")
include("wet_deposition.jl")

end
40 changes: 40 additions & 0 deletions src/wet_deposition.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export WetDeposition

"""
Calculate wet deposition based on formulas at
www.emep.int/UniDoc/node12.html.
Inputs are fraction of grid cell covered by clouds (cloudFrac),
rain mixing ratio (qrain), air density (ρ_air [kg/m3]),
and fall distance (Δz [m]).
Outputs are wet deposition rates for PM2.5, SO2, and other gases
(wdParticle, wdSO2, and wdOtherGas [1/s]).
"""
function WetDeposition(cloudFrac, qrain, ρ_air, Δz)
A = 5.2u"m^3/kg/s" # m3 kg-1 s-1; Empirical coefficient
E = 0.1 # size-dependent collection efficiency of aerosols by the raindrops
wSubSO2 = 0.15 # sub-cloud scavanging ratio
wSubOther = 0.5 # sub-cloud scavanging ratio
wInSO2 = 0.3 # in-cloud scavanging ratio
wInParticle = 1.0 # in-cloud scavanging ratio
wInOther = 1.4 # in-cloud scavanging ratio
ρwater = 1000.0u"kg*m^-3" # kg/m3
Vdr = 5.0u"m/s" # raindrop fall speed, m/s

# precalculated constant combinations
AE = A * E
wSubSO2VdrPerρwater = wSubSO2 * Vdr / ρwater
wSubOtherVdrPerρwater = wSubOther * Vdr / ρwater
wInSO2VdrPerρwater = wInSO2 * Vdr / ρwater
wInParticleVdrPerρwater = wInParticle * Vdr / ρwater
wInOtherVdrPerρwater = wInOther * Vdr / ρwater

# wdParticle (subcloud) = A * P / Vdr * E; P = QRAIN * Vdr * ρgas => wdParticle = A * QRAIN * ρgas * E
# wdGas (subcloud) = wSub * P / Δz / ρwater = wSub * QRAIN * Vdr * ρgas / Δz / ρwater
# wd (in-cloud) = wIn * P / Δz / ρwater = wIn * QRAIN * Vdr * ρgas / Δz / ρwater

wdParticle = qrain * ρ_air * (AE + cloudFrac*(wInParticleVdrPerρwater/Δz))
wdSO2 = (wSubSO2VdrPerρwater + cloudFrac*wSubSO2VdrPerρwater) * qrain * ρ_air / Δz
wdOtherGas = (wSubOtherVdrPerρwater + cloudFrac*wSubOtherVdrPerρwater) * qrain * ρ_air / Δz

return wdParticle, wdSO2, wdOtherGas
end
6 changes: 5 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ using Test, SafeTestsets
@safetestset "wesely1989_test.jl" begin
include("wesely1989_test.jl")
end
end

@safetestset "wetdep_test.jl" begin
include("wetdep_test.jl")
end
end
8 changes: 8 additions & 0 deletions test/wetdep_test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using DepositionMTK
using Test,Unitful

@testset "unit" begin
@test unit(WetDeposition(0.5,0.5,1.204u"kg*m^-3",1u"m")[1]) == u"s^-1"
@test unit(WetDeposition(0.5,0.5,1.204u"kg*m^-3",1u"m")[2]) == u"s^-1"
@test unit(WetDeposition(0.5,0.5,1.204u"kg*m^-3",1u"m")[3]) == u"s^-1"
end

0 comments on commit eb22944

Please sign in to comment.