BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
SlicedCompositionBuilder.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/StandardSamples/SlicedCompositionBuilder.cpp
6 //! @brief Defines classes to build various particles crossing interfaces.
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 using Units::deg;
27 
29 {
30  const double sphere_radius = 10.0;
31  const double bottom_cup_height = 4.0;
32  const double composition_shift = bottom_cup_height;
33 
34  Particle topCup(refMat::Ag,
35  TruncatedSphere(sphere_radius, sphere_radius * 2 - bottom_cup_height, 0));
36  Particle bottomCup(refMat::Teflon, TruncatedSphere(sphere_radius, bottom_cup_height, 0));
37  bottomCup.setRotation(RotationX(180 * deg));
38 
39  ParticleComposition composition;
40  composition.addParticle(topCup, R3(0.0, 0.0, bottom_cup_height));
41  composition.addParticle(bottomCup, R3(0.0, 0.0, bottom_cup_height));
42  composition.setParticlePosition(0, 0, -composition_shift);
43 
44  ParticleLayout particle_layout;
45  particle_layout.addParticle(composition);
46 
47  Layer vacuum_layer(refMat::Vacuum);
48  vacuum_layer.addLayout(particle_layout);
49 
50  Layer substrate_layer(refMat::Substrate2);
51 
52  auto* sample = new MultiLayer();
53  sample->addLayer(vacuum_layer);
54  sample->addLayer(substrate_layer);
55  return sample;
56 }
Defines class Layer.
Defines class MultiLayer.
Defines class ParticleComposition.
Defines class ParticleLayout.
Defines class Particle.
Defines materials in namespace refMat.
Defines IRotation classes.
Defines classes to build various particles crossing interfaces.
Defines class TruncatedSphere.
Defines some unit conversion factors and other constants in namespace Units.
void setParticlePosition(R3 position)
Sets relative position of the particle's reference point in the coordinate system of parent.
Definition: IParticle.h:51
void setRotation(const IRotation &rotation)
Sets transformation.
Definition: IParticle.cpp:36
A layer in a MultiLayer sample.
Definition: Layer.h:26
void addLayout(const ParticleLayout &layout)
Definition: Layer.cpp:49
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:43
A composition of particles at fixed positions.
void addParticle(const IParticle &particle)
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 x axis.
Definition: Rotations.h:74
A truncated Sphere.
MultiLayer * createSlicedComposition()
static constexpr double deg
Definition: Units.h:46
static const Material Substrate2
static const Material Vacuum
static const Material Ag
static const Material Teflon