BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
ReCompound.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Resample/Particle/ReCompound.cpp
6 //! @brief Implements class ReCompound.
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/Util/Algorithms.h"
17 #include "Base/Vector/WavevectorInfo.h" // debug
18 
20 {
21  for (size_t index = 0; index < m_components.size(); ++index)
22  delete m_components[index];
23 }
24 
26 {
27  auto* result = new ReCompound();
28  for (size_t index = 0; index < m_components.size(); ++index)
29  result->addFormFactor(*m_components[index]);
30  return result;
31 }
32 
34 {
35  double result{0.0};
36  for (size_t index = 0; index < m_components.size(); ++index)
37  result += m_components[index]->radialExtension();
38  return result;
39 }
40 
41 double ReCompound::bottomZ(const IRotation* rotation) const
42 {
43  if (m_components.empty())
44  throw std::runtime_error("ReCompound::bottomZ() -> Error: "
45  "'this' contains no form factors.");
47  m_components.begin(), m_components.end(),
48  [&rotation](IReParticle* ff) { return ff->bottomZ(rotation); });
49 }
50 
51 double ReCompound::topZ(const IRotation* rotation) const
52 {
53  if (m_components.empty())
54  throw std::runtime_error("ReCompound::topZ() -> Error: "
55  "'this' contains no form factors.");
57  [&rotation](IReParticle* ff) { return ff->topZ(rotation); });
58 }
59 
60 void ReCompound::addFormFactor(const IReParticle& formfactor)
61 {
62  m_components.push_back(formfactor.clone());
63 }
64 
66 {
67  for (size_t index = 0; index < m_components.size(); ++index)
68  m_components[index]->setAmbientMaterial(material);
69 }
70 
71 complex_t ReCompound::theFF(const WavevectorInfo& wavevectors) const
72 {
73  complex_t result(0.0, 0.0);
74  for (size_t index = 0; index < m_components.size(); ++index)
75  result += m_components[index]->theFF(wavevectors);
76  return result;
77 }
78 
80 {
81  SpinMatrix result;
82  for (size_t index = 0; index < m_components.size(); ++index)
83  result += m_components[index]->thePolFF(wavevectors);
84  return result;
85 }
Defines and implements namespace BaseUtils::algo with some algorithms.
Defines class ReCompound.
Defines WavevectorInfo.
Abstract base class for reprocessed particles.
Definition: IReParticle.h:37
IReParticle * clone() const override=0
Abstract base class for rotations.
Definition: Rotations.h:29
A wrapper for underlying material implementation.
Definition: Material.h:35
A reprocessed ParticleComposition.
Definition: ReCompound.h:29
complex_t theFF(const WavevectorInfo &wavevectors) const override
Returns scattering amplitude for complex wavevectors ki, kf.
Definition: ReCompound.cpp:71
ReCompound()=default
~ReCompound() override
Definition: ReCompound.cpp:19
SpinMatrix thePolFF(const WavevectorInfo &wavevectors) const override
Calculates and returns a polarized form factor calculation in DWBA.
Definition: ReCompound.cpp:79
void addFormFactor(const IReParticle &formfactor)
Definition: ReCompound.cpp:60
ReCompound * clone() const override
Definition: ReCompound.cpp:25
void setAmbientMaterial(const Material &material) override
Passes the material in which this particle is embedded.
Definition: ReCompound.cpp:65
double radialExtension() const override
Returns the (approximate in some cases) radial size of the particle of this form factor's shape....
Definition: ReCompound.cpp:33
double bottomZ(const IRotation *rotation) const override
Returns the z-coordinate of the lowest point in this shape after a given rotation.
Definition: ReCompound.cpp:41
std::vector< IReParticle * > m_components
Definition: ReCompound.h:52
double topZ(const IRotation *rotation) const override
Returns the z-coordinate of the lowest point in this shape after a given rotation.
Definition: ReCompound.cpp:51
Holds all wavevector information relevant for calculating form factors.
double max_value(const Iterator &begin, const Iterator &end, const Evaluator &evaluate)
Returns the maximum value of function evaluate as applied to the elements of an iterator range.
Definition: Algorithms.h:70
double min_value(const Iterator &begin, const Iterator &end, const Evaluator &evaluate)
Returns the minimum value of function evaluate as applied to the elements of an iterator range.
Definition: Algorithms.h:58