BornAgain  1.19.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 reflection and scattering
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 
18 FormFactorCoherentSum::FormFactorCoherentSum(double abundance) : m_abundance(abundance) {}
19 
21 {
22  m_parts.push_back(part);
23 }
24 
26 {
27  complex_t result{};
28  for (const auto& part : m_parts)
29  result += part.evaluate(sim_element);
30  return result;
31 }
32 
33 Eigen::Matrix2cd FormFactorCoherentSum::evaluatePol(const SimulationElement& sim_element) const
34 {
35  Eigen::Matrix2cd result = Eigen::Matrix2cd::Zero();
36  for (const auto& part : m_parts)
37  result += part.evaluatePol(sim_element);
38  return result;
39 }
40 
42 {
43  if (total_abundance <= 0.0)
44  throw std::runtime_error("FormFactorCoherentSum::scaleRelativeAbundance: "
45  "Trying to scale with non strictly positive factor.");
46  m_abundance /= total_abundance;
47 }
48 
50 {
51  return m_parts[0].radialExtension();
52 }
53 
54 FormFactorCoherentSum::FormFactorCoherentSum(const std::vector<FormFactorCoherentPart>& parts,
55  double abundance)
56  : m_parts(parts), m_abundance(abundance)
57 {
58 }
std::complex< double > complex_t
Definition: Complex.h:20
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.