BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
FormFactorItems.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Sample/FormFactorItems.cpp
6 //! @brief Implements FormFactorItems 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 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include "Base/Const/Units.h"
17 #include "Sample/HardParticle/HardParticles.h"
18 
19 /* ------------------------------------------------ */
20 
22 {
23  m_length.init("Length", "Length of the rectangular base", 20.0, Unit::nanometer, "length");
24  m_width.init("Width", "Width of the rectangular base", 16.0, Unit::nanometer, "width");
25  m_height.init("Height", "Height of pyramid", 13.0, Unit::nanometer, "height");
26  m_alpha.init("Alpha", "Dihedral angle between base and facet", 60.0, Unit::degree, "alpha");
27 }
28 
29 std::unique_ptr<IFormFactor> Pyramid2Item::createFormFactor() const
30 {
31  return std::make_unique<Pyramid2>(length(), width(), height(), alpha() * Units::deg);
32 }
33 
34 /* ------------------------------------------------ */
35 
37 {
38  m_length.init("Length", "Length of the base", 20.0, Unit::nanometer, "length");
39  m_width.init("Width", "Width of the base", 16.0, Unit::nanometer, "width");
40  m_height.init("Height", "Height of the box", 13.0, Unit::nanometer, "height");
41 }
42 
43 std::unique_ptr<IFormFactor> BarGaussItem::createFormFactor() const
44 {
45  return std::make_unique<BarGauss>(length(), width(), height());
46 }
47 
48 /* ------------------------------------------------ */
49 
51 {
52  m_length.init("Length", "Length of the base", 20.0, Unit::nanometer, "length");
53  m_width.init("Width", "Width of the base", 16.0, Unit::nanometer, "width");
54  m_height.init("Height", "Height of the box", 13.0, Unit::nanometer, "height");
55 }
56 
57 std::unique_ptr<IFormFactor> BarLorentzItem::createFormFactor() const
58 {
59  return std::make_unique<BarLorentz>(length(), width(), height());
60 }
61 
62 /* ------------------------------------------------ */
63 
65 {
66  m_length.init("Length", "Length of the base", 20.0, Unit::nanometer, "length");
67  m_width.init("Width", "Width of the base", 16.0, Unit::nanometer, "width");
68  m_height.init("Height", "Height of the box", 13.0, Unit::nanometer, "height");
69 }
70 
71 std::unique_ptr<IFormFactor> BoxItem::createFormFactor() const
72 {
73  return std::make_unique<Box>(length(), width(), height());
74 }
75 
76 /* ------------------------------------------------ */
77 
79 {
80  m_radius.init("Radius", "Radius of the base", 10.0, Unit::nanometer, "radius");
81  m_height.init("Height", "Height of the cone", 13.0, Unit::nanometer, "height");
82  m_alpha.init("Alpha", "Angle between the base and the side surface", 60.0, Unit::degree,
83  "alpha");
84 }
85 
86 std::unique_ptr<IFormFactor> ConeItem::createFormFactor() const
87 {
88  return std::make_unique<Cone>(radius(), height(), alpha() * Units::deg);
89 }
90 
91 /* ------------------------------------------------ */
92 
94 {
95  m_baseEdge.init("Base edge", "Edge of the regular hexagonal base", 10.0, Unit::nanometer,
96  "baseEdge");
97  m_height.init("Height", "Height of a truncated pyramid", 13.0, Unit::nanometer, "height");
98  m_alpha.init("Alpha", "Dihedral angle between base and facet", 60.0, Unit::degree, "alpha");
99 }
100 
101 std::unique_ptr<IFormFactor> Pyramid6Item::createFormFactor() const
102 {
103  return std::make_unique<Pyramid6>(baseEdge(), height(), alpha() * Units::deg);
104 }
105 
106 /* ------------------------------------------------ */
107 
109 {
110  m_length.init("Length", "Side length of the common square base", 20.0, Unit::nanometer,
111  "length");
112 
113  m_height.init("Height", "Height of the lower pyramid", 13.0, Unit::nanometer, "height");
114 
115  m_heightRatio.init("Height ratio", "Ratio of heights of top to bottom pyramids", 0.7,
116  Unit::unitless, 3, RealLimits::lowerLimited(0.0), "heightRatio");
117 
118  m_alpha.init("Alpha", "Dihedral angle between base and facets", 60.0, Unit::degree, "alpha");
119 }
120 
121 std::unique_ptr<IFormFactor> Bipyramid4Item::createFormFactor() const
122 {
123  return std::make_unique<Bipyramid4>(length(), height(), heightRatio(), alpha() * Units::deg);
124 }
125 
126 /* ------------------------------------------------ */
127 
129 {
130  m_radius.init("Radius", "Radius of the circular base", 8.0, Unit::nanometer, "radius");
131  m_height.init("Height", "Height of the cylinder", 16.0, Unit::nanometer, "height");
132 }
133 
134 std::unique_ptr<IFormFactor> CylinderItem::createFormFactor() const
135 {
136  return std::make_unique<Cylinder>(radius(), height());
137 }
138 
139 /* ------------------------------------------------ */
140 
142 {
143  m_edge.init("Edge", "Length of the edge", 10.0, Unit::nanometer, "edge");
144 }
145 
146 std::unique_ptr<IFormFactor> DodecahedronItem::createFormFactor() const
147 {
148  return std::make_unique<Dodecahedron>(edge());
149 }
150 
151 /* ------------------------------------------------ */
152 
154 {
155  m_radiusX.init("Radius x", "Radius of the ellipse base in the x-direction", 8.0,
156  Unit::nanometer, "radiusX");
157  m_radiusY.init("Radius y", "Radius of the ellipse base in the y-direction", 13.0,
158  Unit::nanometer, "radiusY");
159  m_height.init("Height", "Height of the ellipsoidal cylinder", 16.0, Unit::nanometer, "height");
160 }
161 
162 std::unique_ptr<IFormFactor> EllipsoidalCylinderItem::createFormFactor() const
163 {
164  return std::make_unique<EllipsoidalCylinder>(radiusX(), radiusY(), height());
165 }
166 
167 /* ------------------------------------------------ */
168 
170 {
171  m_radius.init("Radius", "Radius of the sphere", 8.0, Unit::nanometer, "radius");
172 }
173 
174 std::unique_ptr<IFormFactor> SphereItem::createFormFactor() const
175 {
176  return std::make_unique<Sphere>(radius());
177 }
178 
179 /* ------------------------------------------------ */
180 
182 {
183  m_radius.init("Radius", "Radius of the circular cross section", 10.0, Unit::nanometer,
184  "radius");
185  m_height.init("Height", "Height of the full spheroid", 13.0, Unit::nanometer, "height");
186 }
187 
188 std::unique_ptr<IFormFactor> SpheroidItem::createFormFactor() const
189 {
190  return std::make_unique<Spheroid>(radius(), height());
191 }
192 
193 /* ------------------------------------------------ */
194 
196 {
197  m_radiusX.init("Radius x", "Radius of the ellipse base in the x-direction", 10.0,
198  Unit::nanometer, "radiusX");
199  m_radiusY.init("Radius y", "Radius of the ellipse base in the y-direction", 6.0,
200  Unit::nanometer, "radiusY");
201  m_height.init("Height", "Height of the hemi ellipsoid", 8.0, Unit::nanometer, "height");
202 }
203 
204 std::unique_ptr<IFormFactor> HemiEllipsoidItem::createFormFactor() const
205 {
206  return std::make_unique<HemiEllipsoid>(radiusX(), radiusY(), height());
207 }
208 
209 /* ------------------------------------------------ */
210 
212 {
213  m_edge.init("Edge", "Length of the edge", 10.0, Unit::nanometer, "edge");
214 }
215 
216 std::unique_ptr<IFormFactor> IcosahedronItem::createFormFactor() const
217 {
218  return std::make_unique<Icosahedron>(edge());
219 }
220 
221 /* ------------------------------------------------ */
222 
224 {
225  m_baseEdge.init("Base edge", "Length of the base edge", 10.0, Unit::nanometer, "baseEdge");
226  m_height.init("Height", "Height", 13.0, Unit::nanometer, "height");
227 }
228 
229 std::unique_ptr<IFormFactor> Prism3Item::createFormFactor() const
230 {
231  return std::make_unique<Prism3>(baseEdge(), height());
232 }
233 
234 /* ------------------------------------------------ */
235 
237 {
238  m_baseEdge.init("Base edge", "Length of the hexagonal base", 5.0, Unit::nanometer, "baseEdge");
239  m_height.init("Height", "Height", 11.0, Unit::nanometer, "height");
240 }
241 
242 std::unique_ptr<IFormFactor> Prism6Item::createFormFactor() const
243 {
244  return std::make_unique<Prism6>(baseEdge(), height());
245 }
246 
247 /* ------------------------------------------------ */
248 
250 {
251  m_baseEdge.init("Base edge", "Length of the square base", 18.0, Unit::nanometer, "baseEdge");
252  m_height.init("Height", "Height of the pyramid", 13.0, Unit::nanometer, "height");
253  m_alpha.init("Alpha", "Dihedral angle between the base and a side face", 60.0, Unit::degree,
254  "alpha");
255 }
256 
257 std::unique_ptr<IFormFactor> Pyramid4Item::createFormFactor() const
258 {
259  return std::make_unique<Pyramid4>(baseEdge(), height(), alpha() * Units::deg);
260 }
261 
262 /* ------------------------------------------------ */
263 
265 {
266  m_length.init("Length", "Length of the rectangular base", 27.0, Unit::nanometer, "length");
267  m_width.init("Width", "Width of the rectangular base", 20.0, Unit::nanometer, "width");
268  m_height.init("Height", "Height of the ripple", 14.0, Unit::nanometer, "height");
269 }
270 
271 std::unique_ptr<IFormFactor> CosineRippleBoxItem::createFormFactor() const
272 {
273  return std::make_unique<CosineRippleBox>(length(), width(), height());
274 }
275 
276 /* ------------------------------------------------ */
277 
279 {
280  m_length.init("Length", "Length of the rectangular base", 27.0, Unit::nanometer, "length");
281  m_width.init("Width", "Width of the rectangular base", 20.0, Unit::nanometer, "width");
282  m_height.init("Height", "Height of the ripple", 14.0, Unit::nanometer, "height");
283 }
284 
285 std::unique_ptr<IFormFactor> CosineRippleGaussItem::createFormFactor() const
286 {
287  return std::make_unique<CosineRippleGauss>(length(), width(), height());
288 }
289 
290 /* ------------------------------------------------ */
291 
293 {
294  m_length.init("Length", "Length of the rectangular base", 27.0, Unit::nanometer, "length");
295  m_width.init("Width", "Width of the rectangular base", 20.0, Unit::nanometer, "width");
296  m_height.init("Height", "Height of the ripple", 14.0, Unit::nanometer, "height");
297 }
298 
299 std::unique_ptr<IFormFactor> CosineRippleLorentzItem::createFormFactor() const
300 {
301  return std::make_unique<CosineRippleLorentz>(length(), width(), height());
302 }
303 
304 /* ------------------------------------------------ */
305 
307 {
308  m_length.init("Length", "Length of the rectangular base", 36.0, Unit::nanometer, "length");
309  m_width.init("Width", "Width of the rectangular base", 25.0, Unit::nanometer, "width");
310  m_height.init("Height", "Height of the ripple", 14.0, Unit::nanometer, "height");
311  m_asymmetry.init("Asymmetry", "Asymmetry length of the triangular profile", 3.0,
312  Unit::nanometer, "asymmetry");
313 }
314 
315 std::unique_ptr<IFormFactor> SawtoothRippleBoxItem::createFormFactor() const
316 {
317  return std::make_unique<SawtoothRippleBox>(length(), width(), height(), asymmetry());
318 }
319 
320 /* ------------------------------------------------ */
321 
323 {
324  m_length.init("Length", "Length of the rectangular base", 36.0, Unit::nanometer, "length");
325  m_width.init("Width", "Width of the rectangular base", 25.0, Unit::nanometer, "width");
326  m_height.init("Height", "Height of the ripple", 14.0, Unit::nanometer, "height");
327  m_asymmetry.init("Asymmetry", "Asymmetry length of the triangular profile", 3.0,
328  Unit::nanometer, "asymmetry");
329 }
330 
331 std::unique_ptr<IFormFactor> SawtoothRippleGaussItem::createFormFactor() const
332 {
333  return std::make_unique<SawtoothRippleGauss>(length(), width(), height(), asymmetry());
334 }
335 
336 /* ------------------------------------------------ */
337 
339 {
340  m_length.init("Length", "Length of the rectangular base", 36.0, Unit::nanometer, "length");
341  m_width.init("Width", "Width of the rectangular base", 25.0, Unit::nanometer, "width");
342  m_height.init("Height", "Height of the ripple", 14.0, Unit::nanometer, "height");
343  m_asymmetry.init("Asymmetry", "Asymmetry length of the triangular profile", 3.0,
344  Unit::nanometer, "asymmetry");
345 }
346 
347 std::unique_ptr<IFormFactor> SawtoothRippleLorentzItem::createFormFactor() const
348 {
349  return std::make_unique<SawtoothRippleLorentz>(length(), width(), height(), asymmetry());
350 }
351 
352 /* ------------------------------------------------ */
353 
355 {
356  m_baseEdge.init("Base edge", "Length of one edge of the equilateral triangular base", 15.0,
357  Unit::nanometer, "baseEdge");
358  m_height.init("Height", "Height of the tetrahedron", 6.0, Unit::nanometer, "height");
359  m_alpha.init("Alpha", "Dihedral angle between base and facet", 60.0, Unit::degree, "alpha");
360 }
361 
362 std::unique_ptr<IFormFactor> Pyramid3Item::createFormFactor() const
363 {
364  return std::make_unique<Pyramid3>(baseEdge(), height(), alpha() * Units::deg);
365 }
366 
367 /* ------------------------------------------------ */
368 
370 {
371  m_length.init("Length", "Length of the full cube's edge", 15.0, Unit::nanometer, "length");
372  m_removedLength.init("Removed length", "Removed length from each corner of the cube", 6.0,
373  Unit::nanometer, "removedLength");
374 }
375 
376 std::unique_ptr<IFormFactor> TruncatedCubeItem::createFormFactor() const
377 {
378  return std::make_unique<TruncatedCube>(length(), removedLength());
379 }
380 
381 /* ------------------------------------------------ */
382 
384 {
385  m_radius.init("Radius", "Radius of the truncated sphere", 5.0, Unit::nanometer, "radius");
386  m_height.init("Height", "Height of the truncated sphere", 7.0, Unit::nanometer, "height");
387  m_removedTop.init("Delta height", "Height of the removed top cap", 0.0, Unit::nanometer,
388  "removedTop");
389 }
390 
391 std::unique_ptr<IFormFactor> TruncatedSphereItem::createFormFactor() const
392 {
393  return std::make_unique<TruncatedSphere>(radius(), height(), removedTop());
394 }
395 
396 /* ------------------------------------------------ */
397 
399 {
400  m_radius.init("Radius", "Radius of the truncated spheroid", 7.5, Unit::nanometer, "radius");
401  m_height.init("Height", "Height of the truncated spheroid", 9.0, Unit::nanometer, "height");
402  m_heightFlattening.init(
403  "Height flattening",
404  "Ratio of the height of the corresponding full spheroid to its diameter", 1.2,
405  Unit::unitless, "heightFlattening");
406 
407  m_removedTop.init("Delta height", "Height of the removed top cap", 0.0, Unit::nanometer,
408  "removedTop");
409 }
410 
411 std::unique_ptr<IFormFactor> TruncatedSpheroidItem::createFormFactor() const
412 {
413  return std::make_unique<TruncatedSpheroid>(radius(), height(), heightFlattening(),
414  removedTop());
415 }
416 
417 /* ------------------------------------------------ */
418 
420 {
421  m_length.init("Length", "Length of the full cube's edge", 15.0, Unit::nanometer, "length");
422  m_removedLength.init("Removed length", "Removed length from each edge and vertice of the cube",
423  6.0, Unit::nanometer, "removedLength");
424 }
425 
426 std::unique_ptr<IFormFactor> CantellatedCubeItem::createFormFactor() const
427 {
428  return std::make_unique<CantellatedCube>(length(), removedLength());
429 }
430 
431 /* ------------------------------------------------ */
432 
434 {
435  m_radius.init("Radius", "Radius of the horizontal cylinder", 7.5, Unit::nanometer, "radius");
436  m_length.init("Length", "Length of the horizontal cylinder", 9.0, Unit::nanometer, "length");
437  m_sliceBottom.init("Bottom boundary", "Position of the lower boundary relative to the center",
438  -4.1, Unit::nanometer, "sliceBottom");
439  m_sliceTop.init("Top boundary", "Position of the upper boundary relative to the center", +5.2,
440  Unit::nanometer, "sliceTop");
441 }
442 
443 std::unique_ptr<IFormFactor> HorizontalCylinderItem::createFormFactor() const
444 {
445  return std::make_unique<HorizontalCylinder>(radius(), length(), sliceBottom(), sliceTop());
446 }
447 
448 /* ------------------------------------------------ */
449 
451 {
452  m_edge.init("Edge", "Length of the edge", 10.0, Unit::nanometer, "edge");
453 }
454 
455 std::unique_ptr<IFormFactor> PlatonicOctahedronItem::createFormFactor() const
456 {
457  return std::make_unique<PlatonicOctahedron>(edge());
458 }
459 
460 /* ------------------------------------------------ */
461 
463 {
464  m_edge.init("Edge", "Length of the edge", 10.0, Unit::nanometer, "edge");
465 }
466 
467 std::unique_ptr<IFormFactor> PlatonicTetrahedronItem::createFormFactor() const
468 {
469  return std::make_unique<PlatonicTetrahedron>(edge());
470 }
471 
472 
474 {
475  s.assertVersion(0);
476  for (auto* p : serializationProperties())
477  Serialize::rwProperty(s, *p);
478 }
Defines FormFactorItems classes.
@ unitless
@ nanometer
@ degree
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
virtual QVector< DoubleProperty * > serializationProperties()=0
virtual void serialize(Streamer &s)
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
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
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
std::unique_ptr< IFormFactor > createFormFactor() const override
void rwProperty(Streamer &s, DoubleProperty &d)