BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
CoreShellParticleBuilder.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/StandardSamples/CoreShellParticleBuilder.cpp
6 //! @brief Implements class CoreShellParticleBuilder.
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 
28 // --- CoreShellParticleBuilder ---
29 
31 {
32  complex_t n_particle_shell(1.0 - 1e-4, 2e-8);
33  complex_t n_particle_core(1.0 - 6e-5, 2e-8);
34 
35  Material shell_material = RefractiveMaterial("Shell", n_particle_shell);
36  Material core_material = RefractiveMaterial("Core", n_particle_core);
37 
38  Layer vacuum_layer(refMat::Vacuum);
39 
40  Box ff_box1(16, 16, 8);
41  Particle shell_particle(shell_material, ff_box1);
42 
43  Box ff_box2(12, 12, 7);
44  Particle core_particle(core_material, ff_box2);
45 
46  R3 core_position(0.0, 0.0, 0.0);
47  ParticleCoreShell particle(shell_particle, core_particle, core_position);
48 
49  ParticleLayout particle_layout(particle);
50  vacuum_layer.addLayout(particle);
51 
52  auto* sample = new MultiLayer();
53  sample->addLayer(vacuum_layer);
54  return sample;
55 }
56 
57 // --- CoreShellBoxRotateZandYBuilder ---
58 
60 {
61  const double layer_thickness(100.0);
62 
63  // core shell particle
64  const double shell_length(50.0);
65  const double shell_width(20.0);
66  const double shell_height(10.0);
67  double core_length = shell_length / 2.0;
68  double core_width = shell_width / 2.0;
69  double core_height = shell_height / 2.0;
70 
71  Particle core(refMat::Ag, Box(core_length, core_width, core_height));
72  Particle shell(refMat::AgO2, Box(shell_length, shell_width, shell_height));
73  ParticleCoreShell coreshell(shell, core, R3(0.0, 0.0, (shell_height - core_height) / 2.0));
74  coreshell.setRotation(RotationZ(90.0 * deg));
75  coreshell.rotate(RotationY(90.0 * deg));
76  coreshell.setParticlePosition(R3(0.0, 0.0, -layer_thickness / 2.0));
77 
78  ParticleLayout layout;
79  layout.addParticle(coreshell);
80 
81  Layer vacuum_layer(refMat::Vacuum);
82  Layer middle_layer(refMat::Teflon, layer_thickness);
83  middle_layer.addLayout(layout);
84  Layer substrate(refMat::Substrate2);
85 
86  auto* sample = new MultiLayer();
87  sample->addLayer(vacuum_layer);
88  sample->addLayer(middle_layer);
89  sample->addLayer(substrate);
90 
91  return sample;
92 }
Defines class Box.
Defines class CoreShellParticleBuilder.
Defines class Layer.
Defines class MultiLayer.
Defines ParticleCoreShell.
Defines class ParticleLayout.
Defines class Particle.
Defines materials in namespace refMat.
Defines IRotation classes.
Defines some unit conversion factors and other constants in namespace Units.
A rectangular prism (parallelepiped).
Definition: Box.h:23
void setParticlePosition(R3 position)
Sets relative position of the particle's reference point in the coordinate system of parent.
Definition: IParticle.h:51
IParticle * rotate(const IRotation &rotation)
Rotates the particle, and returns this.
Definition: IParticle.cpp:41
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
A wrapper for underlying material implementation.
Definition: Material.h:35
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:43
A particle with a core/shell geometry.
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 y axis.
Definition: Rotations.h:98
A rotation about the z axis.
Definition: Rotations.h:122
Material RefractiveMaterial(const std::string &name, complex_t refractive_index, R3 magnetization)
MultiLayer * createCoreShellParticle()
MultiLayer * createCoreShellBoxRotateZandY()
static constexpr double deg
Definition: Units.h:46
static const Material Substrate2
static const Material Vacuum
static const Material Ag
static const Material Teflon
static const Material AgO2