Skip to content

Commit

Permalink
apply black formating with 79 character line length, per pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
Edgar-21 committed Aug 4, 2024
1 parent 4cab35a commit 8f8fbe2
Show file tree
Hide file tree
Showing 13 changed files with 764 additions and 872 deletions.
19 changes: 11 additions & 8 deletions Examples/custom_source_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@


# Parastell supports defining custom plasma conditions and reaction rates.
# These can be passed as keyword arguments both to SourceMesh and to
# These can be passed as keyword arguments both to SourceMesh and to
# Stellarator.construct_source_mesh(). Included is an example of defining
# custom (non-physical) plasma conditions and reaction rates. See the
# custom (non-physical) plasma conditions and reaction rates. See the
# docstrings in source_mesh.py for additional information.


def my_custom_plasma_conditions(s):
T_i = np.sin(s*np.pi)
T_i = np.sin(s * np.pi)
n_i = 1
return n_i, T_i


def my_custom_reaction_rate(n_i, T_i):
return n_i*T_i
return n_i * T_i


vmec_file = 'wout_vmec.nc'
vmec_file = "wout_vmec.nc"

vmec_obj = read_vmec.VMECData(vmec_file)

Expand All @@ -29,12 +32,12 @@ def my_custom_reaction_rate(n_i, T_i):
vmec_obj,
mesh_size,
toroidal_extent,
plasma_conditions = my_custom_plasma_conditions,
reaction_rate = my_custom_reaction_rate
plasma_conditions=my_custom_plasma_conditions,
reaction_rate=my_custom_reaction_rate,
)
source_mesh_obj.create_vertices()
source_mesh_obj.create_mesh()

# export and convert to vtk for visualization
source_mesh_obj.export_mesh()
subprocess.run('mbconvert source_mesh.h5m source_mesh.vtk', shell=True)
subprocess.run("mbconvert source_mesh.h5m source_mesh.vtk", shell=True)
37 changes: 12 additions & 25 deletions Examples/nwl_geom_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@


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

# Instantiate ParaStell build
stellarator = ps.Stellarator(vmec_file)
Expand All @@ -25,42 +25,29 @@
poloidal_angles,
wall_s,
empty_radial_build_dict,
split_chamber=False
split_chamber=False,
)
# Export in-vessel component files
stellarator.export_invessel_build(
export_cad_to_dagmc=False,
export_dir=export_dir
export_cad_to_dagmc=False, export_dir=export_dir
)

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

strengths = stellarator.source_mesh.strengths

filepath = Path(export_dir) / 'source_strengths.txt'

file = open(filepath, 'w')
filepath = Path(export_dir) / "source_strengths.txt"

file = open(filepath, "w")
for tet in strengths:
file.write(f'{tet}\n')
file.write(f"{tet}\n")

# Export DAGMC neutronics H5M file
stellarator.build_cubit_model(
skip_imprint=True,
legacy_faceting=True
)
stellarator.export_dagmc(
filename='nwl_geom',
export_dir=export_dir
)
stellarator.build_cubit_model(skip_imprint=True, legacy_faceting=True)
stellarator.export_dagmc(filename="nwl_geom", export_dir=export_dir)
90 changes: 34 additions & 56 deletions Examples/parastell_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@


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

# Instantiate ParaStell build
stellarator = ps.Stellarator(vmec_file)
Expand All @@ -20,86 +20,64 @@
uniform_unit_thickness = np.ones((len(toroidal_angles), len(poloidal_angles)))

radial_build_dict = {
'first_wall': {
'thickness_matrix': uniform_unit_thickness * 5
"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],
]
)
},
'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},
"shield": {"thickness_matrix": uniform_unit_thickness * 50},
"vacuum_vessel": {
"thickness_matrix": uniform_unit_thickness * 10,
"h5m_tag": "vac_vessel",
},
'back_wall': {
'thickness_matrix': uniform_unit_thickness * 5
},
'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
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
export_cad_to_dagmc=False, export_dir=export_dir
)

# Define build parameters for magnet coils
coils_file = 'coils.example'
cross_section = ['circle', 20]
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
coils_file, cross_section, toroidal_extent, sample_mod=6
)
# Export magnet files
stellarator.export_magnets(
step_filename='magnets',
step_filename="magnets",
export_mesh=True,
mesh_filename='magnet_mesh',
export_dir=export_dir
mesh_filename="magnet_mesh",
export_dir=export_dir,
)

# Define source mesh parameters
mesh_size = (11, 81, 61)
toroidal_extent = 90.0
# Construct source
stellarator.construct_source_mesh(
mesh_size,
toroidal_extent
)
stellarator.construct_source_mesh(mesh_size, toroidal_extent)
# Export source file
stellarator.export_source_mesh(
filename='source_mesh',
export_dir=export_dir
)
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)
stellarator.build_cubit_model(skip_imprint=False, legacy_faceting=True)

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

0 comments on commit 8f8fbe2

Please sign in to comment.