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

Update Inputs for User-Facing Classes #85

Merged
merged 14 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 4 additions & 29 deletions Examples/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ vmec_file: wout_vmec.nc
invessel_build:
toroidal_angles: [0.0, 22.5, 45.0, 67.5, 90.0]
poloidal_angles: [0.0, 90.0, 180.0, 270.0, 360.0]
wall_s: 1.08
radial_build:
first_wall:
thickness_matrix:
Expand Down Expand Up @@ -40,54 +41,28 @@ invessel_build:
- [15, 15, 15, 15, 15]
- [15, 15, 15, 15, 15]
mat_tag: vac_vessel
wall_s: 1.08
repeat: 0
num_ribs: 61
num_rib_pts: 61
scale: 100
export_cad_to_dagmc: False
plasma_mat_tag: Vacuum
sol_mat_tag: Vacuum
dagmc_filename: dagmc
export_dir: ''

magnet_coils:
coils_file_path: coils.example
start_line: 3
coils_file: coils.example
cross_section: [circle, 20.0]
toroidal_extent: 90.0
sample_mod: 6
scale: 100
step_filename: magnet_coils
mat_tag: magnet_coils
export_mesh: True
mesh_filename: magnet_mesh
export_dir: ''

source_mesh:
num_s: 11
num_theta: 81
num_phi: 61
mesh_size: [11, 81, 61]
toroidal_extent: 90.0
scale: 100
filename: source_mesh
export_dir: ''

dagmc_export:
# Choose whether to skip imprint procedure (default for ParaStell is False).
# Skipping the imprint procedure can reduce the duration of the DAGMC export
# but risks improperly merging surfaces if there is any overlap between the
# in-vessel component and magnet volumes.
skip_imprint: False
# Choose native Cubit or legacy DAGMC plug-in faceting method (default for
# ParaStell is True).
legacy_faceting: True
# The following parameters are for legacy DAGMC plug-in faceting.
faceting_tolerance: 1
length_tolerance: 5
normal_tolerance: null
# The following parameters are for native Cubit faceting.
anisotropic_ratio: 100
deviation_angle: 5
# Define file path parameters
filename: dagmc
export_dir: ''
174 changes: 85 additions & 89 deletions Examples/example_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,105 +2,101 @@

import parastell.parastell as ps


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

# Define toroidal angles at which radial build is specified.
# Instantiate ParaStell build
stellarator = ps.Stellarator(vmec_file)

