### Beam Angular Spread in Specular Simulations

This example demonstrates beam angular spread effects in reflectivity computations. It also offers a comparison with data generated using another well known code: GenX. Further information about reflectometry simulations can be found in the Reflectometry Simulation Tutorial.

The observed reflectometry signal can be affected either by a spread in the beam wavelength or in the incident angle.

In this example, a Gaussian distribution is used to spread the incident angle, with a standard deviation of $\sigma_{\alpha} = 0.01^{\circ}$.

  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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73  #!/usr/bin/env python3 """ An example of taking into account beam angular divergence and beam footprint correction in reflectometry calculations. """ import numpy as np, os, sys from matplotlib import pyplot as plt 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 beam_sample_ratio = 0.01 # beam-to-sample size ratio # convolution parameters 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 reference_data(filename): """ Loads and returns reference data from GenX simulation """ ax_values, real_data = np.loadtxt(filename, usecols=(0, 1), skiprows=3, unpack=True) # translating axis values from double incident angle # to incident angle ax_values *= 0.5 return ax_values, real_data def get_sample(): return std_samples.alternating_layers() def get_simulation(sample, **kwargs): """ Returns a specular simulation with beam and detector defined. """ n = bp.simargs['n'] footprint = ba.FootprintSquare(beam_sample_ratio) alpha_distr = ba.RangedDistributionGaussian(n_points, n_sig) scan = ba.AlphaScan(wavelength, n, alpha_i_min, alpha_i_max) scan.setFootprintFactor(footprint) scan.setAbsoluteAngularResolution(alpha_distr, d_ang) return ba.SpecularSimulation(scan, sample) if __name__ == '__main__': bp.parse_args(sim_n=500) datadir = os.getenv('BA_EXAMPLE_DATA_DIR', '') data_fname = os.path.join(datadir, "genx_angular_divergence.dat.gz") print(f"DIR={datadir} NAM={data_fname}") sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() bp.plot_simulation_result(result) genx_axis, genx_values = reference_data(data_fname) plt.yscale('log') plt.plot(genx_axis, genx_values, 'ko', markevery=300) plt.legend(['BornAgain', 'GenX'], loc='upper right') if bp.do_show: plt.show() 
Examples/specular/BeamAngularDivergence.py

Reference data: Examples/data/genx_angular_divergence.dat.gz