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

Overhaul radial distance utility #158

Merged
merged 25 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4f124c6
Modify code structure
connoramoreno Sep 18, 2024
fc183b0
Add utility functions
connoramoreno Sep 19, 2024
08c85fb
Rename example file
connoramoreno Sep 19, 2024
6de1b7a
Uncomment source mesh and DAGMC file generation in example file
connoramoreno Sep 19, 2024
68c96e4
Remove line in example file from testing
connoramoreno Sep 19, 2024
5ff0d22
Change documentation wording in example and modify variable name as s…
connoramoreno Sep 19, 2024
a119a83
Add ability to define custom first wall profile
connoramoreno Sep 20, 2024
93ffa4a
Incorporate review suggestions
connoramoreno Sep 23, 2024
98dc878
Restructure code
connoramoreno Oct 1, 2024
218346f
Modify example
connoramoreno Oct 1, 2024
11858f5
Update parastell/magnet_coils.py
connoramoreno Oct 3, 2024
9427be2
Update parastell/magnet_coils.py
connoramoreno Oct 3, 2024
052f226
Update parastell/utils.py
connoramoreno Oct 3, 2024
263d3e4
Update parastell/utils.py
connoramoreno Oct 3, 2024
12a3fde
Update parastell/utils.py
connoramoreno Oct 3, 2024
b1713bf
Incorporate review suggestions
connoramoreno Oct 3, 2024
be845cc
Modify filament toroidal extent check
connoramoreno Oct 8, 2024
eda0183
Update parastell/utils.py
connoramoreno Oct 8, 2024
86d4322
Merge branch 'rdu-modifications' of github.com:svalinn/parastell into…
connoramoreno Oct 8, 2024
5707e72
Apply suggestions from code review
connoramoreno Oct 8, 2024
85d7164
Merge branch 'rdu-modifications' of github.com:svalinn/parastell into…
connoramoreno Oct 8, 2024
ba57ecc
Modify matching of first and last halves in enforce_helical_symmetry
connoramoreno Oct 8, 2024
cd3f865
Revert filament toroidal angle checking
connoramoreno Oct 8, 2024
9b13734
Update parastell/utils.py
connoramoreno Oct 9, 2024
db6406d
PEP8 formatting for comments
connoramoreno Oct 9, 2024
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
2 changes: 1 addition & 1 deletion Examples/parastell_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"shield": {"thickness_matrix": uniform_unit_thickness * 50},
"vacuum_vessel": {
"thickness_matrix": uniform_unit_thickness * 10,
"h5m_tag": "vac_vessel",
"mat_tag": "vac_vessel",
},
}
# Construct in-vessel components
Expand Down
36 changes: 0 additions & 36 deletions Examples/radial_build_distance_example.py

This file was deleted.

110 changes: 110 additions & 0 deletions Examples/radial_distance_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import numpy as np

import parastell.parastell as ps
import parastell.radial_distance_utils as rdu


# Define directory to export all output files to
export_dir = ""
# Define plasma equilibrium VMEC file
vmec_file = "wout_vmec.nc"

# Instantiate ParaStell build
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)
wall_s = 1.08
# Define build parameters for magnet coils
coils_file = "coils.example"
width = 40.0
thickness = 50.0
toroidal_extent = 90.0

# Measure separation between first wall and coils
available_space = rdu.measure_fw_coils_separation(
vmec_file,
toroidal_angles,
poloidal_angles,
wall_s,
coils_file,
width,
thickness,
sample_mod=1,
)
# For matrices defined by angles that are regularly spaced, measurement can
# result in matrix elements that are close to, but not exactly, helcially
# symmetric
available_space = rdu.enforce_helical_symmetry(available_space)
# Smooth matrix
available_space = rdu.smooth_matrix(available_space, 50, 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
available_space = rdu.enforce_helical_symmetry(available_space)
# Modify available space to account for thickness of magnets
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)))
# 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
shield_thickness_matrix = uniform_unit_thickness * 35
vacuum_vessel_thickness_matrix = uniform_unit_thickness * 30

# Compute breeder thickness matrix
breeder_thickness_matrix = (
available_space
- first_wall_thickness_matrix
- back_wall_thickness_matrix
- shield_thickness_matrix
- vacuum_vessel_thickness_matrix
)

radial_build_dict = {
"first_wall": {"thickness_matrix": first_wall_thickness_matrix},
"breeder": {"thickness_matrix": breeder_thickness_matrix},
"back_wall": {"thickness_matrix": back_wall_thickness_matrix},
"shield": {"thickness_matrix": shield_thickness_matrix},
"vacuum_vessel": {
"thickness_matrix": vacuum_vessel_thickness_matrix,
"mat_tag": "vac_vessel",
},
}

# Construct in-vessel components
stellarator.construct_invessel_build(
toroidal_angles,
poloidal_angles,
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,
)
# Export in-vessel component files
stellarator.export_invessel_build()

# Construct magnets
stellarator.construct_magnets(
coils_file, width, thickness, toroidal_extent, sample_mod=6
)
# Export magnet files
stellarator.export_magnets()

# Define source mesh parameters
mesh_size = (11, 81, 61)
toroidal_extent = 90.0
# Construct source
stellarator.construct_source_mesh(mesh_size, toroidal_extent)
# Export source file
stellarator.export_source_mesh(filename="source_mesh", export_dir=export_dir)

# Build Cubit model of Parastell Components
stellarator.build_cubit_model(skip_imprint=False, legacy_faceting=True)

# Export DAGMC neutronics H5M file
stellarator.export_dagmc(filename="dagmc", export_dir=export_dir)
Loading