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
|
#!/usr/bin/env python3
"""
Basic example of specular reflectometry simulation,
using a standard sample from Wrap/Python/std_samples.py.
"""
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):
n = <%= test_mode ? 50 : 500 %>
scan = ba.AlphaScan(n, 2*deg/n, 2*deg)
scan.setWavelength(1.54*angstrom)
return ba.SpecularSimulation(scan, sample)
if __name__ == '__main__':
sample = get_sample()
simulation = get_simulation(sample)
result = simulation.simulate()
<%- if test_mode -%>
from bornagain import ba_check
ba_check.persistence_test(result)
<%- elsif figure_mode -%>
plotargs = bp.parse_commandline()
bp.plot_datafield(result, **plotargs)
bp.export(**plotargs)
<%- else -%>
bp.plot_datafield(result)
bp.plt.show()
<%- end -%>
|