peqdsk#
P-EQDSK files describe kinetics profiles as a function of \(\psi_N\), the normalised poloidal flux function. This is defined such that \(\psi_N = 0\) on the magnetic axis of a tokamak, and \(\psi_N=1\) on the last closed flux surface. Values in the range \([0,1]\) are used to index each nested flux surface.
The data contained within a P-EQDSK file varies depending on the source, but it will typically contain information such as ion/electron number densities and temperatures. It also contains the derivatives of each variaible with respect to \(\psi_N\). Data is represented in a csv-like format, and separated into blocks within the file. Each block of kinetics profile data has the form:
nrows psinorm var dvar/dpsiN
0.000000 3.141592 2.718282
...
1.000000 42.000000 -1.000000
where nrows
is an integer specifying the number of rows in the block, and var
is the variable described by the block.
At the bottom of a P-EQDSK file, a small block contains information describing the atomic number, charge (in units of \(e\)), and atomic mass of the ions:
nrows N Z A of ION SPECIES
6.000000 6.000000 12.000000
1.000000 1.000000 2.000000
1.000000 1.000000 2.000000
- class freeqdsk.peqdsk.ProfileDict(*args, **kwargs)#
TypedDict describing an individual kinetics profile.
-
data:
ndarray
# Kinetics profile
-
derivative:
ndarray
# Derivative of
profile
with respect topsinorm
-
psinorm:
ndarray
# \(\psi_N\) grid, where \(\psi_N=0\) on the magnetic axis and \(\psi_N=1\) on the last closed flux surface
-
units:
str
# Units of
profile
-
data:
- class freeqdsk.peqdsk.SpeciesDict(*args, **kwargs)#
TypedDict describing each species.
-
A:
float
# Atomic mass
-
N:
float
# Atomic number
-
Z:
float
# Charge (units of \(e\))
-
A:
- class freeqdsk.peqdsk.PEQDSKDict(*args, **kwargs)#
TypedDict returned by the read function.
-
profile:
Dict
[str
,ProfileDict
]# Dict of kinetics profiles. The names of each profile are used as keys, while the data is presented in a
ProfileDict
.
-
species:
List
[SpeciesDict
]# List of species.
-
profile:
- peqdsk.read()#
Given a file handle, reads a P-EQDSK file and returns a dict containing profile and species data.
The returned dict has two entries:
data["profiles"]
is a dict of keys andProfileDict
. For example, to access the electron density data, usedata["profiles"]["ne"]["data"]
. To access the ion density dervative with respect to \(\psi_N\), usedata["profiles"]["ni"]["derivative"]
.data["species"]
is a list ofSpeciesDict
. To access the atomic number of the first entry, usedata["species"][0]["N"]
.
- Parameters:
fh (
TextIO
) – File handle. Should be in a text read mode,open(filename, "r")
.- Return type:
- peqdsk.write(fh)#
Given a file handle and a
PEQDSKDict
dict, write a P-EQDSK file. The provided dict should have the same structure as that returned by theread
function.- Parameters:
data (
PEQDSKDict
) – Dict of P-EQDSK data. Should be in the format of aPEQDSKDict
, which is itself composed ofProfileDict
andSpeciesDict
dicts.fh (
TextIO
) – File handle. Should be opened in a text write mode,open(filename, "w")
.
- Return type:
None