Skip to content

Commit

Permalink
test: Fix GBS test asserts and add commented versions for SCCS
Browse files Browse the repository at this point in the history
  • Loading branch information
adigitoleo committed Jul 20, 2023
1 parent 058f881 commit 75f63e0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/pydrex/visualisation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""> PyDRex: Visualisation functions for test outputs and examples."""
import functools as ft

import numpy as np
from matplotlib import projections as mproj
from matplotlib import pyplot as plt
Expand Down
25 changes: 22 additions & 3 deletions tests/test_simple_shear_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ def get_velocity_gradient(x):
axis=_minerals.OLIVINE_PRIMARY_AXIS[mineral.fabric],
)[0]

# Uncomment to use SCCS axis (hexagonal symmetry) for the angle instead.
# mean_angles = np.array(
# [
# _diagnostics.smallest_angle(
# _diagnostics.anisotropy(v)[1][2, :], shear_direction
# )
# for v in _minerals.voigt_averages([mineral], params)
# ]
# )

# Optionally store plotting metadata.
if outdir is not None:
labels.append(f"$M^∗$ = {params['gbm_mobility']}")
Expand Down Expand Up @@ -234,7 +244,6 @@ def test_dudz_GBS(
strain_rate = 5e-6 # Strain rate from Fraters & Billen, 2021, fig. 3.
timestamps = np.linspace(0, 5e5, 251) # Solve until D₀t=2.5 ('shear' γ=5).
n_timesteps = len(timestamps)
i_first_cpo = 50 # First index where Bingham averages are sufficiently stable.
i_strain_100p = [0, 50, 100, 150, 200] # Indices for += 100% strain.

def get_velocity_gradient(x):
Expand Down Expand Up @@ -307,6 +316,16 @@ def get_velocity_gradient(x):
axis=_minerals.OLIVINE_PRIMARY_AXIS[mineral.fabric],
)[0]

# Uncomment to use SCCS axis (hexagonal symmetry) for the angle instead.
# mean_angles = np.array(
# [
# _diagnostics.smallest_angle(
# _diagnostics.anisotropy(v)[1][2, :], shear_direction
# )
# for v in _minerals.voigt_averages([mineral], params)
# ]
# )

# Optionally store plotting metadata.
if outdir is not None:
labels.append(f"$f_{{gbs}}$ = {params['gbs_threshold']}")
Expand Down Expand Up @@ -378,13 +397,13 @@ def get_velocity_gradient(x):
atol=0.015,
)
nt.assert_allclose(
[0.015, 0.4, 0.72, 0.77, 0.79],
[0.015, 0.42, 0.71, 0.77, 0.79],
point100_symmetry[1].take(i_strain_100p),
rtol=0,
atol=0.015,
)
nt.assert_allclose(
[0.015, 0.39, 0.58, 0.61, 0.62],
[0.015, 0.36, 0.57, 0.6, 0.62],
point100_symmetry[2].take(i_strain_100p),
rtol=0,
atol=0.015,
Expand Down

0 comments on commit 75f63e0

Please sign in to comment.