@@ -243,13 +243,15 @@ julia> write_paraview(Grid, "Ridge_Thermal_Structure") # Save model to Paraview
2432431-element Vector{String}:
244244 "Ridge_Thermal_Structure.vts"
245245"""
246- function add_box! (Phase, Temp, Grid:: AbstractGeneralGrid ; # required input
247- xlim:: Tuple = (20 ,100 ), ylim= nothing , zlim:: Tuple = (10 ,80 ), # limits of the box
248- Origin= nothing , StrikeAngle= 0 , DipAngle= 0 , # origin & dip/strike
246+ function add_box! (
247+ Phase, Temp, Grid:: AbstractGeneralGrid ; # required input
248+ xlim:: Tuple = (20 , 100 ), ylim = nothing , zlim:: Tuple = (10 , 80 ), # limits of the box
249+ Origin = nothing , StrikeAngle = 0 , DipAngle = 0 , # origin & dip/strike
249250 phase = ConstantPhase (1 ), # Sets the phase number(s) in the box
250- T= nothing , # Sets the thermal structure (various functions are available)
251- segments= nothing , # Allows defining multiple ridge segments
252- cell= false ) # if true, Phase and Temp are defined on cell centers
251+ T = nothing , # Sets the thermal structure (various functions are available)
252+ segments = nothing , # Allows defining multiple ridge segments
253+ cell = false
254+ ) # if true, Phase and Temp are defined on cell centers
253255
254256
255257 # Retrieve 3D data arrays for the grid
@@ -817,20 +819,22 @@ julia> write_paraview(Grid, "Plate") # Save model to Paraview
817819 "Plate.vts"
818820"""
819821
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 )
822+ function add_plate! (
823+ Phase, Temp, Grid:: AbstractGeneralGrid ;
824+ xlim = (), ylim = (), zlim:: Tuple = (0.0 , 0.8 ),
825+ phase = ConstantPhase (1 ),
826+ T = nothing , segments = nothing , cell = false
827+ )
824828
825829 xlim_ = collect (xlim)
826830 ylim_ = collect (ylim)
827831 zlim_ = collect (zlim)
828832
829- X, Y, Z = coordinate_grids (Grid, cell= cell)
833+ X, Y, Z = coordinate_grids (Grid, cell = cell)
830834 ind = zeros (Bool, size (X))
831835 ind_slice = zeros (Bool, size (X[:, :, 1 ]))
832836
833- for k = 1 : size (Z, 3 )
837+ for k in 1 : size (Z, 3 )
834838 if zlim_[1 ] <= Z[1 , 1 , k] <= zlim_[2 ]
835839 inpolygon! (ind_slice, xlim_, ylim_, X[:, :, k], Y[:, :, k])
836840 @views ind[:, :, k] = ind_slice
@@ -949,7 +953,7 @@ function add_volcano!(
949953 # @views Temp[ind .== false] .= 0.0
950954 if ! isempty (ind_flat)
951955 if ! isnothing (T)
952- Temp[ind_flat] = compute_thermal_structure (Temp[ind_flat], Grid. x. val[ind], Grid. y. val[ind], depth[ind], Phases[ind_flat], T)
956+ Temp[ind_flat] = compute_thermal_structure (Temp[ind_flat], Grid. x. val[ind], Grid. y. val[ind], depth[ind], Phases[ind_flat], T)
953957 end
954958 end
955959
@@ -1235,26 +1239,26 @@ Note: the thermal age at the mid oceanic ridge is set to 1 year to avoid divisio
12351239 MORside = " left" # side of box where the MOR is located
12361240 SpreadingVel = 3 # spreading velocity [cm/yr]
12371241 AgeRidge = 0 # Age of the ridge [Myrs]
1238- maxAge = 60 # maximum thermal age of plate [Myrs]
1242+ maxAge = 60 # maximum thermal age of plate [Myrs]
12391243end
12401244
12411245function compute_thermal_structure (Temp, X, Y, Z, Phase, s:: SpreadingRateTemp )
1242- @unpack Tsurface, Tmantle, Adiabat, MORside, SpreadingVel, AgeRidge, maxAge = s
1246+ @unpack Tsurface, Tmantle, Adiabat, MORside, SpreadingVel, AgeRidge, maxAge = s
12431247
1244- kappa = 1e-6 ;
1245- SecYear = 3600 * 24 * 365
1246- dz = Z[end ]- Z[1 ];
1248+ kappa = 1.0e-6
1249+ SecYear = 3600 * 24 * 365
1250+ dz = Z[end ] - Z[1 ]
12471251
1248- MantleAdiabaticT = Tmantle .+ Adiabat* abs .(Z); # Adiabatic temperature of mantle
1252+ MantleAdiabaticT = Tmantle .+ Adiabat * abs .(Z) # Adiabatic temperature of mantle
12491253
1250- if MORside== " left"
1251- Distance = X .- X[1 ,1 , 1 ];
1252- elseif MORside== " right"
1253- Distance = X[end ,1 , 1 ] .- X;
1254- elseif MORside== " front"
1255- Distance = Y .- Y[1 ,1 , 1 ];
1256- elseif MORside== " back"
1257- Distance = Y[1 ,end ,1 ] .- Y;
1254+ if MORside == " left"
1255+ Distance = X .- X[1 , 1 , 1 ]
1256+ elseif MORside == " right"
1257+ Distance = X[end , 1 , 1 ] .- X
1258+ elseif MORside == " front"
1259+ Distance = Y .- Y[1 , 1 , 1 ]
1260+ elseif MORside == " back"
1261+ Distance = Y[1 , end , 1 ] .- Y
12581262
12591263 else
12601264 error (" unknown side" )
@@ -1305,14 +1309,14 @@ The thermal age is capped at `maxAge` years, and the temperature is adjusted bas
13051309
13061310function compute_thermal_structure (Temp, X, Y, Z, Phase, s:: SpreadingRateTemp , segments:: Vector{Tuple{Tuple{Float64, Float64}, Tuple{Float64, Float64}}} )
13071311 @unpack Tsurface, Tmantle, Adiabat, SpreadingVel, AgeRidge, maxAge = s
1308- kappa = 1e-6 ;
1312+ kappa = 1.0e-6
13091313 SecYear = 3600 * 24 * 365
1310- dz = Z[end ]- Z[1 ];
1314+ dz = Z[end ] - Z[1 ]
13111315
13121316 MantleAdiabaticT = Tmantle .+ Adiabat * abs .(Z)
13131317
13141318 # Create delimiters
1315- delimiters = [(segments[i][2 ], segments[i + 1 ][1 ]) for i in 1 : length (segments) - 1 ]
1319+ delimiters = [(segments[i][2 ], segments[i + 1 ][1 ]) for i in 1 : ( length (segments) - 1 ) ]
13161320
13171321 for I in eachindex (X)
13181322 px, py, pz = X[I], Y[I], Z[I]
@@ -1328,18 +1332,18 @@ function compute_thermal_structure(Temp, X, Y, Z, Phase, s::SpreadingRateTemp, s
13281332 Distance = perpendicular_distance_to_segment (px, py, x1, y1, x2, y2)
13291333
13301334 # Calculate thermal age
1331- ThermalAge = abs (Distance * 1e5 ) / SpreadingVel + AgeRidge * 1e6 # Thermal age in years
1332- if ThermalAge > maxAge * 1e6
1333- ThermalAge = maxAge * 1e6
1335+ ThermalAge = abs (Distance * 1.0e5 ) / SpreadingVel + AgeRidge * 1.0e6 # Thermal age in years
1336+ if ThermalAge > maxAge * 1.0e6
1337+ ThermalAge = maxAge * 1.0e6
13341338 end
13351339
13361340 ThermalAge = ThermalAge * SecYear # Convert to seconds
13371341 if ThermalAge == 0
1338- ThermalAge = 1e -6 # Avoid zero
1342+ ThermalAge = 1.0e -6 # Avoid zero
13391343 end
13401344
13411345 # Calculate temperature
1342- Temp[I] = (Tsurface - Tmantle) * erfc (abs (pz) * 1e3 / (2 * sqrt (kappa * ThermalAge))) + MantleAdiabaticT[I]
1346+ Temp[I] = (Tsurface - Tmantle) * erfc (abs (pz) * 1.0e3 / (2 * sqrt (kappa * ThermalAge))) + MantleAdiabaticT[I]
13431347 end
13441348
13451349 return Temp
@@ -1358,7 +1362,7 @@ end
13581362# Function to determine the side of a point with respect to a line (adjusted for segment direction)
13591363function side_of_line (x, y, x1, y1, x2, y2, direction)
13601364 side = (x2 - x1) * (y - y1) - (y2 - y1) * (x - x1)
1361- direction == :left ? side > 0 : side < 0
1365+ return direction == :left ? side > 0 : side < 0
13621366end
13631367
13641368# Function to determine in which region a point lies (based on delimiters)
0 commit comments