#!/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.
"""importbornagainasbafrombornagainimportba_plotasbp,deg,angstrom,std_samplesdefget_sample():returnstd_samples.alternating_layers()defget_simulation(sample):"""
A standard specular simulation setup.
"""n=bp.simargs['n']scan=ba.AlphaScan(n,2*deg/n,2*deg)scan.setWavelength(1.54*angstrom)returnba.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.