## Specular reflectometry simulation

As introductory example, we simulate specular reflectometry by a sample that consists of 10 Ti/Ni double layers on a Si substrate.

The same script has been used in preceding pages to explain usage and syntax of BornAgain Python code.

### Example script

To generate this image

run this script:

  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  #!/usr/bin/env python3 """ Basic example of specular reflectometry simulation with BornAgain. The sample consists of 20 alternating Ti and Ni layers. Variant with explicit function get_simulation. """ import bornagain as ba from bornagain import ba_plot as bp, deg, angstrom, std_samples def get_sample(): return std_samples.alternating_layers() def get_simulation(sample): """ A standard specular simulation setup. """ n = bp.simargs['n'] scan = ba.AlphaScan(1.54*angstrom, n, 0, 2*deg) return ba.SpecularSimulation(scan, sample) 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/AlternatingLayers2.py

### Explanation

The function get_simulation constructs a SpecularSimulation. The constructor AlphaScan defines a scan as function of inclination angles. The arguments are wavelength, number of points, initial angle, final angle.

The Main program has been explained in the Syntax page. For alternative ways of running simulations and plotting or exporting results, see section Plot and export.