Skip to content

Commit

Permalink
Sync with PALEOboxes v0.22 / PALEOmodel v0.16 dimensions / coordinate…
Browse files Browse the repository at this point in the history
…s updates

See PRs:
    PALEOtoolkit/PALEOboxes.jl#151
    PALEOtoolkit/PALEOmodel.jl#107

Example of change needed from ReactionSedimentGridn1D do_sediment_setup_grid:

    # attach coordinates to grid for output visualisation etc
    if isdefined(PB, :set_coordinates!) # PALEOboxes >= 0.22
        PB.set_coordinates!(rj.domain.grid, "cells", ["zmid", "zlower", "zupper"])
    else
        empty!(rj.domain.grid.z_coords)
        push!(rj.domain.grid.z_coords, PB.FixedCoord("zmid", grid_vars.zmid, PB.get_variable(m, "zmid").attributes))
        push!(rj.domain.grid.z_coords, PB.FixedCoord("zlower", grid_vars.zlower, PB.get_variable(m, "zlower").attributes))
        push!(rj.domain.grid.z_coords, PB.FixedCoord("zupper", grid_vars.zupper, PB.get_variable(m, "zupper").attributes))
    end
  • Loading branch information
sjdaines committed Dec 30, 2024
1 parent 4b74333 commit e4ad448
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Infiltrator = "1.0"
LineSearches = "7.0"
NLsolve = "4.5.1"
PALEOaqchem = "0.3.5"
PALEOboxes = "0.20.4, 0.21"
PALEOmodel = "0.15.8"
PALEOboxes = "0.20.4, 0.21, 0.22"
PALEOmodel = "0.15.8, 0.16"
Pkg = "1.0"
Plots = "1.38"
SparseArrays = "1.0"
Expand Down
3 changes: 2 additions & 1 deletion examples/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
CommonDataModel = "1fbeeb36-5f17-413c-809b-666fb144f157"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Infiltrator = "5903a43b-9cc3-4c30-8d17-598619ec4e9b"
LineSearches = "d3d80556-e9d4-5f37-9878-2ab0fcc64255"
Expand All @@ -16,7 +17,7 @@ Sundials = "c3572dad-4567-51f8-b174-8c6c989267f4"

[compat]
PALEOaqchem = "0.3.10"
PALEOmodel = "0.15.47"
PALEOmodel = "0.15.47, 0.16"

[extras]
PALEOboxes = "804b410e-d900-4b2a-9ecd-f5a06d4c1fd4"
14 changes: 9 additions & 5 deletions src/sediment/SedimentGrid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,15 @@ function do_sediment_setup_grid(
end

# attach coordinates to grid for output visualisation etc
empty!(rj.domain.grid.z_coords)
push!(rj.domain.grid.z_coords, PB.FixedCoord("zmid", grid_vars.zmid, PB.get_variable(m, "zmid").attributes))
push!(rj.domain.grid.z_coords, PB.FixedCoord("zlower", grid_vars.zlower, PB.get_variable(m, "zlower").attributes))
push!(rj.domain.grid.z_coords, PB.FixedCoord("zupper", grid_vars.zupper, PB.get_variable(m, "zupper").attributes))

if isdefined(PB, :set_coordinates!) # PALEOboxes >= 0.22
PB.set_coordinates!(rj.domain.grid, "cells", ["zmid", "zlower", "zupper"])
else
empty!(rj.domain.grid.z_coords)
push!(rj.domain.grid.z_coords, PB.FixedCoord("zmid", grid_vars.zmid, PB.get_variable(m, "zmid").attributes))
push!(rj.domain.grid.z_coords, PB.FixedCoord("zlower", grid_vars.zlower, PB.get_variable(m, "zlower").attributes))
push!(rj.domain.grid.z_coords, PB.FixedCoord("zupper", grid_vars.zupper, PB.get_variable(m, "zupper").attributes))
end

grid_vars.volume .= grid_vars.Abox.*(grid_vars.zupper .- grid_vars.zlower)
grid_vars.volume_total[] = sum(grid_vars.volume)

Expand Down
12 changes: 8 additions & 4 deletions src/sediment/SedimentTransportDeprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,14 @@ function do_sediment_setup_grid(
end

# attach coordinates to grid for output visualisation etc
empty!(rj.domain.grid.z_coords)
push!(rj.domain.grid.z_coords, PB.FixedCoord("zmid", grid_vars.zmid, PB.get_variable(m, "zmid").attributes))
push!(rj.domain.grid.z_coords, PB.FixedCoord("zlower", grid_vars.zlower, PB.get_variable(m, "zlower").attributes))
push!(rj.domain.grid.z_coords, PB.FixedCoord("zupper", grid_vars.zupper, PB.get_variable(m, "zupper").attributes))
if isdefined(PB, :set_coordinates!) # PALEOboxes >= 0.22
PB.set_coordinates!(rj.domain.grid, "cells", ["zmid", "zlower", "zupper"])
else
empty!(rj.domain.grid.z_coords)
push!(rj.domain.grid.z_coords, PB.FixedCoord("zmid", grid_vars.zmid, PB.get_variable(m, "zmid").attributes))
push!(rj.domain.grid.z_coords, PB.FixedCoord("zlower", grid_vars.zlower, PB.get_variable(m, "zlower").attributes))
push!(rj.domain.grid.z_coords, PB.FixedCoord("zupper", grid_vars.zupper, PB.get_variable(m, "zupper").attributes))
end

grid_vars.volume .= grid_vars.Abox.*(grid_vars.zupper .- grid_vars.zlower)
grid_vars.volume_total[] = sum(grid_vars.volume)
Expand Down

0 comments on commit e4ad448

Please sign in to comment.