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
48
49
#!/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
    m_ambient = ba.MaterialBySLD("Ambient", 0, 0)
    m_particle = ba.MaterialBySLD("Particle", 5e-6, 0)
    m_substrate = ba.MaterialBySLD("SiSubstrate", 2.0704e-06, 0)

    # layers
    ambient_layer = ba.Layer(m_ambient)
    substrate_layer = ba.Layer(m_substrate)

    # particle layout
    ff = ba.Cone(5*nm, 10*nm, 75*deg)
    particle = ba.Particle(m_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__':
    bp.parse_args()

    sample = get_sample()
    zpoints, slds = sample_tools.materialProfile(sample, 400)

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

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