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

Fixs data assimilation example #215

Merged
merged 5 commits into from
Oct 2, 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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "OceanBioME"
uuid = "a49af516-9db8-4be4-be45-1dad61c5a376"
authors = ["Jago Strong-Wright <[email protected]> and contributors"]
version = "0.11.1"
version = "0.11.2"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
14 changes: 10 additions & 4 deletions examples/data_assimilation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ using Distributions
using EnsembleKalmanProcesses
using EnsembleKalmanProcesses.ParameterDistributions

using Oceananigans.Fields: FunctionField

const year = years = 365day

rng_seed = 41
Expand All @@ -34,22 +36,26 @@ rng = Random.MersenneTwister(rng_seed)
@inline PAR⁰(t) = 60 * (1 - cos((t + 15days) * 2π / year)) * (1 / (1 + 0.2 * exp(-((mod(t, year) - 200days) / 50days)^2))) + 2

z = -10 # nominal depth of the box for the PAR profile
@inline PAR(t) = PAR⁰(t) * exp(0.2z) # Modify the PAR based on the nominal depth and exponential decay
@inline PAR_func(t) = PAR⁰(t) * exp(0.2z) # Modify the PAR based on the nominal depth and exponential decay

function run_box_simulation(initial_photosynthetic_slope,
base_maximum_growth,
nutrient_half_saturation,
phyto_base_mortality_rate,
j)
grid = BoxModelGrid()
clock = Clock(; time = zero(grid))

biogeochemistry = NutrientPhytoplanktonZooplanktonDetritus(; grid = BoxModelGrid(),
PAR = FunctionField{Center, Center, Center}(PAR_func, grid; clock)

biogeochemistry = NutrientPhytoplanktonZooplanktonDetritus(; grid,
initial_photosynthetic_slope,
base_maximum_growth,
nutrient_half_saturation,
phyto_base_mortality_rate,
light_attenuation_model = nothing)
light_attenuation_model = PrescribedPhotosyntheticallyActiveRadiation(PAR))

model = BoxModel(; biogeochemistry, forcing = (; PAR))
model = BoxModel(; biogeochemistry, clock)

set!(model, N = 10.0, P = 0.1, Z = 0.01)

Expand Down
Loading