Skip to content
Snippets Groups Projects
Commit 224c8c0e authored by Van Herck, Walter's avatar Van Herck, Walter
Browse files

Refactor: removed runMagnetic()

parent f01d03d5
No related branches found
No related tags found
No related merge requests found
...@@ -40,8 +40,6 @@ public: ...@@ -40,8 +40,6 @@ public:
virtual void run(); virtual void run();
protected: protected:
void runMagnetic(const IInterferenceFunctionStrategy *p_strategy);
Layer *mp_layer; Layer *mp_layer;
DiffuseDWBASimulation *mp_diffuseDWBA; DiffuseDWBASimulation *mp_diffuseDWBA;
......
...@@ -48,43 +48,10 @@ void DecoratedLayerDWBASimulation::run() ...@@ -48,43 +48,10 @@ void DecoratedLayerDWBASimulation::run()
boost::scoped_ptr<const IInterferenceFunctionStrategy> P_strategy( boost::scoped_ptr<const IInterferenceFunctionStrategy> P_strategy(
createAndInitStrategy()); createAndInitStrategy());
if (checkPolarizationPresent()) {
runMagnetic(P_strategy.get());
return;
}
calculateCoherentIntensity(P_strategy.get()); calculateCoherentIntensity(P_strategy.get());
calculateInCoherentIntensity(); calculateInCoherentIntensity();
} }
void DecoratedLayerDWBASimulation::runMagnetic(
const IInterferenceFunctionStrategy *p_strategy)
{
msglog(MSG::DEBUG) << "LayerDecoratorDWBASimulation::calculateCoh...()";
double wavelength = getWaveLength();
double total_surface_density =
mp_layer->getTotalParticleSurfaceDensity();
OutputData<Eigen::Matrix2d>::iterator it = mp_polarization_output->begin(
m_thread_info);
while ( it != mp_polarization_output->end(m_thread_info) )
{
Bin1D phi_bin = mp_polarization_output->getBinOfAxis(
"phi_f", it.getIndex());
Bin1D alpha_bin = mp_polarization_output->getBinOfAxis(
"alpha_f", it.getIndex());
double alpha_f = alpha_bin.getMidPoint();
if (m_sim_params.me_framework==SimulationParameters::DWBA &&
alpha_f<0) {
++it;
continue;
}
Bin1DCVector k_f_bin = getKfBin1_matrix(wavelength, alpha_bin, phi_bin);
*it = p_strategy->evaluatePol(m_ki, k_f_bin, alpha_bin, phi_bin)
* total_surface_density;
++it;
}
}
IInterferenceFunctionStrategy IInterferenceFunctionStrategy
*DecoratedLayerDWBASimulation::createAndInitStrategy() const *DecoratedLayerDWBASimulation::createAndInitStrategy() const
{ {
...@@ -104,31 +71,61 @@ void DecoratedLayerDWBASimulation::calculateCoherentIntensity( ...@@ -104,31 +71,61 @@ void DecoratedLayerDWBASimulation::calculateCoherentIntensity(
double total_surface_density = double total_surface_density =
mp_layer->getTotalParticleSurfaceDensity(); mp_layer->getTotalParticleSurfaceDensity();
cvector_t k_ij = m_ki; if (checkPolarizationPresent()) {
k_ij.setZ(-(complex_t)mp_specular_info->getInCoefficients()->getScalarKz()); // polarized dwba calculation:
OutputData<Eigen::Matrix2d>::iterator it =
DWBASimulation::iterator it_intensity = begin(); mp_polarization_output->begin(m_thread_info);
while ( it_intensity != end() ) while ( it != mp_polarization_output->end(m_thread_info) )
{ {
Bin1D phi_bin = getDWBAIntensity().getBinOfAxis( Bin1D phi_bin = mp_polarization_output->getBinOfAxis(
"phi_f", it_intensity.getIndex()); "phi_f", it.getIndex());
Bin1D alpha_bin = getDWBAIntensity().getBinOfAxis( Bin1D alpha_bin = mp_polarization_output->getBinOfAxis(
"alpha_f", it_intensity.getIndex()); "alpha_f", it.getIndex());
double alpha_f = alpha_bin.getMidPoint(); double alpha_f = alpha_bin.getMidPoint();
if (std::abs(mp_specular_info->getOutCoefficients(alpha_f, 0.0) if (m_sim_params.me_framework==SimulationParameters::DWBA &&
->getScalarR())!=0.0 && alpha_f<0) { alpha_f<0) {
++it;
continue;
}
Bin1DCVector k_f_bin = getKfBin1_matrix(wavelength, alpha_bin,
phi_bin);
*it = p_strategy->evaluatePol(m_ki, k_f_bin, alpha_bin, phi_bin)
* total_surface_density;
++it;
}
}
else {
// scalar dwba calculation:
cvector_t k_ij = m_ki;
k_ij.setZ(-(complex_t)mp_specular_info->getInCoefficients()
->getScalarKz());
DWBASimulation::iterator it_intensity = begin();
while ( it_intensity != end() )
{
Bin1D phi_bin = getDWBAIntensity().getBinOfAxis(
"phi_f", it_intensity.getIndex());
Bin1D alpha_bin = getDWBAIntensity().getBinOfAxis(
"alpha_f", it_intensity.getIndex());
double alpha_f = alpha_bin.getMidPoint();
if (std::abs(mp_specular_info->getOutCoefficients(alpha_f, 0.0)
->getScalarR())!=0.0 && alpha_f<0) {
++it_intensity;
continue;
}
Bin1DCVector k_f_bin = getKfBin(wavelength, alpha_bin, phi_bin);
*it_intensity = p_strategy->evaluate(k_ij, k_f_bin, alpha_bin)
* total_surface_density;
++it_intensity; ++it_intensity;
continue;
} }
Bin1DCVector k_f_bin = getKfBin(wavelength, alpha_bin, phi_bin);
*it_intensity = p_strategy->evaluate(k_ij, k_f_bin, alpha_bin)
* total_surface_density;
++it_intensity;
} }
} }
void DecoratedLayerDWBASimulation::calculateInCoherentIntensity() void DecoratedLayerDWBASimulation::calculateInCoherentIntensity()
{ {
if (checkPolarizationPresent()) {
return;
}
msglog(MSG::DEBUG) << "Calculating incoherent scattering..."; msglog(MSG::DEBUG) << "Calculating incoherent scattering...";
if (mp_diffuseDWBA) { if (mp_diffuseDWBA) {
mp_diffuseDWBA->setSpecularInfo(*mp_specular_info); mp_diffuseDWBA->setSpecularInfo(*mp_specular_info);
...@@ -137,6 +134,3 @@ void DecoratedLayerDWBASimulation::calculateInCoherentIntensity() ...@@ -137,6 +134,3 @@ void DecoratedLayerDWBASimulation::calculateInCoherentIntensity()
addDWBAIntensity( mp_diffuseDWBA->getDWBAIntensity() ); addDWBAIntensity( mp_diffuseDWBA->getDWBAIntensity() );
} }
} }
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