Basic

Result

Basic result

Sample

Basic sample

Python 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["bornagain>=25,<26"]
# ///
"""
"""
import numpy as np
import bornagain as ba
ba.require_versions("bornagain>=25,<26")
from bornagain import nm


def get_sample():
    # Materials
    a_color = (0.05, 0.62, 0.55)
    a_mat = ba.SLDMaterial("A", a_color, 5e-06, 0)
    substrate_color = (0.28, 0.57, 0.82)
    substrate_mat = ba.SLDMaterial("Substrate", substrate_color, 2e-06, 0)

    # Layers
    ambient_layer = ba.Layer(ba.Vacuum())
    film = ba.Layer(a_mat, 30*nm)
    substrate_layer = ba.Layer(substrate_mat)

    # Sample
    sample = ba.Sample()
    sample.addLayer(ambient_layer)
    sample.addLayer(film)
    sample.addLayer(substrate_layer)

    return sample

def get_simulation(sample):
    "Specular simulation with a qz-defined beam"
    n = 500
    qzs = np.linspace(0.01, 1, n)  # qz-values
    scan = ba.QzScan(qzs)
    return ba.SpecularSimulation(scan, sample)


if __name__ == '__main__':
    sample = get_sample()
    ba.showSample3D(sample, sample_size=80*nm, seed=0)
    simulation = get_simulation(sample)
    result = simulation.simulate()
    ba.plot_datafield(result)
    ba.plt.show()
auto/Examples/specular/basics/Basic.py