Skip to content

Commit

Permalink
added instant reminerlaisation and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jagoosw committed Jan 2, 2025
1 parent f18ea41 commit 30db3ce
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 189 deletions.
2 changes: 1 addition & 1 deletion src/Models/Models.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Models

export Sediments
export InstantRemineralisationSediment

export NPZD,
NutrientPhytoplanktonZooplanktonDetritus,
Expand Down
24 changes: 10 additions & 14 deletions src/Models/Sediments/instant_remineralization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ sediment_model = InstantRemineralisation(grid)
```
"""
InstantRemineralisationSediment(grid;
sinking_tracers = :D,
sinking_tracers = (:P, :D),
remineralisation_reciever = :N,
burial_efficiency_constant1 = 0.013,
burial_efficiency_constant2 = 0.53,
burial_efficiency_half_saturation = 7.0,
burial_efficiency_half_saturation = 7.0 / 6.56,
kwargs...) =
BiogeochemicalSediment(grid,
InstantRemineralisation(burial_efficiency_constant1,
burial_efficiency_constant2,
burial_efficiency_half_saturation,
tracernames(sinking_tracers),
remineralisation_reciever),
remineralisation_reciever);
kwargs...)

@inline required_sediment_fields(::InstantRemineralisation) = (:storage, )
Expand All @@ -71,27 +71,23 @@ InstantRemineralisationSediment(grid;
b = s.burial_efficiency_constant2
k = s.burial_efficiency_half_saturation

total_sinking_flux = sum(args)
flux = @inbounds sum(args[2:end])

carbon_flux = total_sinking_flux * 6.56

burial_efficiency = a + b * (carbon_flux / (k + carbon_flux)) ^ 2

return burial_efficiency * total_sinking_flux
burial_efficiency = a + b * (flux / (k + flux)) ^ 2

return burial_efficiency * flux
end

@inline function remineralisation(s::InstantRemineralisation, x, y, t, args...)
a = s.burial_efficiency_constant1
b = s.burial_efficiency_constant2
k = s.burial_efficiency_half_saturation

total_sinking_flux = sum(args)

carbon_flux = total_sinking_flux * 6.56
flux = @inbounds sum(args[2:end])

burial_efficiency = a + b * (carbon_flux / (k + carbon_flux)) ^ 2
burial_efficiency = a + b * (flux / (k + flux)) ^ 2

return (1 - burial_efficiency) * total_sinking_flux
return (1 - burial_efficiency) * flux
end

function add_remineralisation_methods!(remineralisation_reciever; fname = remineralisation)
Expand Down
1 change: 1 addition & 0 deletions src/OceanBioME.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module OceanBioME

# Biogeochemistry models and useful things
export Biogeochemistry, LOBSTER, PISCES, NutrientPhytoplanktonZooplanktonDetritus, NPZD, redfield
export InstantRemineralisationSediment
export DepthDependantSinkingSpeed, PrescribedLatitude, ModelLatitude, PISCESModel

# Macroalgae models
Expand Down
6 changes: 5 additions & 1 deletion src/Sediments/Sediments.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ end
@inline sinking_fluxs(s::BiogeochemicalSediment) = sinking_fluxs(s.biogeochemistry)
@inline coupled_tracers(s::BiogeochemicalSediment) = coupled_tracers(s.biogeochemistry)

abstract type AbstractSedimentBiogeochemistry end
abstract type AbstractContinuousFormSedimentBiogeochemistry <: AbstractSedimentBiogeochemistry end

const ACFSBGC = AbstractContinuousFormSedimentBiogeochemistry

include("timesteppers.jl")
include("bottom_indices.jl")
include("tracked_fields.jl")
include("update_state.jl")
include("sediment_biogeochemistries.jl")
include("compute_tendencies.jl")
include("tracer_coupling.jl")

Expand Down
8 changes: 5 additions & 3 deletions src/Sediments/compute_tendencies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ using Oceananigans.Fields: Center
using Oceananigans.Grids: xnode, ynode

function compute_sediment_tendencies!(model)
fields = prognostic_fields(model)
field_names = required_sediment_fields(model)

sediment_fields = model.fields
tracked_fields = model.tracked_fields

grid = model.grid
Expand All @@ -15,10 +17,10 @@ function compute_sediment_tendencies!(model)

arch = architecture(grid)

for (field_name, field) in pairs(fields)
for field_name in field_names
G = Gⁿ[field_name]

args = (Val(field_name), biogeochemistry, fields, tracked_fields, clock)
args = (Val(field_name), biogeochemistry, sediment_fields, tracked_fields, clock)

launch!(arch, grid, :xy, compute_sediment_tendency!, G, grid, args)
end
Expand Down
4 changes: 0 additions & 4 deletions src/Sediments/sediment_biogeochemistries.jl

This file was deleted.

2 changes: 1 addition & 1 deletion src/Sediments/update_state.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function update_biogeochemical_state!(model, sediment_model::BiogeochemicalSedim
update_tracked_fields!(sediment_model, model)

if isfinite(Δt)
time_step!(sediment_model, Δt)
time_step!(sediment_model, Δt;)
end

return nothing
Expand Down
Loading

0 comments on commit 30db3ce

Please sign in to comment.