BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
MagneticLayersBuilder.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/StandardSamples/MagneticLayersBuilder.cpp
6 //! @brief Implements class to build samples with magnetic layers
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"
17 #include "Base/Util/Assert.h"
26 #include <map>
27 
28 using Units::deg;
29 
30 namespace {
31 
32 const double sphere_radius = 5;
33 
34 const std::map<std::string, std::pair<double, RoughnessModel>> RoughnessCases = {
35  {"Flat", {0., RoughnessModel::TANH}},
36  {"Tanh", {2., RoughnessModel::TANH}},
37  {"NevotCroce", {2., RoughnessModel::NEVOT_CROCE}},
38 };
39 
40 } // namespace
41 
42 // ************************************************************************************************
43 
45 {
46  R3 substr_field(0.0, 0.0, 0.0);
47  R3 particle_field(0.1, 0.0, 0.0);
48  Material vacuum_material = RefractiveMaterial("Vacuum", 0.0, 0.0);
49  Material substrate_material = RefractiveMaterial("Substrate", 7e-6, 2e-8, substr_field);
50  Material particle_material = RefractiveMaterial("MagParticle", 6e-4, 2e-8, particle_field);
51 
52  ParticleLayout particle_layout;
53  R3 position(0.0, 0.0, -10.0);
54  Sphere ff_sphere(sphere_radius);
55  Particle particle(particle_material, ff_sphere);
56  particle.translate(position);
57  particle_layout.addParticle(particle);
58 
59  Layer vacuum_layer(vacuum_material);
60  Layer substrate_layer(substrate_material);
61  substrate_layer.addLayout(particle_layout);
62 
63  auto* sample = new MultiLayer();
64  sample->addLayer(vacuum_layer);
65  sample->addLayer(substrate_layer);
66  return sample;
67 }
68 
69 // ************************************************************************************************
70 
72 {
73  auto* sample = new MultiLayer();
74 
75  R3 layer_field = R3(0.0, 1e8, 0.0);
76  Material vacuum_material = MaterialBySLD("Vacuum", 0.0, 0.0);
77  Material layer_material = MaterialBySLD("MagLayer", 1e-4, 1e-8, layer_field);
78  Material substrate_material = MaterialBySLD("Substrate", 7e-5, 2e-6);
79 
80  Layer vacuum_layer(vacuum_material);
81  Layer intermediate_layer(layer_material, 10.0); // 10 nm layer thickness
82  Layer substrate_layer(substrate_material);
83 
84  sample->addLayer(vacuum_layer);
85  sample->addLayer(intermediate_layer);
86  sample->addLayer(substrate_layer);
87  return sample;
88 }
89 
90 // ************************************************************************************************
91 
93 {
94  auto* sample = new MultiLayer();
95 
96  R3 layer_field = R3(0.0, 0.0, 1e6);
97  R3 particle_field(1e6, 0.0, 0.0);
98  Material vacuum_material = RefractiveMaterial("Vacuum0", 0.0, 0.0);
99  Material layer_material = RefractiveMaterial("Vacuum1", 0.0, 0.0, layer_field);
100  Material substrate_material = RefractiveMaterial("Substrate", 7e-6, 2e-8);
101  Material particle_material = RefractiveMaterial("MagParticle", 6e-4, 2e-8, particle_field);
102 
103  ParticleLayout particle_layout;
104  Sphere ff_sphere(sphere_radius);
105  Particle particle(particle_material, ff_sphere);
106  particle_layout.addParticle(particle);
107 
108  Layer vacuum_layer(vacuum_material);
109  vacuum_layer.addLayout(particle_layout);
110  Layer substrate_layer(substrate_material);
111 
112  sample->addLayer(vacuum_layer);
113  sample->addLayer(substrate_layer);
114  return sample;
115 }
116 
117 // ************************************************************************************************
118 
119 MultiLayer*
121 {
122  const auto& [sigmaRoughness, roughnessModel] = RoughnessCases.at(roughnessKey);
123  auto* sample = new MultiLayer();
124 
125  R3 substr_field = R3(0.0, 1e6, 0.0);
126  R3 layer_field = R3(1e6, 1e6, 0.0);
127  Material vacuum_material = RefractiveMaterial("Vacuum", 0.0, 0.0);
128  Material substrate_material = RefractiveMaterial("Substrate", 7e-6, 2e-8, substr_field);
129  Material layer_material = RefractiveMaterial("MagLayer", 6e-4, 2e-8, layer_field);
130 
131  auto roughness = LayerRoughness();
132  roughness.setSigma(sigmaRoughness * Units::angstrom);
133 
134  Layer vacuum_layer(vacuum_material);
135  Layer substrate_layer(substrate_material);
136  Layer layer(layer_material, 200 * Units::angstrom);
137  sample->addLayer(vacuum_layer);
138  sample->addLayerWithTopRoughness(layer, roughness);
139  sample->addLayerWithTopRoughness(substrate_layer, roughness);
140  sample->setRoughnessModel(roughnessModel);
141  return sample;
142 }
143 
144 // ************************************************************************************************
145 
147 {
148  auto* sample = new MultiLayer();
149 
150  R3 substr_field = R3(0.0, 1e6, 0.0);
151  R3 particle_field(1e6, 0.0, 0.0);
152  Material vacuum_material = RefractiveMaterial("Vacuum", 0.0, 0.0);
153  Material substrate_material = RefractiveMaterial("Substrate", 7e-6, 2e-8, substr_field);
154  Material particle_material = RefractiveMaterial("MagParticle", 6e-4, 2e-8, particle_field);
155 
156  ParticleLayout particle_layout;
157  R3 position(0.0, 0.0, -10.0);
158  Sphere ff_sphere(sphere_radius);
159  Particle particle(particle_material, ff_sphere);
160  RotationZ rot_z(90 * deg);
161  particle.rotate(rot_z);
162  particle.translate(position);
163  particle_layout.addParticle(particle);
164 
165  Layer vacuum_layer(vacuum_material);
166  Layer substrate_layer(substrate_material);
167  substrate_layer.addLayout(particle_layout);
168 
169  sample->addLayer(vacuum_layer);
170  sample->addLayer(substrate_layer);
171  return sample;
172 }
Defines the macro ASSERT.
Defines class LayerRoughness.
Defines class Layer.
Defines class to build samples with magnetic layers.
Factory functions used to create material instances.
Defines class MultiLayer.
Defines class ParticleLayout.
Defines class Particle.
Defines IRotation classes.
Defines class Sphere.
Defines some unit conversion factors and other constants in namespace Units.
IParticle * translate(R3 translation)
Translates the particle, and returns this.
Definition: IParticle.cpp:25
IParticle * rotate(const IRotation &rotation)
Rotates the particle, and returns this.
Definition: IParticle.cpp:41
A roughness of interface between two layers.
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
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 z axis.
Definition: Rotations.h:122
A full sphere.
Definition: Sphere.h:23
Material RefractiveMaterial(const std::string &name, complex_t refractive_index, R3 magnetization)
Material MaterialBySLD()
MultiLayer * createMagneticSubstrateZeroField()
MultiLayer * createSimpleMagneticRotationWithRoughness(const std::string &roughnessKey)
MultiLayer * createSimpleMagneticLayer()
MultiLayer * createMagneticLayer()
MultiLayer * createMagneticRotation()
static constexpr double deg
Definition: Units.h:46
static constexpr double angstrom
Definition: Units.h:34