FieldModel

class disco.FieldModel(Bx, By, Bz, Ex, Ey, Ez, axes, B0=<Quantity 31000. nT>, extra_fields=None)[source]

Bases: object

Magnetic and electric field models used to propagate particles.

Get an instance that is dimensionalized and stored on the GPU.

Input argument should have astropy units attached.

Parameters:
Bx: array of shape (nx, ny, nz, nt), with units

External Magnetic Field X component, SM Coordinates

By: array of shape (nx, ny, nz, nt), with units

External Magnetic Field Y component, SM Coordinates

Bz: array of shape (nx, ny, nz, nt), with units

External Magnetic Field Z component, SM Coordinates

Ex: array of shape (nx, ny, nz, nt), with units

Electric Field X component, SM Coordinates

Ey: array of shape (nx, ny, nz, nt), with units

Electric Field Y component, SM Coordinates

Ez: array of shape (nx, ny, nz, nt), with units

Electric Field Z component, SM Coordinates

axes: Axes

Rectilinear grid information and inner boundary

B0: scalar with units, optional

Internal Dipole strength to add to external field interpolating.

extra_fields: dict, optional

Dictionary of additional fields to include in the field model, such as plasma parameters rho, p, T, etc. The keys should be strings representing the field names, and the values should be arrays with shape (nx, ny, nz, nt) with no units.

Methods Summary

dimensionalize(mass, charge)

Convert to a DimensionalizedFieldModel instance.

duplicate_in_time([time_axis])

Duplicate the FieldModel in time, to support tracing in a single time step.

load(hdf_path[, B0])

Load a FieldModel from an HDF5 file.

save(hdf_path)

Save the FieldModel to an HDF5 file.

Methods Documentation

dimensionalize(mass, charge)[source]

Convert to a DimensionalizedFieldModel instance.

Parameters:
massscalar with untis

Scalar mass, used for dimensionalization

chargescalar with untis

Scalar charge, used for dimensionalization

duplicate_in_time(time_axis=<Quantity [-1., 1.] yr>)[source]

Duplicate the FieldModel in time, to support tracing in a single time step.

Parameters:
time_axis: array with units of time

Time axis values to use for duplication. The default is made sufficiently large that it is unrealistic for a particle to ever hit the time limit bounds.

Returns:
instance of FieldModel with duplicated time axis
classmethod load(hdf_path, B0=<Quantity 31000. nT>)[source]

Load a FieldModel from an HDF5 file.

Parameters:
hdf5_path: str

Path to the HDF5 file to load from.

B0: scalar with units, optional

Internal Dipole strength to add to external field interpolating.

Returns:
FieldModel

An instance of FieldModel loaded from the HDF5 file.

Raises:
ValueError

If the shapes of the arrays in the HDF5 file do not match expected dimensions.

Notes

Required HDF5 variables:

  • Bx: shape (nx, ny, nz, nt), units nT

  • By: shape (nx, ny, nz, nt), units nT

  • Bz: shape (nx, ny, nz, nt), units nT

  • Ex: shape (nx, ny, nz, nt), units mV/m

  • Ey: shape (nx, ny, nz, nt), units mV/m

  • Ez: shape (nx, ny, nz, nt), units mV/m

  • xaxis: shape (nx,), units Re

  • yaxis: shape (ny,), units Re

  • zaxis: shape (nz,), units Re

  • taxis: shape (nt,), units seconds

  • r_inner: scalar, units Re

Additional comments:

  • B values must have the dipole subtracted (also known as being the “external” model)

  • Any NaN’s encoutered will halt integration immediately, so they can be used to place irregular outer boundaries.

save(hdf_path)[source]

Save the FieldModel to an HDF5 file. Can be loaded with the FieldModel.load() method.

Parameters:
hdf5_path: str

Path to the HDF5 file to save to.