BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FormFactorCoherentSum.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/Fresnel/FormFactorCoherentSum.cpp
6 //! @brief Implements class FormFactorCoherentSum.
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 
17 #include "Base/Types/Exceptions.h"
18 
19 FormFactorCoherentSum::FormFactorCoherentSum(double abundance) : m_abundance(abundance) {}
20 
22 {
23  m_parts.push_back(part);
24 }
25 
27 {
28  complex_t result{};
29  for (auto& part : m_parts) {
30  result += part.evaluate(sim_element);
31  }
32  return result;
33 }
34 
35 Eigen::Matrix2cd FormFactorCoherentSum::evaluatePol(const SimulationElement& sim_element) const
36 {
37  Eigen::Matrix2cd result = Eigen::Matrix2cd::Zero();
38  for (auto& part : m_parts) {
39  result += part.evaluatePol(sim_element);
40  }
41  return result;
42 }
43 
45 {
46  if (total_abundance > 0.0) {
47  m_abundance /= total_abundance;
48  return;
49  }
50  throw Exceptions::LogicErrorException("FormFactorCoherentSum::scaleRelativeAbundance: "
51  "Trying to scale with non strictly positive factor.");
52 }
53 
55 {
56  return m_parts[0].radialExtension();
57 }
58 
59 FormFactorCoherentSum::FormFactorCoherentSum(const std::vector<FormFactorCoherentPart>& parts,
60  double abundance)
61  : m_parts(parts), m_abundance(abundance)
62 {
63 }
std::complex< double > complex_t
Definition: Complex.h:20
Defines many exception classes in namespace Exceptionss.
Defines class FormFactorCoherentSum.
Defines class SimulationElement.
Information about single particle form factor and specular info of the embedding layer.
complex_t evaluate(const SimulationElement &sim_element) const
void scaleRelativeAbundance(double total_abundance)
Eigen::Matrix2cd evaluatePol(const SimulationElement &sim_element) const
FormFactorCoherentSum(double abundance)
std::vector< FormFactorCoherentPart > m_parts
void addCoherentPart(const FormFactorCoherentPart &part)
Data stucture containing both input and output of a single detector cell.