Beam Wavelength Spread in Specular Simulations

This example demonstrates beam wavelength spread effects in reflectivity computations. All simulation parameters (except for those related to beam spread itself) coincide with those defined in reflectometry simulation tutorial.

In real specular experiments the observed reflectivity is always affected by the beam spread in both wavelength and incident angle.

Intensity image

In this example the following parameters related to the spread of the beam were set to the simulation:

  • Gaussian distributions both in wavelength and incident angle
  • The mean value for beam wavelength $\lambda_0 = 0.154$ nm
  • Standard deviation in the wavelength $\sigma_{\lambda} = 0.01 \cdot \lambda_0$
  • Standard deviation in the incident angle $\sigma_{\alpha} = 0.01^{\circ}$

As one can see from the Python script, the definitions of beam parameter distributions match ones described in similar example for GISAS simulations. However, in the case of the incident angle one should always use a distribution with zero mean, since the actual mean value is substituted by SpecularSimulation in dependence on the defined inclination angle range. If the distribution of the incident angle has non-zero mean value, an exception is thrown:

terminate called after throwing an instance of 'std::runtime_error'
  what():  Error in SpecularSimulation: parameter distribution of beam inclination angle should have zero mean.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
"""
An example of taking into account beam angular and wavelength
divergence in reflectometry calculations with BornAgain.
"""
import bornagain as ba
from bornagain import angstrom, ba_plot as bp, deg, std_samples

# input parameters
wavelength = 1.54*angstrom
alpha_i_min = 0  # min incident angle, deg
alpha_i_max = 2*deg  # max incident angle, rad

# convolution parameters
d_wl = 0.01*wavelength  # spread width for wavelength
d_ang = 0.01*deg  # spread width for incident angle
n_sig = 3  # number of sigmas to convolve over
n_points = 25  # number of points to convolve over


def get_sample():
    return std_samples.alternating_layers()


def get_simulation(sample):
    """
    Returns a specular simulation with beam and detector defined.
    """
    n = bp.simargs['n']

    alpha_distr = ba.RangedDistributionGaussian(n_points, n_sig)
    wavelength_distr = ba.RangedDistributionGaussian(n_points, n_sig)

    scan = ba.AlphaScan(wavelength, n, alpha_i_min, alpha_i_max)
    scan.setAbsoluteAngularResolution(alpha_distr, d_ang)
    scan.setAbsoluteWavelengthResolution(wavelength_distr, d_wl)

    return ba.SpecularSimulation(scan, sample)

    return simulation


if __name__ == '__main__':
    bp.parse_args(sim_n=500)
    sample = get_sample()
    simulation = get_simulation(sample)
    result = simulation.simulate()
    bp.plot_simulation_result(result)
Examples/specular/BeamFullDivergence.py