pyoculus.maps.cylindrical_bfield_section

Functions

njit(func)

class pyoculus.maps.cylindrical_bfield_section.CylindricalBfieldSection(cylindricalbfield: CylindricalBfield, phi0=0.0, R0=None, Z0=None, domain=None, finderargs={}, cache_size=None, **kwargs)

Map given by following the a magnetic field in cylindrical system \((R, \phi, Z)\) and recording the intersections with symmetry planes \(\phi = \phi_0, \phi_0 + T, ...\).

mf

The magnetic field to follow.

Type:

CylindricalBfield

phi0

The cylindrical angle from which to start the field line tracing.

Type:

float

R0

The major radius of the magnetic axis in the \(\phi_0\) plane.

Type:

float

Z0

The vertical position of the magnetic axis in the \(\phi_0\) plane.

Type:

float

find_axis(guess=None, **kwargs)

Finds the magnetic axis of a magnetic field using a FixedPoint solver.

This method attempts to locate the magnetic axis by solving a fixed-point problem, where the magnetic axis is a point where the magnetic field lines close on themselves after exactly one mapping.

Parameters:
  • guess (tuple, optional) – An initial guess for the coordinates of the magnetic axis. If not provided, a default guess is used.

  • **kwargs – Arbitrary keyword arguments passed directly to the FixedPoint solver’s find method. This can be used to specify solver options such as tolerance levels, maximum iterations, etc.

property axis

Returns the coordinates of the magnetic axis.

f(t, y0)

Trace the field line for a number of periods.

Traces one field period at a time and caches the results if the number of periods is integer. Otherwise, it traces the field line for the given number of fractional periods in one go.

df(t, y0)

Compute the Jacobian of the field line map for a number of periods.

to_rhotheta(y, y0=None)

Converts the cylindrical coordinates to polar coordinates centered around the magnetic axis.

to_RZ(rt)

Converts the polar coordinates centered around the magnetic axis to cylindrical coordinates.

lagrangian(y0, t)

Set Meiss’s Lagrangiat for the magnetic field.

winding(t, y0, y1=None)

Calculates the winding number of the field line starting at \(y_0\) around the one starting at \(y_1\). By going into the poloidal coordinates centered around the position of the field line given by \(y_0\) and integrating the angle change along the trajectory.

Parameters:
  • t (float) – The number of periods to integrate.

  • y0 (array) – The starting point of the field line.

  • y1 (array, optional) – Another field line around which winding is to be calculated. If not provided, the magnetic axis is used.

Returns:

The radius difference between initial and final point and winding number between the two field lines.

Return type:

np.ndarray

dwinding(t, y0, y1=None)

Calculates the Jacobian of the winding number

class pyoculus.maps.cylindrical_bfield_section.Cache(size=None)

A cache to store the results of integrations. Entries are catalogued by the starting point of the field line and the type of result. the cache will return a dictionary of {t: result} where t is the time period and result is the result of the integration t times. The cache is limited in size and will remove the oldest entry if the limit is reached. The keys are a hash of the starting position and a string specifying the type of result. These are not specified in the cache itself, but by the functions that use the cache. Currently implemented types are: (y0, ‘f’) for the field line position at time t (y0, ‘df’) for the jacobian of the field line position at time t (y0, ‘f_noninteger’) for the field line position at time t for non-integer t (y0, ‘df_noninteger’) for the jacobian of the field line position at time t for non-integer t (y0, ‘lagrangian’) for the lagrangian form at time t (y0, ‘winding’) for the winding number at time t (y0, ‘dwinding’) for the jacobian of the winding number at time t [Note: the cache entries are based on starting point of a trajectory, so calculations starting at an intermediate point of a previous trajectory will not be retrieved from the cache.] non-integer integrations are always computed from phi=0, and do not continue from a previous result.

size

The maximum size of the cache.

Type:

int

cache

The cache storage.

Type:

dictionary

retrieve(y0, what)

Retrieves a cached result if available.

Parameters:
  • y0 (array) – The starting point of the field line.

  • what (str) – The type of result to retrieve.

Returns:

The cached result if available, otherwise None.

Return type:

dict or None

save(y0, what, t, res)

Saves a result to the cache.

Parameters:
  • t (float) – The time period.

  • y0 (array) – The starting point of the field line.

  • dic (dict) – The result to cache.

clear()

Clears the cache.