Skip to content

Commit e807ae6

Browse files
committed
Do not round 1d LithosphericTemp profile to nearest km (fixes extrapolation error)
1 parent 3c83dfe commit e807ae6

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/Setup_geometry.jl

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,28 +1444,27 @@ function compute_thermal_structure(Temp, X, Y, Z, Phase, s::LithosphericTemp)
14441444
dtfac, nz, rheology = s
14451445

14461446
# Create 1D depth profile within the box
1447-
z = LinRange(round(maximum(Z)), round(minimum(Z)), nz) # [km]
1448-
z = @. z * 1.0e3 # [m]
1447+
z = LinRange(maximum(Z) * 1.0e3, minimum(Z) * 1.0e3, nz) # [m]
14491448
dz = z[2] - z[1] # Gride resolution
1450-
14511449
# Initialize 1D arrays for explicit solver
14521450
T = zeros(nz)
14531451
phase = Int64.(zeros(nz))
14541452

14551453
# Assign phase id from Phase to 1D phase array
14561454
phaseid = (minimum(Phase):1:maximum(Phase))
1457-
ztop = round(maximum(Z[findall(Phase .== phaseid[1])]))
1458-
zlayer = zeros(length(phaseid))
1455+
zsurf = maximum(Z[findall(Phase .== phaseid[1])]) * 1.0e3
1456+
zbase = zeros(length(phaseid)) # base of each layer
1457+
1458+
# for each phase id
14591459
for i in 1:length(phaseid)
14601460
# Calculate layer thickness from Phase array
1461-
zlayer[i] = round(minimum(Z[findall(Phase .== phaseid[i])]))
1462-
zlayer[i] = zlayer[i] * 1.0e3
1461+
zbase[i] = minimum(Z[findall(Phase .== phaseid[i])]) * 1.0e3
14631462
end
14641463
for i in 1:length(phaseid)
14651464
# Assign phase ids
1466-
ind = findall((z .>= zlayer[i]) .& (z .<= ztop))
1465+
ztop = i === 1 ? zsurf : zbase[i - 1]
1466+
ind = findall((z .>= zbase[i]) .& (z .<= ztop))
14671467
phase[ind] .= phaseid[i]
1468-
ztop = zlayer[i]
14691468
end
14701469

14711470
# Setup initial T-profile

0 commit comments

Comments
 (0)