BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
InterferenceItems.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Sample/InterferenceItems.cpp
6 //! @brief Implements InterferenceItems's classes
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2021
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include "Base/Const/Units.h"
23 #include "Sample/Aggregate/Interferences.h"
24 
26 {
27  m_positionVariance.init("PositionVariance", "Variance of the position in each dimension", 0.0,
28  Unit::nanometer2, "PositionVariance");
29 }
30 
32 {
33  return m_positionVariance;
34 }
35 
37 {
38  s.assertVersion(0);
40 }
41 
42 // --------------------------------------------------------------------------------------------- //
43 
45 {
46  m_length.init("Length", "Lattice length", 20.0, Unit::nanometer, "Length");
48  "Xi", "Rotation of lattice with respect to x-axis of reference frame (beam direction)", 0.0,
49  Unit::degree, "xi");
51  "Decay Function", "One-dimensional decay function (finite size effects)", "decay");
52 }
53 
54 std::unique_ptr<IInterference> Interference1DLatticeItem::createInterference() const
55 {
56  auto result =
57  std::make_unique<Interference1DLattice>(m_length, Units::deg2rad(m_rotationAngle));
58  result->setDecayFunction(*m_decayFunction->createProfile());
59  result->setPositionVariance(positionVariance());
60  return std::unique_ptr<IInterference>(result.release());
61 }
62 
64 {
65  return m_length;
66 }
67 
69 {
70  return m_rotationAngle;
71 }
72 
74 {
76 }
77 
79 {
80  return m_decayFunction;
81 }
82 
84 {
85  s.assertVersion(0);
89  Serialize::rwSelected<Profile1DItemCatalog>(s, m_decayFunction);
90 }
91 
92 // --------------------------------------------------------------------------------------------- //
93 
95 {
96  return m_latticeType;
97 }
98 
100 {
101  m_latticeType.set(p);
102 }
103 
105 {
106  return m_xiIntegration;
107 }
108 
110 {
112 }
113 
115  : m_xiIntegration(xiIntegration)
116 {
117  m_latticeType.init<Lattice2DItemCatalog>("Lattice type", "", "latticeType");
119 }
120 
121 // --------------------------------------------------------------------------------------------- //
122 
125 {
127  "Decay Function", "Two-dimensional decay function (finite size effects)", "decay");
128 }
129 
130 std::unique_ptr<IInterference> Interference2DLatticeItem::createInterference() const
131 {
132  Lattice2DItem* latticeItem = latticeType().currentItem();
133  std::unique_ptr<Interference2DLattice> result(
134  new Interference2DLattice(*latticeItem->createLattice()));
135 
136  result->setDecayFunction(*m_decayFunction->createProfile());
137  result->setIntegrationOverXi(xiIntegration());
138  result->setPositionVariance(positionVariance());
139 
140  return std::unique_ptr<IInterference>(result.release());
141 }
142 
144 {
145  s.assertVersion(0);
147  Serialize::rwValue(s, "integrate", m_xiIntegration);
148  Serialize::rwSelected<Lattice2DItemCatalog>(s, m_latticeType);
149  Serialize::rwSelected<Profile2DItemCatalog>(s, m_decayFunction);
150 }
151 
153 {
154  m_decayFunction.set(p);
155 }
156 
158 {
159  return m_decayFunction;
160 }
161 
162 // --------------------------------------------------------------------------------------------- //
163 
166 {
167  m_dampingLength.init("Damping length", "The damping (coherence) length of the paracrystal", 0.0,
168  Unit::nanometer, "dampingLen");
169  m_domainSize1.init("Domain size 1", "Size of the coherent domain along the first basis vector",
170  20000.0, Unit::nanometer, "size1");
171  m_domainSize2.init("Domain size 2", "Size of the coherent domain along the second basis vector",
172  20000.0, Unit::nanometer, "size2");
174  "PDF 1", "Probability distribution in first lattice direction", "pdf1");
176  "PDF 2", "Probability distribution in second lattice direction", "pdf2");
177 }
178 
179 std::unique_ptr<IInterference> Interference2DParaCrystalItem::createInterference() const
180 {
181  Lattice2DItem* latticeItem = latticeType().currentItem();
182 
183  std::unique_ptr<Interference2DParaCrystal> result(
184  new Interference2DParaCrystal(*latticeItem->createLattice(), 0, 0, 0));
185 
186  result->setDampingLength(m_dampingLength);
187  result->setDomainSizes(m_domainSize1, m_domainSize2);
188  result->setIntegrationOverXi(xiIntegration());
189  result->setProbabilityDistributions(*m_pdf1->createProfile(), *m_pdf2->createProfile());
190  result->setPositionVariance(positionVariance());
191  return std::unique_ptr<IInterference>(result.release());
192 }
193 
195 {
196  s.assertVersion(0);
198  Serialize::rwValue(s, "integrate", m_xiIntegration);
199  Serialize::rwSelected<Lattice2DItemCatalog>(s, m_latticeType);
203  Serialize::rwSelected<Profile2DItemCatalog>(s, m_pdf1);
204  Serialize::rwSelected<Profile2DItemCatalog>(s, m_pdf2);
205 }
206 
208 {
209  return m_dampingLength;
210 }
211 
213 {
215 }
216 
218 {
219  return m_domainSize1;
220 }
221 
223 {
224  m_domainSize1.set(size);
225 }
226 
228 {
229  return m_domainSize2;
230 }
231 
233 {
234  m_domainSize2.set(size);
235 }
236 
238 {
239  return m_pdf1;
240 }
241 
243 {
244  m_pdf1.set(p);
245 }
246 
248 {
249  return m_pdf2;
250 }
251 
253 {
254  m_pdf2.set(p);
255 }
256 
257 // --------------------------------------------------------------------------------------------- //
258 
261 {
262  m_domainSize1.init("Domain size 1", "Domain size 1 in number of unit cells", 100,
263  Unit::unitless, "size1");
264  m_domainSize2.init("Domain size 2", "Domain size 2 in number of unit cells", 100,
265  Unit::unitless, "size2");
266 }
267 
268 std::unique_ptr<IInterference> InterferenceFinite2DLatticeItem::createInterference() const
269 {
270  Lattice2DItem* latticeItem = latticeType().currentItem();
271  auto result = std::make_unique<InterferenceFinite2DLattice>(*latticeItem->createLattice(),
273 
274  result->setIntegrationOverXi(xiIntegration());
275  result->setPositionVariance(positionVariance());
276 
277  return result;
278 }
279 
281 {
282  s.assertVersion(0);
284  Serialize::rwValue(s, "integrate", m_xiIntegration);
285  Serialize::rwSelected<Lattice2DItemCatalog>(s, m_latticeType);
288 }
289 
291 {
292  return m_domainSize1;
293 }
294 
296 {
297  m_domainSize1.set(size);
298 }
299 
301 {
302  return m_domainSize2;
303 }
304 
306 {
307  m_domainSize2.set(size);
308 }
309 
310 // --------------------------------------------------------------------------------------------- //
311 
313 {
314  m_radius.init("Radius", "Hard disk radius", 5.0, Unit::nanometer, "radius");
315  m_density.init("Total particle density", "Particle density in particles per area", 0.002,
316  Unit::nanometerMinus2, "density");
317 }
318 
319 std::unique_ptr<IInterference> InterferenceHardDiskItem::createInterference() const
320 {
321  auto result = std::make_unique<InterferenceHardDisk>(m_radius, m_density);
322  result->setPositionVariance(positionVariance());
323  return std::unique_ptr<IInterference>(result.release());
324 }
325 
327 {
328  s.assertVersion(0);
332 }
333 
335 {
336  return m_density;
337 }
338 
340 {
341  return m_radius;
342 }
343 
344 // --------------------------------------------------------------------------------------------- //
345 
347 {
348  m_peakDistance.init("Peak distance", "Average distance to the next neighbor", 20.0,
349  Unit::nanometer, "peak");
350  m_dampingLength.init("Damping length", "The damping (coherence) length of the paracrystal",
351  1000.0, Unit::nanometer, "dampingLen");
352  m_domainSize.init("Domain size", "Size of coherence domain along the lattice main axis", 0.0,
353  Unit::nanometer, "size");
354  m_kappa.init("SizeSpaceCoupling",
355  "Size spacing coupling parameter of the Size Spacing Correlation Approximation",
356  0.0, Unit::unitless, "kappa");
357  m_pdf.init<Profile1DItemCatalog>("PDF", "One-dimensional probability distribution", "pdf");
358 }
359 
360 std::unique_ptr<IInterference> InterferenceRadialParaCrystalItem::createInterference() const
361 {
362  auto result = std::make_unique<InterferenceRadialParaCrystal>(m_peakDistance, m_dampingLength);
363  result->setDomainSize(m_domainSize);
364  result->setKappa(m_kappa);
365  auto pdf = m_pdf->createProfile();
366  result->setProbabilityDistribution(*pdf);
367  result->setPositionVariance(positionVariance());
368  return std::unique_ptr<IInterference>(result.release());
369 }
370 
372 {
373  s.assertVersion(0);
379  Serialize::rwSelected<Profile1DItemCatalog>(s, m_pdf);
380 }
381 
383 {
384  return m_peakDistance;
385 }
386 
388 {
389  return m_dampingLength;
390 }
391 
393 {
394  return m_domainSize;
395 }
396 
398 {
399  return m_kappa;
400 }
401 
404 {
405  return m_pdf;
406 }
407 
409 {
410  m_pdf.set(p);
411 }
Defines InterferenceItems's classes.
Defines class Lattice2DItemCatalog.
Defines classes Lattice2DItems.
Defines ProfileItemCatalog classes.
Defines Profile1DItem's classes.
Defines class Streamer.
Defines class UIntDescriptor.
@ nanometerMinus2
@ nanometer2
@ unitless
@ nanometer
@ degree
Describes properties of a double value which are necessary to allow GUI representation,...
void set(double d)
Set the contained value.
void init(const QString &label, const QString &tooltip, double value, const variant< QString, Unit > &unit, const QString &persistentTag)
SelectionProperty< Profile1DItem * > m_decayFunction
void serialize(Streamer &s) override
DoubleDescriptor length() const
std::unique_ptr< IInterference > createInterference() const override
void setDecayFunction(Profile1DItem *p)
SelectionDescriptor< Profile1DItem * > decayFunction() const
DoubleDescriptor rotationAngle() const
void setLatticeType(Lattice2DItem *p)
SelectionDescriptor< Lattice2DItem * > latticeType() const
Interference2DAbstractLatticeItem(bool xiIntegration)
SelectionProperty< Lattice2DItem * > m_latticeType
void setXiIntegration(bool xiIntegration)
SelectionProperty< Profile2DItem * > m_decayFunction
void setDecayFunctionType(Profile2DItem *p)
void serialize(Streamer &s) override
std::unique_ptr< IInterference > createInterference() const override
SelectionDescriptor< Profile2DItem * > decayFunction() const
SelectionDescriptor< Profile2DItem * > probabilityDistribution2() const
DoubleDescriptor dampingLength() const
void setPDF2Type(Profile2DItem *p)
void serialize(Streamer &s) override
void setDampingLength(double dampingLength)
DoubleDescriptor domainSize1() const
DoubleDescriptor domainSize2() const
std::unique_ptr< IInterference > createInterference() const override
void setPDF1Type(Profile2DItem *p)
SelectionProperty< Profile2DItem * > m_pdf1
SelectionProperty< Profile2DItem * > m_pdf2
SelectionDescriptor< Profile2DItem * > probabilityDistribution1() const
void serialize(Streamer &s) override
void setDomainSize1(unsigned int domain_size1)
void setDomainSize2(unsigned int domain_size2)
UIntDescriptor domainSize2() const
std::unique_ptr< IInterference > createInterference() const override
UIntDescriptor domainSize1() const
DoubleDescriptor density() const
void serialize(Streamer &s) override
DoubleDescriptor radius() const
std::unique_ptr< IInterference > createInterference() const override
virtual void serialize(Streamer &s)=0
DoubleDescriptor positionVariance() const
DoubleProperty m_positionVariance
SelectionDescriptor< Profile1DItem * > probabilityDistribution() const
DoubleDescriptor dampingLength() const
void serialize(Streamer &s) override
SelectionProperty< Profile1DItem * > m_pdf
std::unique_ptr< IInterference > createInterference() const override
DoubleDescriptor domainSize() const
DoubleDescriptor peakDistance() const
virtual std::unique_ptr< Lattice2D > createLattice() const =0
virtual std::unique_ptr< IProfile1D > createProfile() const =0
virtual std::unique_ptr< IProfile2D > createProfile() const =0
Describes a selection (various possibilities and the current one).
void set(T t, bool callInitializer=false)
Directly set the new item.
void init(const QString &label, const QString &tooltip, const QString &persistentTag, ArgsForCreation... argsForCreation)
Initialize by means of a catalog class and optional creation arguments.
Supports serialization to or deserialization from QXmlStream.
Definition: Streamer.h:36
void assertVersion(unsigned expectedVersion) const
As reader, throws DeserializationException unless the expected version is read. As writer,...
Definition: Streamer.cpp:26
Describes properties of a uint value which are necessary to allow GUI representation,...
void set(uint d)
Definition: UIntProperty.h:50
void init(const QString &label, const QString &tooltip, uint value, const variant< QString, Unit > &unit, const QString &persistentTag)
void rwProperty(Streamer &s, DoubleProperty &d)
void rwValue(Streamer &s, const QString &tag, bool &val)
Definition: Serialize.cpp:19