Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If all currents are fixed, IF statement is needed #71

Merged
merged 1 commit into from
Oct 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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