BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FormFactorCantellatedCube.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/HardParticle/FormFactorCantellatedCube.cpp
6 //! @brief Implements class FormFactorCantellatedCube.
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 
18  {
19  /* 0 */ {{0, 1, 2, 3}, true},
20  /* 1 */ {{0, 8, 5, 1}, true},
21  /* 2 */ {{1, 9, 6, 2}, true},
22  /* 3 */ {{2, 10, 7, 3}, true},
23  /* 4 */ {{3, 11, 4, 0}, true},
24  /* 5 */ {{0, 4, 8}, false},
25  /* 6 */ {{1, 5, 9}, false},
26  /* 7 */ {{2, 6, 10}, false},
27  /* 8 */ {{3, 7, 11}, false},
28  /* 9 */ {{4, 12, 16, 8}, true},
29  /* 10 */ {{5, 13, 17, 9}, true},
30  /* 11 */ {{4, 11, 19, 12}, true},
31  /* 12 */ {{5, 8, 16, 13}, true},
32  /* 13 */ {{7, 10, 18, 15}, true},
33  /* 14 */ {{6, 9, 17, 14}, true},
34  /* 15 */ {{7, 15, 19, 11}, true},
35  /* 16 */ {{6, 14, 18, 10}, true},
36  /* 17 */ {{13, 21, 17}, false},
37  /* 18 */ {{12, 20, 16}, false},
38  /* 19 */ {{15, 23, 19}, false},
39  /* 20 */ {{14, 22, 18}, false},
40  /* 21 */ {{14, 17, 21, 22}, true},
41  /* 22 */ {{13, 16, 20, 21}, true},
42  /* 23 */ {{12, 19, 23, 20}, true},
43  /* 24 */ {{15, 18, 22, 23}, true},
44  /* 25 */ {{20, 23, 22, 21}, true},
45  },
46  true};
47 
50  {"CantellatedCube",
51  "a cube with truncated edges and vertices",
52  {{"Length", "nm", "length of untruncated edge", 0, +INF, 0},
53  {"RemovedLength", "nm",
54  "side length of the trirectangular tetrahedron removed one corner", 0, +INF, 0}}},
55  P)
56  , m_length(m_P[0])
57  , m_removed_length(m_P[1])
58 {
59  onChange();
60 }
61 
62 FormFactorCantellatedCube::FormFactorCantellatedCube(double length, double removed_length)
63  : FormFactorCantellatedCube(std::vector<double>{length, removed_length})
64 {
65 }
66 
68 {
69  if (m_removed_length > 0.5 * m_length) {
70  std::ostringstream ostr;
71  ostr << "::FormFactorCantellatedCube() -> Error in class initialization ";
72  ostr << "with parameters 'length':" << m_length;
73  ostr << " 'removed_length':" << m_removed_length << "\n\n";
74  ostr << "Check for removed_length <= 0.5*length failed.";
75  throw std::runtime_error(ostr.str());
76  }
77  double a = m_length / 2;
78  double c = a - m_removed_length;
79 
80  setPolyhedron(topology, -a, {{-c, -c, +a}, // point 0
81  {+c, -c, +a}, {+c, +c, +a}, {-c, +c, +a}, {-a, -c, +c}, // point 4
82  {+c, -a, +c}, {+a, +c, +c}, {-c, +a, +c}, {-c, -a, +c}, // point 8
83  {+a, -c, +c}, {+c, +a, +c}, {-a, +c, +c}, {-a, -c, -c}, // point 12
84  {+c, -a, -c}, {+a, +c, -c}, {-c, +a, -c}, {-c, -a, -c}, // point 16
85  {+a, -c, -c}, {+c, +a, -c}, {-a, +c, -c}, {-c, -c, -a}, // point 20
86  {+c, -c, -a}, {+c, +c, -a}, {-c, +c, -a}});
87 }
Defines class FormFactorCantellatedCube.
const double INF
Definition: INode.h:25
A cube, with truncation of all edges and corners, as in Croset (2017) Fig 7.
FormFactorCantellatedCube(const std::vector< double > P)
static const PolyhedralTopology topology
void onChange() final
Action to be taken in inherited class when a parameter has changed.
A polyhedron, for form factor computation.
void setPolyhedron(const PolyhedralTopology &topology, double z_bottom, const std::vector< kvector_t > &vertices)
Called by child classes to set faces and other internal variables.
For internal use in IFormFactorPolyhedron.
Definition: filesystem.h:81