![]() |
The Open FUSION Toolkit 26.9
An open-source framework for fusion and plasma science and engineering
|
In this example we show how to recompute the baseline flattop operating point for the MANTA device based on an gEQDSK file.
This example utilizes the mesh built in TokaMaker Meshing Example: Building a mesh for MANTA.
To load the TokaMaker python module we need to tell python where to the module is located. This can be done either through the PYTHONPATH environment variable or using 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 on macOS).
First we create a TokaMaker instance to use for equilibrium calculations. Note at present only a single instance can be used per python kernel, so this command should only be called once in a given Jupyter notebook or python script. In the future this restriction may be relaxed.
#----------------------------------------------
____ ____________
/ __ \/ ____/_ __/
/ / / / /_ / /
/ /_/ / __/ / /
\____/_/ /_/
Base release: v1.0.0-beta7
Development branch: release_26_06
Revision id: 978c4b9f
Parallelization Info:
Not compiled with MPI
# of OpenMP threads = 2
Linear Algebra backend: native
#----------------------------------------------
A dictionary containing the equilibrium information is obtained using read_eqdsk(). The dictionary contains multiple key quantities that are useful for reproducing the equilibrium in TokaMaker:
Now we load the mesh generated in doc_gs_mesh_ex2 using load_gs_mesh and setup_mesh. Then we use setup_regions to define the different region types. Finally, we call setup to setup the required solver objects. During this call we can specify the desired element order (min=2, max=4) and the toroidal field through F0 = B0*R0, where B0 is the toroidal field at a reference location R0.
**** Loading OFT surface mesh
**** Generating surface grid level 1
Generating boundary domain linkage
Mesh statistics:
Area = 7.741E+01
# of points = 8001
# of edges = 23766
# of cells = 15766
# of boundary points = 234
# of boundary edges = 234
# of boundary cells = 234
Resolution statistics:
hmin = 1.185E-02
hrms = 1.130E-01
hmax = 2.363E-01
Surface grounded at vertex 1202
**** Creating Lagrange FE space
Order = 2
Minlev = -1
Computing flux BC matrix
Inverting real matrix
Time = 3.7980000000000002E-003
The input mesh can be plotted using plot_mesh to view the grid for each region type.
Hard limits on coil currents can be set using set_coil_bounds. In this case we use the PF coil limits provided in the MANTA paper and simple and approximate bi-directional limit of 20 MA and 100 kA in each CS and VSC coil respectively.
For the inverse case we define a target for the plasma current and the peak plasma pressure, which occurs on the magnetic axis.
In order to constrain the shape of the plasma we can utilize two types of constraints:
Here we define isoflux constraints to match the LCFS of the input gEQDSK file as well as hardcoded X-point locations that are used both for the isoflux and saddle constraints. For double null equilibria it is often useful to provide additional constraint of the up-down symmetry of the flux surfaces. To do this we repeat the isoflux points twice, using the inner most isoflux point as the reference location for the first set and the vertical mirror of each point for the second set with a higher weight. This adds additional weight to the up-down symmetry of the equilibrium.
In general, for a given coil set a given plasma shape cannot be exactly reproduced, which generally yields large amplitude coil currents if no constraint on the coil currents is applied. As a result, it is useful to include regularization terms for the coils to balance minimization of the shape error with the amplitude of current in the coils. In TokaMaker, these regularization terms have the general form, where each term corresponds to a set of coil coefficients, target value, and weight. The coil_reg_term() method is provided to aid in defining these terms.
In this case, one regularization term is added for each upper coil with a single unit coefficient for that coil and target of zero with modest weights. This regularization acts to penalize the amplitude of current in each coil, acting to balance coil current with error in the shape targets. We also add a regularization term to regularize the matching upper and lower coils to have the same current to support the up-down symmetry as above.
Here we simply use the profiles obtained through transport analysis in the original MANTA paper.
We can now compute a free-boundary equilibrium using these constraints. Note that before running a calculation for the first time we must initialize the flux function \(\psi\), which can be done using init_psi. This subroutine initializes the flux using the specified Ip_target from above, which is evenly distributed over the entire plasma region when no arguments are specified. For close-fitting limiters like MANTA this is often sufficient. Coil currents are also initialized at this point using the constraints above and this uniform plasma current initialization.
solve is then called to compute a self-consitent Grad-Shafranov equilibrium. If the result variable (err_flag) is zero then the solution has converged to the desired tolerance ( \(10^{-6}\) by default).
Starting non-linear GS solver
1 -1.2117E+00 1.2674E+00 8.9554E-02 4.7708E+00 1.4364E-05 -0.0000E+00
2 2.6593E+01 7.5258E-01 1.6930E-02 4.7609E+00 -1.8012E-05 -0.0000E+00
3 3.0345E+01 6.9850E-01 7.3870E-03 4.7526E+00 -7.0188E-05 -0.0000E+00
4 3.1181E+01 6.8886E-01 3.8095E-03 4.7469E+00 -2.8730E-05 -0.0000E+00
5 3.1386E+01 6.8711E-01 2.0031E-03 4.7434E+00 2.0449E-06 -0.0000E+00
6 3.1437E+01 6.8689E-01 1.0217E-03 4.7414E+00 2.3187E-05 -0.0000E+00
7 3.1450E+01 6.8685E-01 6.2153E-04 4.7402E+00 3.4250E-05 -0.0000E+00
8 3.1449E+01 6.8682E-01 3.9401E-04 4.7396E+00 4.0717E-05 -0.0000E+00
9 3.1449E+01 6.8688E-01 6.7035E-04 4.7392E+00 4.5582E-05 -0.0000E+00
10 3.1446E+01 6.8686E-01 3.7427E-04 4.7390E+00 4.8017E-05 -0.0000E+00
11 3.1447E+01 6.8687E-01 2.9795E-04 4.7389E+00 5.2031E-05 -0.0000E+00
12 3.1445E+01 6.8684E-01 2.5925E-04 4.7389E+00 5.5609E-05 -0.0000E+00
13 3.1443E+01 6.8685E-01 5.6180E-05 4.7388E+00 5.8270E-05 -0.0000E+00
14 3.1442E+01 6.8686E-01 1.3056E-05 4.7388E+00 6.0132E-05 -0.0000E+00
15 3.1441E+01 6.8686E-01 3.8974E-06 4.7388E+00 6.1387E-05 -0.0000E+00
16 3.1441E+01 6.8686E-01 1.6119E-06 4.7388E+00 6.2212E-05 -0.0000E+00
17 3.1441E+01 6.8687E-01 7.9745E-07 4.7388E+00 6.2749E-05 -0.0000E+00
Timing: 0.14703700004611164
Source: 5.3658000193536282E-002
Solve: 4.8613000137265772E-002
Boundary: 3.6259998450987041E-003
Other: 4.1139999870210886E-002
Flux surfaces of the computed equilibrium can be plotted using the plot_psi method. The additional plotting methods plot_machine and plot_constraints are also used to show context and other information. Each method has a large number of optional arguments for formatting and other options.
Basic parameters can be displayed using the print_info method. For access to these quantities as variables instead the get_stats can be used.
The final coil currents can also be retrieved using the get_coil_currents method, which are all within the approximate coil limits imposed above.
Equilibrium Statistics: Topology = Diverted Toroidal Current [A] = 1.0000E+07 Current Centroid [m] = 4.678 -0.000 Magnetic Axis [m] = 4.739 0.000 Elongation = 1.459 (U: 1.445, L: 1.472) Triangularity = -0.531 (U: -0.518, L: -0.543) Plasma Volume [m^3] = 150.446 q_0, q_95 = 0.699 2.372 Plasma Pressure [Pa] = Axis: 1.6355E+06, Peak: 1.6355E+06 Stored Energy [J] = 9.7480E+07 <Beta_pol> [%] = 53.7740 <Beta_tor> [%] = 0.8865 <Beta_n> [%] = 1.1525 Diamagnetic flux [Wb] = 2.6897E-01 Toroidal flux [Wb] = 5.6704E+01 l_i = 0.9488 Coil Currents: PF1U: -6.57 [MA] PF2U: 5.83 [MA] PF3U: -4.40 [MA] PF1L: -6.57 [MA] PF2L: 5.83 [MA] PF3L: -4.40 [MA] CS2L: 0.00 [MA] CS1L: -0.00 [MA] CS1U: -0.00 [MA] CS2U: 0.00 [MA] VSC: -1.19 [kA] Total PF current: 33.60 [MA]
We save our TokaMaker equilibrium as a gEQDSK file using the save_eqdsk() method. We modify the resolution of the equilibrium file by increasing the nr and nz parameters and decreasing the padding on the last closed flux surface (lcfs_pad).
Saving gEQDSK: gMANTA_tkmkr