G2C3

VMEC Conversion To spdata

VMEC Conversion

Table of Contents

Introduction

In stellarators, the equilibrium parameters involving the magnetic field are saved in a file spdata.dat, which is being read by the GTC Code as an input before any stellarator simulation.
The origin of this input file spdata.dat, is from an equilibrium code named VMEC which solves for MHD equilibrium configurations in magnetically confined fusion devices like that of stellarators. Now, to load the magnetic configurations generated from VMEC in the GTC code, the output needs to converted in a proper format for GTC to use it as its input. This conversion is mentioned in this article, which eventually generates this file spdata.dat for the GTC code.

Guide

Follow the below steps for conversion,

1. Logging In: Log into SUN. (Get the account details from the supervisor).


If you are provided with some input file which starts like this "input.<test_input>" then follow from Step 2 below. If you are provided with some input file of the format "wout_<test_input>.nc" then follow from Step 5 below.


2. Folder Creation: Create a folder say "VMEC_To_GTC_Run".

3. Input File: Inside the folder VMEC_To_GTC_Run/ copy the "input.<test_input>" file.

4. VMEC Run: Find the path to your "STELLOPT" package folder, say "/home/user/downloads/STELLOPT/". Now while you are inside VMEC_To_GTC_Run/ run the following,
$ /home/user/downloads/STELLOPT/VMEC2000/Release/xvmec2000 input.<test_input>

This will generate the outputs,

parvmecinfo.txt
jxbout_<test_input>.nc
mercier_<test_input>.nc
wout_<test_input>.nc
timing.txt
threed1.<test_input>

Confirm wout_<test_input>.nc file is generated above in your terminal, since this is needed to proceed further.

5. Finding "ns" value: If you are provided with input.<test_input>, then open it, and find the value of last element contained in "ns_array". If you are provided with wout_<test_input>.nc, then open it based upon following MATLAB script, and find the ns value inside "data" variable.

#MATLAB Code:
ncFile = 'wout_<test_input>.nc';
info = ncinfo(ncFile);
disp(info);                     % Inside info find list of variables, typically "ns" variable contains the number of surfaces.

data = ncread(ncFile, 'ns');    % Replace 'variable_name' with the actual variable name in your NetCDF file

6. Defining Boozer Cood. Input file: In the same folder create a file with the name "in_booz.<test_input>", and inside it write the following,

72 15
test_in
1    2    3    4     ..10
11   12               ...
...                   ...
...                   ...
... ... ns

In above, The "72" is the number of poloidal harmonics, "15" for toroidal harmonics. And then 1 to ns are the numbers of surfaces (IN OLD NOTES FINAL LIMIT: From 2 to 199).

7. Conversion to Boozer Cood.: In the same folder, execute the following,

$ /home/user/downloads/STELLOPT/BOOZ_XFORM/Release/xbooz_xform in_booz.<test_in>

This will generate a file named boozmn_<test_input>.nc.

8. Copying Don's Script: Copy Don's Scripts in the current folder, and open bld_boozmn_to_gtc_sun and modify the LIBSTELL and LIBSTELLA variable based upon the location of STELLOPT-develop, i.e.

LIBSTELL=/home/user/downloads/STELLOPT/LIBSTELL
LIBSTELLA=/home/user/downloads/STELLOPT/LIBSTELL/Release/libstell.a

9. Executing Don's Scripts: Execute the following commands,

$ ./bld_boozmn_to_gtc_sun  ! To compile the code of fitpack.f and boozmn_..f and generate xboz_gtc_vmec
and then,
$ ./xboz_gtc_vmec in_booz.<test_input>   ! To generate *silo and spdata.dat files


Finally you will see the output of the Step 9. are the following files

fluxes_tor_pol.dat
profile_data_in_booz.<test_input>
Z_sin_n.silo
Z_cos_n.silo
R_sin_n.silo
R_cos_n.silo
Phi_sin_n.silo
Phi_cos_n.silo
mod_b_sin_n.silo
mod_b_cos_n.silo
spdata.dat
tor_plane_viz.silo

Copy the spdata.dat file in your GTC simulation folder to finally perform the simulations.