diff --git a/examples/2_Intermediate/exact_magnet_PM4Stell.py b/examples/2_Intermediate/exact_magnet_PM4Stell.py index 5068f8c41..2dd8053aa 100644 --- a/examples/2_Intermediate/exact_magnet_PM4Stell.py +++ b/examples/2_Intermediate/exact_magnet_PM4Stell.py @@ -40,21 +40,21 @@ max_nMagnets = 20 downsample = 100 # drastically downsample the grid if running CI else: - N = 16 # >= 64 for high-resolution runs - nIter_max = 100000 - max_nMagnets = 1000 + N = 32 # >= 64 for high-resolution runs + nIter_max = 40000 + # max_nMagnets = 2000 downsample = 1 - dims = np.array([1,1,1]) #currently can only have all magnets be same shape + # dims = np.array([1,1,1]) #currently can only have all magnets be same shape nphi = N ntheta = N -algorithm = 'ArbVec_backtracking' -nBacktracking = 200 -nAdjacent = 10 -thresh_angle = np.pi # / np.sqrt(2) +algorithm = 'baseline' +# nBacktracking = 200 +# nAdjacent = 10 +# thresh_angle = np.pi # / np.sqrt(2) nHistory = 10 -angle = int(thresh_angle * 180 / np.pi) -out_dir = Path("exactPM4Stell_angle{angle}_nb{nBacktracking)_na{nAdjacent}") +# angle = int(thresh_angle * 180 / np.pi) +out_dir = Path("exactPM4Stell") out_dir.mkdir(parents=True, exist_ok=True) print('out directory = ', out_dir) @@ -145,10 +145,7 @@ pol_vectors[:, :, 2] = mag_data.pol_z # Using m_maxima functionality to try out unrealistically strong magnets -B_max = 5 # 5 Tesla!!!! -mu0 = 4 * np.pi * 1e-7 -m_maxima = B_max / mu0 -kwargs_geo = {"pol_vectors": pol_vectors, "m_maxima": m_maxima, "downsample": downsample, "dims": dims} +kwargs_geo = {"pol_vectors": pol_vectors, "downsample": downsample} # Initialize the permanent magnet grid from the PM4Stell arrangement pm_ncsx = ExactMagnetGrid.geo_setup_from_famus( @@ -173,7 +170,7 @@ # Save files if True: - pm_ncsx.dims = dims + # pm_ncsx.dims = dims # Make BiotSavart object from the magnets and plot solution b_exact = ExactField( pm_ncsx.pm_grid_xyz, diff --git a/examples/2_Intermediate/permanent_magnet_PM4Stell.py b/examples/2_Intermediate/permanent_magnet_PM4Stell.py index 7d90f0b2a..13589a30a 100755 --- a/examples/2_Intermediate/permanent_magnet_PM4Stell.py +++ b/examples/2_Intermediate/permanent_magnet_PM4Stell.py @@ -40,9 +40,9 @@ downsample = 100 # drastically downsample the grid if running CI else: N = 16 # >= 64 for high-resolution runs - nIter_max = 1000 - max_nMagnets = 400 - downsample = 50 + nIter_max = 40000 + max_nMagnets = 10000 + downsample = 4 nphi = N ntheta = N @@ -51,7 +51,7 @@ # nBacktracking = 200 # nAdjacent = 10 # thresh_angle = np.pi # / np.sqrt(2) -nHistory = 100 +nHistory = 10 # angle = int(thresh_angle * 180 / np.pi) out_dir = Path("PM4Stell") out_dir.mkdir(parents=True, exist_ok=True) diff --git a/src/simsopt/geo/permanent_magnet_grid.py b/src/simsopt/geo/permanent_magnet_grid.py index 13e4d7cd0..8b51d8d6d 100644 --- a/src/simsopt/geo/permanent_magnet_grid.py +++ b/src/simsopt/geo/permanent_magnet_grid.py @@ -371,7 +371,10 @@ def geo_setup_between_toroidal_surfaces( normal_inner = inner_toroidal_surface.unitnormal().reshape(-1, 3) normal_outer = outer_toroidal_surface.unitnormal().reshape(-1, 3) pm_grid._setup_uniform_grid() +<<<<<<< HEAD print(normal_inner.shape, normal_outer.shape, pm_grid.xyz_uniform.shape, pm_grid.xyz_inner.shape, pm_grid.xyz_outer.shape) +======= +>>>>>>> fe113881e652e58bc85b9ba9847357f9a2f9f5ef # pm_grid.dipole_grid_xyz = define_a_uniform_cartesian_grid_between_two_toroidal_surfaces( # normal_inner, # normal_outer, @@ -379,7 +382,10 @@ def geo_setup_between_toroidal_surfaces( # pm_grid.xyz_inner, # pm_grid.xyz_outer # ) +<<<<<<< HEAD +======= +>>>>>>> fe113881e652e58bc85b9ba9847357f9a2f9f5ef pm_grid.dipole_grid_xyz = sopp.define_a_uniform_cartesian_grid_between_two_toroidal_surfaces( contig(normal_inner), contig(normal_outer), @@ -387,7 +393,6 @@ def geo_setup_between_toroidal_surfaces( contig(pm_grid.xyz_inner), contig(pm_grid.xyz_outer)) inds = np.ravel(np.logical_not(np.all(pm_grid.dipole_grid_xyz == 0.0, axis=-1))) - print(inds.shape) pm_grid.dipole_grid_xyz = pm_grid.dipole_grid_xyz[inds, :] pm_grid.ndipoles = pm_grid.dipole_grid_xyz.shape[0] pm_grid.pm_phi = np.arctan2(pm_grid.dipole_grid_xyz[:, 1], pm_grid.dipole_grid_xyz[:, 0])