Skip to content

Commit

Permalink
Modify example
Browse files Browse the repository at this point in the history
  • Loading branch information
connoramoreno committed Oct 1, 2024
1 parent 98dc878 commit 218346f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
20 changes: 11 additions & 9 deletions Examples/radial_distance_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
stellarator = ps.Stellarator(vmec_file)

# Define build parameters for in-vessel components
toroidal_angles = np.linspace(0, 90, num=61)
poloidal_angles = np.linspace(0, 360, num=67)
toroidal_angles = np.linspace(0, 90, num=97)
poloidal_angles = np.linspace(0, 360, num=97)
wall_s = 1.08
# Define build parameters for magnet coils
coils_file = "coils.example"
Expand All @@ -39,7 +39,7 @@
# symmetric
available_space = enforce_helical_symmetry(available_space)
# Smooth matrix
available_space = smooth_matrix(available_space, 50, 1)
available_space = smooth_matrix(available_space, 100, 1)
# For matrices defined by angles that are regularly spaced, matrix smoothing
# can result in matrix elements that are close to, but not exactly, helcially
# symmetric
Expand All @@ -48,7 +48,9 @@
available_space = available_space - max(width, thickness)

# Define a matrix of uniform unit thickness
uniform_unit_thickness = np.ones((len(toroidal_angles), len(poloidal_angles)))
uniform_unit_thickness = np.ones(
(len(toroidal_angles[::8]), len(poloidal_angles[::8]))
)
# Define thickness matrices for each in-vessel component of uniform thickness
first_wall_thickness_matrix = uniform_unit_thickness * 5
back_wall_thickness_matrix = uniform_unit_thickness * 5
Expand All @@ -57,7 +59,7 @@

# Compute breeder thickness matrix
breeder_thickness_matrix = (
available_space
available_space[::8, ::8]
- first_wall_thickness_matrix
- back_wall_thickness_matrix
- shield_thickness_matrix
Expand All @@ -77,14 +79,14 @@

# Construct in-vessel components
stellarator.construct_invessel_build(
toroidal_angles,
poloidal_angles,
toroidal_angles[::8],
poloidal_angles[::8],
wall_s,
radial_build_dict,
# Set num_ribs and num_rib_pts to be less than length of corresponding
# array to ensure that only defined angular locations are used
num_ribs=len(toroidal_angles) - 1,
num_rib_pts=len(poloidal_angles) - 1,
num_ribs=61,
num_rib_pts=61,
)
# Export in-vessel component files
stellarator.export_invessel_build()
Expand Down
24 changes: 23 additions & 1 deletion parastell/magnet_coils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from . import log
from . import cubit_io as cubit_io
from .utils import read_yaml_config, filter_kwargs, m2cm
from .utils import read_yaml_config, filter_kwargs, reorder_loop, m2cm

export_allowed_kwargs = ["step_filename", "export_mesh", "mesh_filename"]

Expand Down Expand Up @@ -468,6 +468,28 @@ def get_ob_mp_index(self):

return outboard_index

def reorder_coords(self, index):
"""Reorders coil filament coordinate loop about a given index.
Arguments:
index (int): index about which to reorder coordinate loop.
"""
self.coords = reorder_loop(self.coords, index)

def orient_coords(self, positive=True):
"""Orients coil filament coordinate loop such that they initially
progress positively or negatively.
Arguments:
positive (bool): progress coordinates in positive direciton
(defaults to True). If negative, coordinates will progress in
negative direction.
"""
if (positive and self.coords[0, 2] > self.coords[1, 2]) or (
not positive and self.coords[0, 2] < self.coords[1, 2]
):
self.coords = np.flip(self.coords, axis=0)


def parse_args():
"""Parser for running as a script"""
Expand Down
11 changes: 3 additions & 8 deletions parastell/radial_distance_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from . import magnet_coils
from . import invessel_build as ivb
from . import cubit_io
from .utils import reorder_loop, downsample_loop
from .utils import downsample_loop


def reorder_filament(coil):
Expand All @@ -22,15 +22,10 @@ def reorder_filament(coil):
"""
# Start the filament at the outboard midplane
outboard_index = coil.get_ob_mp_index()

# Ensure filament is a closed loop
if outboard_index != 0:
reordered_coords = reorder_loop(coil.coords, outboard_index)

coil.reorder_coords(outboard_index)
# Ensure points initially progress in positive z-direction
if reordered_coords[0, 2] > reordered_coords[1, 2]:
reordered_coords = np.flip(reordered_coords, axis=0)
coil.coords = reordered_coords
coil.orient_coords()


def reorder_coils(magnet_set):
Expand Down

0 comments on commit 218346f

Please sign in to comment.