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 preprocessing
>>> preprocessing.prefida(inputs, grid, nbi, plasma, fields, dist, spec=spec, npa=npa)
where arguments are defined as follows. Click the argument description for extreme detail.
inputs
: General Settingsgrid
: Interpolation gridnbi
: Neutral Beam Geometryfields
: Electromagnetic Fieldsplasma
: Plasma Parametersdist
: Fast-ion Distributionspec
: Spectral Geometrynpa
: NPA GeometryPREFIDA will create the following files
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.
PREFIDA uses two types of grids**: the Interpolation Grid and the Beam Grid.
By default, axisymmetry is assumed and the Interpolation Grid is a 2D grid in the R-Z plane that is used for interpolating the plasma parameters and the electromagnetic fields.
A 3D cylindrical grid in R, Z and Phi can be created if the user inputs phi variable information.
The routine rz_grid
(IDL,Python) accomplishes the task and creates the grid
structure. For example, the command below will create a 2D grid,
IDL> grid = rz_grid(rmin,rmax,nr,zmin,zmax,nz)
whereas the following command will create a 3D grid,
IDL> grid = rz_grid(rmin,rmax,nr,zmin,zmax,nz,phimin=phimin,phimax=phimax,nphi=nphi)
In Python, the 2D grid can be created with,
>>> from fidasim.utils import rz_grid
>>> grid = rz_grid(rmin,rmax,nr,zmin,zmax,nz)
and the 3D grid with,
>>> from fidasim.utils import rz_grid
>>> grid = rz_grid(rmin,rmax,nr,zmin,zmax,nz,phimin=phimin,phimax=phimax,nphi=nphi)
The output 2D grid structure will have Phi = 0.0 and nphi = 1, but the 3D grid structure will have values based on what the user input.
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)
FIDASIM creates a third grid for passive calculations.
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,rho=rho,btipsign=btipsign)
or in Python
>>> from fidasim.utils import read_geqdsk
>>> fields, rho, btipsign = read_geqdsk('g159243.00300',grid)
where grid
is the interpolation grid, rho
keyword is a named variable that recieves the sqrt(normalized torodial flux) upon executation, and btipsign
is a named variable that recieves the Bt-Ip sign (-1 for anti-parallel, 1 for parallel).
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,rho)
or in Python
>>> from fidasim.utils import extract_transp_plasma
>>> plasma = extract_transp_plasma("159243H06.CDF",1.02,grid,rho)
where grid
is the interpolation grid and rho
is the sqrt(normalized torodial flux).
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.
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.
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)