Tool to compute energy density of synchrotron radiation in the spectral volume using the Fourier transformed Lienard-Wiechert potentials (see eq. (14.65) of J.D.Jackson's Classical electrodynamics).
This software processes the 3D (x, y, z, px, py, pz) trajectories of the charged point-like particles with weights, and maps the emittied energy to the 3D spectral domain (omega, theta, phi). The package also contains a number of convenience methods for pre- and post-proccessing.
SynchRad is written in openCL and is interfaced with Python via PyOpenCL.
Code also uses Mako template manager for tweaking with the data types and native functions. It was tested on GPU and CPU devices using NVIDIA, AMD and Apple platforms, and it demonstrates a reasonable performance on GPUs, while on CPU the simillar OpenMP implementation is signifincantly faster.
Given that openCL and PyOpenCL are installed (e.g. via conda
or pip
) and configured on your machine, you can install SynchRad in a standard way, i.e. by cloning the source
and running the setup.py
script:
git clone https://github.com/hightower8083/synchrad.git
cd synchrad/
python setup.py install
To be able to use the software with multiple GPU or CPU devices via MPI one should also install mpi4py
. To output result in VTK format via exportToVTK
method, the tvtk.api
should be installed.
A minimal example of SynchRad usage can be found in example/
folder of this repository.
Another common example would be to calculate radiation produced by the particles from, for example, a PIC simulation. In case if PIC software supports output in OpenPMD standard, this can be done with help of openPMD-viewer, using the conversion function:
from openpmd_viewer import OpenPMDTimeSeries, ParticleTracker
from synchrad.utils import tracksFromOPMD
ts = LpaDiagnostics('./run/diags_track/hdf5/', check_all_files=False)
ref_iteration = ts.iterations[-1]
pt = ParticleTracker( ts, iteration=ref_iteration,
preserve_particle_index=True)
tracksFromOPMD( ts, pt, ref_iteration=ref_iteration, fname='tracks.h5')
where one can see doc-lines of tracksFromOPMD for more optional arguments.
The prepared track can be processed and saved to file using following commands:
import numpy as np
from synchrad.calc import SynchRad
calc_input = {'grid':[ (1e3/1.24e-6, 75e3/1.24e-6),
(0, 0.04),
(0.,2*np.pi),
(256, 32, 32) ],
'dtype':'double',
}
calc = SynchRad(calc_input)
calc.calculate_spectrum(file_tracks='./tracks.h5',file_spectrum='./spectrum.h5')
where radiation within 40 urad angle is calculated for the energies range [1 keV, 75 keV].
For more details see the example notebooks in tutorials/
This software is developed by Igor A Andriyash ([email protected]), and it is on the early stage of development.
Everyone is welcome to contribute either by testing and benchmarking, or by introducing further optimizations and adding utility methods.