-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from jialinl6/Fix171821
Fix171821
- Loading branch information
Showing
5 changed files
with
62 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
[deps] | ||
AtmosphericDeposition = "1a52f20c-0d16-41d8-a00a-b2996d86a462" | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa" | ||
EarthSciMLBase = "e53f1632-a13c-4728-9402-0c66d48804b0" | ||
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" | ||
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" | ||
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,49 @@ | ||
# Dry Deposition | ||
# Dry Deposition | ||
## Model | ||
This is an implementation of a box model used to calculate changes in gas species concentration due to dry deposition. | ||
|
||
## Running the model | ||
Here's an example of how concentration of different species, such as SO<sub>2</sub>, O<sub>3</sub>, NO<sub>2</sub>, NO, H<sub>2</sub>O<sub>2</sub> and CH<sub>2</sub>O change due to dry deposition. | ||
|
||
We can create an instance of the model in the following manner: | ||
```julia @example 1 | ||
using AtmosphericDeposition | ||
using ModelingToolkit | ||
using DifferentialEquations | ||
using EarthSciMLBase | ||
using Unitful | ||
|
||
@parameters t [unit = u"s", description="Time"] | ||
model = DrydepositionG(t) | ||
``` | ||
Before running any simulations with the model we need to convert it into a system of differential equations. | ||
```julia @example 1 | ||
sys = structural_simplify(get_mtk(model)) | ||
tspan = (0.0, 3600*24) | ||
u0 = [2.0,10.0,5,5,2.34,0.15] # initial concentrations of SO₂, O₃, NO₂, NO, H₂O₂, CH₂O | ||
sol = solve(ODEProblem(sys, u0, tspan, []),AutoTsit5(Rosenbrock23()), saveat=10.0) # default parameters | ||
``` | ||
which we can plot as | ||
```julia @example 1 | ||
using Plots | ||
plot(sol, xlabel="Time (second)", ylabel="concentration (ppb)", legend=:outerright) | ||
``` | ||
|
||
## Parameters | ||
The parameters in the model are: | ||
```julia @example 1 | ||
parameters(sys) # [z, z₀, u_star, L, ρA, G, T, θ] | ||
``` | ||
where ```z``` is the top of the surface layer [m], ```z₀``` is the roughness length [m], ```u_star``` is friction velocity [m/s], and ```L``` is Monin-Obukhov length [m], ```ρA``` is air density [kg/m3], ```T``` is surface air temperature [K], ```G``` is solar irradiation [W m-2], ```Θ``` is the slope of the local terrain [radians]. | ||
|
||
Let's run some simulation with different value for parameter ```z```. | ||
```julia @example 1 | ||
@unpack O3 = sys | ||
|
||
p1 = [50,0.04,0.44,0,1.2,300,298,0] | ||
p2 = [10,0.04,0.44,0,1.2,300,298,0] | ||
sol1 = solve(ODEProblem(sys, u0, tspan, p1),AutoTsit5(Rosenbrock23()), saveat=10.0) | ||
sol2 = solve(ODEProblem(sys, u0, tspan, p2),AutoTsit5(Rosenbrock23()), saveat=10.0) | ||
|
||
plot([sol1[O3],sol2[O3]], label = ["z=50m" "z=10m"], title = "Change of O3 concentration due to dry deposition", xlabel="Time (second)", ylabel="concentration (ppb)") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters