Skip to content

Commit

Permalink
Free boundary optimization might need the minimization of Bout-Bin at…
Browse files Browse the repository at this point in the history
… the surface. Added that term
  • Loading branch information
rogeriojorge committed Sep 22, 2023
1 parent df2a747 commit e1e2a20
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion examples/3_Advanced/single_stage_optimization_finite_beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from math import isnan
from pathlib import Path
from scipy.optimize import minimize
from simsopt.mhd.vmec_diagnostics import B_cartesian
from simsopt.util import MpiPartition, proc0_print, comm_world
from simsopt._core.util import ObjectiveFailure
from simsopt import make_optimizable
Expand Down Expand Up @@ -172,8 +173,16 @@ def fun_J(prob, coils_prob):
except ObjectiveFailure as e:
pass

bs.set_points(vc.trgt_surf.gamma().reshape((-1, 3)))
Bvmec = np.transpose(np.array(B_cartesian(vmec, quadpoints_phi=vc.trgt_surf.quadpoints_phi,
quadpoints_theta=vc.trgt_surf.quadpoints_theta)),(1,2,0))
Bvirtualcasing = vc.B_external
Bcoil = bs.B().reshape(Bvirtualcasing.shape)
Bsquared_interface = np.sum((Bcoil - Bvirtualcasing)*(Bcoil - Bvirtualcasing + 2*Bvmec),axis=-1)
sum_Bsquared_interface = np.sum(Bsquared_interface**2)

bs.set_points(surf.gamma().reshape((-1, 3)))
J_stage_2 = coils_objective_weight * JF.J()
J_stage_2 = coils_objective_weight * (JF.J() + sum_Bsquared_interface)
J = J_stage_1 + J_stage_2
return J

Expand Down

0 comments on commit e1e2a20

Please sign in to comment.