BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
CustomMorphologyBuilder.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/StandardSamples/CustomMorphologyBuilder.cpp
6 //! @brief Implements class CustomMorphologyBuilder.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include "Base/Const/Units.h"
24 
25 using Units::deg;
26 
28 {
29  Material mat_vacuum = refMat::Vacuum;
30  Material mat_particle = refMat::Particle;
31 
32  Layer vacuum_layer(mat_vacuum);
33  ParticleLayout particle_layout;
34 
35  // add particle number 1:
36  Box ff1(2.0, 2.0, 1.0);
37  R3 pos1(0.0, 0.0, 0.0);
38  Particle p1(mat_particle, ff1);
39  p1.setParticlePosition(pos1);
40  particle_layout.addParticle(p1, 0.5);
41  // add particle number 2:
42  Box ff2(2.0, 4.0, 1.0);
43  R3 pos2(5.0, 5.0, 0.0);
44  RotationZ m2(10 * deg);
45  Particle p2(mat_particle, ff2, m2);
46  p2.setParticlePosition(pos2);
47  particle_layout.addParticle(p2, 0.5);
48  // add particle number 3:
49  Box ff3(2.0, 6.0, 1.0);
50  R3 pos3(-5.0, -5.0, 0.0);
51  RotationZ m3(20 * deg);
52  Particle p3(mat_particle, ff3, m3);
53  p3.setParticlePosition(pos3);
54  particle_layout.addParticle(p3, 0.5);
55  // add particle number 4:
56  Box ff4(2.0, 8.0, 1.0);
57  R3 pos4(5.0, -5.0, 0.0);
58  RotationZ m4(30 * deg);
59  Particle p4(mat_particle, ff4, m4);
60  p4.setParticlePosition(pos4);
61  particle_layout.addParticle(p4, 0.5);
62  // add particle number 5:
63  Box ff5(2.0, 10.0, 1.0);
64  R3 pos5(-5.0, 5.0, 0.0);
65  RotationZ m5(40 * deg);
66  Particle p5(mat_particle, ff5, m5);
67  p5.setParticlePosition(pos5);
68  particle_layout.addParticle(p5, 0.5);
69  // add particle number 6:
70  Box ff6(2.0, 2.0, 1.0);
71  R3 pos6(0.0, 0.0, 0.0);
72  RotationZ m6(50 * deg);
73  Particle p6(mat_particle, ff6, m6);
74  p6.setParticlePosition(pos6);
75  particle_layout.addParticle(p6, 0.5);
76  // add particle number 7:
77  Box ff7(2.0, 4.0, 1.0);
78  R3 pos7(5.0, 5.0, 0.0);
79  RotationZ m7(60 * deg);
80  Particle p7(mat_particle, ff7, m7);
81  p7.setParticlePosition(pos7);
82  particle_layout.addParticle(p7, 0.5);
83  // add particle number 8:
84  Box ff8(2.0, 6.0, 1.0);
85  R3 pos8(-5.0, -5.0, 0.0);
86  RotationZ m8(70 * deg);
87  Particle p8(mat_particle, ff8, m8);
88  p8.setParticlePosition(pos8);
89  particle_layout.addParticle(p8, 0.5);
90  // add particle number 9:
91  Box ff9(2.0, 8.0, 1.0);
92  R3 pos9(5.0, -5.0, 0.0);
93  RotationZ m9(80 * deg);
94  Particle p9(mat_particle, ff9, m9);
95  p9.setParticlePosition(pos9);
96  particle_layout.addParticle(p9, 0.5);
97  // add particle number 10:
98  Box ff10(2.0, 10.0, 1.0);
99  R3 pos10(-5.0, 5.0, 0.0);
100  RotationZ m10(90 * deg);
101  Particle p10(mat_particle, ff10, m10);
102  p10.setParticlePosition(pos10);
103  particle_layout.addParticle(p10, 0.5);
104  vacuum_layer.addLayout(particle_layout);
105 
106  auto* sample = new MultiLayer();
107  sample->addLayer(vacuum_layer);
108  return sample;
109 }
Defines class Box.
Defines class CustomMorphologyBuilder.
Defines class Layer.
Defines class MultiLayer.
Defines class ParticleLayout.
Defines class Particle.
Defines materials in namespace refMat.
Defines IRotation classes.
Defines some unit conversion factors and other constants in namespace Units.
A rectangular prism (parallelepiped).
Definition: Box.h:23
void setParticlePosition(R3 position)
Sets relative position of the particle's reference point in the coordinate system of parent.
Definition: IParticle.h:51
A layer in a MultiLayer sample.
Definition: Layer.h:26
void addLayout(const ParticleLayout &layout)
Definition: Layer.cpp:49
A wrapper for underlying material implementation.
Definition: Material.h:35
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:43
Decorator class that adds particles to ISampleNode objects.
void addParticle(const IParticle &particle, double abundance=-1.0)
Adds particle to the layout with abundance, position and the rotation defined.
A particle with a form factor and refractive index.
Definition: Particle.h:25
A rotation about the z axis.
Definition: Rotations.h:122
MultiLayer * createCustomMorphology()
static constexpr double deg
Definition: Units.h:46
static const Material Vacuum
static const Material Particle