-
Notifications
You must be signed in to change notification settings - Fork 35
New function for generating tectonic plates with custom geometries and constant depth #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boriskaus
reviewed
Jan 19, 2025
boriskaus
reviewed
Jan 19, 2025
boriskaus
reviewed
Jan 19, 2025
albert-de-montserrat
previously requested changes
Jan 19, 2025
08e486e
to
ccebfc3
Compare
Your PR requires formatting changes to meet the project's style guidelines. Click here to view the suggested changes.diff --git a/src/Setup_geometry.jl b/src/Setup_geometry.jl
index 2c88c16..33d34d1 100644
--- a/src/Setup_geometry.jl
+++ b/src/Setup_geometry.jl
@@ -817,20 +817,22 @@ julia> write_paraview(Grid, "Plate") # Save model to Paraview
"Plate.vts"
"""
-function add_plate!(Phase, Temp, Grid::AbstractGeneralGrid;
- xlim=(), ylim=(), zlim::Tuple = (0.0,0.8),
- phase = ConstantPhase(1),
- T=nothing, segments=nothing, cell=false )
+function add_plate!(
+ Phase, Temp, Grid::AbstractGeneralGrid;
+ xlim = (), ylim = (), zlim::Tuple = (0.0, 0.8),
+ phase = ConstantPhase(1),
+ T = nothing, segments = nothing, cell = false
+ )
xlim_ = collect(xlim)
ylim_ = collect(ylim)
zlim_ = collect(zlim)
- X, Y, Z = coordinate_grids(Grid, cell=cell)
+ X, Y, Z = coordinate_grids(Grid, cell = cell)
ind = zeros(Bool, size(X))
ind_slice = zeros(Bool, size(X[:, :, 1]))
- for k = 1:size(Z, 3)
+ for k in 1:size(Z, 3)
if zlim_[1] <= Z[1, 1, k] <= zlim_[2]
inpolygon!(ind_slice, xlim_, ylim_, X[:, :, k], Y[:, :, k])
@views ind[:, :, k] = ind_slice
diff --git a/test/test_plate.jl b/test/test_plate.jl
index 8e201b3..2c05cb0 100644
--- a/test/test_plate.jl
+++ b/test/test_plate.jl
@@ -4,9 +4,9 @@ using Test
@testset "Plate Tests" begin
# Grid parameters
nx, ny, nz = 512, 512, 128
- x = range(-1000, 0, length=nx)
- y = range(-1000, 1000, length=ny)
- z = range(-660, 0, length=nz)
+ x = range(-1000, 0, length = nx)
+ y = range(-1000, 1000, length = ny)
+ z = range(-660, 0, length = nz)
Grid = CartData(xyz_grid(x, y, z))
# Phases and temperature
@@ -17,20 +17,22 @@ using Test
segments = [
((-500.0, -1000.0), (-500.0, 0.0)), # Segment 1
((-250.0, 0.0), (-250.0, 200.0)), # Segment 2
- ((-750.0, 200.0), (-750.0, 1000.0)) # Segment 3
+ ((-750.0, 200.0), (-750.0, 1000.0)), # Segment 3
]
# Lithospheric phases
- lith = LithosphericPhases(Layers=[15 55], Phases=[1 2], Tlab=1250)
+ lith = LithosphericPhases(Layers = [15 55], Phases = [1 2], Tlab = 1250)
# Replace add_box with add_polygon_xy to allow for arbitrary-shaped ridges
- add_plate!(Phases, Temp, Grid;
- xlim=(-1000.0, -750.0, -250.0, 0.0, -250.0, -750.0),
- ylim=(0.0, 500.0, 500.0, 0.0, -500.0, -500.0),
- zlim=(-150.0, 0.0),
- phase=lith,
- T=SpreadingRateTemp(SpreadingVel=3),
- segments=segments)
+ add_plate!(
+ Phases, Temp, Grid;
+ xlim = (-1000.0, -750.0, -250.0, 0.0, -250.0, -750.0),
+ ylim = (0.0, 500.0, 500.0, 0.0, -500.0, -500.0),
+ zlim = (-150.0, 0.0),
+ phase = lith,
+ T = SpreadingRateTemp(SpreadingVel = 3),
+ segments = segments
+ )
# Add and save results
Grid = addfield(Grid, (; Phases, Temp))
@@ -38,10 +40,10 @@ using Test
@test minimum(Temp) >= 0.0 # Minimum temperature
@test maximum(Temp) <= 1350.0 # Maximum temperature
- @test all(≥(0), Temp) # Ensure no negative temperatures
+ @test all(≥(0), Temp) # Ensure no negative temperatures
@test all(≤(1350), Temp) # Ensure no temperatures above max
# Check if phases are correctly assigned in expected regions
@test first(Phases) == 2 # Example: Verify a point's phase
- @test last(Phases) == 2 # Example: Verify another point's phase.
-end
\ No newline at end of file
+ @test last(Phases) == 2 # Example: Verify another point's phase.
+end |
aelligp
approved these changes
Feb 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thank you for your contribution
changes have been addressed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new function, add_plate, to create tectonic plates based on xy coordinates. This function builds upon the existing functionality of add_polygon, but is specifically adapted for defining tectonic plates with complex geometries and properties. The user can input multiple coordinates in the x and y directions to define the plate's geometry, while specifying a single tuple in the z direction to determine the depth range of the plate.
Additionally, this new function integrates the recently introduced functionality for segmented ridges, allowing plates to incorporate ridge structures. The add_plate function now accepts the temperature calculations from the ridge structure, enabling more accurate thermal and phase modeling for tectonic plates.