Skip to content
Snippets Groups Projects
Commit f69bf4c7 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

Decoupling Approximation: more compact notation for scalarCalculation

parent e5cf34a4
No related branches found
No related tags found
1 merge request!1017consequential use of OwningVector
......@@ -33,7 +33,7 @@ DecouplingApproximationStrategy::DecouplingApproximationStrategy(
double DecouplingApproximationStrategy::scalarCalculation(const DiffuseElement& ele) const
{
double intensity = 0.0;
complex_t amplitude = complex_t(0.0, 0.0);
complex_t amplitude = 0;
for (const auto& ffw : m_weighted_formfactors) {
const complex_t ff = ffw->summedFF(ele);
if (std::isnan(ff.real()))
......@@ -43,9 +43,7 @@ double DecouplingApproximationStrategy::scalarCalculation(const DiffuseElement&
amplitude += fraction * ff;
intensity += fraction * std::norm(ff);
}
const double amplitude_norm = std::norm(amplitude); // squared magnitude
const double coherence_factor = m_iff->structureFactor(ele.meanQ());
return intensity + amplitude_norm * (coherence_factor - 1.0);
return intensity + (m_iff->structureFactor(ele.meanQ()) - 1) * std::norm(amplitude);
}
//! This is the polarized version
......@@ -70,6 +68,5 @@ double DecouplingApproximationStrategy::polarizedCalculation(const DiffuseElemen
const SpinMatrix intensity_matrix = polarization_handler.analyzerMatrix() * mean_intensity;
const double amplitude_trace = std::abs(amplitude_matrix.trace());
const double intensity_trace = std::abs(intensity_matrix.trace());
const double coherence_factor = m_iff->structureFactor(ele.meanQ());
return intensity_trace + amplitude_trace * (coherence_factor - 1.0);
return intensity_trace + (m_iff->structureFactor(ele.meanQ()) - 1) * amplitude_trace;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment