gtsimulation.magnetic_field#

Magnetic field models.

This subpackage provides an abstract interface for custom magnetic field implementations as well as several predefined magnetic field models, including a uniform magnetic field.

class gtsimulation.magnetic_field.AbsBfield[source]#

Abstract base class for magnetic field models.

A subclass implements the field model in calc_field in the native coordinate units of the model: for example, galactic models take coordinates in kpc. calc_field must return the magnetic field in nT. The class attribute to_meters is the native length unit in metres (e.g. Units.kpc) and must be set in the subclass; the default value 1 corresponds to metres. A subclass must also implement update_state. Fields can be combined with +, which returns their vector sum.

abstractmethod calc_field(x, y, z)[source]#

Calculate the magnetic field in the native units of the model.

Parameters:
x, y, zfloat

Coordinates in the native units of the model.

Returns:
Bx, By, Bzfloat

Magnetic field components in nT.

get_field(x, y, z)[source]#
to_meters = 1#
abstractmethod update_state(new_date)[source]#

Update the model for a new date.

Models that do not depend on the date implement this method as a no-op.

Parameters:
new_datedatetime.datetime

New date.

class gtsimulation.magnetic_field.Uniform(B)[source]#

Uniform magnetic field.

The field has the same magnitude and direction at every point.

Parameters:
Barray-like, shape (3,)

Magnetic field components (Bx, By, Bz) in nT.

calc_field(x, y, z)[source]#

Calculate the magnetic field in the native units of the model.

Parameters:
x, y, zfloat

Coordinates in the native units of the model.

Returns:
Bx, By, Bzfloat

Magnetic field components in nT.

update_state(new_date)[source]#

Update the model for a new date.

Models that do not depend on the date implement this method as a no-op.

Parameters:
new_datedatetime.datetime

New date.

Modules