Skip to content

Conversation

adbayonao
Copy link
Contributor

@adbayonao adbayonao commented Dec 11, 2024

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.

Screenshot from 2025-01-19 09-13-26

Screenshot from 2025-01-19 09-13-48

@adbayonao adbayonao closed this Dec 11, 2024
@adbayonao adbayonao reopened this Dec 11, 2024
@adbayonao adbayonao changed the title Contribution_2 Model Oceanic Ridge Configurations and Temperature Variations Based on Spreading and Age Dec 11, 2024
@adbayonao adbayonao changed the title Model Oceanic Ridge Configurations and Temperature Variations Based on Spreading and Age Oceanic Ridge Configurations Dec 11, 2024
@adbayonao adbayonao marked this pull request as draft December 12, 2024 13:39
@adbayonao adbayonao changed the title Oceanic Ridge Configurations New function for generating tectonic plates with custom geometries and constant depth Jan 19, 2025
@adbayonao adbayonao marked this pull request as ready for review January 19, 2025 17:22
@adbayonao adbayonao marked this pull request as draft January 20, 2025 07:53
@adbayonao adbayonao marked this pull request as ready for review January 20, 2025 15:46
@adbayonao adbayonao marked this pull request as draft January 22, 2025 16:17
@adbayonao adbayonao marked this pull request as ready for review January 28, 2025 17:57
Copy link

github-actions bot commented Jan 28, 2025

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic main) to apply these changes.

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

Copy link
Member

@aelligp aelligp left a 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

@aelligp aelligp dismissed albert-de-montserrat’s stale review February 20, 2025 12:36

changes have been addressed

@aelligp aelligp merged commit 0e47fee into JuliaGeodynamics:main Feb 20, 2025
18 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants