Skip to content

Commit 9f0a283

Browse files
authored
Merge pull request #6 from jbisits/joe-seticsbetter
Better method for setting TS staircase
2 parents 01683f4 + fa0b9aa commit 9f0a283

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "StaircaseShenanigans"
22
uuid = "c2bb06a8-94f3-4279-b990-30bf3ab8ba6f"
33
authors = ["Josef Bisits <jbisits@gmail.com>"]
4-
version = "0.0.1"
4+
version = "0.1.0"
55

66
[deps]
77
GibbsSeaWater = "9a22fb26-0b63-4589-b28e-8f9d0b5c3d05"

src/set_staircase_initial_conditions.jl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,30 @@ Set initial salinity and temperature staircases in `model`.
55
function set_staircase_initial_conditions!(model, ics::StepInitialConditions)
66

77
depth_of_steps = ics.depth_of_steps
8+
z = znodes(model.grid, Center())
89
S = ics.salinity_values
910
T = ics.temperature_values
10-
initial_S_steps(x, y, z) = set_steps(z, S, depth_of_steps)
11-
initial_T_steps(x, y, z) = set_steps(z, T, depth_of_steps)
1211

13-
set!(model, S = initial_S_steps, T = initial_T_steps)
12+
S₀ = similar(interior(model.tracers.S, :, :, :))
13+
T₀ = similar(interior(model.tracers.T, :, :, :))
14+
S₀[:, :, z .> depth_of_steps[1]] .= S[1]
15+
T₀[:, :, z .> depth_of_steps[1]] .= T[1]
16+
for i 1:length(depth_of_steps)-1
17+
S₀[:, :, depth_of_steps[i+1] .≤ z .< depth_of_steps[i]] .= S[i]
18+
T₀[:, :, depth_of_steps[i+1] .≤ z .< depth_of_steps[i]] .= T[i]
19+
end
20+
S₀[:, :, z .< depth_of_steps[end]] .= S[end]
21+
T₀[:, :, z .< depth_of_steps[end]] .= T[end]
22+
23+
set!(model, S = S₀, T = T₀)
1424

1525
return nothing
1626
end
1727
function set_staircase_initial_conditions!(model, ics::SmoothStepInitialConditions)
1828

1929
# TODO: write methods to set smooth changes using the function provied in
20-
# `ics::SmoothStepInitialConditions`.
30+
# `ics::SmoothStepInitialConditions`. I can use something like the above
31+
# normalise then set with the smoothing function
2132
#set!(model, S = initial_S_steps, T = initial_T_steps)
2233

2334
return nothing

src/staircase_initial_conditions.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ set in the ranges:
3434
- z ∈ [depth_of_steps[1], 0)
3535
- z ∈ [depth_of_steps[i], depth_of_steps[i-1]) for i = 2:number_of_steps-1
3636
- z ∈ [-Lz, depth_of_steps[1]).
37+
38+
**Not currently in use and will remove if not needed.**
3739
"""
3840
function set_steps(z, C, depth_of_steps)
3941

0 commit comments

Comments
 (0)