Skip to content

Commit 9506170

Browse files
committed
In sph geom, (r|z)_coord contains radial position
They were previously set to r_coord - rcmb.
1 parent 9b87dc8 commit 9506170

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

stagpy/_step.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ def __init__(self, header, par):
8383
self._coords[0] = np.array(np.pi / 2)
8484
elif self.twod_xz:
8585
self._coords[1] = np.array(0)
86-
r_coord = self.z_coord + self.rcmb
86+
self._coords[2] += self.rcmb
8787
if par['magma_oceans_in']['magma_oceans_mode']:
88-
r_coord += header['mo_lambda']
89-
r_coord *= header['mo_thick_sol']
88+
self._coord[2] += header['mo_lambda']
89+
self._coord[2] *= header['mo_thick_sol']
9090
t_mesh, p_mesh, r_mesh = np.meshgrid(
91-
self.x_coord, self.y_coord, r_coord, indexing='ij')
91+
self.t_coord, self.p_coord, self.r_coord, indexing='ij')
9292
# compute cartesian coordinates
9393
# z along rotation axis at theta=0
9494
# x at th=90, phi=0
@@ -166,8 +166,10 @@ def threed(self):
166166
def at_z(self, zval):
167167
"""Return iz closest to given zval position.
168168
169-
This is different than radial position in spherical geometry.
169+
In spherical geometry, the bottom boundary is considered to be at z=0.
170170
"""
171+
if self.curvilinear:
172+
zval += self.rcmb
171173
return np.argmin(np.abs(self.z_coord - zval))
172174

173175
def __getattr__(self, attr):

stagpy/plates.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def detect_plates_vzcheck(step, seuil_memz):
1818
n_z = step.geom.nztot
1919
nphi = step.geom.nptot # -1? should be OK, ghost not included
2020
rcmb = max(0, step.geom.rcmb)
21-
radius = step.geom.r_coord + rcmb
21+
radius = step.geom.r_coord
2222
radiusgrid = step.geom.rgeom[:, 0] + rcmb
2323
dphi = 1 / nphi
2424

@@ -93,7 +93,8 @@ def detect_plates(step, vrms_surface, fids, time):
9393
dsa = step.sdat.par['boundaries']['air_thickness']
9494
# we are a bit below the surface; should check if you are in the
9595
# thermal boundary layer
96-
indsurf = np.argmin(abs((1 - dsa) - step.geom.r_coord)) - 4
96+
indsurf = np.argmin(
97+
np.abs(1 - dsa - step.geom.r_coord + step.geom.rcmb)) - 4
9798
else:
9899
indsurf = -1
99100

@@ -211,9 +212,11 @@ def plot_plates(step, time, vrms_surface, trench, ridge, agetrench,
211212
# to be just below
212213
# the surface (that is considered plane here); should check if you are
213214
# in the thermal boundary layer
214-
indsurf = np.argmin(abs((1 - dsa) - step.geom.r_coord)) - 4
215+
indsurf = np.argmin(
216+
np.abs(1 - dsa - step.geom.r_coord + step.geom.rcmb)) - 4
215217
# depth to detect the continents
216-
indcont = np.argmin(abs((1 - dsa) - np.array(step.geom.r_coord))) - 10
218+
indcont = np.argmin(
219+
np.abs(1 - dsa - step.geom.r_coord + step.geom.rcmb)) - 10
217220
else:
218221
indsurf = -1
219222
indcont = -1 # depth to detect continents
@@ -514,7 +517,8 @@ def lithospheric_stress(step, trench, ridge, time):
514517
# to be just below
515518
dsa = step.sdat.par['boundaries']['air_thickness']
516519
# depth to detect the continents
517-
indcont = np.argmin(abs((1 - dsa) - step.geom.r_coord)) - 10
520+
indcont = np.argmin(
521+
np.abs(1 - dsa - step.geom.r_coord + step.geom.rcmb)) - 10
518522
else:
519523
# depth to detect continents
520524
indcont = -1

stagpy/processing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def stream_function(step):
349349
psi = np.zeros_like(v_x)
350350
if step.geom.spherical: # YZ annulus
351351
# positions
352-
r_nc = step.geom.r_coord + step.geom.rcmb # numerical centers
352+
r_nc = step.geom.r_coord # numerical centers
353353
r_pc = step.geom.r_mesh[0, 0, :] # physical centers
354354
r_nw = r_edges(step)[0][:2] # numerical walls of first cell
355355
# vz at center of bottom cells

stagpy/stagyyparsers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,6 @@ def _read_coord_h5(files, shapes, header, twod):
651651
if header['rcmb'] == 0:
652652
header['rcmb'] = -1
653653
else:
654-
# could make the difference between r_coord and z_coord
655654
header['e3_coord'] = header['e3_coord'] - header['rcmb']
656655
if twod is None or 'X' in twod:
657656
header['e1_coord'] = header['e1_coord'][:-1]

0 commit comments

Comments
 (0)