Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add descriptions to parameters and variables & delete unnecessary export functions and variables in wesley1989.jl #30

Merged
merged 5 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/dry_deposition.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export defaults, ra, mu, mfp, cc, vs, dParticle, dH2O, sc, stSmooth, stVeg, RbGas, z₀_table, A_table, α_table, γ_table, RbParticle, DryDepGas, DryDepParticle, DrydepositionG

@constants g = 9.81 [unit = u"m*s^-2", description = "gravitational acceleration"]
@constants κ = 0.4 # von Karman constant
@constants κ = 0.4 [description = "von Karman constant"]
@constants k = 1.3806488e-23 [unit = u"m^2*kg*s^-2/K", description = "Boltzmann constant"]
@constants M_air = 28.97e-3 [unit = u"kg/mol", description = "molecular weight of air"]
@constants R = 8.3144621 [unit = u"kg*m^2*s^−2*K^-1*mol^-1", description = "Gas constant"]
Expand All @@ -23,8 +23,8 @@
return rₐ
end

@constants unit_T = 1 [unit = u"K"]
@constants unit_convert_mu = 1 [unit = u"kg/m/s"]
@constants unit_T = 1 [unit = u"K", description = "unit one for temperature"]
@constants unit_convert_mu = 1 [unit = u"kg/m/s", description = "unit one for mu"]
"""
Function mu calculates the dynamic viscosity of air [kg m-1 s-1] where T is temperature [K].
"""
Expand All @@ -51,7 +51,7 @@
return 1 + 2 * λ / Dₚ * (1.257 + 0.4 * exp(-1.1 * Dₚ / (2 * λ)))
end

@constants unit_v = 1 [unit = u"m/s"]
@constants unit_v = 1 [unit = u"m/s", description = "unit one for speed"]
"""
Function vs calculates the terminal setting velocity of a
particle where Dp is particle diameter [m], ρₚ is particle density [kg/m3], Cc is the Cunningham slip correction factor, and μ is air dynamic viscosity [kg/(s m)].
Expand All @@ -71,8 +71,8 @@
return k * T * Cc / (3 * pi * μ * Dₚ)
end

@constants T_unitless = 1 [unit = u"K^-1"]
@constants unit_dH2O = 1 [unit = u"m^2/s"]
@constants T_unitless = 1 [unit = u"K^-1", description = "used to offset temperature unit"]
@constants unit_dH2O = 1 [unit = u"m^2/s", description = "unit for molecular diffusivity"]
"""
Function dH2O calculates molecular diffusivity of water vapor in air [m2/s] where T is temperature [K]
using a regression fit to data in Bolz and Tuve (1976) found here: http://www.cambridge.org/us/engineering/author/nellisandklein/downloads/examples/EXAMPLE_9.2-1.pdf
Expand Down Expand Up @@ -174,8 +174,8 @@
return 1 / (3 * u_star * (term_1 + term_2 + term_3) * R1)
end

@constants G_unitless = 1 [unit = u"m^2/W"]
@constants Rc_unit = 1 [unit = u"s/m"]
@constants G_unitless = 1 [unit = u"m^2/W", description = "used to offset the unit of irradiation"]
@constants Rc_unit = 1 [unit = u"s/m", description = "unit for surface resistance"]
"""
Function DryDepGas calculates dry deposition velocity [m/s] for a gas species,
where z is the height of the surface layer [m], zo is roughness length [m], u_star is friction velocity [m/s],
Expand Down Expand Up @@ -243,14 +243,14 @@
iLandUse = 10
rain = false
dew = false
@parameters z = 50 [unit = u"m"]
@parameters z₀ = 0.04 [unit = u"m"]
@parameters u_star = 0.44 [unit = u"m/s"]
@parameters L = 0 [unit = u"m"]
@parameters ρA = 1.2 [unit = u"kg*m^-3"]
@parameters G = 300 [unit = u"W*m^-2"]
@parameters T = 298 [unit = u"K"]
@parameters θ = 0
@parameters z = 50 [unit = u"m", description = "top of the surface layer"]
@parameters z₀ = 0.04 [unit = u"m", description = "roughness lenght"]
@parameters u_star = 0.44 [unit = u"m/s", description = "friction velocity"]
@parameters L = 0 [unit = u"m", description = "Monin-Obukhov length"]
@parameters ρA = 1.2 [unit = u"kg*m^-3", description = "air density"]
@parameters G = 300 [unit = u"W*m^-2", description = "solar irradiation"]
@parameters T = 298 [unit = u"K", description = "temperature"]
@parameters θ = 0 [description = "slope of the local terrain, in unit radians"]

Check warning on line 253 in src/dry_deposition.jl

View check run for this annotation

Codecov / codecov/patch

src/dry_deposition.jl#L246-L253

Added lines #L246 - L253 were not covered by tests

D = Differential(t)

Expand Down
3 changes: 1 addition & 2 deletions src/wesley1989.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export GasData, r_s, r_dc, r_mx, r_smx, r_lux, r_clx, r_gsx, WesleySurfaceResistance, inf, r_i, r_lu, r_ac, r_gsS, r_gsO, r_clS, r_clO, So2Data, O3Data, No2Data, NoData, Hno3Data, H2o2Data, GasData, AldData, HchoData, OpData, PaaData, OraData, Nh3Data, PanData, Hno2Data

export WesleySurfaceResistance

const inf = 1.e25

Expand Down
2 changes: 1 addition & 1 deletion src/wet_deposition.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export WetDeposition, Wetdeposition, wd_defaults

@constants A_wd = 5.2 [unit = u"m^3/kg/s", description = "Empirical coefficient"]
@constants ρwater = 1000.0 [unit = u"kg*m^-3"]
@constants ρwater = 1000.0 [unit = u"kg*m^-3", description = "water density"]
@constants Vdr = 5.0 [unit = u"m/s", description = "raindrop fall speed"]

"""
Expand Down
4 changes: 2 additions & 2 deletions test/drydep_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ end
#@test unit(dH2O(300u"K"))==u"m^2/s"
@test ModelingToolkit.get_unit(DryDepParticle(z, z₀, u_star, L, Dp, T, P, ρParticle, ρA, 1, 1)) == u"m/s"
#@test unit(DryDepParticle(0.4u"m",0.3u"m",1u"m/s", 1u"m", 1e-6u"m", 300u"K", 10300u"Pa", 1u"kg*m^-3",0.001u"kg*m^-3",1,1)) == u"m/s"
@test ModelingToolkit.get_unit(DryDepGas(z, z₀, u_star, L, ρA, So2Data, G, T, θ, 1, 1, false, false, true, false)) == u"m/s"
@test ModelingToolkit.get_unit(DryDepGas(z, z₀, u_star, L, ρA, AtmosphericDeposition.So2Data, G, T, θ, 1, 1, false, false, true, false)) == u"m/s"
#@test unit(DryDepGas(0.4u"m",0.3u"m",1u"m/s", 1u"m", 0.001u"kg*m^-3", So2Data, 800u"W*m^-2", 300u"K", 0, 1, 1, false, false, true, false)) == u"m/s"
end

