BornAgain  1.19.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 reflection and scattering
4 //
5 //! @file Sample/Interference/IInterferenceFunctionStrategy.h
6 //! @brief Defines interface 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 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_SAMPLE_INTERFERENCE_IINTERFERENCEFUNCTIONSTRATEGY_H
21 #define BORNAGAIN_SAMPLE_INTERFERENCE_IINTERFERENCEFUNCTIONSTRATEGY_H
22 
23 #include "Base/Types/Complex.h"
25 #include <memory>
26 #include <vector>
27 
28 template <class T> class IntegratorMCMiser;
31 class SimulationElement;
32 
33 //! Base class of all interference function strategy classes.
34 //! Provides an 'evaluate' function that computes the total scattering intensity
35 //! from a decorated layer, taking into account a specific inter-particle interference function.
36 //! This function uses the low-level functions scalarCalculation and polarizedCalculation
37 //! that are to be overriden in the derived classes.
38 //! Inheritance is used to support different approximation schemes
39 //! (DecouplingApproximationStrategy, SSCApproximationStrategy).
40 //!
41 //! Instantiation of child classes takes place in LayoutStrategyBuilder::createStrategy,
42 //! which is called from ParticleLayoutComputation::eval.
43 //!
44 //! @ingroup algorithms_internal
45 
47 public:
48  IInterferenceFunctionStrategy(const std::vector<FormFactorCoherentSum>& weighted_formfactors,
49  const SimulationOptions& sim_params, bool polarized);
51 
52  //! Calculates the intensity for scalar particles/interactions
53  double evaluate(const SimulationElement& sim_element) const;
54 
55 protected:
56  std::vector<FormFactorCoherentSum> m_weighted_formfactors;
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  //! Evaluates the intensity in the scalar case
64  virtual double scalarCalculation(const SimulationElement& sim_element) const = 0;
65  //! Evaluates the intensity in the polarized case
66  virtual double polarizedCalculation(const SimulationElement& sim_element) const = 0;
67 
69 
70 #ifndef SWIG
71  std::unique_ptr<IntegratorMCMiser<IInterferenceFunctionStrategy>> m_integrator;
72 #endif
73 };
74 
75 #endif // BORNAGAIN_SAMPLE_INTERFERENCE_IINTERFERENCEFUNCTIONSTRATEGY_H
76 #endif // USER_API
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.
std::unique_ptr< IntegratorMCMiser< IInterferenceFunctionStrategy > > m_integrator
double evaluate_for_fixed_angles(double *fractions, size_t dim, void *params) const
IInterferenceFunctionStrategy(const std::vector< FormFactorCoherentSum > &weighted_formfactors, const SimulationOptions &sim_params, bool polarized)
virtual double scalarCalculation(const SimulationElement &sim_element) const =0
Evaluates the intensity in the scalar case.
double evaluate(const SimulationElement &sim_element) const
Calculates the intensity for scalar particles/interactions.
double evaluateSinglePoint(const SimulationElement &sim_element) const
double MCIntegratedEvaluate(const SimulationElement &sim_element) const
Performs a Monte Carlo integration over the bin for the evaluation of the intensity.
virtual double polarizedCalculation(const SimulationElement &sim_element) const =0
Evaluates the intensity in the polarized case.
std::vector< FormFactorCoherentSum > m_weighted_formfactors
Abstract 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.
matrixFFVector_t polarized(const SimulationElement &sim_element, const std::vector< FormFactorCoherentSum > &ff_wrappers)