Preprocessing Inputs

Preprocessing Inputs

Create FIDASIM input files using PREFIDA

FIDASIM requires inputs to be in a specific format. PREFIDA(IDL,Python) is an routine that takes the required inputs, checks their validity, and transforms them into a form FIDASIM understands.

PREFIDA is called as follows

IDL> prefida, inputs, grid, nbi, plasma, fields, dist, spec=spec, npa=npa

or using Python

>>> import fidasim
>>> fidasim.prefida(inputs, grid, nbi, plasma, fields, dist, spec=spec, npa=npa)

where arguments are defined as follows. Click the argument's description for extreme detail.

PREFIDA will create the following files

  • Namelist File
  • Geometry File
  • Equilibrium File
  • Distribution File

Most devices may have already setup helper routines to make running FIDASIM and Prefida easy. Click here to find out if someone has done your work for you.

Making Grids

PREFIDA uses two types of grids: the Interpolation Grid and the Beam Grid. The Interpolation Grid is 2D grid in the R-Z plane and as the name suggests it is used for interpolating the plasma parameters and the electromagnetic fields. The routine rz_grid(IDL,Python) can be used to easily create the interpolation grid structure.

IDL> grid = rz_grid(rmin,rmax,nr,zmin,zmax,nz)

or in Python

>>> from fidasim.utils import rz_grid
>>> grid = rz_grid(rmin,rmax,nr,zmin,zmax,nz)

The beam grid is a 3D grid used for most of the calculations in FIDASIM. It represents the 3D volume where the neutral beam lives and interacts with the plasma. To maximize the resolution of this grid it is useful to align the beam grid with the beam centerline. The routine beam_grid(IDL,Python) calculates from the neutral beam geometry the optimal beam grid settings that would align the grid with the beam sightline.

IDL> bgrid = beam_grid(nbi,rstart)

or in Python

>>> from fidasim.utils import beam_grid
>>> bgrid = beam_grid(nbi,rstart)

Reading GEQDSK files

Most tokamaks use EFIT to reconstruct the MHD equilibrium. To make things easy we provide the IDL routine read_geqdsk.pro to calculate the fields structure from EFITs GEQDSK file.

IDL> fields = read_geqdsk('g159243.00300',grid,flux=flux,btipsign=btipsign)

or in Python

>>> from fidasim.utils import read_geqdsk
>>> fields, flux, btipsign = read_geqdsk('g159243.00300',grid)

where grid is the interpolation grid, flux keyword is a named variable that recieves the torodial flux upon executation, and btipsign is a named variable that recieves the Bt-Ip sign (-1 for anti-parallel, 1 for parallel).

Extracting GEQDSK file and Plasma Parameters from TRANSP

It is convenient to grab FIDASIM inputs from previously calculated TRANSP runs.

The python script, extract_transp_geqdsk, can be used to extract the MHD equilibrium from TRANSP's .DATA* files. For example:

extract_transp_geqdsk /p/transparch/result/NSTX/14 159243H06 

will create a GEQDSK file for every .DATA* file in the 159243H06 TRANSP run. Run extract_transp_geqdsk -h for the full documentation.

The IDL routine extract_transp_plasma.pro or the equivalent Python function creates the plasma structure at a given time.

IDL> plasma = extract_transp_plasma("159243H06.CDF",1.02,grid,flux)

or in Python

>>> from fidasim.utils import extract_transp_plasma
>>> plasma = extract_transp_plasma("159243H06.CDF",1.02,grid,flux)

where grid is the interpolation grid and flux is the torodial flux.

Translating NUBEAM Neutral Beam Geometry

The IDL routine nubeam_geometry.pro can be used to translate the NUBEAM neutral beam geometry definition into the correct format.

IDL> nbi = nubeam_geometry(nubeam)

or in Python

>>> from fidasim.utils import nubeam_geometry
>>> nbi = nubeam_geometry(nubeam)

where nubeam is a structure/dictionary containing the NUBEAM geometry variables taken from the TRANSP namelist.

Extracting the Fast-ion Distribution Function from TRANSP/NUBEAM

The python script, extract_transp_fbm, provides a easy way to extract the fast-ion distribution. For example:

extract_transp_fbm /p/transparch/result/NSTX/14 159243H06

extracts a distribution function for every .DATA* file in the 159243H06 TRANSP run. Run extract_transp_fbm -h for the full documentation.

Reading NUBEAM/SPIRAL Fast-ion Distributions

Out of the box, FIDASIM provides IDL and Python routines for reading different fast-ion distributions. We provide routines for:

IDL> f = read_nubeam(nubeam_distribution_file,grid,btipsign = -1) 
IDL> mcf = read_mc_nubeam(mc_nubeam_distribution_file,Ntotal=1e19,btipsign=-1)
IDL> s = read_spiral(spiral_file,Ntotal=1e19,btipsign=-1)

or in Python

>>> from fidasim.utils import read_nubeam
>>> f = read_nubeam(nubeam_distribution_file, grid, btipsign=-1)