Skip to content

Commit a1325cc

Browse files
committed
add condition if T=nothing
1 parent 0e47fee commit a1325cc

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

src/Setup_geometry.jl

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ julia> segments = [((-500.0, -1000.0), (-500.0, 0.0)),
235235
((-250.0, 0.0), (-250.0, 200.0)),
236236
((-750.0, 200.0), (-750.0, 1000.0))];
237237
julia> lith = LithosphericPhases(Layers=[15 55], Phases=[1 2], Tlab=1250);
238-
julia> add_box!(Phases, Temp, Grid; xlim=(-1000.0, 0.0), ylim=(-500.0, 500.0),
239-
zlim=(-80.0, 0.0), phase=lith,
238+
julia> add_box!(Phases, Temp, Grid; xlim=(-1000.0, 0.0), ylim=(-500.0, 500.0),
239+
zlim=(-80.0, 0.0), phase=lith,
240240
T=SpreadingRateTemp(SpreadingVel=3), segments=segments)
241241
julia> Grid = addfield(Grid, (; Phases, Temp)); # Add to Cartesian model
242242
julia> write_paraview(Grid, "Ridge_Thermal_Structure") # Save model to Paraview
@@ -248,7 +248,7 @@ function add_box!(Phase, Temp, Grid::AbstractGeneralGrid; # required input
248248
Origin=nothing, StrikeAngle=0, DipAngle=0, # origin & dip/strike
249249
phase = ConstantPhase(1), # Sets the phase number(s) in the box
250250
T=nothing, # Sets the thermal structure (various functions are available)
251-
segments=nothing, # Allows defining multiple ridge segments
251+
segments=nothing, # Allows defining multiple ridge segments
252252
cell=false ) # if true, Phase and Temp are defined on cell centers
253253

254254

@@ -804,23 +804,23 @@ julia> segments = [
804804
((-750.0, 200.0), (-750.0, 1000.0)) # Segment 3
805805
]
806806
julia> lith = LithosphericPhases(Layers=[15 55], Phases=[1 2], Tlab=1250)
807-
julia> add_plate!(Phases, Temp, Grid;
808-
xlim=(-1000.0, -750.0, -250.0, 0.0, -250.0, -750.0),
809-
ylim=(0.0, 500.0, 500.0, 0.0, -500.0, -500.0),
810-
zlim=(-150.0, 0.0),
811-
phase=lith,
812-
T=SpreadingRateTemp(SpreadingVel=3),
807+
julia> add_plate!(Phases, Temp, Grid;
808+
xlim=(-1000.0, -750.0, -250.0, 0.0, -250.0, -750.0),
809+
ylim=(0.0, 500.0, 500.0, 0.0, -500.0, -500.0),
810+
zlim=(-150.0, 0.0),
811+
phase=lith,
812+
T=SpreadingRateTemp(SpreadingVel=3),
813813
segments=segments)
814814
julia> Grid = addfield(Grid, (; Phases, Temp)) # Add fields
815815
julia> write_paraview(Grid, "Plate") # Save model to Paraview
816816
1-element Vector{String}:
817817
"Plate.vts"
818818
"""
819819

820-
function add_plate!(Phase, Temp, Grid::AbstractGeneralGrid;
821-
xlim=(), ylim=(), zlim::Tuple = (0.0,0.8),
822-
phase = ConstantPhase(1),
823-
T=nothing, segments=nothing, cell=false )
820+
function add_plate!(Phase, Temp, Grid::AbstractGeneralGrid;
821+
xlim=(), ylim=(), zlim::Tuple = (0.0,0.8),
822+
phase = ConstantPhase(1),
823+
T=nothing, segments=nothing, cell=false )
824824

825825
xlim_ = collect(xlim)
826826
ylim_ = collect(ylim)
@@ -948,7 +948,9 @@ function add_volcano!(
948948

949949
# @views Temp[ind .== false] .= 0.0
950950
if !isempty(ind_flat)
951+
if !isnothing(T)
951952
Temp[ind_flat] = compute_thermal_structure(Temp[ind_flat], Grid.x.val[ind], Grid.y.val[ind], depth[ind], Phases[ind_flat], T)
953+
end
952954
end
953955

954956
return nothing
@@ -1244,7 +1246,7 @@ function compute_thermal_structure(Temp, X, Y, Z, Phase, s::SpreadingRateTemp)
12441246
dz = Z[end]-Z[1];
12451247

12461248
MantleAdiabaticT = Tmantle .+ Adiabat*abs.(Z); # Adiabatic temperature of mantle
1247-
1249+
12481250
if MORside=="left"
12491251
Distance = X .- X[1,1,1];
12501252
elseif MORside=="right"
@@ -1257,7 +1259,7 @@ function compute_thermal_structure(Temp, X, Y, Z, Phase, s::SpreadingRateTemp)
12571259
else
12581260
error("unknown side")
12591261
end
1260-
1262+
12611263
for i in eachindex(Temp)
12621264
ThermalAge = abs(Distance[i] * 1.0e3 * 1.0e2) / SpreadingVel + AgeRidge * 1.0e6 # Thermal age in years
12631265
if ThermalAge > maxAge * 1.0e6
@@ -1272,7 +1274,7 @@ function compute_thermal_structure(Temp, X, Y, Z, Phase, s::SpreadingRateTemp)
12721274
Temp[i] = (Tsurface .- Tmantle) * erfc((abs.(Z[i]) * 1.0e3) ./ (2 * sqrt(kappa * ThermalAge))) + MantleAdiabaticT[i]
12731275

12741276
end
1275-
1277+
12761278
return Temp
12771279
end
12781280

@@ -1310,7 +1312,7 @@ function compute_thermal_structure(Temp, X, Y, Z, Phase, s::SpreadingRateTemp, s
13101312
MantleAdiabaticT = Tmantle .+ Adiabat * abs.(Z)
13111313

13121314
#Create delimiters
1313-
delimiters = [(segments[i][2], segments[i + 1][1]) for i in 1:length(segments) - 1]
1315+
delimiters = [(segments[i][2], segments[i + 1][1]) for i in 1:length(segments) - 1]
13141316

13151317
for I in eachindex(X)
13161318
px, py, pz = X[I], Y[I], Z[I]

0 commit comments

Comments
 (0)