BornAgain  1.19.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 reflection and scattering
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 static const FormFactorComponents ff_components;
29 
30 } // namespace
31 
33  : m_ff(new FormFactorFullSphere(5.0 * Units::nm))
34 {
35 }
36 
38 
40 {
41  const double middle_layer_thickness(60.0 * Units::nm);
42 
43  Particle particle(refMat::Ag, *m_ff);
44  particle.setRotation(RotationZ(10.0 * Units::deg));
45  particle.rotate(RotationY(10.0 * Units::deg));
46  particle.rotate(RotationX(10.0 * Units::deg));
47  particle.setPosition(kvector_t(0.0, 0.0, -middle_layer_thickness / 2.0));
48 
49  ParticleLayout layout;
50  layout.addParticle(particle);
51 
52  Layer vacuum_layer(refMat::Vacuum);
54  Layer substrate(refMat::Substrate2);
55 
56  middle_layer.addLayout(layout);
57 
58  MultiLayer* multi_layer = new MultiLayer();
59  multi_layer->addLayer(vacuum_layer);
60  multi_layer->addLayer(middle_layer);
61  multi_layer->addLayer(substrate);
62  return multi_layer;
63 }
64 
66 {
67  const std::string name = ff_components.keys().at(index);
68  m_ff.reset(ff_components.getItem(name)->clone());
69  setName(name);
70  return buildSample();
71 }
72 
74 {
75  return ff_components.size();
76 }
Defines sample components for complex sample builders.
Defines class FormFactorFullSphere.
Defines class LayerInterface.
Defines class Layer.
Defines class LayersWithAbsorptionBuilder.
const double middle_layer_thickness(60.0 *Units::nm)
Defines class MultiLayer.
Defines class ParticleLayout.
Defines class Particle.
Defines materials in namespace refMat.
Defines some unit conversion factors and other constants in namespace Units.
BasicVector3D< double > kvector_t
Definition: Vectors3D.h:21
Predefined form factors for functional tests.
void setName(const std::string &name)
void setPosition(kvector_t position)
Sets relative position of the particle's reference point in the coordinate system of parent.
Definition: IParticle.h:50
void rotate(const IRotation &rotation) final
Rotates the particle.
Definition: IParticle.cpp:50
void setRotation(const IRotation &rotation)
Sets transformation.
Definition: IParticle.cpp:44
A layer in a MultiLayer sample.
Definition: Layer.h:27
void addLayout(const ParticleLayout &decoration)
Definition: Layer.cpp:58
virtual MultiLayer * buildSample() const
std::unique_ptr< IFormFactor > m_ff
MultiLayer * createSampleByIndex(size_t index)
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:41
void addLayer(const Layer &layer)
Adds layer with default (zero) roughness.
Definition: MultiLayer.cpp:53
Decorator class that adds particles to ISampleNode 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:24
A rotation about the x axis.
Definition: Rotations.h:73
A rotation about the y axis.
Definition: Rotations.h:93
A rotation about the z axis.
Definition: Rotations.h:113
QString const & name(EShape k)
Definition: particles.cpp:21
Constants and functions for physical unit conversions.
Definition: Units.h:30
static constexpr double deg
Definition: Units.h:46
static constexpr double nm
Definition: Units.h:39
static const Material Substrate2
static const Material Vacuum
static const Material Ag
static const Material Teflon