Skip to content

Commit

Permalink
fixed some logic for linkages when units are None
Browse files Browse the repository at this point in the history
  • Loading branch information
robfalck committed Mar 22, 2023
1 parent b5d4d13 commit fb1f8fc
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions dymos/trajectory/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,13 +597,17 @@ def _update_linkage_options_configure(self, linkage_options):
if linkage_options['units_b'] is _unspecified:
linkage_options['units_b'] = units['b']

conversion_scaler, conversion_offset = unit_conversion(linkage_options['units_a'], linkage_options['units_b'])

if not linkage_options['connected'] and linkage_options['units'] is _unspecified and \
(abs(conversion_scaler - 1.0) > 1.0E-15 or abs(conversion_offset) > 1.0E-15):
raise ValueError(f'{info_str}Linkage units were not specified but the units of {phase_name_a}.{var_a} '
f'({units["a"]}) and {phase_name_b}.{var_b} ({units["b"]}) are not equivalent. '
f'Units for this linkage constraint must be specified explicitly.')
if units['a'] is not None and units['b'] is not None:
conversion_scaler, conversion_offset = unit_conversion(units['a'], units['b'])
else:
conversion_scaler, conversion_offset = (1.0, 0.0)

if not linkage_options['connected'] \
and linkage_options['units'] is _unspecified \
and (abs(conversion_scaler - 1.0) > 1.0E-15 or abs(conversion_offset) > 1.0E-15):
raise ValueError(f'{info_str}Linkage units were not specified but the units of {phase_name_a}.{var_a} '
f'({units["a"]}) and {phase_name_b}.{var_b} ({units["b"]}) are not equivalent. '
f'Units for this linkage constraint must be specified explicitly.')
else:
linkage_options['units'] = units['a']

Expand Down

0 comments on commit fb1f8fc

Please sign in to comment.