diff --git a/pyproject.toml b/pyproject.toml index 49d542f23..35ddd5e42 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,8 @@ #pyproject.toml [build-system] # Minimum requirements for the build system to execute. -requires = ['setuptools>=45.0', 'wheel', 'cython>=0.29', 'oldest-supported-numpy', 'mpi4py==3.1.1'] +requires = ['setuptools>=45.0', 'wheel', 'cython>=0.29', 'oldest-supported-numpy', + # Build against an old version (3.1.1) of mpi4py for forward compatibility + "mpi4py==3.1.1; python_version<'3.11'", + # Python 3.11 requires 3.1.4+ + "mpi4py==3.1.4; python_version>='3.11'"] diff --git a/src/elements/TACSElementVerification.cpp b/src/elements/TACSElementVerification.cpp index 61701ca3a..7721d8f9a 100644 --- a/src/elements/TACSElementVerification.cpp +++ b/src/elements/TACSElementVerification.cpp @@ -106,8 +106,9 @@ bool TacsAssertAllClose(TacsScalar *testVals, TacsScalar *refVals, int size, double atol, double rtol) { bool all_close = true; for (int i = 0; i < size; i++) { - if (fabs(TacsRealPart(testVals[i] - refVals[i])) > - atol + rtol * fabs(TacsRealPart(refVals[i]))) { + double absError = fabs(TacsRealPart(testVals[i] - refVals[i])); + double combinedTol = atol + rtol * fabs(TacsRealPart(refVals[i])); + if (absError > combinedTol) { all_close = false; break; } diff --git a/tests/constitutive_tests/test_basic_beam_constitutive.py b/tests/constitutive_tests/test_basic_beam_constitutive.py index 6b6018d09..aaf81f807 100644 --- a/tests/constitutive_tests/test_basic_beam_constitutive.py +++ b/tests/constitutive_tests/test_basic_beam_constitutive.py @@ -9,15 +9,14 @@ class ConstitutiveTest(unittest.TestCase): def setUp(self): # fd/cs step size if TACS.dtype is complex: - self.dh = 1e-50 + self.dh = 1e-200 self.rtol = 1e-11 else: self.dh = 1e-8 - self.rtol = 1e-3 + self.rtol = 1e-6 self.dtype = TACS.dtype - # Basically, only check relative tolerance - self.atol = self.rtol + self.atol = np.clip(1e-5 * self.rtol, 1e-8, 1e-14) self.print_level = 0 # Set element index diff --git a/tests/constitutive_tests/test_composite_shell_constitutive.py b/tests/constitutive_tests/test_composite_shell_constitutive.py index 5edcca5a4..34acbcd67 100644 --- a/tests/constitutive_tests/test_composite_shell_constitutive.py +++ b/tests/constitutive_tests/test_composite_shell_constitutive.py @@ -11,15 +11,14 @@ class ConstitutiveTest(unittest.TestCase): def setUp(self): # fd/cs step size if TACS.dtype is complex: - self.dh = 1e-50 - self.rtol = 1e-9 + self.dh = 1e-200 + self.rtol = 1e-12 else: self.dh = 1e-8 - self.rtol = 1e-3 + self.rtol = 1e-6 self.dtype = TACS.dtype - # Basically, only check relative tolerance - self.atol = self.rtol + self.atol = np.clip(1e-5 * self.rtol, 1e-8, 1e-14) self.print_level = 0 # Set element index @@ -229,8 +228,8 @@ def test_constitutive_failure_strain_sens(self): self.x, self.dh, self.print_level, - self.rtol, self.atol, + self.rtol, ) self.assertFalse(fail) diff --git a/tests/constitutive_tests/test_dof_spring_constitutive.py b/tests/constitutive_tests/test_dof_spring_constitutive.py index db156edc4..03b8ec176 100644 --- a/tests/constitutive_tests/test_dof_spring_constitutive.py +++ b/tests/constitutive_tests/test_dof_spring_constitutive.py @@ -9,15 +9,14 @@ class ConstitutiveTest(unittest.TestCase): def setUp(self): # fd/cs step size if TACS.dtype is complex: - self.dh = 1e-50 + self.dh = 1e-200 self.rtol = 1e-11 else: self.dh = 1e-8 - self.rtol = 1e-3 + self.rtol = 1e-6 self.dtype = TACS.dtype - # Basically, only check relative tolerance - self.atol = self.rtol + self.atol = np.clip(1e-5 * self.rtol, 1e-8, 1e-14) self.print_level = 0 # Set element index diff --git a/tests/constitutive_tests/test_general_mass_constitutive.py b/tests/constitutive_tests/test_general_mass_constitutive.py index 016aa8342..077c323b4 100644 --- a/tests/constitutive_tests/test_general_mass_constitutive.py +++ b/tests/constitutive_tests/test_general_mass_constitutive.py @@ -9,15 +9,14 @@ class ConstitutiveTest(unittest.TestCase): def setUp(self): # fd/cs step size if TACS.dtype is complex: - self.dh = 1e-50 + self.dh = 1e-200 self.rtol = 1e-11 else: self.dh = 1e-8 - self.rtol = 1e-3 + self.rtol = 1e-6 self.dtype = TACS.dtype - # Basically, only check relative tolerance - self.atol = self.rtol + self.atol = np.clip(1e-5 * self.rtol, 1e-8, 1e-14) self.print_level = 0 # Set element index diff --git a/tests/constitutive_tests/test_general_spring_constitutive.py b/tests/constitutive_tests/test_general_spring_constitutive.py index cb6aece2f..2c803e669 100644 --- a/tests/constitutive_tests/test_general_spring_constitutive.py +++ b/tests/constitutive_tests/test_general_spring_constitutive.py @@ -9,15 +9,14 @@ class ConstitutiveTest(unittest.TestCase): def setUp(self): # fd/cs step size if TACS.dtype is complex: - self.dh = 1e-50 + self.dh = 1e-200 self.rtol = 1e-11 else: self.dh = 1e-8 - self.rtol = 1e-3 + self.rtol = 1e-6 self.dtype = TACS.dtype - # Basically, only check relative tolerance - self.atol = self.rtol + self.atol = np.clip(1e-5 * self.rtol, 1e-8, 1e-14) self.print_level = 0 # Set element index diff --git a/tests/constitutive_tests/test_iso_rectangle_beam_constitutive.py b/tests/constitutive_tests/test_iso_rectangle_beam_constitutive.py index 3d06a56a8..58ffb1aea 100644 --- a/tests/constitutive_tests/test_iso_rectangle_beam_constitutive.py +++ b/tests/constitutive_tests/test_iso_rectangle_beam_constitutive.py @@ -9,16 +9,15 @@ class ConstitutiveTest(unittest.TestCase): def setUp(self): # fd/cs step size if TACS.dtype is complex: - self.dh = 1e-50 - self.rtol = 1e-11 - self.atol = 1e-5 + self.dh = 1e-200 + self.rtol = 1e-12 else: self.dh = 1e-8 - self.rtol = 1e-3 - self.atol = 1e-1 - + self.rtol = 1e-6 self.dtype = TACS.dtype + self.atol = np.clip(1e-5 * self.rtol, 1e-8, 1e-14) + self.print_level = 0 # Set element index diff --git a/tests/constitutive_tests/test_iso_shell_constitutive.py b/tests/constitutive_tests/test_iso_shell_constitutive.py index 48eda783e..5ad323e4c 100644 --- a/tests/constitutive_tests/test_iso_shell_constitutive.py +++ b/tests/constitutive_tests/test_iso_shell_constitutive.py @@ -9,15 +9,14 @@ class ConstitutiveTest(unittest.TestCase): def setUp(self): # fd/cs step size if TACS.dtype is complex: - self.dh = 1e-50 + self.dh = 1e-200 self.rtol = 1e-11 else: self.dh = 1e-8 - self.rtol = 1e-3 + self.rtol = 1e-6 self.dtype = TACS.dtype - # Basically, only check relative tolerance - self.atol = self.rtol + self.atol = np.clip(1e-5 * self.rtol, 1e-8, 1e-14) self.print_level = 0 # Set element index diff --git a/tests/constitutive_tests/test_iso_tube_beam_constitutive.py b/tests/constitutive_tests/test_iso_tube_beam_constitutive.py index a58e7df58..d030bfac1 100644 --- a/tests/constitutive_tests/test_iso_tube_beam_constitutive.py +++ b/tests/constitutive_tests/test_iso_tube_beam_constitutive.py @@ -9,15 +9,15 @@ class ConstitutiveTest(unittest.TestCase): def setUp(self): # fd/cs step size if TACS.dtype is complex: - self.dh = 1e-50 - self.rtol = 1e-11 - self.atol = 1e-5 + self.dh = 1e-200 + self.rtol = 1e-12 else: self.dh = 1e-8 - self.rtol = 1e-3 - self.atol = 1e-1 + self.rtol = 1e-6 self.dtype = TACS.dtype + self.atol = np.clip(1e-5 * self.rtol, 1e-8, 1e-14) + self.print_level = 0 # Set element index diff --git a/tests/constitutive_tests/test_pcm_constitutive.py b/tests/constitutive_tests/test_pcm_constitutive.py index 0cff2ed78..f260c49b1 100644 --- a/tests/constitutive_tests/test_pcm_constitutive.py +++ b/tests/constitutive_tests/test_pcm_constitutive.py @@ -9,15 +9,14 @@ class ConstitutiveTest(unittest.TestCase): def setUp(self): # fd/cs step size if TACS.dtype is complex: - self.dh = 1e-50 + self.dh = 1e-200 self.rtol = 1e-11 else: self.dh = 1e-8 - self.rtol = 1e-3 + self.rtol = 1e-6 self.dtype = TACS.dtype - # Basically, only check relative tolerance - self.atol = self.rtol + self.atol = np.clip(1e-5 * self.rtol, 1e-8, 1e-14) self.print_level = 0 # Set element index diff --git a/tests/constitutive_tests/test_plane_stress_constitutive.py b/tests/constitutive_tests/test_plane_stress_constitutive.py index 607fe9712..585b49501 100644 --- a/tests/constitutive_tests/test_plane_stress_constitutive.py +++ b/tests/constitutive_tests/test_plane_stress_constitutive.py @@ -9,15 +9,14 @@ class ConstitutiveTest(unittest.TestCase): def setUp(self): # fd/cs step size if TACS.dtype is complex: - self.dh = 1e-50 + self.dh = 1e-200 self.rtol = 1e-11 else: self.dh = 1e-8 - self.rtol = 1e-3 + self.rtol = 1e-6 self.dtype = TACS.dtype - # Basically, only check relative tolerance - self.atol = self.rtol + self.atol = np.clip(1e-5 * self.rtol, 1e-8, 1e-14) self.print_level = 0 # Set element index diff --git a/tests/constitutive_tests/test_point_mass_constitutive.py b/tests/constitutive_tests/test_point_mass_constitutive.py index 323d705aa..4ddeef6b4 100644 --- a/tests/constitutive_tests/test_point_mass_constitutive.py +++ b/tests/constitutive_tests/test_point_mass_constitutive.py @@ -9,15 +9,14 @@ class ConstitutiveTest(unittest.TestCase): def setUp(self): # fd/cs step size if TACS.dtype is complex: - self.dh = 1e-50 + self.dh = 1e-200 self.rtol = 1e-11 else: self.dh = 1e-8 - self.rtol = 1e-3 + self.rtol = 1e-6 self.dtype = TACS.dtype - # Basically, only check relative tolerance - self.atol = self.rtol + self.atol = np.clip(1e-5 * self.rtol, 1e-8, 1e-14) self.print_level = 0 # Set element index diff --git a/tests/constitutive_tests/test_solid_constitutive.py b/tests/constitutive_tests/test_solid_constitutive.py index 915713f24..b1873ad81 100644 --- a/tests/constitutive_tests/test_solid_constitutive.py +++ b/tests/constitutive_tests/test_solid_constitutive.py @@ -9,15 +9,14 @@ class ConstitutiveTest(unittest.TestCase): def setUp(self): # fd/cs step size if TACS.dtype is complex: - self.dh = 1e-50 + self.dh = 1e-200 self.rtol = 1e-11 else: self.dh = 1e-8 - self.rtol = 1e-3 + self.rtol = 1e-6 self.dtype = TACS.dtype - # Basically, only check relative tolerance - self.atol = self.rtol + self.atol = np.clip(1e-5 * self.rtol, 1e-8, 1e-14) self.print_level = 0 # Set element index