BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
IInterferenceFunctionStrategy.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/Interference/IInterferenceFunctionStrategy.h
6 //! @brief Defines class IInterferenceFunctionStrategy.
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 
15 #ifndef BORNAGAIN_CORE_MULTILAYER_IINTERFERENCEFUNCTIONSTRATEGY_H
16 #define BORNAGAIN_CORE_MULTILAYER_IINTERFERENCEFUNCTIONSTRATEGY_H
17 
18 #include "Base/Types/Complex.h"
20 #include <memory>
21 #include <vector>
22 
23 template <class T> class IntegratorMCMiser;
26 class SimulationElement;
27 
28 //! Base class of all interference function strategy classes.
29 //! Provides an 'evaluate' function that computes the total scattering intensity
30 //! from a decorated layer, taking into account a specific inter-particle interference function.
31 //! This function uses the low-level functions scalarCalculation and polarizedCalculation
32 //! that are to be overriden in the derived classes.
33 //! Inheritance is used to support different approximation schemes
34 //! (DecouplingApproximationStrategy, SSCApproximationStrategy).
35 //!
36 //! Instantiation of child classes takes place in LayoutStrategyBuilder::createStrategy,
37 //! which is called from ParticleLayoutComputation::eval.
38 //!
39 //! @ingroup algorithms_internal
40 
42 {
43 public:
44  IInterferenceFunctionStrategy(const SimulationOptions& sim_params, bool polarized);
46 
47  //! Initializes the object with form factors and an interference function
48  void init(const std::vector<FormFactorCoherentSum>& weighted_formfactors,
49  const IInterferenceFunction* p_iff);
50 
51  //! Calculates the intensity for scalar particles/interactions
52  double evaluate(const SimulationElement& sim_element) const;
53 
54 protected:
55  std::vector<FormFactorCoherentSum> m_formfactor_wrappers;
56  std::unique_ptr<IInterferenceFunction> mP_iff;
57  SimulationOptions m_options;
58 
59 private:
60  double evaluateSinglePoint(const SimulationElement& sim_element) const;
61  double MCIntegratedEvaluate(const SimulationElement& sim_element) const;
62  double evaluate_for_fixed_angles(double* fractions, size_t dim, void* params) const;
63  virtual void strategy_specific_post_init();
64  //! Evaluates the intensity in the scalar case
65  virtual double scalarCalculation(const SimulationElement& sim_element) const = 0;
66  //! Evaluates the intensity in the polarized case
67  virtual double polarizedCalculation(const SimulationElement& sim_element) const = 0;
68 
69  bool m_polarized;
70 
71 #ifndef SWIG
72  std::unique_ptr<IntegratorMCMiser<IInterferenceFunctionStrategy>> mP_integrator;
73 #endif
74 };
75 
76 #endif // BORNAGAIN_CORE_MULTILAYER_IINTERFERENCEFUNCTIONSTRATEGY_H
Defines complex_t, and a few elementary functions.
Defines class SimulationOptions.
Information about particle form factor and abundance.
Base class of all interference function strategy classes.
double evaluate(const SimulationElement &sim_element) const
Calculates the intensity for scalar particles/interactions.
void init(const std::vector< FormFactorCoherentSum > &weighted_formfactors, const IInterferenceFunction *p_iff)
Initializes the object with form factors and an interference function.
Pure virtual base class of interference functions.
Template class to use Monte Carlo MISER integration of class member functions.
Data stucture containing both input and output of a single detector cell.
Collect the different options for simulation.