Skip to content

Dealing with energy

Bliss provides tools to deal with energy related topics.

bliss.physics.diffraction module which is based on mendeleev external module allows to deal with various notions encountered when programming sequences for X-Ray experiments:

Some functions to calculate usualy associated values are also provided:

To ease and secure the handling of data in various units, Bliss provides a module named units.


De Broglie

\lambda = \frac{h}{p}


  • λ: wavelength
  • h: Planck constant
  • p: momentum = mass * velocity

Bragg’s law

\lambda = 2.d.sin(\theta)

as $$ E = mc^2 \qquad and \qquad p = mv $$

\lambda = \frac{hc}{E} \Leftrightarrow E = \frac{hc}{\lambda} \Leftrightarrow E = \frac{nhc}{2.d.sin(\theta)}


  • n: order of reflection [1..]
  • λ: wavelength incident angle
  • θ: scattering angle
  • d: interplanar distance between lattice planes

Cubic crystal diffraction

d = \frac{a}{\sqrt{h^2+k^2+l^2}}

Units management with units

When an argument to any function represents a physical quantity, the library expects the units to be coherent. Passing Quantity objects makes sure you are coherent.

The implementation is permissive, which means that if you pass a float/int instead of a Quantity, the library assumes the argument to be in the correct units which are SI units. Failure to comply will result in unexpected values.

units is based on pintexternal module.


Example to convert 0.1 miligram in Kjoules with unknown formula.

import bliss.physics.diffraction
from bliss.physics.units import ur
mass = 0.1 *
E = mass * ur.c**2
print( )
>>> 8987551.78737 kilojoule

Example of usage


mendeleev.elements usage example:

from mendeleev import elements
Si = elements.Si
print("Atomic number of {} is {}.".format(, Si.atomic_number))
>>> Atomic number of Silicon is 14.


Cubic crystal:

from bliss.physics.diffraction import Crystal
from mendeleev import elements
Si = Crystal(elements.Si)
Si111 = Si('111')
>>> Si(111)

Most crystals are already available at the module level so you rarely need to create an instance of this class:

>>> Si

>>> Ge

Crystal Plane:

from bliss.physics.diffraction import CrystalPlane
Si110 = CrystalPlane.fromstring('Si110')

Bragg angle

How to find the bragg angle (in degrees) for a silicon crystal at the 110 plane when the energy is 12.5 keV:

from bliss.physics.units import ur
from bliss.physics.diffraction import Si
keV, deg = ur.keV, ur.deg
Si110 = Si('110')
energy = 12.5*keV
angle = Si110.bragg_angle(energy)

# angle is a Quantity (radians)
print( angle )
>>> 0.12952587191 radian

# view it as a Quantity (degrees)
print( )
>>> 7.42127016 degree

# get the float in degrees
print('deg').magnitude )
>>> 7.42127016

Bragg energy

How to find the bragg energy (keV) for a germanium crystal at 444 plane when the angle is 25.6 degrees:

from bliss.physics.diffraction import Ge
deg = ur.deg

Ge444 = Ge('444')
angle = 25.6*deg
energy = Ge444.bragg_energy(angle)
wavelength = Ge444.bragg_wavelength(angle)

>>> <Quantity(2.81372042834e-15, 'joule')>

>>> <Quantity(7.05985450176e-11, 'meter')>

print( )
>>> 17.5618627264 kiloelectron_volt

print( )
>>> 17.5618627264


energy_to_wavevector(edge_energy, energy):

wavevector_to_energy(edge_energy, k):

user-friendly functions:

from bliss.physics import spectroscopy
#  1.6531226083801578

#  7.500002760141831