Skip to content

Commit

Permalink
Add documentation, and make export_full_model arguments conform to ou…
Browse files Browse the repository at this point in the history
…r convention for Python users
  • Loading branch information
connoramoreno committed Apr 29, 2024
1 parent 796e4c7 commit 8806bac
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 23 deletions.
3 changes: 2 additions & 1 deletion parastell/invessel_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
normalize, expand_ang_list, read_yaml_config, filter_kwargs, m2cm
)


def orient_spline_surfaces(volume_id):
"""Extracts the inner and outer surface IDs for a given ParaStell in-vessel
component volume in Coreform Cubit.
Expand Down Expand Up @@ -796,7 +797,7 @@ def generate_invessel_build():

invessel_build.export_cad_to_dagmc(
export_dir=args.export_dir,
**(filter_kwargs(invessel_build_dict,['dagmc_filename']))
**(filter_kwargs(invessel_build_dict, ['dagmc_filename']))
)


Expand Down
4 changes: 3 additions & 1 deletion parastell/magnet_coils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
from .utils import (
normalize, read_yaml_config, filter_kwargs, m2cm
)

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


class MagnetSet(object):
"""An object representing a set of modular stellarator magnet coils.
Expand Down Expand Up @@ -633,7 +635,7 @@ def generate_magnet_set():

magnet_set.export_step(
export_dir=args.export_dir,
**(filter_kwargs(magnet_coils_dict,['step_filename']))
**(filter_kwargs(magnet_coils_dict, ['step_filename']))
)

if magnet_coils_dict['export_mesh']:
Expand Down
56 changes: 37 additions & 19 deletions parastell/parastell.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,15 @@ def export_dagmc(
)

def build_full_model(self, invessel_build, magnet_coils, source_mesh):
"""Use all of the input to make a complete stellarator model
with invessel components, magnets, and a source mesh
"""
"""Use all of the input to make a complete stellarator model with
in-vessel components, magnets, and a source mesh.
# In-Vessel Build
Arguments:
invessel_build (dict): dictionary of RadialBuild and InVesselBuild
parameters.
magnet_coils (dict): dictionary of MagnetSet parameters.
source_mesh (dict): dictionary of SourceMesh parameters.
"""
self.construct_invessel_build(
invessel_build['toroidal_angles'],
invessel_build['poloidal_angles'],
Expand All @@ -426,24 +430,35 @@ def build_full_model(self, invessel_build, magnet_coils, source_mesh):
**invessel_build
)

# Magnet Coils
self.construct_magnets(
magnet_coils['coils_file'],
magnet_coils['cross_section'],
magnet_coils['toroidal_extent'],
**magnet_coils
)

# Source Mesh
self.construct_source_mesh(
source_mesh['mesh_size'],
source_mesh['toroidal_extent'],
**source_mesh
)

def export_full_model(self, export_dir, invessel_build,
magnet_coils, source_mesh, dagmc_export):

def export_full_model(
self, invessel_build, magnet_coils, source_mesh, dagmc_export,
export_dir=''
):
"""Exports a complete stellarator model when in-vessel components,
magnets, and source mesh have been constructed.
Arguments:
invessel_build (dict): dictionary of RadialBuild and InVesselBuild
parameters.
magnet_coils (dict): dictionary of MagnetSet parameters.
source_mesh (dict): dictionary of SourceMesh parameters.
dagmc_export (dict): dictionary of DAGMC export parameters.
export_dir (str): directory to which output files are exported
(optional, defaults to empty string).
"""
export_cad_to_dagmc = invessel_build.get('export_cad_to_dagmc', False)
dagmc_filename = invessel_build.get('dagmc_filename', 'dagmc')

Expand All @@ -455,15 +470,14 @@ def export_full_model(self, export_dir, invessel_build,

self.export_magnets(
export_dir=export_dir,
**(filter_kwargs(magnet_coils,mc.export_allowed_kwargs))
**(filter_kwargs(magnet_coils, mc.export_allowed_kwargs))
)

self.export_source_mesh(
export_dir=export_dir,
**(filter_kwargs(source_mesh, sm.export_allowed_kwargs))
)

# DAGMC export
self.export_dagmc(
export_dir=export_dir,
**dagmc_export
Expand Down Expand Up @@ -617,15 +631,19 @@ def parastell():
logger=logger
)

stellarator.build_full_model(all_data['invessel_build'],
all_data['magnet_coils'],
all_data['source_mesh'])
stellarator.build_full_model(
all_data['invessel_build'],
all_data['magnet_coils'],
all_data['source_mesh']
)

stellarator.export_full_model(args.export_dir,
all_data['invesel_build'],
all_data['magnet_coils'],
all_data['source_mesh'],
all_data['dagmc_export'])
stellarator.export_full_model(
all_data['invesel_build'],
all_data['magnet_coils'],
all_data['source_mesh'],
all_data['dagmc_export'],
export_dir=args.export_dir,
)


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion parastell/source_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

export_allowed_kwargs = ['filename']


def rxn_rate(s):
"""Calculates fusion reaction rate in plasma.
Expand Down Expand Up @@ -457,7 +458,7 @@ def generate_source_mesh():

source_mesh.export_mesh(
export_dir=args.export_dir,
**(filter_kwargs(source_mesh_dict,['filename']))
**(filter_kwargs(source_mesh_dict, ['filename']))
)


Expand Down
1 change: 0 additions & 1 deletion parastell/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import numpy as np


m2cm = 100


Expand Down

0 comments on commit 8806bac

Please sign in to comment.