Basic exampleΒΆ

The following example shows how to load an equilibrium saved in the EQDSK format and perform some basic operations with it. Several test equilibria come shipped with PLEQUE; here we will use one of them.

[1]:
from importlib import resources

from pleque.io import readers
import matplotlib as plt

#Locate the test equilibrium
filepath = resources.files('pleque').joinpath('resources', 'baseline_eqdsk')

The heart of PLEQUE is its Equilibrium class, which contains all the equilibrium information (and much more). Typically its instances are called eq.

[2]:
# Create an instance of the `Equilibrium` class
eq = readers.read_geqdsk(filepath)
  nx = 65, ny = 129
197 1
Found 5 o-points and 6 x-points with order 20

The Equilibrium class comes with many interesting functions and caveats.

[3]:
# Plot a simple overview of the equilibrium
eq.plot_overview()

# Calculate the separatrix area
sep_area = eq.lcfs.area
print('Separatrix area: A_sep = %.3f m^2' % sep_area)

# Get absolute magnetic field magnitude at given point
R = 0.7 #m
Z = 0.1 #m
B = eq.B_abs(R, Z)
print('Magnetic field at R=%.1f m and Z=%.1f m: B = %.1f T' % (R, Z, B))
Matplotlib is building the font cache; this may take a moment.
Separatrix area: A_sep = 0.381 m^2
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_729/2168947156.py in <cell line: 0>()
     10 Z = 0.1 #m
     11 B = eq.B_abs(R, Z)
---> 12 print('Magnetic field at R=%.1f m and Z=%.1f m: B = %.1f T' % (R, Z, B))

TypeError: only 0-dimensional arrays can be converted to Python scalars
_images/basic_example_link_5_3.png

Browse various attributes and functions of the Equilibrium class to see what it has to offer.