BATest2.py

Script to import - dmitry, 21 Mar 2018 17:55

Download (1.67 KB)

 
1
import numpy
2
import bornagain as ba
3
from bornagain import deg, angstrom, nm, kvector_t
4

    
5

    
6
def get_sample():
7
    # Defining Materials
8
    material_1 = ba.HomogeneousMaterial("example01_Air", 0.0, 0.0)
9
    material_2 = ba.HomogeneousMaterial("example01_Particle", 0.0006, 2e-08)
10
    material_3 = ba.HomogeneousMaterial("example01_Substrate", 6e-06, 2e-08)
11

    
12
    # Defining Layers
13
    layer_1 = ba.Layer(material_1)
14
    layer_2 = ba.Layer(material_3)
15

    
16
    # Defining Form Factors
17
    formFactor_1 = ba.FormFactorCylinder(5.0*nm, 5.0*nm)
18
    formFactor_2 = ba.FormFactorPrism3(10.0*nm, 5.0*nm)
19

    
20
    # Defining Particles
21
    particle_1 = ba.Particle(material_2, formFactor_1)
22
    particle_2 = ba.Particle(material_2, formFactor_2)
23

    
24
    # Defining Particle Layouts and adding Particles
25
    layout_1 = ba.ParticleLayout()
26
    layout_1.addParticle(particle_1, 0.5)
27
    layout_1.addParticle(particle_2, 0.5)
28
    layout_1.setTotalParticleSurfaceDensity(1)
29

    
30
    # Adding layouts to layers
31
    layer_1.addLayout(layout_1)
32

    
33
    # Defining Multilayers
34
    multiLayer_1 = ba.MultiLayer()
35
    multiLayer_1.addLayer(layer_1)
36
    multiLayer_1.addLayer(layer_2)
37
    return multiLayer_1
38

    
39

    
40
def get_simulation():
41
    simulation = ba.GISASSimulation()
42
    simulation.setDetectorParameters(100, -1.0*deg, 1.0*deg, 100, 0.0*deg, 2.0*deg)
43
    
44
    simulation.setBeamParameters(0.1*nm, 0.2*deg, 0.0*deg)
45
    simulation.setBeamIntensity(1.0e+08)
46
    return simulation
47

    
48

    
49
def run_simulation():
50
    sample = get_sample()
51
    simulation = get_simulation()
52
    simulation.setSample(sample)
53
    simulation.runSimulation()
54
    return simulation.result()
55

    
56

    
57
if __name__ == '__main__': 
58
    result = run_simulation()
59
    ba.plot_simulation_result(result)