E852 documentation: track swimming routines

Introduction

This document describes the routines used to integrate trajectories of charged particles in a magnetic field. These routines also work for neutral particles and in the absense of the magnetic field.

Particles are propagated from a starting point to:

Include files, libraries and initialization

To use routines documented herein, the program should include these include files: and be linked with these libraries: (the last two libraries are needed only for the the package initialization code and are not used by the swimming routines themselves)

To initialize the package, call:

#include <trackswim.h> #include <param.h> param_loadDatabase("trackswim",0); trackswim_init();

Track definition

These routines can use the following definitions of tracks:

Common arguments and return values

The functions return 0 if success, non 0 in case if failure.

The track returned by the functions is always the point where the swimming had stopped.

The flags argument is normally 0. See the include file for more details.

The box argument defines the boundary volume. Swimming is terminated when the trajectory leaves this volume. To swim without restrictions, set this argument to NULL.

Swimming routines

Mathematics used inside the package

The package can be configured to use the following trajectory integration methods:

Staight line approximation is slow and inefficient, but very simple to implement and therefore "bug free". It is used mainly to debug the other methods.

ptracb is the tracking code written by S.U.Chung and successfully used to analyze previous MPS experiments. It works fairly well in a uniform magnetic field. It's main flaws are: lack of interface with "boundary conditions", errors in defining the "plane" boundary conditions and lack of variable step size.

The arc approximating method was developed mainly to fix the aforementioned flaws in ptracb. It uses the same arc approximation formulaes as ptracb. One step of either method will give identical results. The main difference is in the way the variable step size and the boundary conditions are implemented.

The variable step size is implemented by sampling the magnetic field along the trajectory and will decrease the step size if it detects "fast changes of the field". If the field "stops changing", the step size is automatically increased. This feature enables to run with larger step size (4 cm versus 1 cm in ptracb). Larger step size means less steps, less calculations of the magnetic field and faster integration.

The "boundary conditions" are implemented by a goal function, which is minimized along the trajectory. For example, when swimming to a plane, this function is defined as "the distance from the current point to the plane". The minimum of the goal function is found by the golden-ratio algorithm for single variable optimization (see: Bronshtein/Semendyayev, "Handbook of Mathematics", section 9.2.2.2.1, published by Van Nostrand Reinhold Company, Inc.).

Config files

The package uses the configuration database trackswim.db, which is extensively self documented.

This file defines, among other things, the step size and the trajectory integration technique.

CO 1995-May-07
//end file