Field

The field type is selected with a variant:

using celeritas::inp::Field = std::variant<NoField, UniformField, RZMapField, CylMapField, CartMapField>

Magnetic field specification.

In the JSON representation, a "_type" field selects the variant alternative using one of the following values:

  • “none”: NoField

  • ”uniform”: UniformField

  • ”rzmap”: RZMapField

  • ”cylmap”: CylMapField

  • ”cartmap”: CartMapField

The field currently allows a few hard-coded options. It will be extended to additional field types and may allow completely custom field implementations.

struct NoField

Build a problem without magnetic fields.

struct UniformField

Create a uniform nonzero field.

If volumes are specified, the field will only be present in those volumes.

Todo:

Field driver options will be separate from the magnetic field. They, plus the field type, will be specified in a FieldParams that maps region/particle/energy to field setup. NOTE ALSO that driver_options.max_substeps is redundant with p.tracking.limits.field_substeps .

Public Members

UnitSystem units = {UnitSystem::si}

Default field units are tesla.

Real3 strength = {0, 0, 0}

Field strength.

FieldDriverOptions driver_options

Field driver options.

VariantSetVolume volumes

Volumes where the field is present (optional)

struct CylMapField

Input data for a magnetic R-Phi-Z vector field stored on an R-Phi-Z grid.

The magnetic field is discretized at nodes on an R-Phi-Z grid, and at each point the field vector is approximated by a 3-D vector in R-Phi-Z. The input units of this field are in NATIVE UNITS (cm/gauss when CGS).

The field values are all indexed with Z having stride 1, Phi having stride (num_grid_z), and R having stride (num_grid_phi * num_grid_z): [R][Phi][Z]

Todo:

Driver options should be outside field

Public Functions

inline explicit operator bool() const

Whether grids have been assigned.

Public Members

std::vector<double> grid_r

r, phi, and z grid points

std::vector<double> field

Flattened R-Phi-Z field component [bfield].

FieldDriverOptions driver_options

Todo:

Remove from field input; should be a separate input

struct CartMapField

Input data for a magnetic X-Y-Z vector field stored on an X-Y-Z grid.

The magnetic field is discretized at nodes on an X-Y-Z grid, and at each point the field vector is approximated by a 3-D vector in X-Y-Z. The input units of this field are in NATIVE UNITS (cm/gauss when CGS).

The field values are all indexed with Z having stride 3, for the 3-dimensional vector at that position, Y having stride (num_grid_z * 3), and X having stride (num_grid_y * num_grid_z * 3): [X][Y][Z][3]

Public Functions

inline explicit operator bool() const

Whether all data are assigned and valid.

Public Members

AxisGrid<double> x

Grid specification for each axis [len].

std::vector<double> field

Flattened X-Y-Z field component [bfield].

FieldDriverOptions driver_options

Todo:

Remove from field input; should be a separate input

struct RZMapFieldInput

Input data for an magnetic R-Z vector field stored on an R-Z grid.

The magnetic field is discretized at nodes on an R-Z grid, and each point the field vector is approximated by a 2-D vector in R-Z. The input units of this field are in NATIVE UNITS (cm/gauss when CGS). An optional _units field in the input can specify whether the input is in SI or CGS units, with allowable values of “si”, “cgs”, or “clhep”. The native CLHEP unit strength is 1000*tesla.

The field values are all indexed with R having stride 1: [Z][R]

Todo:

Use C indexing instead of Fortran? Or rename to ZR field?

Public Functions

inline explicit operator bool() const

Whether all data are assigned and valid.

Public Members

double min_z = {}

Lower z coordinate [len].

double max_z = {}

Last z coordinate [len].

double min_r = {}

Lower r coordinate [len].

double max_r = {}

Last r coordinate [len].

std::vector<double> field_z

Flattened Z field component [bfield].

std::vector<double> field_r

Flattened R field component [bfield].

The field driver options are not yet a stable part of the API:

struct FieldDriverOptions

Configuration options for field propagation and substepping.

TODO: replace epsilon_rel_max with 1/epsilon_rel_max^2 TODO: replace safety with step_shrink_mul (or something to indicate that it’s a multiplicative factor for reducing the step, not anything with geometry) TODO: remove errcon TODO: for some of these we could probably use single-precision

Public Functions

inline explicit operator bool() const

Whether all data are assigned and valid.

Public Members

real_type minimum_step = 1.0e-5 * units::millimeter

The minimum length of the field step.

real_type delta_chord = 0.25 * units::millimeter

The maximum sagitta of each substep (“miss distance”)

real_type delta_intersection = 1.0e-4 * units::millimeter

Accuracy of intersection of the boundary crossing.

real_type epsilon_step = 1.0e-5

Discretization error tolerance for each field substep.

real_type epsilon_rel_max = 1.0e-3

Targeted discretization error for “integrate step”.

real_type errcon = 1.0e-4

UNUSED: Targeted discretization error for “one good step”.

real_type pgrow = -0.20

Exponent to increase a step size.

real_type pshrink = -0.25

Exponent to decrease a step size.

real_type safety = 0.9

Scale factor for the predicted step size.

real_type max_stepping_increase = 5

Largest allowable relative increase a step size.

real_type max_stepping_decrease = 0.1

Smallest allowable relative decrease in step size.

short int max_nsteps = 100

Maximum number of integrations (or trials)

short int max_substeps = 10

Maximum number of substeps in the field propagator.

Public Static Attributes

static constexpr real_type initial_step_tol = 1e-6

Initial step tolerance.

static constexpr real_type dchord_tol = 1e-5 * units::millimeter

Chord distance fudge factor.

static constexpr real_type min_chord_shrink = 0.5

Lowest allowable scaling factor when searching for a chord.