BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
IInterparticleStrategy Class Referenceabstract

Description

Abstract base class of DecouplingApproximationStrategy, SSCAStrategy. Provides function 'evaluate' that computes the total scattering intensity from a decorated layer.

Instantiation of child classes takes place in LayoutStrategyBuilder::createStrategy, which is called from ParticleLayoutContribution::eval.

Definition at line 41 of file IInterparticleStrategy.h.

Inheritance diagram for IInterparticleStrategy:
[legend]
Collaboration diagram for IInterparticleStrategy:
[legend]

Public Member Functions

 IInterparticleStrategy (const std::vector< std::unique_ptr< const CoherentFFSum >> &weighted_formfactors, const SimulationOptions &sim_params, bool polarized)
 
virtual ~IInterparticleStrategy ()
 
double evaluate (const DiffuseElement &ele) const
 Calculates the intensity for scalar particles/interactions. More...
 

Protected Attributes

const SimulationOptions m_options
 
const std::vector< std::unique_ptr< const CoherentFFSum > > & m_weighted_formfactors
 

Private Member Functions

double evaluate_for_fixed_angles (const double *fractions, size_t dim, const void *params) const
 
double evaluateSinglePoint (const DiffuseElement &ele) const
 
double MCIntegratedEvaluate (const DiffuseElement &ele) const
 Performs a Monte Carlo integration over the bin for the evaluation of the intensity. More...
 
virtual double polarizedCalculation (const DiffuseElement &ele) const =0
 Evaluates the intensity in the polarized case. More...
 
virtual double scalarCalculation (const DiffuseElement &ele) const =0
 Evaluates the intensity in the scalar case. More...
 

Private Attributes

const std::unique_ptr< IntegratorMCMiser< IInterparticleStrategy > > m_integrator
 
const bool m_polarized
 

Constructor & Destructor Documentation

◆ IInterparticleStrategy()

IInterparticleStrategy::IInterparticleStrategy ( const std::vector< std::unique_ptr< const CoherentFFSum >> &  weighted_formfactors,
const SimulationOptions sim_params,
bool  polarized 
)

Definition at line 21 of file IInterparticleStrategy.cpp.

