Reciprocal Lattice Calculator And Visualizer In 2D And 3D


Simple Python program for calculation and visualization of 2d and 3d reciprocal space


While working with spectroscopic methods to determine surface properties in the field of ultrafast electron dynamics, I wanted a tool to calculate and visualize real and reciprocal space unit cells and lattices in two and three dimensions.



Calculation of reciprocal lattices is straight forward and only requires small amount of formulas. These can be found anywhere and are even well explained on Wikipedia.

2D reciprocal space

With the condition for the reciprocal basis

    \[b_i\cdot a_j = 2\pi\delta_{ij},\]

where a_i is the primitive vector matrix for real space and b_i for reciprocal space and \delta_{ij} is the Kronecker delta. With this is easy to multiply with the explicit matrix inverse to get

    \[\begin{pmatrix} b_{1x} & b_{2x} \\ b_{1y} & b_{2y} \end{pmatrix} = \frac{2\pi}{a_{1x}a_{2y}-a_{1y}a_{2x}} \begin{pmatrix} a_{2y} & -a_{1y} \\ -a_{2x} & a_{1x} \end{pmatrix}.\]

This can now be used to calculate the 2d reciprocal unit vectors.

3D reciprocal space

For the calculation in 3d is as straight forward. By using the scalar triple product, the volume of the unit cell can be calculated.

    \[V = a_1 \cdot (a_2 \times a_3)\]

The primitive reciprocal vectors can be calculated.

    \[b_1 = \dfrac{2\pi}{V} a_2 \times a_3\]

    \[b_2 = \dfrac{2\pi}{V} a_3 \times a_1\]

    \[b_3 = \dfrac{2\pi}{V} a_1 \times a_2\]

One response to “Reciprocal Lattice Calculator And Visualizer In 2D And 3D”

  1. Fettmann avatar


Leave a Reply

Your email address will not be published. Required fields are marked *