From 75f63e0971aa10feeb7af28d373476da9c9da1d1 Mon Sep 17 00:00:00 2001 From: adigitoleo Date: Fri, 21 Jul 2023 05:47:48 +1000 Subject: [PATCH] test: Fix GBS test asserts and add commented versions for SCCS --- src/pydrex/visualisation.py | 2 -- tests/test_simple_shear_2d.py | 25 ++++++++++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/pydrex/visualisation.py b/src/pydrex/visualisation.py index edee6db8..8867e116 100644 --- a/src/pydrex/visualisation.py +++ b/src/pydrex/visualisation.py @@ -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 diff --git a/tests/test_simple_shear_2d.py b/tests/test_simple_shear_2d.py index 0aab6065..89bdf1d1 100644 --- a/tests/test_simple_shear_2d.py +++ b/tests/test_simple_shear_2d.py @@ -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']}") @@ -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): @@ -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']}") @@ -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,