|
The Open FUSION Toolkit 1.0.0-beta5
Modeling tools for plasma and fusion research and engineering
|
In this example we demonstrate how to compute a current potential from a given B-norm on a toroidal surface. This has application to compute eddy current and sensor reponse to plasma modes.
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).
In most cases the mode will be imported and/or converted from another tool (eg. DCON). However, in this case we will generate a simple mode shape with fixed toroidal and poloidal mode number for a simple torus. Using a simple helper function we define an n=2, m=3 mode on an R=1.0 m, a=0.4 m torus.
We can now create a ThinCurr model from the mode definition file by using build_torus_bnorm_grid() to build a uniform grid over one toroidal field period and build_periodic_mesh() to build a mesh from the resulting grid. The result is a ThinCurr model, including periodicity mapping information (r_map), and the normal field at each mesh vertex for the Real and Imaginary components of the mode (bnorm).
Loading toroidal plasma mode filename = tCurr_mode.dat N = 2 # of pts = 200 R0 = (1.0000E+00, -1.7087E-17) Mode pair sums -7.6050E-15 -2.9976E-15
Saving mesh: thincurr_mode.h5
We now create a ThinCurr instance to use for equilibrium calculations. 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 plasma directory to use for saving I/O files to keep things separate for the other cases to be run in ThinCurr Python Example: Compute frequency-response in a torus.
#---------------------------------------------- Open FUSION Toolkit Initialized Development branch: main Revision id: 8440e61 Parallelization Info: Not compiled with MPI # of OpenMP threads = 4 Fortran input file = 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 = 12640 Loading V(t) driver coils Loading I(t) driver coils # of points = 6320 # of edges = 18960 # of cells = 12640 # of holes = 3 # of Vcoils = 0 # of closures = 2 # of Icoils = 0 Building holes WARNING: Unable to find "thincurr" XML node WARNING: No "thincurr" XML node, using "eta=mu0" for all regions
With the model setup, we can now compute the self-inductance matrix. A numpy version of the self-inductance matrix will be stored at tw_plate.Lmat. For this case we will use the self-inductance to convert between the surface flux \(\Phi\) corresponding to the normal field computed above (bnorm) and an equivalent surface current
\(\textrm{L} I = \Phi\)
While model definition above handles most of the periodicity, however as pointed out we still end up with nfp copies of the poloidal hole. So if nfp>1 we must condense the self-inductance matrix by summing values over these rows/columns.
Finally, we compute \(\textrm{L}^{-1}\).
Building element<->element self inductance matrix
Time = 19s
Now we can compute the equivalent currents for the Real and Imaginary component of normal field \(B_n\) from above. To do this we need to convert to flux \(\Phi\) by scaling the field by the area of each vertex using scale_va(). As the flux is only given on points we need to supplement those values to the full system size by adding the toroidal and poloidal holes (copying if necessary for nfp>1). As a single closure is also needed, we remove the first entry of flux_flat as well.
Removing old Xdmf files Creating output files
We now plot the resulting current potential (top) and mode shape (bottom) over a single toroidal mode period to show how the fields are related and ensure no errors.
Finally we save the currents to the model file as a "driver" to utilize in frequency response calculations in ThinCurr Python Example: Compute frequency-response in a torus.