Simulations¶
Simulating diffraction patterns
Polycrystalline Diffraction Simulation¶
The simplest diffraction simulation available in scikit-ued is polycrystalline diffraction simulation.
All you need is a Crystal
object and a range of scattering length, defined from
scattering angles s as \(s = \sin{\theta}/\lambda\):
import matplotlib.pyplot as plt
import numpy as np
from skued import powdersim
from skued import Crystal
graphite = Crystal.from_database('C')
q = np.linspace(1, 10, 1024)
diff = powdersim(graphite, q)
plt.figure()
plt.plot(q, diff/diff.max())
After plot formatting:
(Source code, png, hires.png, pdf)
Electrostatic Potential Simulation¶
The scattering potential of electrons is the crystal electrostatic potential; hence computing such potential is a useful tool.
To compute the electrostatic potential for an infinite crystal on an arbitrary 3D mesh,
take a look at electrostatic()
:
from skued import Crystal
from skued import electrostatic
graphite = Crystal.from_database('C')
extent = np.linspace(-10, 10, 256)
xx, yy, zz = np.meshgrid(extent, extent, extent)
potential = electrostatic(graphite, xx, yy, zz)
Another possibility is to calculate the electrostatic potential for an infinite slab in the
x-y plane, but finite in z-direction, using pelectrostatic()
(p for projected):
from skued import pelectrostatic
extent = np.linspace(-5, 5, 256)
xx, yy= np.meshgrid(extent, extent)
potential = pelectrostatic(graphite, xx, yy)
After plot formatting:
(Source code, png, hires.png, pdf)