From e4ae3300ffd19543ed7377f6700f7e7a7ea866c4 Mon Sep 17 00:00:00 2001 From: Rob Falck Date: Wed, 29 Jan 2025 12:42:12 -0500 Subject: [PATCH] Fixed default ref/res_ref for RadauIterGroup --- .../components/radau_iter_group.py | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/dymos/transcriptions/pseudospectral/components/radau_iter_group.py b/dymos/transcriptions/pseudospectral/components/radau_iter_group.py index 7c5bda6ad..b913f85e9 100644 --- a/dymos/transcriptions/pseudospectral/components/radau_iter_group.py +++ b/dymos/transcriptions/pseudospectral/components/radau_iter_group.py @@ -1,5 +1,6 @@ import numpy as np import openmdao.api as om +from openmdao.utils.general_utils import determine_adder_scaler from .input_resids_comp import InputResidsComp from .radau_defect_comp import RadauDefectComp @@ -227,6 +228,19 @@ def configure_io(self, phase): states_resids_comp.add_input(f'final_state_defects:{name}', shape=(1,) + shape, units=units) states_resids_comp.add_input(f'state_rate_defects:{name}', shape=(ncn,) + shape, units=units) + if options['defect_ref'] is not None: + defect_ref = options['defect_ref'] + else: + if options['defect_scaler'] is None: + defect_ref = 1.0 + else: + defect_ref = 1. / options['defect_scaler'] + + adder, scaler = determine_adder_scaler(options['ref0'], options['ref'], + options['adder'], options['scaler']) + ref0 = -adder + ref = (1.0 / scaler) - adder + if ns > 1 and not gd.compressed: states_resids_comp.add_input(f'state_cnty_defects:{name}', shape=(ns - 1,) + shape, @@ -237,8 +251,9 @@ def configure_io(self, phase): shape=(nn,) + shape, lower=options['lower'], upper=options['upper'], - ref=options['ref'], - res_ref=options['defect_ref'], + ref0=ref0, + ref=ref, + res_ref=defect_ref, units=units) else: # For compressed transcirption, resids comp provides values at input nodes. @@ -247,8 +262,9 @@ def configure_io(self, phase): shape=(nin,) + shape, lower=options['lower'], upper=options['upper'], - ref=options['ref'], - res_ref=options['defect_ref'], + ref0=ref0, + ref=ref, + res_ref=defect_ref, units=units) if options['initial_bounds'] is None: @@ -266,14 +282,16 @@ def configure_io(self, phase): if f'initial_states:{name}' in self._implicit_outputs: states_resids_comp.add_output(f'initial_states:{name}', shape=(1,) + shape, units=units, lower=initial_lb, upper=initial_ub, - ref=options['ref'], - res_ref=options['defect_ref'],) + ref0=ref0, + ref=ref, + res_ref=defect_ref,) if f'final_states:{name}' in self._implicit_outputs: states_resids_comp.add_output(f'final_states:{name}', shape=(1,) + shape, units=units, lower=final_lb, upper=final_ub, - ref=options['ref'], - res_ref=options['defect_ref'],) + ref0=ref0, + ref=ref, + res_ref=defect_ref,) try: rate_source_var = options['rate_source']