BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
MagneticParticlesBuilder.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/StandardSamples/MagneticParticlesBuilder.cpp
6 //! @brief Implements classes to build magnetic samples
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 // ----------------------------------------------------------------------------
27 // Magnetic cylinders and zero magnetic field
28 // ----------------------------------------------------------------------------
29 
31 {
32  const double m_cylinder_radius(5);
33  const double m_cylinder_height(5);
34 
35  Material vacuum_material = RefractiveMaterial("Vacuum", 0.0, 0.0);
36  Material substrate_material = RefractiveMaterial("Substrate", 6e-6, 2e-8);
37  R3 magnetic_field(0.0, 0.0, 0.0);
38  Material particle_material = RefractiveMaterial("MagParticle", 6e-4, 2e-8, magnetic_field);
39 
40  Layer vacuum_layer(vacuum_material);
41  Layer substrate_layer(substrate_material);
42 
43  Cylinder ff_cylinder(m_cylinder_radius, m_cylinder_height);
44 
45  Particle particle(particle_material, ff_cylinder);
46  ParticleLayout particle_layout(particle);
47 
48  vacuum_layer.addLayout(particle_layout);
49 
50  auto* sample = new MultiLayer();
51  sample->addLayer(vacuum_layer);
52  sample->addLayer(substrate_layer);
53  return sample;
54 }
55 
56 // ----------------------------------------------------------------------------
57 // Magnetic cylinders and non-zero magnetization
58 // ----------------------------------------------------------------------------
59 
61 {
62  const double m_cylinder_radius(5);
63  const double m_cylinder_height(5);
64 
65  Material vacuum_material = RefractiveMaterial("Vacuum", 0.0, 0.0);
66  Material substrate_material = RefractiveMaterial("Substrate", 15e-6, 0.0);
67  R3 magnetization(0.0, 1e6, 0.0);
68  Material particle_material = RefractiveMaterial("MagParticle2", 5e-6, 0.0, magnetization);
69 
70  Layer vacuum_layer(vacuum_material);
71  Layer substrate_layer(substrate_material);
72 
73  Cylinder ff_cylinder(m_cylinder_radius, m_cylinder_height);
74 
75  Particle particle(particle_material, ff_cylinder);
76  ParticleLayout particle_layout(particle);
77 
78  vacuum_layer.addLayout(particle_layout);
79 
80  auto* sample = new MultiLayer();
81  sample->addLayer(vacuum_layer);
82  sample->addLayer(substrate_layer);
83  return sample;
84 }
85 
86 // ----------------------------------------------------------------------------
87 // Magnetic spheres inside substrate
88 // ----------------------------------------------------------------------------
89 
91 {
92  const double m_sphere_radius(5);
93 
94  R3 magnetization(0.0, 0.0, 1e7);
95  Material particle_material = RefractiveMaterial("Particle", 2e-5, 4e-7, magnetization);
96  Material vacuum_material = RefractiveMaterial("Vacuum", 0.0, 0.0);
97  Material substrate_material = RefractiveMaterial("Substrate", 7e-6, 1.8e-7);
98 
99  Sphere ff_sphere(m_sphere_radius);
100  Particle particle(particle_material, ff_sphere);
101  R3 position(0.0, 0.0, -2.0 * m_sphere_radius);
102  particle.translate(position);
103 
104  ParticleLayout particle_layout;
105  particle_layout.addParticle(particle);
106 
107  Layer vacuum_layer(vacuum_material);
108  Layer substrate_layer(substrate_material);
109  substrate_layer.addLayout(particle_layout);
110 
111  auto* sample = new MultiLayer();
112  sample->addLayer(vacuum_layer);
113  sample->addLayer(substrate_layer);
114  return sample;
115 }
Defines class Cylinder.
Defines class LayerInterface.
Defines class LayerRoughness.
Defines class Layer.
Defines class to build magnetic samples.
Factory functions used to create material instances.
Defines class MultiLayer.
Defines class ParticleLayout.
Defines class Particle.
Defines class Sphere.
A circular cylinder.
Definition: Cylinder.h:23
IParticle * translate(R3 translation)
Translates the particle, and returns this.
Definition: IParticle.cpp:25
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 full sphere.
Definition: Sphere.h:23
Material RefractiveMaterial(const std::string &name, complex_t refractive_index, R3 magnetization)
MultiLayer * createMagneticParticleZeroField()
MultiLayer * createMagneticSpheres()
MultiLayer * createMagneticCylinders()