Skip to content

Commit f48575f

Browse files
authored
switch to OM's assert_check_totals (#463)
1 parent 7ae28a8 commit f48575f

5 files changed

Lines changed: 11 additions & 53 deletions

File tree

openaerostruct/utils/testing.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -514,42 +514,3 @@ def get_single_section_surface_AS():
514514
}
515515

516516
return surface_dict
517-
518-
519-
def assert_check_totals(totals, atol=1e-6, rtol=1e-6):
520-
for of_wrt_pair in totals.keys():
521-
of, wrt = of_wrt_pair
522-
total_dict = totals[of_wrt_pair]
523-
abs_error = total_dict["abs error"]
524-
rel_error = total_dict["rel error"]
525-
for i_mode, mode in enumerate(["forward", "forward_reverse", "reverse"]):
526-
if rel_error[i_mode] is not None:
527-
if np.abs(rel_error[i_mode]) - rtol > 0.0:
528-
err_str = (
529-
"Total deriv (mode "
530-
+ mode
531-
+ ") of "
532-
+ of
533-
+ " with respect to "
534-
+ wrt
535-
+ " had rel error "
536-
+ str(rel_error[i_mode])
537-
+ " which is greater than tol "
538-
+ str(rtol)
539-
)
540-
raise ValueError(err_str)
541-
if abs_error[i_mode] is not None:
542-
if np.abs(abs_error[i_mode]) - atol > 0.0:
543-
err_str = (
544-
"Total deriv (mode "
545-
+ mode
546-
+ ") of "
547-
+ of
548-
+ " with respect to "
549-
+ wrt
550-
+ " had abs error "
551-
+ str(abs_error[i_mode])
552-
+ " which is greater than tol "
553-
+ str(atol)
554-
)
555-
raise ValueError(err_str)

tests/integration_tests/test_aero_ground_effect.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ def test(self):
1212
from openaerostruct.geometry.geometry_group import Geometry
1313
from openaerostruct.aerodynamics.aero_groups import AeroPoint
1414

15-
from openmdao.utils.assert_utils import assert_near_equal
16-
from openaerostruct.utils.testing import assert_check_totals
15+
from openmdao.utils.assert_utils import assert_near_equal, assert_check_totals
1716

1817
# Create a dictionary to store options about the mesh
1918
mesh_dict = {"num_y": 7, "num_x": 2, "wing_type": "CRM", "symmetry": True, "num_twist_cp": 5}
@@ -126,7 +125,7 @@ def test(self):
126125
compact_print=True,
127126
out_stream=None,
128127
)
129-
assert_check_totals(totals, atol=1e-2, rtol=1e-5)
128+
assert_check_totals(totals, atol=1e-5, rtol=1e-5)
130129

131130

132131
if __name__ == "__main__":

tests/integration_tests/test_aero_ground_effect_right.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ def test(self):
66
# docs checkpoint 0
77
from openaerostruct.meshing.mesh_generator import generate_mesh
88

9-
from openmdao.utils.assert_utils import assert_near_equal
10-
from openaerostruct.utils.testing import assert_check_totals
9+
from openmdao.utils.assert_utils import assert_near_equal, assert_check_totals
1110

1211
# Create a dictionary to store options about the mesh
1312
mesh_dict = {"num_y": 7, "num_x": 2, "wing_type": "CRM", "symmetry": True, "num_twist_cp": 5}
@@ -49,7 +48,7 @@ def test(self):
4948
compact_print=True,
5049
out_stream=None,
5150
)
52-
assert_check_totals(totals, atol=1e-2, rtol=1e-5)
51+
assert_check_totals(totals, atol=1e-5, rtol=1e-5)
5352

5453
def setup_problem(self, mesh, twist_cp):
5554
"""

tests/integration_tests/test_aerostruct_groundeffect.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from openmdao.utils.assert_utils import assert_near_equal
1+
from openmdao.utils.assert_utils import assert_near_equal, assert_check_totals
22
import unittest
3-
from openaerostruct.utils.testing import assert_check_totals, assert_opt_successful
3+
from openaerostruct.utils.testing import assert_opt_successful
44

55

66
class Test(unittest.TestCase):
@@ -160,7 +160,7 @@ def test(self):
160160
abs_err_tol=1e-2,
161161
rel_err_tol=1e-5,
162162
)
163-
assert_check_totals(totals, atol=1e-2, rtol=1e-5)
163+
assert_check_totals(totals, atol=1e-5, rtol=1e-5)
164164

165165

166166
if __name__ == "__main__":

tests/integration_tests/test_scaneagle.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
import numpy as np
44

55
import openmdao.api as om
6-
from openmdao.utils.assert_utils import assert_near_equal
6+
from openmdao.utils.assert_utils import assert_near_equal, assert_check_totals
77

88
from openaerostruct.meshing.mesh_generator import generate_mesh
99
from openaerostruct.integration.aerostruct_groups import AerostructGeometry, AerostructPoint
1010
from openaerostruct.utils.constants import grav_constant
11-
from openaerostruct.utils.testing import assert_check_totals
1211

1312

1413
class Test(unittest.TestCase):
@@ -221,10 +220,10 @@ def test_totals(self):
221220
step=1e-3,
222221
step_calc="rel",
223222
compact_print=True,
224-
abs_err_tol=1e-4,
225-
rel_err_tol=1e-4,
223+
abs_err_tol=1e-5,
224+
rel_err_tol=1e-5,
226225
)
227-
assert_check_totals(totals, atol=1e-4, rtol=1e-4)
226+
assert_check_totals(totals, atol=1e-5, rtol=1e-5)
228227

229228

230229
if __name__ == "__main__":

0 commit comments

Comments
 (0)