File: GaussianBeams.py

package info (click to toggle)
bornagain 23.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,936 kB
  • sloc: cpp: 423,131; python: 40,997; javascript: 11,167; awk: 630; sh: 318; ruby: 173; xml: 130; makefile: 51; ansic: 24
file content (37 lines) | stat: -rwxr-xr-x 1,005 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env python3
"""
Reflectivity of a multilayer with different widths of the
Gaussian distribution of incident angles alpha_i.
"""
import numpy as np, os, sys
import bornagain as ba
from bornagain import ba_plot as bp, deg, std_samples


def get_sample():
    return std_samples.alternating_layers()


def simulate(sample, alpha_width, title):
    n = 200
    scan = ba.AlphaScan(n, 2*deg/n, 2*deg)
    scan.setWavelength(0.154)
    scan.setGrazingAngleDistribution(ba.DistributionGaussian(0, alpha_width, 25, 3.))

    result = ba.SpecularSimulation(scan, sample).simulate()
    result.setTitle(title)
    return result


if __name__ == '__main__':
    sample = get_sample()

    results = [
        simulate(sample, 0, "0 deg"),
        simulate(sample, 0.003 * deg, "0.003 deg"),
        simulate(sample, 0.01 * deg, "0.01 deg"),
        simulate(sample, 0.03 * deg, "0.03 deg"),
    ]
    plotargs = bp.parse_commandline()
    bp.plot_multicurve(results, **plotargs)
    bp.export(**plotargs)