# Define build parameters for in-vessel components
toroidal_angles = [0.0, 11.25, 22.5, 33.75, 45.0, 56.25, 67.5, 78.75, 90.0]
# Define poloidal angles at which radial build is specified.
poloidal_angles = [0.0, 45.0, 90.0, 135.0, 180.0, 225.0, 270.0, 315.0, 360.0]
# Define build parameters for in-vessel componenets
invessel_build = {
'toroidal_angles': toroidal_angles,
'poloidal_angles': poloidal_angles,
'radial_build': {
'first_wall': {
'thickness_matrix': np.ones(
(len(toroidal_angles), len(poloidal_angles))
)*5
},
'breeder': {
'thickness_matrix': ([
[75.0, 75.0, 75.0, 25.0, 25.0, 25.0, 75.0, 75.0, 75.0],
[75.0, 75.0, 75.0, 25.0, 25.0, 75.0, 75.0, 75.0, 75.0],
[75.0, 75.0, 25.0, 25.0, 75.0, 75.0, 75.0, 75.0, 75.0],
[65.0, 25.0, 25.0, 65.0, 75.0, 75.0, 75.0, 75.0, 65.0],
[45.0, 45.0, 75.0, 75.0, 75.0, 75.0, 75.0, 45.0, 45.0],
[65.0, 75.0, 75.0, 75.0, 75.0, 65.0, 25.0, 25.0, 65.0],
[75.0, 75.0, 75.0, 75.0, 75.0, 25.0, 25.0, 75.0, 75.0],
[75.0, 75.0, 75.0, 75.0, 25.0, 25.0, 75.0, 75.0, 75.0],
[75.0, 75.0, 75.0, 25.0, 25.0, 25.0, 75.0, 75.0, 75.0]
])
},
'back_wall': {
'thickness_matrix': np.ones(
(len(toroidal_angles), len(poloidal_angles))
)*5
},
'shield': {
'thickness_matrix': np.ones(
(len(toroidal_angles), len(poloidal_angles))
)*50
},
'vacuum_vessel': {
'thickness_matrix': np.ones(
(len(toroidal_angles), len(poloidal_angles))
)*10,
'h5m_tag': 'vac_vessel'
}
wall_s = 1.08

# Define a matrix of uniform unit thickness
uniform_unit_thickness = np.ones((len(toroidal_angles), len(poloidal_angles)))

radial_build_dict = {
'first_wall': {
'thickness_matrix': uniform_unit_thickness * 5
},
'breeder': {
'thickness_matrix': ([
[75.0, 75.0, 75.0, 25.0, 25.0, 25.0, 75.0, 75.0, 75.0],
[75.0, 75.0, 75.0, 25.0, 25.0, 75.0, 75.0, 75.0, 75.0],
[75.0, 75.0, 25.0, 25.0, 75.0, 75.0, 75.0, 75.0, 75.0],
[65.0, 25.0, 25.0, 65.0, 75.0, 75.0, 75.0, 75.0, 65.0],
[45.0, 45.0, 75.0, 75.0, 75.0, 75.0, 75.0, 45.0, 45.0],
[65.0, 75.0, 75.0, 75.0, 75.0, 65.0, 25.0, 25.0, 65.0],
[75.0, 75.0, 75.0, 75.0, 75.0, 25.0, 25.0, 75.0, 75.0],
[75.0, 75.0, 75.0, 75.0, 25.0, 25.0, 75.0, 75.0, 75.0],
[75.0, 75.0, 75.0, 25.0, 25.0, 25.0, 75.0, 75.0, 75.0]
])
},
'back_wall': {
'thickness_matrix': uniform_unit_thickness * 5
},
'wall_s': 1.08,
'repeat': 0,
'num_ribs': 61,
'num_rib_pts': 61,
'scale': 100,
'plasma_mat_tag': 'Vacuum',
'sol_mat_tag': 'Vacuum',
'export_dir': export_dir
'shield': {
'thickness_matrix': uniform_unit_thickness * 50
},
'vacuum_vessel': {
'thickness_matrix': uniform_unit_thickness * 10,
'h5m_tag': 'vac_vessel'
}
}
# Construct in-vessel components
stellarator.construct_invessel_build(
toroidal_angles,
poloidal_angles,
wall_s,
radial_build_dict
)
# Export in-vessel component files
stellarator.export_invessel_build(
export_cad_to_dagmc=False,
export_dir=export_dir
)

# Define magnet coil parameters
magnets = {
'coils_file_path': 'coils.example',
'start_line': 3,
'cross_section': ['circle', 20],
'toroidal_extent': 90.0,
'sample_mod': 6,
'scale': 100,
'step_filename': 'magnet_coils',
'mat_tag': 'magnets',
'export_mesh': True,
'mesh_filename': 'magnet_mesh',
'export_dir': export_dir
}
# Define build parameters for magnet coils
coils_file = 'coils.example'
cross_section = ['circle', 20]
toroidal_extent = 90.0
# Construct magnets
stellarator.construct_magnets(
coils_file,
cross_section,
toroidal_extent,
sample_mod=6
)
# Export magnet files
stellarator.export_magnets(
step_filename='magnets',
export_mesh=True,
mesh_filename='magnet_mesh',
export_dir=export_dir
)

# Define source mesh parameters
source = {
'num_s': 11,
'num_theta': 81,
'num_phi': 61,
'toroidal_extent': 90.0,
'scale': 100,
'filename': 'source_mesh',
'export_dir': export_dir
}
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
)

# Define DAGMC export parameters
dagmc_export = {
'skip_imprint': False,
'legacy_faceting': True,
'faceting_tolerance': 1,
'length_tolerance': 5,
'normal_tolerance': None,
'filename': 'dagmc',
'export_dir': export_dir
}

# Generate parametric stellarator model
stellarator = ps.Stellarator(vmec_file)
stellarator.construct_invessel_build(invessel_build)
stellarator.construct_magnets(magnets)
stellarator.construct_source_mesh(source)
stellarator.export_dagmc(dagmc_export)
# Export DAGMC neutronics H5M file
stellarator.export_dagmc(
skip_imprint=False,
legacy_faceting=True,
filename='dagmc',
export_dir=export_dir
)
23 changes: 0 additions & 23 deletions Examples/example_yaml.py

This file was deleted.

18 changes: 9 additions & 9 deletions parastell/cubit_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ def export_dagmc_cubit_legacy(
plug-in faceting method for Coreform Cubit.

Arguments:
faceting_tolerance (double): maximum distance a facet may be from
faceting_tolerance (float): maximum distance a facet may be from
surface of CAD representation for DAGMC export (defaults to None).
length_tolerance (double): maximum length of facet edge for DAGMC export
(double, defaults to None).
normal_tolerance (double): maximum change in angle between normal
vector of adjacent facets (defaults to None).
length_tolerance (float): maximum length of facet edge for DAGMC export
(defaults to None).
normal_tolerance (float): maximum change in angle between normal vector
of adjacent facets (defaults to None).
filename (str): name of DAGMC output file, excluding '.h5m' extension
(defaults to 'dagmc').
export_dir (str): directory to which to export the DAGMC output file
Expand Down Expand Up @@ -124,11 +124,11 @@ def export_dagmc_cubit_native(
faceting method for Coreform Cubit.

Arguments:
anisotropic_ratio (double): controls edge length ratio of elements
anisotropic_ratio (float): controls edge length ratio of elements
(defaults to 100.0).
deviation_angle (double): controls deviation angle of facet from
surface (i.e., lesser deviation angle results in more elements in
areas with higher curvature) (defaults to 5.0).
deviation_angle (float): controls deviation angle of facet from surface
(i.e., lesser deviation angle results in more elements in areas
with higher curvature) (defaults to 5.0).
filename (str): name of DAGMC output file, excluding '.h5m' extension
(defaults to 'dagmc').
export_dir (str): directory to which to export the DAGMC output file
Expand Down
Loading