From fda06855ef00ed76dd7dcc3034a407350bca04c5 Mon Sep 17 00:00:00 2001 From: Pablo RF Date: Wed, 26 Oct 2022 12:42:10 -0400 Subject: [PATCH] If all currents are fixed, IF statement is needed --- freegs/control.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/freegs/control.py b/freegs/control.py index eec00a8..dda3584 100644 --- a/freegs/control.py +++ b/freegs/control.py @@ -176,13 +176,14 @@ def max_total_currents(x): cons.append(con1) # Use the analytical current change as the initial guess - x0 = self.current_change - sol = optimize.minimize( - objective, x0, method="SLSQP", bounds=current_change_bnds, constraints=cons - ) - - self.current_change = sol.x - tokamak.controlAdjust(self.current_change) + if self.current_change.shape[0] > 0: + x0 = self.current_change + sol = optimize.minimize( + objective, x0, method="SLSQP", bounds=current_change_bnds, constraints=cons + ) + + self.current_change = sol.x + tokamak.controlAdjust(self.current_change) # Store info for user self.current_change = self.current_change