24  : m_weighted_formfactors(weighted_formfactors)
25  , m_options(sim_params)
26  , m_polarized(polarized)
27  , m_integrator(
29 {
31 }
#define ASSERT(condition)
Definition: Assert.h:45
P_integrator_miser< T > make_integrator_miser(const T *object, miser_integrand< T > mem_function, size_t dim)
Template function to create an integrator object.
const std::unique_ptr< IntegratorMCMiser< IInterparticleStrategy > > m_integrator
double evaluate_for_fixed_angles(const double *fractions, size_t dim, const void *params) const
const std::vector< std::unique_ptr< const CoherentFFSum > > & m_weighted_formfactors
const SimulationOptions m_options

References ASSERT, and m_weighted_formfactors.

◆ ~IInterparticleStrategy()

IInterparticleStrategy::~IInterparticleStrategy ( )
virtualdefault

Member Function Documentation

◆ evaluate()

double IInterparticleStrategy::evaluate ( const DiffuseElement ele) const

Calculates the intensity for scalar particles/interactions.

Definition at line 35 of file IInterparticleStrategy.cpp.

36 {
37  if (m_options.isIntegrate() && (ele.solidAngle() > 0.0))
38  return MCIntegratedEvaluate(ele);
39  return evaluateSinglePoint(ele);
40 }
double solidAngle() const
double evaluateSinglePoint(const DiffuseElement &ele) const
double MCIntegratedEvaluate(const DiffuseElement &ele) const
Performs a Monte Carlo integration over the bin for the evaluation of the intensity.
bool isIntegrate() const

References evaluateSinglePoint(), SimulationOptions::isIntegrate(), m_options, MCIntegratedEvaluate(), and DiffuseElement::solidAngle().

Here is the call graph for this function:

◆ evaluate_for_fixed_angles()

double IInterparticleStrategy::evaluate_for_fixed_angles ( const double *  fractions,
size_t  dim,
const void *  params 
) const
private

Definition at line 57 of file IInterparticleStrategy.cpp.

59 {
60  double par0 = fractions[0];
61  double par1 = fractions[1];
62 
63  const auto* pars = static_cast<const DiffuseElement*>(params);
64 
65  DiffuseElement ele = pars->pointElement(par0, par1);
66  return pars->integrationFactor(par0, par1) * evaluateSinglePoint(ele);
67 }
Data stucture containing both input and output of a single detector cell.
double integrationFactor(double x, double y) const
DiffuseElement pointElement(double x, double y) const
Returns copy of this DiffuseElement with k_f given by in-pixel coordinate x,y.

References evaluateSinglePoint(), DiffuseElement::integrationFactor(), and DiffuseElement::pointElement().

Here is the call graph for this function:

◆ evaluateSinglePoint()

double IInterparticleStrategy::evaluateSinglePoint ( const DiffuseElement ele) const
private

Definition at line 42 of file IInterparticleStrategy.cpp.

43 {
44  if (!m_polarized)
45  return scalarCalculation(ele);
46  return polarizedCalculation(ele);
47 }
virtual double scalarCalculation(const DiffuseElement &ele) const =0
Evaluates the intensity in the scalar case.
virtual double polarizedCalculation(const DiffuseElement &ele) const =0
Evaluates the intensity in the polarized case.

References m_polarized, polarizedCalculation(), and scalarCalculation().

Referenced by evaluate(), and evaluate_for_fixed_angles().

Here is the call graph for this function:

◆ MCIntegratedEvaluate()

double IInterparticleStrategy::MCIntegratedEvaluate ( const DiffuseElement ele) const
private

Performs a Monte Carlo integration over the bin for the evaluation of the intensity.

Definition at line 50 of file IInterparticleStrategy.cpp.

51 {
52  double min_array[] = {0.0, 0.0};
53  double max_array[] = {1.0, 1.0};
54  return m_integrator->integrate(min_array, max_array, (void*)&ele, m_options.getMcPoints());
55 }
size_t getMcPoints() const

References SimulationOptions::getMcPoints(), m_integrator, and m_options.

Referenced by evaluate().

Here is the call graph for this function:

◆ polarizedCalculation()

virtual double IInterparticleStrategy::polarizedCalculation ( const DiffuseElement ele) const
privatepure virtual

Evaluates the intensity in the polarized case.

Implemented in SSCAStrategy, and DecouplingApproximationStrategy.

Referenced by evaluateSinglePoint().

◆ scalarCalculation()

virtual double IInterparticleStrategy::scalarCalculation ( const DiffuseElement ele) const
privatepure virtual

Evaluates the intensity in the scalar case.

Implemented in SSCAStrategy, and DecouplingApproximationStrategy.

Referenced by evaluateSinglePoint().

Member Data Documentation

◆ m_integrator

const std::unique_ptr<IntegratorMCMiser<IInterparticleStrategy> > IInterparticleStrategy::m_integrator
private

Definition at line 66 of file IInterparticleStrategy.h.

Referenced by MCIntegratedEvaluate().

◆ m_options

const SimulationOptions IInterparticleStrategy::m_options
protected

Definition at line 53 of file IInterparticleStrategy.h.

Referenced by evaluate(), and MCIntegratedEvaluate().

◆ m_polarized

const bool IInterparticleStrategy::m_polarized
private

Definition at line 64 of file IInterparticleStrategy.h.

Referenced by evaluateSinglePoint().

◆ m_weighted_formfactors

const std::vector<std::unique_ptr<const CoherentFFSum> >& IInterparticleStrategy::m_weighted_formfactors
protected

The documentation for this class was generated from the following files: