SLD profile with a sliced particle layer

This example shows how to plot a z dependent Scattering Length Density (SLD) profile caused by a dense assembly of conical particles.

The staircase profile comes from slicing of the vacuum layer that accounts for the z dependent particle density. The slicing is specified by the statement

ambient_layer.setNumberOfSlices(20).
 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
#!/usr/bin/env python3
"""
Plot an SLD profile for a sample with a sliced particle layer.
"""

import bornagain as ba
from bornagain import angstrom, ba_plot as bp, deg, nm, sample_tools
import numpy as np
import matplotlib.pyplot as plt


def get_sample():
    # materials
    vacuum = ba.MaterialBySLD("Vacuum", 0, 0)
    material_particle = ba.MaterialBySLD("Particle", 5e-6, 0)
    material_substrate = ba.MaterialBySLD("SiSubstrate", 2.0704e-06, 0)

    # layers
    ambient_layer = ba.Layer(vacuum)
    substrate_layer = ba.Layer(material_substrate)

    # particle layout
    ff = ba.Cone(5*nm, 10*nm, 75*deg)
    particle = ba.Particle(material_particle, ff)
    layout = ba.ParticleLayout()
    layout.addParticle(particle)
    iff = ba.Interference2DLattice(ba.SquareLattice2D(10*nm, 0))
    layout.setInterference(iff)
    ambient_layer.addLayout(layout)
    ambient_layer.setNumberOfSlices(20)

    # sample
    sample = ba.MultiLayer()
    sample.addLayer(ambient_layer)
    sample.addLayer(substrate_layer)

    return sample


if __name__ == '__main__':
    sample = get_sample()
    zpoints, slds = sample_tools.materialProfile(sample, 400)

    plt.figure()
    plt.plot(zpoints, np.real(slds))

    bp.show_or_export()
auto/Examples/varia/MaterialProfileWithParticles.py