### 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.

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  #!/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 # convolution parameters d_wl = 0.01*wavelength # spread width for wavelength d_ang = 0.01*deg # spread width for incident angle 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'] scan = ba.AlphaScan(n, 2*deg/n, 2*deg) alpha_distr = ba.DistributionGaussian(0, d_ang, 25, 3.) scan.setAngleDistribution(alpha_distr) wavelength_distr = ba.DistributionGaussian(wavelength, d_wl, 25, 3.) scan.setWavelengthDistribution(wavelength_distr) 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