BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
LayersWithAbsorptionBuilder.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/StandardSamples/LayersWithAbsorptionBuilder.cpp
6 //! @brief Implements class LayersWithAbsorptionBuilder.
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"
25 
26 namespace
27 {
28 
29 static const FormFactorComponents ff_components;
30 
31 } // namespace
32 
33 LayersWithAbsorptionBuilder::LayersWithAbsorptionBuilder()
34  : m_ff(new FormFactorFullSphere(5.0 * Units::nanometer))
35 {
36 }
37 
38 LayersWithAbsorptionBuilder::~LayersWithAbsorptionBuilder() = default;
39 
40 MultiLayer* LayersWithAbsorptionBuilder::buildSample() const
41 {
42  const double middle_layer_thickness(60.0 * Units::nanometer);
43 
44  Particle particle(refMat::Ag, *m_ff);
45  particle.setRotation(RotationZ(10.0 * Units::degree));
46  particle.rotate(RotationY(10.0 * Units::degree));
47  particle.rotate(RotationX(10.0 * Units::degree));
48  particle.setPosition(kvector_t(0.0, 0.0, -middle_layer_thickness / 2.0));
49 
50  ParticleLayout layout;
51  layout.addParticle(particle);
52 
53  Layer vacuum_layer(refMat::Vacuum);
54  Layer middle_layer(refMat::Teflon, middle_layer_thickness);
55  Layer substrate(refMat::Substrate2);
56 
57  middle_layer.addLayout(layout);
58 
59  MultiLayer* multi_layer = new MultiLayer();
60  multi_layer->addLayer(vacuum_layer);
61  multi_layer->addLayer(middle_layer);
62  multi_layer->addLayer(substrate);
63  return multi_layer;
64 }
65 
66 MultiLayer* LayersWithAbsorptionBuilder::createSampleByIndex(size_t index)
67 {
68  const std::string name = ff_components.keys().at(index);
69  m_ff.reset(ff_components.getItem(name)->clone());
70  setName(name);
71  return buildSample();
72 }
73 
74 size_t LayersWithAbsorptionBuilder::size()
75 {
76  return ff_components.size();
77 }
Defines class FormFactorFullSphere.
Defines class LayerInterface.
Defines class Layer.
Defines class LayersWithAbsorptionBuilder.
Defines class MultiLayer.
Defines class ParticleLayout.
Defines class Particle.
Defines materials in namespace refMat.
Defines sample components for complex sample builders.
Defines some unit conversion factors and other constants in namespace Units.
Predefined form factors for functional tests.
A layer, with thickness (in nanometer) and material.
Definition: Layer.h:28
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:42
void addLayer(const Layer &layer)
Adds object to multilayer.
Definition: MultiLayer.cpp:54
Decorator class that adds particles to ISample objects.
void addParticle(const IAbstractParticle &particle, double abundance=-1.0, const kvector_t position={}, const IRotation &rotation=IdentityRotation())
Adds particle to the layout with abundance, position and the rotation defined.
A particle with a form factor and refractive index.
Definition: Particle.h:26
A rotation about the x axis.
Definition: Rotations.h:72
A rotation about the y axis.
Definition: Rotations.h:93
A rotation about the z axis.
Definition: Rotations.h:114
Constants and functions for physical unit conversions.
Definition: Units.h:21