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

Description

Strategy class to compute the total scattering from a particle layout in the size-spacing correlation approximation.

Definition at line 31 of file SSCAStrategy.h.

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

Public Member Functions

 SSCAStrategy (const std::vector< std::unique_ptr< const CoherentFFSum >> &weighted_formfactors, const InterferenceRadialParaCrystal *iff, SimulationOptions sim_params, bool polarized, double kappa)
 
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

complex_t calculatePositionOffsetPhase (double qp, double radial_extension) const
 
double evaluate_for_fixed_angles (const double *fractions, size_t dim, const void *params) const
 
double evaluateSinglePoint (const DiffuseElement &ele) const
 
complex_t getCharacteristicSizeCoupling (double qp, const std::vector< std::unique_ptr< const CoherentFFSum >> &ff_wrappers) const
 
double MCIntegratedEvaluate (const DiffuseElement &ele) const
 Performs a Monte Carlo integration over the bin for the evaluation of the intensity. More...
 
double polarizedCalculation (const DiffuseElement &ele) const override
 This is the polarized version. More...
 
double scalarCalculation (const DiffuseElement &ele) const override
 Returns the total scattering intensity for given kf and for one particle layout (implied by the given particle form factors). This is the scalar version. More...
 

Private Attributes

const std::unique_ptr< InterferenceRadialParaCrystalm_iff
 
const std::unique_ptr< IntegratorMCMiser< IInterparticleStrategy > > m_integrator
 
const double m_kappa
 
const double m_mean_radius
 
const bool m_polarized
 

Constructor & Destructor Documentation

◆ SSCAStrategy()

SSCAStrategy::SSCAStrategy ( const std::vector< std::unique_ptr< const CoherentFFSum >> &  weighted_formfactors,
const InterferenceRadialParaCrystal iff,
SimulationOptions  sim_params,
bool  polarized,
double  kappa 
)

Definition at line 33 of file SSCAStrategy.cpp.

37  : IInterparticleStrategy(weighted_formfactors, sim_params, polarized)
38  , m_iff(iff->clone())
39  , m_kappa(kappa)
40  , m_mean_radius(meanRadius(weighted_formfactors))
41 {
42 }
IInterparticleStrategy(const std::vector< std::unique_ptr< const CoherentFFSum >> &weighted_formfactors, const SimulationOptions &sim_params, bool polarized)
InterferenceRadialParaCrystal * clone() const override
const double m_kappa
Definition: SSCAStrategy.h:46
const std::unique_ptr< InterferenceRadialParaCrystal > m_iff
Definition: SSCAStrategy.h:45
const double m_mean_radius
Definition: SSCAStrategy.h:47

Member Function Documentation

◆ calculatePositionOffsetPhase()

complex_t SSCAStrategy::calculatePositionOffsetPhase ( double  qp,
double  radial_extension 
) const
private

Definition at line 110 of file SSCAStrategy.cpp.

111 {
112  return exp_I(m_kappa * qp * (radial_extension - m_mean_radius));
113 }

References m_kappa, and m_mean_radius.

Referenced by getCharacteristicSizeCoupling(), polarizedCalculation(), and scalarCalculation().

◆ evaluate()

double IInterparticleStrategy::evaluate ( const DiffuseElement ele) const
inherited

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.
const SimulationOptions m_options
bool isIntegrate() const

References IInterparticleStrategy::evaluateSinglePoint(), SimulationOptions::isIntegrate(), IInterparticleStrategy::m_options, IInterparticleStrategy::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
privateinherited

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 IInterparticleStrategy::evaluateSinglePoint(), DiffuseElement::integrationFactor(), and DiffuseElement::pointElement().

Here is the call graph for this function:

◆ evaluateSinglePoint()

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

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 IInterparticleStrategy::m_polarized, IInterparticleStrategy::polarizedCalculation(), and IInterparticleStrategy::scalarCalculation().

Referenced by IInterparticleStrategy::evaluate(), and IInterparticleStrategy::evaluate_for_fixed_angles().

Here is the call graph for this function:

◆ getCharacteristicSizeCoupling()

complex_t SSCAStrategy::getCharacteristicSizeCoupling ( double  qp,
const std::vector< std::unique_ptr< const CoherentFFSum >> &  ff_wrappers 
) const
private

Definition at line 100 of file SSCAStrategy.cpp.

102 {
103  complex_t result = 0;
104  for (const auto& ffw : ff_wrappers)
105  result += ffw->relativeAbundance()
106  * calculatePositionOffsetPhase(2.0 * qp, ffw->radialExtension());
107  return result;
108 }
complex_t calculatePositionOffsetPhase(double qp, double radial_extension) const

References calculatePositionOffsetPhase().

Referenced by polarizedCalculation(), and scalarCalculation().

Here is the call graph for this function:

◆ MCIntegratedEvaluate()

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

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 }
const std::unique_ptr< IntegratorMCMiser< IInterparticleStrategy > > m_integrator
size_t getMcPoints() const

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

Referenced by IInterparticleStrategy::evaluate().

Here is the call graph for this function:

◆ polarizedCalculation()

double SSCAStrategy::polarizedCalculation ( const DiffuseElement ele) const
overrideprivatevirtual

