Skip to content

jcdiazvelez/ptracing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 

Repository files navigation

ptracing

Code for cosmic-ray propagation in healiosphere and interstellar magnetic field.

Description

ptracing is a numerical code for calculating the propagation of relativistic charged particles. The code includes interfaces for different heliospheric model as well simple geometric magnetic fields used for testing purposed. It also supports several numerical integration methods.

Trajectories are calculated by numerically integrating the following set of 6--dimensional ordinary differential equations

$$\frac{d\mathbf{p}}{dt} = q \left(\mathbf{v}\times\mathbf{B} \right),$$

$$\frac{d\mathbf{r}}{dt} = \mathbf{v},$$

describing the Lorentz force exerted by the magnetic field $\mathbf{B}$ on particles with velocity $\mathbf{v}$, where $\mathbf{r}$ is their position vector and $\mathbf{p}$ the momentum. We introduce a fiducial magnetic field strength $B_0$, which in practice will be the magnitude of the mean, or guide field. We then adopt dimensionless magnetic and electric fields $\hat{\mathbf{B}}\equiv\mathbf{B}/B_0$. We introduce the fiducial proton gyrofrequency $\omega_0\equiv eB_0/mc$ (with $m$ the proton mass) and replace time $t$ by $s\equiv\omega_0t$. We introduce a fiducial gyroradius $r_0\equiv c/\omega_0$ and express lengths in units of $r_0$; $\hat{\mathbf{r}}\equiv\mathbf{r}/r_0$. We express momentum in units of $mc$; $\hat{\mathbf{p}}\equiv\mathbf{p}/mc$. The particle velocity $\mathbf{v}$ is related to $\hat{\mathbf{p}}$ by $\mathbf{v} = \hat{\mathbf{p}}/\sqrt{1+\hat p^2}$ and the particle Lorentz factor $\gamma = \sqrt{1+\hat p^2}$. In these units the dimensionless particle gyroradius is $\hat r_g = \hat p_{\perp}$, and the dimensionless gyro-frequency is $\hat \omega_g = 1/\gamma$. We denote normalized variables with a hat.

This code support magentic field models in ASCII format as awell HDF5. The original simulation box is extended beyond the boundaries of the model by extrapolating and the coordinates are shifteted with the Sun located at $(0,0,0)$. In the extension of the simulation box, a uniform magnetic field with intensity $3\mu\mathrm{G}$ at infinity and with the same direction as in the simulation is assumed. Such a model of the heliosphere is suitable for studying its effects on CR particles with gyroradius comparable to or larger than the heliosphere's size.

The equations of motion are numerically integrated using various integration methods including the explicit $4^\mathrm{th}$ order Runge-Kutta and Boris Push algorithm (Boris, J.P. Proc. of the 4th Conf. on Num. Sim. of Plasmas. pp. 3–67. 1970). An adaptive time step size is used in the calculations, with tolerance level $\epsilon$ to keep truncation errors sufficiently small (see Paolo Desiati and Ellen G. Zweibel 2014 ApJ 791 51 for more discussion on numerical accuracy). Particle trajectory integrations terminate when the maximum integration time $t_\mathrm{max}$ is reached or when particles have reached a radiums $r_\mathrm{max}$.

The code has been updated to support multi-threading and thus take advantage of computers with a large number of CPU cores with shared memory.

Installation

Prerequisites:

dependencies:

You will also need:

  • CMake >= 3.1
  • A C++11-compliant compiler (e.g. gcc >= 4.8.1 or clang >= 3.3)

Installation:

The C++ projects are built using CMake. Each project has a CMakeList.txt that will detect dependencies and generate a MakeFile. To do this cd into the build directory and excecute the commands:

cmake ../src; make

About

integration of charge particle trajectories in magnetic field.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published