7.2. Plasma equilibrium¶
- class cherab.tools.equilibrium.efit.EFITEquilibrium¶
An object representing an EFIT equilibrium time-slice.
EFIT is a code commonly used throughout the Fusion research community for calculating the plasma magnetic equilibrium from a range of magnetics measurements (L. Lao et. al. Nucl. Fusion 25 1985). This equilibrium object allows the calculation of the tokamak magnetic field from a number of EFIT code outputs. To use this class properly users should be familiar with the output data of EFIT.
The EFIT data is interpolated to produced continuous functions of the equilibrium attributes, such as the magnetic flux (psi) and magnetic field.
Note: psin_to_r mapping only exists if the psi axis is monotonic.
For examples of how to instantiate this class, see the examples in the machine specific packages.
- Parameters:
r – EFIT grid radius axis values (array).
z – EFIT grid height axis values (array).
psi_grid – EFIT psi grid values (array).
psi_axis (float) – The psi value at the magnetic axis.
psi_lcfs (float) – The psi value at the LCFS.
magnetic_axis (Point2D) – The coordinates of the magnetic axis.
x_points – A list or tuple of x-points.
strike_points – A list or tuple of strike-points.
f_profile – The current flux profile on psin (2xN array).
q_profile – The safety factor (q) profile on psin (2xN array).
b_vacuum_radius (float) – Vacuum B-field reference radius (in meters).
b_vacuum_magnitude (float) – Vacuum B-Field magnitude at the reference radius.
lcfs_polygon – A 2xN array of [[x0, …], [y0, …]] vertices specifying the LCFS boundary.
limiter_polygon – A 2xN array of [[x0, …], [y0, …]] vertices specifying the limiter.
time (float) – The time stamp of the time-slice (in seconds).
- Variables:
psi (Function2D) – The poloidal flux in the r-z plane, \(\psi(r,z)\).
psi_normalised (Function2D) – The normalised poloidal flux in the r-z plane, \(\psi_n(r,z)\).
f_profile (Function1D) – The current flux at the specified normalised poloidal flux, \(F(\psi_n)\).
q (Function1D) – The safety factor \(q\) at the specified normalised poloidal flux, \(q(\psi_n)\).
b_field (VectorFunction2D) – A 2D function that returns the magnetic field vector at the specified point in the r-z plane, \(B(r, z)\).
toroidal_vector (VectorFunction2D) – The toroidal flux coordinate basis vector, \(\hat{\phi}(r, z)\).
poloidal_vector (VectorFunction2D) – The poloidal flux coordinate basis vector, \(\hat{ \theta }(r, z)\).
surface_normal (VectorFunction2D) – The surface normal flux coordinate basis vector, \(\hat{\psi}(r, z)\).
inside_lcfs (Function2D) – A 2D function that identifies if a given (r, z) coordinate lies inside or outside the plasma Last Closed Flux Surface (LCFS). This mask function returns a value of 1 if the requested point lies inside the LCFS. A value of 0.0 is returned outside the LCFS.
inside_limiter (Function2D) – A 2D function that identifies if a given (r, z) coordinate lies inside or outside the first wall limiter polygon. This mask function returns a value of 1 if the requested point lies inside the limit polygon. A value of 0.0 is returned outside the polygon.
- map2d(profile, value_outside_lcfs)¶
Maps a 1D profile onto the equilibrium to give a 2D profile.
Useful for mapping flux surface quantities in the r-z plane.
- Parameters:
profile – A 1D function or 2xN array.
value_outside_lcfs – Value returned if point requested outside the LCFS (default=0.0).
- Returns:
Function2D object.
>>> # Hypothesise a 1D electron temperature profile as a function of psi_n. >>> te_data = np.zeros((2, 6)) >>> te_data[0, :] = [0, 0.1, 0.2, 0.4, 0.7, 1.0] >>> te_data[1, :] = [0, 100, 400, 500, 550, 600] >>> te = equilibrium.map2d(te_data) >>> >>> # evaluate temperature mapped on flux surfaces in (r, z) >>> te(3.1, 0.2) 487.924780234
- map3d(profile, value_outside_lcfs)¶
Maps a 1D profile onto the equilibrium to give a 3D profile.
Useful for mapping flux surface quantities in 3D space.
- Parameters:
profile – A 1D function or Nx2 array.
value_outside_lcfs – Value returned if point requested outside the LCFS (default=0.0).
- Returns:
Function3D object.
>>> # Hypothesise a 1D electron temperature profile as a function of psi_n. >>> te_data = np.zeros((2, 6)) >>> te_data[0, :] = [0, 0.1, 0.2, 0.4, 0.7, 1.0] >>> te_data[1, :] = [0, 100, 400, 500, 550, 600] >>> te = equilibrium.map3d(te_data) >>> >>> # evaluate temperature mapped on flux surfaces in (r, z) >>> te(3.1, -2.9, 0.2) 357.8793240
- map_vector2d(toroidal, poloidal, normal, value_outside_lcfs)¶
Maps velocity components in flux coordinates onto flux surfaces in the r-z plane.
It is often convenient to express the plasma velocity components in flux coordinates, assuming the velocities are flux functions. This function allows the user to specify velocity components as 1D functions of \(\psi_n\). The three velocity components are combined to yield a velocity vector at the requested r-z coordinate.
- Parameters:
toroidal – Toroidal velocity \(v_{\phi} (\psi_n)\), specified as a 1D function or Nx2 array.
poloidal – Poloidal vector \(v_{\theta} (\psi_n)\), specified as a 1D function or Nx2 array.
normal – Velocity along the flux surface normal \(v_{\psi} (\psi_n)\), specified as a 1D function or Nx2 array.
value_outside_lcfs – Value returned if point requested outside the LCFS (default= Vector3D(0, 0, 0)).
- Returns:
VectorFunction2D object that returns the velocity vector at a given r,z coordinate, \(v(r,z)\).
>>> # Hypothesise 1D profiles for the toroidal and poloidal velocities on psi_n. >>> v_toroidal = np.zeros((2, 6)) >>> v_toroidal[0, :] = [0, 0.1, 0.2, 0.4, 0.7, 1.0] >>> v_toroidal[1, :] = [0, 1e4, 3e4, 5e4, 5.5e4, 6e4] >>> v_poloidal = np.zeros((2, 6)) >>> v_poloidal[0, :] = [0, 0.1, 0.2, 0.4, 0.7, 1.0] >>> v_poloidal[1, :] = [4e4, 1e4, 3e3, 1e3, 0, 0] >>> # Assume zero velocity normal to flux surface >>> v_normal = 0.0 >>> >>> # generate VectorFunction2D and sample >>> v = equilibrium.map_vector2d(v_toroidal, v_poloidal, v_normal) >>> v(3.1, 0.2) Vector3D(134.523, 543.6347, 25342.16)
- map_vector3d(toroidal, poloidal, normal, value_outside_lcfs)¶
Maps velocity components in flux coordinates onto flux surfaces in 3D space.
It is often convenient to express the plasma velocity components in flux coordinates, assuming the velocities are flux functions. This function allows the user to specify velocity components as 1D functions of \(\psi_n\). The three velocity components are combined to yield a velocity vector at the requested 3D coordinate.
- Parameters:
toroidal – Toroidal velocity \(v_{\phi} (\psi_n)\), specified as a 1D function or Nx2 array.
poloidal – Poloidal vector \(v_{\theta} (\psi_n)\), specified as a 1D function or Nx2 array.
normal – Velocity along the flux surface normal \(v_{\psi} (\psi_n)\), specified as a 1D function or Nx2 array.
value_outside_lcfs – Value returned if point requested outside the LCFS (default= Vector3D(0, 0, 0)).
- Returns:
VectorFunction2D object that returns the velocity vector at a given r,z coordinate, \(v(r,z)\).
>>> # Hypothesise 1D profiles for the toroidal and poloidal velocities on psi_n. >>> v_toroidal = np.zeros((2, 6)) >>> v_toroidal[0, :] = [0, 0.1, 0.2, 0.4, 0.7, 1.0] >>> v_toroidal[1, :] = [0, 1e4, 3e4, 5e4, 5.5e4, 6e4] >>> v_poloidal = np.zeros((2, 6)) >>> v_poloidal[0, :] = [0, 0.1, 0.2, 0.4, 0.7, 1.0] >>> v_poloidal[1, :] = [4e4, 1e4, 3e3, 1e3, 0, 0] >>> # Assume zero velocity normal to flux surface >>> v_normal = 0.0 >>> >>> # generate VectorFunction2D and sample >>> v = equilibrium.map_vector3d(v_toroidal, v_poloidal, v_normal) >>> v(3.1, -0.1, 0.2) Vector3D(134.523, 543.6347, 25342.16)
- cherab.tools.equilibrium.example.example_equilibrium()¶
Return a populated instance of the example equilibrium.
>>> from cherab.tools.equilibrium import example_equilibrium >>> equilibrium = example_equilibrium()
- cherab.tools.equilibrium.plot.plot_equilibrium(equilibrium, detail=False, resolution=0.025)¶
Generates some overview plots of a given EFIT equilibrium.
- Parameters:
equilibrium – The input EFIT equilibrium object.
detail – If true, prints additional information about the equilibrium.
resolution (float) – Spatial resolution for sampling (default=0.025).
>>> from cherab.tools.equilibrium import example_equilibrium, plot_equilibrium >>> >>> equilibrium = example_equilibrium() >>> plot_equilibrium(equilibrium, detail=False, resolution=0.001)
- cherab.tools.equilibrium.eqdsk.import_eqdsk(file_path, drop_nan=False)¶
Imports equilibrium data from an EFIT G EQDSK file.
The file format is described at https://w3.pppl.gov/ntcc/TORAY/G_EQDSK.pdf.
Warning
The G EQDSK file format is unstable and unreliable. Use with caution.
- Parameters:
file_path (str) – Path to the EFIT eqdsk file.
drop_nan (bool) – Drop NaN values in the f and q profiles.
- Return type:
>>> from cherab.tools.equilibrium import import_eqdsk >>> equilibrium = import_eqdsk("equilibrium.eqdsk")