From 7abc1d4c1c3051b0515643a14c3ed40e9abebd59 Mon Sep 17 00:00:00 2001 From: Tom Body
Date: Mon, 12 Feb 2024 13:02:21 -0500 Subject: [PATCH] Require current lims for all coils --- freegs/control.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/freegs/control.py b/freegs/control.py index dda3584..e3e5dcd 100644 --- a/freegs/control.py +++ b/freegs/control.py @@ -145,11 +145,13 @@ def __call__(self, eq): for i in range(ncontrols): current_change_bounds.append((-inf, inf)) else: - for i in range(ncontrols): - cur = tokamak.controlCurrents()[i] - lower_lim = self.current_lims[i][0] - cur - upper_lim = self.current_lims[i][1] - cur - current_change_bounds.append((lower_lim, upper_lim)) + assert len(self.current_lims) == len(tokamak.coils), \ + f"Should provide current limits for all coils. Provided {len(self.current_lims)} limits for {len(tokamak.coils)} coils." + for i, (_, coil) in enumerate(tokamak.coils): + if coil.control: + lower_lim = self.current_lims[i][0] - coil.current + upper_lim = self.current_lims[i][1] - coil.current + current_change_bounds.append((lower_lim, upper_lim)) current_change_bnds = array(current_change_bounds)