From a155bdfb6af0abd30338bd5db9b90e01dbb33bda Mon Sep 17 00:00:00 2001 From: swryan Date: Fri, 8 Mar 2024 09:47:11 -0500 Subject: [PATCH] update benchmarks with OM331 fix --- benchmark/benchmark_derivs_full.py | 20 ++++++++++++++++---- benchmark/benchmark_derivs_full_par.py | 20 ++++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/benchmark/benchmark_derivs_full.py b/benchmark/benchmark_derivs_full.py index 9667178..5472d84 100644 --- a/benchmark/benchmark_derivs_full.py +++ b/benchmark/benchmark_derivs_full.py @@ -5,8 +5,11 @@ import unittest +from packaging.version import Version + import numpy as np +from openmdao import __version__ as om_version from openmdao.api import Problem, LinearBlockGS from openmdao.utils.assert_utils import assert_near_equal @@ -69,7 +72,16 @@ def benchmark_cadre_mdp_derivs_full(self): # ---------------------------------------- J = prob.compute_totals() - assert_near_equal(J['obj.val', 'bp.antAngle'][0][0], - 67.15777407, 1e-4) - assert_near_equal(J['obj.val', 'parallel.pt1.design.CP_gamma'][-1][-1], - -0.62410223816776056, 1e-4) + if Version(om_version) <= Version("3.30"): + assert_near_equal(J['obj.val', 'bp.antAngle'][0][0], + 67.15777407, 1e-4) + assert_near_equal(J['obj.val', 'parallel.pt1.design.CP_gamma'][-1][-1], + -0.62410223816776056, 1e-4) + else: + # as of OpenMDAO 3.31.0, the keys in the jac are the 'user facing' names + # given to the design vars and responses, rather than the absolute names + # that were used previously + assert_near_equal(J['obj.val', 'bp.antAngle'][0][0], + 67.15777407, 1e-4) + assert_near_equal(J['obj.val', 'pt1.CP_gamma'][-1][-1], + -0.62410223816776056, 1e-4) diff --git a/benchmark/benchmark_derivs_full_par.py b/benchmark/benchmark_derivs_full_par.py index 7e063c0..578cbdf 100644 --- a/benchmark/benchmark_derivs_full_par.py +++ b/benchmark/benchmark_derivs_full_par.py @@ -5,8 +5,11 @@ import unittest +from packaging.version import Version + import numpy as np +from openmdao import __version__ as om_version from openmdao.api import Problem, LinearBlockGS from openmdao.utils.assert_utils import assert_near_equal @@ -71,7 +74,16 @@ def benchmark_cadre_mdp_derivs_full_par(self): # ---------------------------------------- J = prob.compute_totals() - assert_near_equal(J['obj.val', 'bp.antAngle'][0][0], - 67.15777407, 1e-4) - assert_near_equal(J['obj.val', 'parallel.pt1.design.CP_gamma'][-1][-1], - -0.62410223816776056, 1e-4) + if Version(om_version) <= Version("3.30"): + assert_near_equal(J['obj.val', 'bp.antAngle'][0][0], + 67.15777407, 1e-4) + assert_near_equal(J['obj.val', 'parallel.pt1.design.CP_gamma'][-1][-1], + -0.62410223816776056, 1e-4) + else: + # as of OpenMDAO 3.31.0, the keys in the jac are the 'user facing' names + # given to the design vars and responses, rather than the absolute names + # that were used previously + assert_near_equal(J['obj.val', 'bp.antAngle'][0][0], + 67.15777407, 1e-4) + assert_near_equal(J['obj.val', 'pt1.CP_gamma'][-1][-1], + -0.62410223816776056, 1e-4)