Expand Down Expand Up @@ -73,7 +73,7 @@ end

@testset "DryDepGas" begin
vd_true = 0.03 # m/s
@test (substitute(DryDepGas(z, z₀, u_star, L, ρA, No2Data, G, T, 0, 1, 10, false, false, false, false), Dict(z => 50, z₀ => 0.04, u_star => 0.44, L => 0, T => 298, ρA => 1.2, G => 300, defaults...)) - vd_true) / vd_true < 0.33
@test (substitute(DryDepGas(z, z₀, u_star, L, ρA, AtmosphericDeposition.No2Data, G, T, 0, 1, 10, false, false, false, false), Dict(z => 50, z₀ => 0.04, u_star => 0.44, L => 0, T => 298, ρA => 1.2, G => 300, defaults...)) - vd_true) / vd_true < 0.33
end

@testset "DryDepParticle" begin
Expand Down
24 changes: 12 additions & 12 deletions test/wesely1989_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ function TestWesely()

testData = [SO2, O3, NO2, H2O2, ALD, HCHO, OP, PAA, ORA, NH3, PAN, HNO2]
gasData = [
So2Data, O3Data, No2Data,
H2o2Data, AldData, HchoData,
OpData, PaaData, OraData,
Nh3Data, PanData, Hno2Data]
AtmosphericDeposition.So2Data, AtmosphericDeposition.O3Data, AtmosphericDeposition.No2Data,
AtmosphericDeposition.H2o2Data, AtmosphericDeposition.AldData, AtmosphericDeposition.HchoData,
AtmosphericDeposition.OpData, AtmosphericDeposition.PaaData, AtmosphericDeposition.OraData,
AtmosphericDeposition.Nh3Data, AtmosphericDeposition.PanData, AtmosphericDeposition.Hno2Data]

for i in 1:12
pol = polNames[i]
Expand Down Expand Up @@ -148,12 +148,12 @@ end

@testset "wesley1989.jl" begin
@test TestWesely() == true
@test r_s(1.0, 1.0, 1, 1, true) ≈ 3.0772306344553016e30
@test r_dc(1.0, 1.0) ≈ 9.181727363545544
@test r_mx(1.0, 1.0) ≈ 0.009999966666777778
@test r_smx(1.0, 1.0, 1.0) ≈ 2.0
@test r_lux(1.0, 1.0, 1, 1, true, false, true, false) ≈ 50
@test r_clx(1.0, 1.0, 1, 1) ≈ 9.999899563027895e24
@test r_gsx(1.0, 1.0, 1, 1) ≈ 299.9977500168749
@test WesleySurfaceResistance(So2Data, 1.0, 1.0, 1.0, 1, 1, true, true, true, false) ≈ 45.45454545454546
@test AtmosphericDeposition.r_s(1.0, 1.0, 1, 1, true) ≈ 3.0772306344553016e30
@test AtmosphericDeposition.r_dc(1.0, 1.0) ≈ 9.181727363545544
@test AtmosphericDeposition.r_mx(1.0, 1.0) ≈ 0.009999966666777778
@test AtmosphericDeposition.r_smx(1.0, 1.0, 1.0) ≈ 2.0
@test AtmosphericDeposition.r_lux(1.0, 1.0, 1, 1, true, false, true, false) ≈ 50
@test AtmosphericDeposition.r_clx(1.0, 1.0, 1, 1) ≈ 9.999899563027895e24
@test AtmosphericDeposition.r_gsx(1.0, 1.0, 1, 1) ≈ 299.9977500168749
@test WesleySurfaceResistance(AtmosphericDeposition.So2Data, 1.0, 1.0, 1.0, 1, 1, true, true, true, false) ≈ 45.45454545454546
end
Loading