22 const std::vector<std::unique_ptr<const CoherentFFSum>>& weighted_formfactors,
35 double intensity = 0.0;
36 complex_t amplitude = complex_t(0.0, 0.0);
38 const complex_t
ff = ffw->summedFF(ele);
39 if (std::isnan(
ff.real()))
40 throw std::runtime_error(
41 "numerical error in coherent sum (scalar, DA): amplitude is NaN");
42 const double fraction = ffw->relativeAbundance();
43 amplitude += fraction *
ff;
44 intensity += fraction * std::norm(
ff);
46 const double amplitude_norm = std::norm(amplitude);
47 const double coherence_factor =
m_iff->structureFactor(ele.
meanQ());
48 return intensity + amplitude_norm * (coherence_factor - 1.0);
57 const auto& polarization_handler = ele.
polMatrices();
61 throw std::runtime_error(
62 "numerical error in coherent sum (polarized, DA): amplitude is NaN");
63 const double fraction = ffw->relativeAbundance();
64 mean_amplitude += fraction *
ff;
65 mean_intensity += fraction * (
ff * polarization_handler.polarizerMatrix() *
ff.adjoint());
67 const SpinMatrix amplitude_matrix = polarization_handler.analyzerMatrix() * mean_amplitude
68 * polarization_handler.polarizerMatrix()
70 const SpinMatrix intensity_matrix = polarization_handler.analyzerMatrix() * mean_intensity;
71 const double amplitude_trace = std::abs(amplitude_matrix.
trace());
72 const double intensity_trace = std::abs(intensity_matrix.
trace());
73 const double coherence_factor =
m_iff->structureFactor(ele.
meanQ());
74 return intensity_trace + amplitude_trace * (coherence_factor - 1.0);
Defines class CoherentFFSum.
Defines class DecouplingApproximationStrategy.
Defines class DiffuseElement.
Defines class InterferenceNone.
double polarizedCalculation(const DiffuseElement &ele) const override
This is the polarized version.
const std::unique_ptr< IInterference > m_iff
double scalarCalculation(const DiffuseElement &ele) const override
Returns the total incoherent and coherent scattering intensity for given kf and for one particle layo...
DecouplingApproximationStrategy(const std::vector< std::unique_ptr< const CoherentFFSum >> &weighted_formfactors, const IInterference *iff, SimulationOptions sim_params, bool polarized)
Data stucture containing both input and output of a single detector cell.
const PolMatrices & polMatrices() const
Returns polarizer and analyzer matrices.
Abstract base class of interference functions.
Abstract base class of DecouplingApproximationStrategy, SSCAStrategy. Provides function 'evaluate' th...
const std::vector< std::unique_ptr< const CoherentFFSum > > & m_weighted_formfactors
Default interference function (i.e. absence of any interference).
Collect the different options for simulation.SimulationOptions.
SpinMatrix adjoint() const