The Open FUSION Toolkit 1.0.0-8905cc5
Modeling tools for plasma and fusion research and engineering
|
In this example we demonstrate how to compute a current potential on one surface that minimizes the error of the normal magnetic field on another. This is relevant to stellarator optimization when the normal field is minimized on a desired plasma surface and the current potential lies on a so-called winding surface here coils will be initialized for further optimization.
pip
or other standard methods.To load the ThinCurr python module we need to tell python where to the module is located. This can be done either through the PYTHONPATH
environment variable or within a script using sys.path.append()
as below, where we look for the environement variable OFT_ROOTPATH
to provide the path to where the OpenFUSIONToolkit is installed (/Applications/OFT
for binaries on macOS).
First we create ThinCurr models for the winding and plasma surfaces using a REGCOIL definition of the NCSX stellarator using build_regcoil_grid(). This subroutine builds a uniform grid over one field period, which can then be used by build_periodic_mesh() to build a mesh from the resulting grid. The result is a ThinCurr model, including periodicity mapping information (r_map
).
We can now create ThinCurr models for the winding and plasma surfaces using a REGCOIL definition of the NCSX stellarator using build_regcoil_grid() and ThinCurr_periodic_toroid, which provides functionality for working with toroidally periodic meshes. The result are ThinCurr_periodic_toroid objects for the plasma (plasma_grid
) and winding surface (coil_grid
).
Saving mesh: thincurr_coil.h5
Saving mesh: thincurr_plasma.h5
We now create a OFT_env instance for execution using four threads and a ThinCurr instance for the winding surface that utilizes that execution environment. Once created, we setup the model from an existing HDF5 and XML mesh definition using setup_model().
We also initialize I/O for this model using setup_io() to enable output of plotting files for 3D visualization in VisIt or Paraview.
In this case we specify a coil
directory to use for saving I/O files to keep things separate for the other cases to be run in this notebook and in ThinCurr Python Example: Compute frequency-response in a torus.
#---------------------------------------------- Open FUSION Toolkit Initialized Development branch: v1_beta6 Revision id: 681e857 Parallelization Info: # of MPI tasks = 1 # of NUMA nodes = 1 # of OpenMP threads = 4 Fortran input file = /var/folders/52/n5qxh27n4w19qxzqygz2btbw0000gn/T/oft_65254/oftpyin XML input file = none Integer Precisions = 4 8 Float Precisions = 4 8 16 Complex Precisions = 4 8 LA backend = native #---------------------------------------------- Creating thin-wall model Orientation depth = 24192 Loading V(t) driver coils Loading I(t) driver coils # of points = 12096 # of edges = 36288 # of cells = 24192 # of holes = 4 # of Vcoils = 0 # of closures = 3 # of Icoils = 0 Building holes WARNING: Unable to find "thincurr" XML node WARNING: No "thincurr" XML node, using "eta=mu0" for all regions
We do the same process for the plasma surface.
Creating thin-wall model Orientation depth = 24576 Loading V(t) driver coils Loading I(t) driver coils # of points = 12288 # of edges = 36864 # of cells = 24576 # of holes = 2 # of Vcoils = 0 # of closures = 1 # of Icoils = 0 Building holes WARNING: Unable to find "thincurr" XML node WARNING: No "thincurr" XML node, using "eta=mu0" for all regions
Reading element<->element mutual inductance matrix
Removing old Xdmf files Removed 1 files Creating output files: oft_xdmf.XXXX.h5 Found Group: thincurr Found Mesh: smesh # of blocks: 1 Removing old Xdmf files Removed 1 files Creating output files: oft_xdmf.XXXX.h5 Found Group: thincurr Found Mesh: smesh # of blocks: 1