This is the polarized version.

Implements IInterparticleStrategy.

Definition at line 71 of file SSCAStrategy.cpp.

72 {
73  const double qp = ele.meanQ().magxy();
74  SpinMatrix diffuse_matrix;
75  const auto& polarization_handler = ele.polMatrices();
76  SpinMatrix ff_orig;
77  SpinMatrix ff_conj;
78  for (const auto& ffw : m_weighted_formfactors) {
79  const SpinMatrix ff = ffw->summedPolFF(ele);
80  const double fraction = ffw->relativeAbundance();
81  diffuse_matrix += fraction * (ff * polarization_handler.polarizerMatrix() * ff.adjoint());
82  const double radial_extension = ffw->radialExtension();
83  const complex_t prefac =
84  ffw->relativeAbundance() * calculatePositionOffsetPhase(qp, radial_extension);
85  ff_orig += prefac * ff;
86  ff_conj += prefac * ff.adjoint();
87  }
88  const complex_t p2kappa = getCharacteristicSizeCoupling(qp, m_weighted_formfactors);
89  const complex_t omega = m_iff->FTPDF(qp);
90  const SpinMatrix interference_matrix = (2.0 * omega / (1.0 - p2kappa * omega))
91  * polarization_handler.analyzerMatrix() * ff_orig
92  * polarization_handler.polarizerMatrix() * ff_conj;
93  const SpinMatrix diffuse_matrix2 = polarization_handler.analyzerMatrix() * diffuse_matrix;
94  const double interference_trace = std::abs(interference_matrix.trace());
95  const double diffuse_trace = std::abs(diffuse_matrix2.trace());
96  const double dw_factor = m_iff->DWfactor(ele.meanQ());
97  return diffuse_trace + dw_factor * interference_trace;
98 }
const PolMatrices & polMatrices() const
Returns polarizer and analyzer matrices.
Definition: IElement.h:37
const std::vector< std::unique_ptr< const CoherentFFSum > > & m_weighted_formfactors
complex_t getCharacteristicSizeCoupling(double qp, const std::vector< std::unique_ptr< const CoherentFFSum >> &ff_wrappers) const
complex_t trace() const
Definition: SpinMatrix.cpp:165

References calculatePositionOffsetPhase(), getCharacteristicSizeCoupling(), m_iff, IInterparticleStrategy::m_weighted_formfactors, DiffuseElement::meanQ(), IElement::polMatrices(), and SpinMatrix::trace().

Here is the call graph for this function:

◆ scalarCalculation()

double SSCAStrategy::scalarCalculation ( const DiffuseElement ele) const
overrideprivatevirtual

Returns the total scattering intensity for given kf and for one particle layout (implied by the given particle form factors). This is the scalar version.

Implements IInterparticleStrategy.

Definition at line 47 of file SSCAStrategy.cpp.

48 {
49  const double qp = ele.meanQ().magxy();
50  double diffuse_intensity = 0.0;
51  complex_t ff_orig = 0., ff_conj = 0.; // original and conjugated mean formfactor
52  for (const auto& ffw : m_weighted_formfactors) {
53  complex_t ff = ffw->summedFF(ele);
54  double fraction = ffw->relativeAbundance();
55  diffuse_intensity += fraction * std::norm(ff);
56  double radial_extension = ffw->radialExtension();
57  complex_t prefac =
58  ffw->relativeAbundance() * calculatePositionOffsetPhase(qp, radial_extension);
59  ff_orig += prefac * ff;
60  ff_conj += prefac * std::conj(ff);
61  }
62  const complex_t mean_ff_norm = ff_orig * ff_conj;
63  const complex_t p2kappa = getCharacteristicSizeCoupling(qp, m_weighted_formfactors);
64  const complex_t omega = m_iff->FTPDF(qp);
65  const double iff = 2.0 * (mean_ff_norm * omega / (1.0 - p2kappa * omega)).real();
66  const double dw_factor = m_iff->DWfactor(ele.meanQ());
67  return diffuse_intensity + dw_factor * iff;
68 }

References calculatePositionOffsetPhase(), getCharacteristicSizeCoupling(), m_iff, IInterparticleStrategy::m_weighted_formfactors, and DiffuseElement::meanQ().

Here is the call graph for this function:

Member Data Documentation

◆ m_iff

const std::unique_ptr<InterferenceRadialParaCrystal> SSCAStrategy::m_iff
private

Definition at line 45 of file SSCAStrategy.h.

Referenced by polarizedCalculation(), and scalarCalculation().

◆ m_integrator

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

◆ m_kappa

const double SSCAStrategy::m_kappa
private

Definition at line 46 of file SSCAStrategy.h.

Referenced by calculatePositionOffsetPhase().

◆ m_mean_radius

const double SSCAStrategy::m_mean_radius
private

Definition at line 47 of file SSCAStrategy.h.

Referenced by calculatePositionOffsetPhase().

◆ m_options

const SimulationOptions IInterparticleStrategy::m_options
protectedinherited

◆ m_polarized

const bool IInterparticleStrategy::m_polarized
privateinherited

◆ m_weighted_formfactors

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

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