Skip to content

Commit

Permalink
Merge pull request #71 from freegs-plasma/recover_nocontrol
Browse files Browse the repository at this point in the history
If all currents are fixed, IF statement is needed
  • Loading branch information
pabloprf committed Oct 26, 2022
2 parents fcee05b + fda0685 commit 477be4c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions freegs/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 477be4c

Please sign in to comment.