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 
30 
31 } // namespace
32 
34  : m_ff(new FormFactorFullSphere(5.0 * Units::nanometer))
35 {
36 }
37 
39 
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);
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 
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 
75 {
76  return ff_components.size();
77 }
Defines class FormFactorFullSphere.
Defines class LayerInterface.
Defines class Layer.
Defines class LayersWithAbsorptionBuilder.
const double middle_layer_thickness(60.0 *Units::nanometer)
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.
BasicVector3D< double > kvector_t
Definition: Vectors3D.h:21
Predefined form factors for functional tests.
IFormFactor * clone() const override=0
Returns a clone of this ISample object.
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) override final
Rotates the particle.
Definition: IParticle.cpp:50
void setRotation(const IRotation &rotation)
Sets transformation.
Definition: IParticle.cpp:44
size_t size() const
Definition: IRegistry.h:48
const ValueType * getItem(const std::string &key) const
Definition: IRegistry.h:31
std::vector< std::string > keys() const
Definition: IRegistry.h:40
A layer, with thickness (in nanometer) and material.
Definition: Layer.h:28
void addLayout(const ILayout &decoration)
Definition: Layer.cpp:57
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: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
static constexpr double degree
Definition: Units.h:40
static constexpr double nanometer
Definition: Units.h:24
static const Material Substrate2
static const Material Vacuum
static const Material Ag
static const Material Teflon