Skip to content

Commit

Permalink
Merge branch 'planar_coil_arrays' of https://github.com/hiddenSymmetr…
Browse files Browse the repository at this point in the history
…ies/simsopt into planar_coil_arrays
  • Loading branch information
akaptano committed Dec 20, 2024
2 parents 9e629e1 + 220c0d6 commit 965500c
Show file tree
Hide file tree
Showing 150 changed files with 3,543 additions and 12,185 deletions.
2 changes: 1 addition & 1 deletion examples/1_Simple/just_a_quadratic.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# Solve the minimization problem:
least_squares_serial_solve(prob)

print("An optimum was found at x=", iden1.x, ", y=", iden2.x, \
print("An optimum was found at x=", iden1.x, ", y=", iden2.x,
", z=", iden3.x)
print("The minimum value of the objective function is ", prob.objective())
print("End of 1_Simple/just_a_quadratic.py")
Expand Down
27 changes: 19 additions & 8 deletions examples/1_Simple/permanent_magnet_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,26 @@
from simsopt.field import DipoleField, ToroidalField
from simsopt.geo import PermanentMagnetGrid, SurfaceRZFourier
from simsopt.solve import GPMO
from simsopt.util import in_github_actions
from simsopt.util.permanent_magnet_helper_functions import *

nphi = 16 # change to 64 for a real run
ntheta = 16
# nphi = ntheta >= 64 needed for accurate full-resolution runs
if in_github_actions:
nphi = 4
ntheta = nphi
# Set some hyperparameters for the optimization
kwargs = initialize_default_kwargs('GPMO')
kwargs['K'] = 1000
kwargs['nhistory'] = 10
downsample = 10
else:
nphi = 16
ntheta = 16
kwargs = initialize_default_kwargs('GPMO')
kwargs['K'] = 10000
kwargs['nhistory'] = 100
downsample = 4 # Downsamples the permanent magnet grid -- set = 1 for full scale run

input_name = 'wout_c09r00_fixedBoundary_0.5T_vacuum_ns201.nc'
famus_filename = 'init_orient_pm_nonorm_5E4_q4_dp.focus'

Expand All @@ -49,17 +65,12 @@
Bnormal = np.sum(bs.B().reshape((nphi, ntheta, 3)) * s.unitnormal(), axis=2)

# Finally, initialize the permanent magnet class
kwargs_geo = {"coordinate_flag": "cylindrical"} # , "downsample": downsample}
kwargs_geo = {"coordinate_flag": "cylindrical", "downsample": downsample}
pm_opt = PermanentMagnetGrid.geo_setup_from_famus(
s, Bnormal, famus_filename, **kwargs_geo
)
print('Number of available dipoles = ', pm_opt.ndipoles)

# Set some hyperparameters for the optimization
kwargs = initialize_default_kwargs('GPMO')
kwargs['K'] = 40000
kwargs['nhistory'] = 100

# Optimize the permanent magnets greedily
R2_history, Bn_history, m_history = GPMO(pm_opt, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion examples/1_Simple/surf_vol_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# property to True.
surf.fix('rc(0,0)')

# LeastSquaresProble can be initialized in couple of ways.
# LeastSquaresProble can be initialized in couple of ways.
prob1 = LeastSquaresProblem(funcs_in=[surf.area, surf.volume],
goals=[desired_area, desired_volume],
weights=[1, 1])
Expand Down
1 change: 0 additions & 1 deletion examples/2_Intermediate/B_external_normal.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@

print('B_external_normal, loaded from file:')
print(vc2.B_external_normal[:4, :4])

Loading

0 comments on commit 965500c

Please sign in to comment.