pyoculus.fields.cylindrical_bfield_analytic

class pyoculus.fields.cylindrical_bfield_analytic.AnalyticCylindricalBfield(R, Z, sf, shear, perturbations_args=[])

Analytical Bfield problem class that allows adding analytical perturbations to an analytical equilibrium field. The equilibrium field is derived from the vector potential A_squared(R, Z, sf, shear) (circular quadratic q-profile) and the perturbations can be choosen from the type dictionary. The possible types are:

  • “maxwell-boltzmann”: Maxwell-Boltzmann distributed perturbation

  • “gaussian”: Normally distributed perturbation

  • “circular-current-loop”: Field generated by a constant current toroidal loop

  • “squared-circle”: Field generated by a squared circle (in fact from equ_squared)

sf

Safety factor on the magnetic axis

Type:

float

shear

Shear factor

Type:

float

perturbations_args

List of dictionaries with the arguments of each perturbation

Type:

list

amplitude

List of amplitudes of the perturbations. One can set the amplitude of all perturbations at once by setting this attribute: $ myBfield.amplitudes = [1, 2, 3] $ myBfield.amplitudes >> [1, 2, 3]

Type:

list

perturbations

List of perturbations functions. To call a certain (for instance the first) perturbation one can do: $ myBfield.perturbations[0](rphiz) >> value

Type:

list

set_amplitude(index, value)

Set the amplitude of the perturbation at index to value

set_perturbation(index, perturbation_args)

Set the perturbation at index to be defined by perturbation_args

add_perturbation(perturbation_args)

Add a new perturbation defined by perturbation_args

remove_perturbation(index)

Remove the perturbation at index, (default: -1, the last one)

B_equilibrium(rphiz)

Equilibrium field function

dBdX_equilibrium(rphiz)

Gradient of the equilibrium field function

B_perturbation(rphiz)

Perturbation field function

dBdX_perturbation(rphiz)

Gradient of the perturbation field function

classmethod with_new_axis(R, Z, sf, shear, perturbations_args=[], RZguess=None)

Create a new AnalyticCylindricalBfield object whose axis location is found. Perturbations such as circular-current-loop displace the axis. This perturbation is first added, then the axis location is found, and perturbations such as maxwell-boltzmann and gaussian are added on this new axis.

property amplitudes

List of amplitudes of the perturbations.

set_amplitude(index, value, find_axis=True)

Set the amplitude of the perturbation at index to value

set_perturbation(index, perturbation_args, find_axis=True)

Set the perturbation at index to be defined by perturbation_args

add_perturbation(perturbation_args)

Add a new perturbation defined by perturbation_args

remove_perturbation(index=-1)

Remove the perturbation at index or the last one if no index is given.

property perturbations

List of the perturbations functions (jited using jax). To call a certain (for instance the first) perturbation one can do: $ myBfield.perturbations[0](rphiz) >> value

B(coords, *args)

Total field function at the point rr. Where B = B_equilibrium + B_perturbation.

dBdX(coords, *args)

Gradient of the total field function at the point coords. Where (dBdX)^i_j = dB^i/dX^j with i the row index and j the column index of the matrix.

A(coords, *args)

Total vector potential function at the point rr.

divB(rr)

Divergence of the total field function at the point rr.

plot_perturbation_levels(rw, zw, nl=[100, 100], RZ_manifold=None, N_levels=50, alpha=0.5, colorbar=False, **kwargs)

Plot the perturbation psi flux function and the perturbation B field in the RZ plane at the provided points. The perturbation psi is the sum of the perturbations defined in the perturbations_args attribute.

plot_perturbation_vector(locations, normed=True, **kwargs)

Plot the perturbation vector field at the provided locations.