Skip to main content

pySRU

Synchrotron Radiation Undulator emission in python

Main development website: https://github.com/oasys-kit/pySRU

A toolbox to calculate the emission of radiation by undulators in storage rings.

This software library implements formulas to calculate the emission of radiation by undulators in storage rings, and more generally, the emission of a relativistic electron in an arbitrary magnetic field.

The software is written in pure python, using standard packages as numpy and scipy. It uses matplotlib for plots, but it is not required for calculations.

License

This code is relased under the MIT license as detailed in the LICENSE file.

Installation

To build the library for python use, just use the pip install . in the pySRU directory. It is also available in http://pypi.python.org/pypi/pySRU/: pip install pySRU

Example

The file Simulations.py contains a number of simulations. For example the following code created the emission of an undulator like in fig 2.5 of the X-ray Data Booklet (http://xdb.lbl.gov/Section2/Sec_2-1.html)

This piece of Python code shows how the library can be used via its python binding.

from pySRU.ElectronBeam import ElectronBeam
from pySRU.MagneticStructureUndulatorPlane import MagneticStructureUndulatorPlane as Undulator
from pySRU.Simulation import create_simulation
from pySRU.TrajectoryFactory import TRAJECTORY_METHOD_ANALYTIC,TRAJECTORY_METHOD_ODE
from pySRU.RadiationFactory import RADIATION_METHOD_NEAR_FIELD, RADIATION_METHOD_APPROX_FARFIELD

print("======================================================================")
print("======      Undulator from X-ray data booklet                  =======")
print("====== fig 2.5 in  http://xdb.lbl.gov/Section2/Sec_2-1.html    =======")
print("======================================================================")

# note that the flux in the reference fig 2.6 is a factor 10 smaller than the calculated here.
# This factor comes from the units:
#     here: phot / s  / A / 0.1%bw / (mrad)^2
#     ref : phot / s  / A /   1%bw / (0.1 mrad)^2

undulator_test = Undulator(K=1.87, period_length=0.035, length=0.035 * 14)
electron_beam_test = ElectronBeam(Electron_energy=1.3, I_current=1.0)

simulation_test = create_simulation(magnetic_structure=undulator_test,electron_beam=electron_beam_test,
                    magnetic_field=None, photon_energy=None,
                    traj_method=TRAJECTORY_METHOD_ANALYTIC,Nb_pts_trajectory=None,
                    rad_method=RADIATION_METHOD_APPROX_FARFIELD, Nb_pts_radiation=101,
                    initial_condition=None, distance=None,XY_are_list=False,X=None,Y=None)


# simulation_test.print_parameters()

# simulation_test.trajectory.plot_3D(title="Electron Trajectory")

simulation_test.radiation.plot(title="Flux in far field vs angle")
https://raw.githubusercontent.com/oasys-kit/pySRU/master/doc/radiation_xraybooklet.jpeg

Result link: https://github.com/oasys-kit/pySRU/blob/master/doc/radiation_xraybooklet.jpeg

Documentation

For using pySRU, start with prepared simulations in Simulation.py

A comparison of the pySRU results with other codes can be found at: https://github.com/oasys-kit/pySRU/blob/master/doc/pySRU_comparison.pdf

A document including the formulas and algorithms used is: https://github.com/oasys-kit/pySRU/blob/master/doc/report_thery_m1.pdf

Testing

Run the test suite with:

./pySRU/tests/run_tests.sh

To do

  • Quicker calculation of intensity spectrum

  • Implement simplified formulas for calculating power density

  • Add electron emittance via convolutions

  • Implement the pi polarization

  • Extend to helical undulators

Metadata

Release files for pySRU 0.5.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pySRU 0.5.6
File Size Uploaded Provenance Actions
pysru-0.5.6.tar.gz 38.8 kB Without provenance Details for pysru-0.5.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pySRU 0.5.6
File Interpreter ABI Platform Actions
pysru-0.5.6-py3-none-any.whl Python 3 none any Details for pysru-0.5.6-py3-none-any.whl

Total release size: 105.1 kB

Release files / pysru-0.5.6.tar.gz

Download URL pysru-0.5.6.tar.gz
Size 38.8 kB
Tags Source
SHA-256 checksum
How to use checksums
556e374587902476300bd8fcf8c5333bad4746667dae74207293f48f447f5834
BLAKE2b-256 checksum
How to use checksums
8bc24244eb2670faf33625264fa3ec9d8610e7959f07c4ccd6b4666502569488
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / pysru-0.5.6-py3-none-any.whl

Download URL pysru-0.5.6-py3-none-any.whl
Size 66.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d87182820e73897c2ac28edd73ec781339ecb836a6173fa65de244880a5acc8a
BLAKE2b-256 checksum
How to use checksums
1ac327c0c33a4f2e4da6ea967c9fdf0be4a5487b383108920f95fbf977e2a6ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for pySRU 0.5.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page