Skip to content

Commit

Permalink
Merge pull request #9 from connoramoreno/continuous_radial_build
Browse files Browse the repository at this point in the history
  • Loading branch information
gonuke authored Nov 4, 2023
2 parents 78b3ac0 + 3da99dd commit c96d9c5
Show file tree
Hide file tree
Showing 5 changed files with 301 additions and 101 deletions.
102 changes: 83 additions & 19 deletions ExampleScript.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,99 @@
import parametric_stellarator
import parastell
import logging


# Define plasma equilibrium VMEC file
plas_eq = 'plas_eq.nc'
# Define number of periods in stellarator plasma
num_periods = 4
# Define radial build
radial_build = {
'sol': {'thickness': 10, 'h5m_tag': 'Vacuum'},
'first_wall': {'thickness': 5},
'blanket': {'thickness': 5},
'back_wall': {'thickness': 5},
'shield': {'thickness': 20},
'coolant_manifolds': {'thickness': 5},
'gap': {'thickness': 5, 'h5m_tag': 'Vacuum'},
# Note that some neutron transport codes (such as OpenMC) will interpret
# materials with "vacuum" in the name as void material
'vacuum_vessel': {'thickness': 20, 'h5m_tag': 'vv'}
build = {
'phi_list': [0.0, 22.5, 45.0, 67.5, 90.0],
'theta_list': [0.0, 5.0, 90.0, 175.0, 180.0, 185.0, 270.0, 355.0, 360.0],
'wall_s': 1.2,
'radial_build': {
'first_wall': {
'thickness_matrix': [
[5, 5, 5, 5, 5, 5, 5, 5, 5],
[5, 5, 5, 5, 5, 5, 5, 5, 5],
[5, 5, 5, 5, 5, 5, 5, 5, 5],
[5, 5, 5, 5, 5, 5, 5, 5, 5],
[5, 5, 5, 5, 5, 5, 5, 5, 5]
]
},
'breeder': {
'thickness_matrix': [
[100, 100, 30, 10, 10, 10, 30, 100, 100],
[30, 30, 10, 5, 5, 5, 20, 30, 30],
[25, 25, 25, 5, 5, 5, 25, 25, 25],
[30, 30, 20, 5, 5, 5, 10, 30, 30],
[100, 100, 30, 10, 10, 10, 30, 100, 100]
]
},
'back_wall': {
'thickness_matrix': [
[5, 5, 5, 5, 5, 5, 5, 5, 5],
[5, 5, 5, 5, 5, 5, 5, 5, 5],
[5, 5, 5, 5, 5, 5, 5, 5, 5],
[5, 5, 5, 5, 5, 5, 5, 5, 5],
[5, 5, 5, 5, 5, 5, 5, 5, 5]
]
},
'shield': {
'thickness_matrix': [
[25, 25, 25, 25, 25, 25, 25, 25, 25],
[25, 25, 25, 25, 25, 25, 25, 25, 25],
[25, 25, 25, 25, 25, 25, 25, 25, 25],
[25, 25, 25, 25, 25, 25, 25, 25, 25],
[25, 25, 25, 25, 25, 25, 25, 25, 25]
]
},
'manifolds': {
'thickness_matrix': [
[50, 50, 15, 5, 5, 5, 15, 50, 50],
[20, 20, 5, 5, 5, 5, 15, 20, 20],
[15, 15, 15, 5, 5, 5, 15, 15, 15],
[20, 20, 15, 5, 5, 5, 5, 20, 20],
[50, 50, 15, 5, 5, 5, 15, 50, 50]
]
},
'gap': {
'thickness_matrix': [
[5, 5, 5, 5, 5, 5, 5, 5, 5],
[5, 5, 5, 5, 5, 5, 5, 5, 5],
[5, 5, 5, 5, 5, 5, 5, 5, 5],
[5, 5, 5, 5, 5, 5, 5, 5, 5],
[5, 5, 5, 5, 5, 5, 5, 5, 5]
],
'h5m_tag': 'Vacuum'
},
# Note that some neutron transport codes (such as OpenMC) will interpret
# materials with "vacuum" in the name as void material
'vacuum_vessel': {
'thickness_matrix': [
[15, 15, 15, 15, 15, 15, 15, 15, 15],
[15, 15, 15, 15, 15, 15, 15, 15, 15],
[15, 15, 15, 15, 15, 15, 15, 15, 15],
[15, 15, 15, 15, 15, 15, 15, 15, 15],
[15, 15, 15, 15, 15, 15, 15, 15, 15]
],
'h5m_tag': 'vac_vessel'
}
}
}
# Define number of periods in stellarator plasma
num_periods = 4
# Define number of periods to generate
gen_periods = 1
# Define number of toroidal cross-sections to make
num_phi = 60
# Define number of poloidal points to include in each toroidal cross-section
num_theta = 100
num_theta = 60
# Define magnet coil parameters
magnets = {
'file': 'coils.txt',
'cross_section': ['circle', 20],
'start': 3,
'stop': None,
'sample': 6,
'name': 'magnet_coils',
'h5m_tag': 'magnets',
'meshing': True
Expand All @@ -47,7 +110,8 @@
'graveyard': False,
'step_export': True,
'h5m_export': 'Cubit',
'plas_h5m_tag': None,
'plas_h5m_tag': 'Vacuum',
'sol_h5m_tag': 'Vacuum',
# Note the following export parameters are used only for Cubit H5M exports
'facet_tol': 1,
'len_tol': 5,
Expand Down Expand Up @@ -82,8 +146,8 @@
logger.addHandler(f_handler)

# Create stellarator
parametric_stellarator.parametric_stellarator(
plas_eq, num_periods, radial_build, gen_periods, num_phi, num_theta,
parastell.parastell(
plas_eq, num_periods, build, gen_periods, num_phi, num_theta,
magnets = magnets, source = source,
export = export, logger = logger
)
)
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## parametric_stellarator
Parametric 3D CAD modeling tool for stellarator fusion devices. This toolset takes VMEC plasma equilibrium data to build a blanket with components of uniform thickness from a user-specified radial build, as well as corresponding coil filament point-locus data to build magnet coils of user-specified cross-section.
## ParaStell
Parametric 3D CAD modeling tool for stellarator fusion devices. This toolset takes VMEC plasma equilibrium data to build intra-magnet components of varying thickness from a user-specified radial build, as well as corresponding coil filament point-locus data to build magnet coils of user-specified cross-section.

# Dependencies
This tool depends on:

- [The VMEC tools](https://github.com/aaroncbader/pystell_uw/blob/master/read_vmec.py) developed by @aaroncbader
- [The VMEC tools](https://github.com/aaroncbader/pystell_uw/) developed by @aaroncbader
- [CadQuery](https://cadquery.readthedocs.io/en/latest/installation.html)
- [MOAB](https://bitbucket.org/fathomteam/moab/src/master/)
- [Coreform Cubit](https://coreform.com/products/downloads/) or [Cubit](https://cubit.sandia.gov/downloads/) by Sandia National Laboratories
20 changes: 13 additions & 7 deletions magnet_coils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import log
import cubit
import numpy as np
import sys


def unit_vector(vec):
Expand Down Expand Up @@ -277,14 +276,15 @@ def create_magnets(filaments, cross_section, meshing, logger):
return vol_ids


def extract_filaments(file, start, stop):
def extract_filaments(file, start, stop, sample):
"""Extracts filament data from magnet coil data file.
Arguments:
file (str): path to magnet coil data file.
start (int): index for line in data file where coil data begins.
stop (int): index for line in data file where coil data ends (defaults
to None).
sample (int): sampling modifier for filament points.
Returns:
filaments (list of list of list of float): list filament coordinates.
Expand All @@ -301,7 +301,7 @@ def extract_filaments(file, start, stop):
coords = []

# Extract magnet coil data
for line in data:
for i, line in enumerate(data):
# Parse line in magnet coil data
columns = line.strip().split()

Expand All @@ -317,10 +317,13 @@ def extract_filaments(file, start, stop):
s = float(columns[3])

# Coil current of zero signals end of filament
# If current is not zero, store coordinate in filament list
# If current is not zero, conditionally store coordinate in filament
# list
if s != 0:
# Append coordinates to list
coords.append([x, y, z])
# Only store every five points
if i % sample == 0:
# Append coordinates to list
coords.append([x, y, z])
# Otherwise, store filament coordinates but do not append final
# filament point. In Cubit, continuous curves are created by setting
# the initial and final vertex indices equal. This is handled in the
Expand All @@ -345,6 +348,9 @@ def magnet_coils(magnets, logger = None):
'cross_section': coil cross-section definition (list),
'start': starting line index for data in file (int),
'stop': stopping line index for data in file (int),
'sample': sampling modifier for filament points (int). For a
user-supplied value of n, sample every n points in list of
points in each filament,
'name': name to use for STEP export (str),
'h5m_tag': material tag to use in H5M neutronics model (str)
}
Expand All @@ -369,7 +375,7 @@ def magnet_coils(magnets, logger = None):

# Extract filament data
filaments = extract_filaments(
magnets['file'], magnets['start'], magnets['stop']
magnets['file'], magnets['start'], magnets['stop'], magnets['sample']
)

# Generate magnet coil solids
Expand Down
Loading

0 comments on commit c96d9c5

Please sign in to comment.