Skip to main content

Python synchrotron undulator calcution

Project description

WARNING: PROJECT UNDER DEVELOPMENT!!

Synchrotron Radiation Undulator emission in python

Main development website: https://github.com/SophieTh/und_Sophie_2016

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 python setup.py install approach.

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://github.com/SophieTh/und_Sophie_2016/blob/classic/data/radiation_xraybooklet.jpeg

Result link: https://github.com/SophieTh/und_Sophie_2016/blob/classic/data/radiation_xraybooklet.jpeg

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pySRU-0.5.2.tar.gz (30.9 kB view details)

Uploaded Source

File details

Details for the file pySRU-0.5.2.tar.gz.

File metadata

  • Download URL: pySRU-0.5.2.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pySRU-0.5.2.tar.gz
Algorithm Hash digest
SHA256 1f01a01fc9664b8de28c6e5f05dd677b91a8aaef524d43ea972a1fd8fb53a32c
MD5 1bc5dd37d99e6f4c632960ecd8817508
BLAKE2b-256 241c01570e0a09ba9499e11c537279d18e7a4d998e86f1cabaeeefd8cfb6ff18

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page