BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FormFactorTruncatedCube.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/HardParticle/FormFactorTruncatedCube.cpp
6 //! @brief Implements class FormFactorTruncatedCube.
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  {{{0, 1, 7, 6, 9, 10, 4, 3}, true},
19  {{0, 2, 1}, false},
20  {{3, 4, 5}, false},
21  {{9, 11, 10}, false},
22  {{6, 7, 8}, false},
23  {{0, 3, 5, 17, 15, 12, 14, 2}, true},
24  {{4, 10, 11, 23, 22, 16, 17, 5}, true},
25  {{1, 2, 14, 13, 19, 20, 8, 7}, true},
26  {{6, 8, 20, 18, 21, 23, 11, 9}, true},
27  {{15, 17, 16}, false},
28  {{12, 13, 14}, false},
29  {{18, 20, 19}, false},
30  {{21, 22, 23}, false},
31  {{12, 15, 16, 22, 21, 18, 19, 13}, true}},
32  true};
33 
36  {"TruncatedCube",
37  "class_tooltip",
38  {{"Length", "nm", "untruncated edge length", 0, +INF, 0},
39  {"RemovedLength", "nm", "edge length removed from one corner", 0, +INF, 0}}},
40  P)
41  , m_length(m_P[0])
42  , m_removed_length(m_P[1])
43 {
44  onChange();
45 }
46 
47 FormFactorTruncatedCube::FormFactorTruncatedCube(double length, double removed_length)
48  : FormFactorTruncatedCube(std::vector<double>{length, removed_length})
49 {
50 }
51 
53 {
54  if (m_removed_length > 0.5 * m_length) {
55  std::ostringstream ostr;
56  ostr << "::FormFactorTruncatedCube() -> Error in class initialization ";
57  ostr << "with parameters 'length':" << m_length;
58  ostr << " 'removed_length':" << m_removed_length << "\n\n";
59  ostr << "Check for removed_length <= 0.5*length failed.";
60  throw std::runtime_error(ostr.str());
61  }
62 
63  double a = m_length / 2;
64  double c = a - m_removed_length;
65 
67  {{-c, -a, -a}, {-a, -c, -a}, {-a, -a, -c}, {c, -a, -a}, {a, -c, -a}, {a, -a, -c},
68  {-c, a, -a}, {-a, c, -a}, {-a, a, -c}, {c, a, -a}, {a, c, -a}, {a, a, -c},
69  {-c, -a, a}, {-a, -c, a}, {-a, -a, c}, {c, -a, a}, {a, -c, a}, {a, -a, c},
70  {-c, a, a}, {-a, c, a}, {-a, a, c}, {c, a, a}, {a, c, a}, {a, a, c}});
71 }
Defines class FormFactorTruncatedCube.
const double INF
Definition: INode.h:25
A cube, with tetrahedral truncation of all corners.
FormFactorTruncatedCube(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