BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
ParticleCompositionBuilder.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/StandardSamples/ParticleCompositionBuilder.cpp
6 //! @brief Implements class ParticleCompositionBuilder.
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 
25 
26 // --- ParticleCompositionBuilder ---
27 
29 {
30  Layer vacuum_layer(refMat::Vacuum);
31  Layer substrate_layer(refMat::Substrate);
32 
33  double radius(10.0);
34  Sphere sphere_ff(radius);
35  Particle sphere(refMat::Particle, sphere_ff);
36  ParticleLayout particle_layout;
37 
38  std::vector<R3> positions = {{},
39  {radius, radius / std::sqrt(3.0), std::sqrt(8.0 / 3.0) * radius}};
40 
41  ParticleComposition basis;
42 
43  basis.addParticles(sphere, positions);
44  particle_layout.addParticle(basis);
45 
46  Interference2DLattice iff(HexagonalLattice2D(radius * 2.0, 0));
47  Profile2DCauchy pdf(10, 10, 0);
48  iff.setDecayFunction(pdf);
49 
50  particle_layout.setInterference(iff);
51 
52  vacuum_layer.addLayout(particle_layout);
53 
54  auto* sample = new MultiLayer();
55  sample->addLayer(vacuum_layer);
56  sample->addLayer(substrate_layer);
57  return sample;
58 }
Defines class Interference2DLattice.
Defines class Layer.
Defines class MultiLayer.
Defines class ParticleCompositionBuilder.
Defines class ParticleComposition.
Defines class ParticleLayout.
Defines class Particle.
Defines interface class IProfile2D, and children thereof.
Defines materials in namespace refMat.
Defines class Sphere.
A two-dimensional Bravais lattice with hexagonal symmetry.
Definition: Lattice2D.h:98
Interference function of a 2D lattice.
void setDecayFunction(const IProfile2D &decay)
Sets two-dimensional decay function.
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 addParticles(const IParticle &particle, std::vector< R3 > positions)
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.
void setInterference(const IInterference &interparticle)
Adds interference functions.
A particle with a form factor and refractive index.
Definition: Particle.h:25
Two-dimensional Cauchy distribution in Fourier space; corresponds to a normalized exp(-r) in real spa...
Definition: Profiles2D.h:71
A full sphere.
Definition: Sphere.h:23
MultiLayer * createParticleComposition()
static const Material Vacuum
static const Material Particle
static const Material Substrate