From cf49f069620307510b2796bc0f1ce7e29b277d10 Mon Sep 17 00:00:00 2001 From: "Leaf, Andrew T" Date: Thu, 16 Jan 2025 12:17:36 -0600 Subject: [PATCH] fix(Mover Package SFR connections across LGR model interfaces (mover.py::get_sfr_package_connections)): Follow-up fix to fbe1bb1656f3; handle cases where parent model SFR reach along the LGR interface has both upstream and downstream connections to the inset model. --- mfsetup/mover.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/mfsetup/mover.py b/mfsetup/mover.py index bb61182a..2309b2f9 100644 --- a/mfsetup/mover.py +++ b/mfsetup/mover.py @@ -164,18 +164,20 @@ def neighbors(i, j): for parent_reach, inset_reach in parent_to_inset.items(): if parent_reach in inset_to_parent.values(): parent_to_inset_distance = parent_to_inset_distances[parent_reach] - inset_to_parent_distance = inset_to_parent_distances[inset_reach] - if inset_to_parent_distance < parent_to_inset_distance: - delete_parent_to_inset_items.add(parent_reach) - elif parent_to_inset_distance < inset_to_parent_distance: - del inset_to_parent[inset_reach] - else: - raise ValueError("Circular connection between SFR Packages in the Mover Package input.\n" - f"Connection distance between the end of parent reach {parent_reach} " - f"in parent model and start of inset reach {inset_reach} in inset model " - f"is equal to\nthe distance between the end of inset reach {inset_reach} " - f"and start of parent reach {parent_reach}.\nCheck input linework." - ) + if inset_to_parent_distances.get(inset_reach) is not None: + inset_to_parent_distance = inset_to_parent_distances[inset_reach] + if inset_to_parent_distance < parent_to_inset_distance: + delete_parent_to_inset_items.add(parent_reach) + elif parent_to_inset_distance < inset_to_parent_distance: + del inset_to_parent[inset_reach] + else: + raise ValueError( + "Circular connection between SFR Packages in the Mover Package input.\n" + f"Connection distance between the end of parent reach {parent_reach} " + f"in parent model and start of inset reach {inset_reach} in inset model " + f"is equal to\nthe distance between the end of inset reach {inset_reach} " + f"and start of parent reach {parent_reach}.\nCheck input linework." + ) for parent_reach in delete_parent_to_inset_items: del parent_to_inset[parent_reach] return parent_to_inset, inset_to_parent