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
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#!/usr/bin/env python3
"""
In this example we demonstrate how to plot a simulation result with
axes in different units (nbins, mm, degs and QyQz).
"""
import bornagain as ba
from bornagain import angstrom, ba_plot as bp, deg, nm
from matplotlib import rcParams
def get_sample():
# Materials
air_color = (0.90, 0.93, 0.97)
air_mat = ba.RefractiveMaterial("Air", air_color, 0, 0)
particle_color = (0.86, 0.24, 0.18)
particle_mat = ba.RefractiveMaterial("Particle", particle_color, 6e-5, 2e-08)
substrate_color = (0.28, 0.57, 0.82)
substrate_mat = ba.RefractiveMaterial("Substrate", substrate_color, 6e-06, 2e-08)
# Particles
R = 2.5*nm
ff = ba.Spheroid(R, R)
particle = ba.Particle(particle_mat, ff)
# Interference function
lattice = ba.SquareLattice2D(10*nm, 2*deg)
layout = ba.Crystal2D(particle, lattice)
pdf = ba.Profile2DCauchy(50*nm, 50*nm, 0)
layout.setDecayFunction(pdf)
# Layers
l_air = ba.Layer(air_mat)
l_air.deposit2D(layout)
l_substrate = ba.Layer(substrate_mat)
# Sample
sample = ba.Sample()
sample.addLayer(l_air)
sample.addLayer(l_substrate)
return sample
def get_simulation(sample, wavelength, alpha_i):
beam = ba.Beam(1e9, wavelength, alpha_i)
n = 200
detector = ba.SphericalDetector(n, -1*deg, 1*deg, n, 0, 1*deg)
simulation = ba.ScatteringSimulation(beam, sample, detector)
return simulation
if __name__ == '__main__':
sample = get_sample()
wavelength = 0.04*nm
alpha_i = 0.2*deg
simulation = get_simulation(sample, wavelength, alpha_i)
result = simulation.simulate()
trafo = ba.FrameTrafo.ScatteringToQ(wavelength, alpha_i)
res2 = trafo.transformedDatafield(result)
ba.showSample3D(sample, sample_size=100*nm, seed=0)
bp.plot_datafield(res2, unit_aspect=1)
bp.plt.show()
|