diff --git a/Core/Aggregate/FormFactorWrapper.cpp b/Core/Aggregate/FormFactorCoherentSum.cpp similarity index 72% rename from Core/Aggregate/FormFactorWrapper.cpp rename to Core/Aggregate/FormFactorCoherentSum.cpp index 0cb4dca33fa41e736d043526e59e38f4c6457566..a6ee47c18b4dbcd53e7206ea1637d6a4770d590e 100644 --- a/Core/Aggregate/FormFactorWrapper.cpp +++ b/Core/Aggregate/FormFactorCoherentSum.cpp @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit scattering at grazing incidence // -//! @file Core/Aggregate/FormFactorWrapper.cpp -//! @brief Implements class FormFactorWrapper. +//! @file Core/Aggregate/FormFactorCoherentSum.cpp +//! @brief Implements class FormFactorCoherentSum. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -13,7 +13,7 @@ // // ************************************************************************** // -#include "FormFactorWrapper.h" +#include "FormFactorCoherentSum.h" #include "IFormFactor.h" #include "SimulationElement.h" #include "WavevectorInfo.h" @@ -21,21 +21,21 @@ #include "ILayerRTCoefficients.h" #include "Exceptions.h" -FormFactorWrapper::FormFactorWrapper(IFormFactor *ff, double abundance) +FormFactorCoherentSum::FormFactorCoherentSum(IFormFactor *ff, double abundance) : mP_ff(ff), m_abundance(abundance) { } -FormFactorWrapper::~FormFactorWrapper() {} +FormFactorCoherentSum::~FormFactorCoherentSum() {} -FormFactorWrapper* FormFactorWrapper::clone() const +FormFactorCoherentSum* FormFactorCoherentSum::clone() const { - auto clone = new FormFactorWrapper(mP_ff->clone(), m_abundance); + auto clone = new FormFactorCoherentSum(mP_ff->clone(), m_abundance); clone->setSpecularInfo(*mP_specular_info); return clone; } -complex_t FormFactorWrapper::evaluate(const SimulationElement &sim_element) const +complex_t FormFactorCoherentSum::evaluate(const SimulationElement &sim_element) const { double wavelength = sim_element.getWavelength(); double wavevector_scattering_factor = M_PI/wavelength/wavelength; @@ -49,7 +49,7 @@ complex_t FormFactorWrapper::evaluate(const SimulationElement &sim_element) cons return wavevector_scattering_factor*mP_ff->evaluate(wavevectors); } -Eigen::Matrix2cd FormFactorWrapper::evaluatePol(const SimulationElement &sim_element) const +Eigen::Matrix2cd FormFactorCoherentSum::evaluatePol(const SimulationElement &sim_element) const { double wavelength = sim_element.getWavelength(); double wavevector_scattering_factor = M_PI/wavelength/wavelength; @@ -63,22 +63,22 @@ Eigen::Matrix2cd FormFactorWrapper::evaluatePol(const SimulationElement &sim_ele return wavevector_scattering_factor*mP_ff->evaluatePol(wavevectors); } -void FormFactorWrapper::setSpecularInfo(const LayerSpecularInfo &specular_info) +void FormFactorCoherentSum::setSpecularInfo(const LayerSpecularInfo &specular_info) { mP_specular_info.reset(specular_info.clone()); } -void FormFactorWrapper::scaleRelativeAbundance(double total_abundance) +void FormFactorCoherentSum::scaleRelativeAbundance(double total_abundance) { if (total_abundance>0.0) { m_abundance /= total_abundance; return; } - throw Exceptions::LogicErrorException("FormFactorWrapper::scaleRelativeAbundance: " + throw Exceptions::LogicErrorException("FormFactorCoherentSum::scaleRelativeAbundance: " "Trying to scale with non strictly positive factor."); } -double FormFactorWrapper::radialExtension() const +double FormFactorCoherentSum::radialExtension() const { return mP_ff->getRadialExtension(); } diff --git a/Core/Aggregate/FormFactorWrapper.h b/Core/Aggregate/FormFactorCoherentSum.h similarity index 76% rename from Core/Aggregate/FormFactorWrapper.h rename to Core/Aggregate/FormFactorCoherentSum.h index 3b3193ea49387f331c7265f67fa71b369cc2b542..8dd32e2fb9b399026448e00b2c863efd7eef347f 100644 --- a/Core/Aggregate/FormFactorWrapper.h +++ b/Core/Aggregate/FormFactorCoherentSum.h @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit scattering at grazing incidence // -//! @file Core/Aggregate/FormFactorWrapper.h -//! @brief Defines class FormFactorWrapper. +//! @file Core/Aggregate/FormFactorCoherentSum.h +//! @brief Defines class FormFactorCoherentSum. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -13,8 +13,8 @@ // // ************************************************************************** // -#ifndef FORMFACTORWRAPPER_H -#define FORMFACTORWRAPPER_H +#ifndef FORMFACTORCOHERENTSUM_H +#define FORMFACTORCOHERENTSUM_H #include "ICloneable.h" #include "Complex.h" @@ -28,12 +28,12 @@ class LayerSpecularInfo; //! Information about particle form factor and abundance. //! @ingroup formfactors_internal -class BA_CORE_API_ FormFactorWrapper : public ICloneable +class BA_CORE_API_ FormFactorCoherentSum : public ICloneable { public: - FormFactorWrapper(IFormFactor* ff, double abundance); - virtual ~FormFactorWrapper(); - virtual FormFactorWrapper* clone() const; + FormFactorCoherentSum(IFormFactor* ff, double abundance); + virtual ~FormFactorCoherentSum(); + virtual FormFactorCoherentSum* clone() const; complex_t evaluate(const SimulationElement& sim_element) const; #ifndef SWIG @@ -50,4 +50,4 @@ private: double m_abundance; }; -#endif // FORMFACTORWRAPPER_H +#endif // FORMFACTORCOHERENTSUM_H diff --git a/Core/Multilayer/DecouplingApproximationStrategy.cpp b/Core/Multilayer/DecouplingApproximationStrategy.cpp index ba584454fd1002eafce4bc00697d61886d80fe7e..e35555f9b9c0b36c47914c4172de62ad4b9ae0d3 100644 --- a/Core/Multilayer/DecouplingApproximationStrategy.cpp +++ b/Core/Multilayer/DecouplingApproximationStrategy.cpp @@ -16,7 +16,7 @@ #include "DecouplingApproximationStrategy.h" #include "Exceptions.h" -#include "FormFactorWrapper.h" +#include "FormFactorCoherentSum.h" #include "IInterferenceFunction.h" #include "MathFunctions.h" #include "RealParameter.h" diff --git a/Core/Multilayer/IInterferenceFunctionStrategy.cpp b/Core/Multilayer/IInterferenceFunctionStrategy.cpp index fa84c56246df867e2f9a4434340a4c49e5d4ee0d..07fe771c5d3bbd4a688b164a4efd1ecd821fedd4 100644 --- a/Core/Multilayer/IInterferenceFunctionStrategy.cpp +++ b/Core/Multilayer/IInterferenceFunctionStrategy.cpp @@ -15,7 +15,7 @@ // ************************************************************************** // #include "IInterferenceFunctionStrategy.h" -#include "FormFactorWrapper.h" +#include "FormFactorCoherentSum.h" #include "IFormFactor.h" #include "IInterferenceFunction.h" #include "IntegratorMCMiser.h" @@ -41,7 +41,7 @@ IInterferenceFunctionStrategy::~IInterferenceFunctionStrategy() //! Initializes the object with form factors and interference functions void IInterferenceFunctionStrategy::init( - const SafePointerVector<FormFactorWrapper>& weighted_formfactors, + const SafePointerVector<FormFactorCoherentSum>& weighted_formfactors, const IInterferenceFunction& iff) { if (weighted_formfactors.size()==0) diff --git a/Core/Multilayer/IInterferenceFunctionStrategy.h b/Core/Multilayer/IInterferenceFunctionStrategy.h index f53e083fc9f184073936e058c3d725d13a845eb6..7f221ae42a34d5d09407bdbef763d84db417ccfc 100644 --- a/Core/Multilayer/IInterferenceFunctionStrategy.h +++ b/Core/Multilayer/IInterferenceFunctionStrategy.h @@ -27,7 +27,7 @@ template <class T> class IntegratorMCMiser; class Bin1DCVector; -class FormFactorWrapper; +class FormFactorCoherentSum; class IInterferenceFunction; class LayerSpecularInfo; class SimulationElement; @@ -55,7 +55,7 @@ public: IInterferenceFunctionStrategy(const SimulationOptions& sim_params); virtual ~IInterferenceFunctionStrategy(); - void init(const SafePointerVector<FormFactorWrapper>& weighted_formfactors, + void init(const SafePointerVector<FormFactorCoherentSum>& weighted_formfactors, const IInterferenceFunction& iff); //! Calculates the intensity for scalar particles/interactions @@ -69,7 +69,7 @@ protected: virtual double evaluateForList(const SimulationElement& sim_element) const =0; double m_total_abundance; //!< cached sum of particle abundances, computed by init() - SafePointerVector<FormFactorWrapper> m_formfactor_wrappers; + SafePointerVector<FormFactorCoherentSum> m_formfactor_wrappers; std::unique_ptr<IInterferenceFunction> mP_iff; SimulationOptions m_options; diff --git a/Core/Multilayer/LayerStrategyBuilder.cpp b/Core/Multilayer/LayerStrategyBuilder.cpp index 5aee3b37160c6da40d856678460bcc731e43fbb0..66dad66155fa16968cf8692c1ddd833e7cb61825 100644 --- a/Core/Multilayer/LayerStrategyBuilder.cpp +++ b/Core/Multilayer/LayerStrategyBuilder.cpp @@ -15,7 +15,7 @@ #include "LayerStrategyBuilder.h" #include "Exceptions.h" -#include "FormFactorWrapper.h" +#include "FormFactorCoherentSum.h" #include "FormFactorDWBA.h" #include "FormFactorDWBAPol.h" #include "ILayout.h" @@ -49,7 +49,7 @@ LayerStrategyBuilder::~LayerStrategyBuilder() IInterferenceFunctionStrategy* LayerStrategyBuilder::createStrategy() const { assert(mP_layer->getNumberOfLayouts()>0); - SafePointerVector<class FormFactorWrapper> ff_wrappers = collectFormFactorWrappers(); + SafePointerVector<class FormFactorCoherentSum> ff_wrappers = collectFormFactorList(); std::unique_ptr<class IInterferenceFunction> P_interference_function{ mP_layer->getLayout(m_layout_index)->cloneInterferenceFunction()}; @@ -87,18 +87,18 @@ IInterferenceFunctionStrategy* LayerStrategyBuilder::createStrategy() const } //! Sets m_formfactor_wrappers, the list of weighted form factors. -SafePointerVector<class FormFactorWrapper> LayerStrategyBuilder::collectFormFactorWrappers() const +SafePointerVector<class FormFactorCoherentSum> LayerStrategyBuilder::collectFormFactorList() const { assert(mP_layer->getNumberOfLayouts()>0); - SafePointerVector<class FormFactorWrapper> result; + SafePointerVector<class FormFactorCoherentSum> result; const ILayout* p_layout = mP_layer->getLayout(m_layout_index); const IMaterial* p_layer_material = mP_layer->getMaterial(); double total_abundance = mP_layer->getTotalAbundance(); if (total_abundance<=0.0) // TODO: why this can happen? why not throw error? total_abundance = 1.0; for (const IParticle* particle: p_layout->getParticles()) { - FormFactorWrapper* p_weighted_ff; - p_weighted_ff = createFormFactorWrapper(particle, p_layer_material); + FormFactorCoherentSum* p_weighted_ff; + p_weighted_ff = createFormFactorCoherentSum(particle, p_layer_material); p_weighted_ff->scaleRelativeAbundance(total_abundance); p_weighted_ff->setSpecularInfo(*mP_specular_info); result.push_back(p_weighted_ff); @@ -107,7 +107,7 @@ SafePointerVector<class FormFactorWrapper> LayerStrategyBuilder::collectFormFact } //! Returns a new formfactor wrapper for a given particle in given ambient material. -FormFactorWrapper* LayerStrategyBuilder::createFormFactorWrapper( +FormFactorCoherentSum* LayerStrategyBuilder::createFormFactorCoherentSum( const IParticle* particle, const IMaterial* p_ambient_material) const { const std::unique_ptr<IParticle> P_particle_clone{ particle->clone() }; @@ -123,5 +123,5 @@ FormFactorWrapper* LayerStrategyBuilder::createFormFactorWrapper( } else p_ff_framework = P_ff_particle->clone(); - return new FormFactorWrapper(p_ff_framework, particle->getAbundance()); + return new FormFactorCoherentSum(p_ff_framework, particle->getAbundance()); } diff --git a/Core/Multilayer/LayerStrategyBuilder.h b/Core/Multilayer/LayerStrategyBuilder.h index 4dfa12e900ebab6f9e3e46d7f4f5fb64989b4de2..02c6de38f7d69c5bd1e9f52c0ee33797e308efe6 100644 --- a/Core/Multilayer/LayerStrategyBuilder.h +++ b/Core/Multilayer/LayerStrategyBuilder.h @@ -20,7 +20,7 @@ #include "SimulationOptions.h" #include <memory> -class FormFactorWrapper; +class FormFactorCoherentSum; class IInterferenceFunctionStrategy; class IMaterial; class IParticle; @@ -44,8 +44,8 @@ public: IInterferenceFunctionStrategy* createStrategy() const; private: - SafePointerVector<class FormFactorWrapper> collectFormFactorWrappers() const; - FormFactorWrapper* createFormFactorWrapper( + SafePointerVector<class FormFactorCoherentSum> collectFormFactorList() const; + FormFactorCoherentSum* createFormFactorCoherentSum( const IParticle* particle, const IMaterial* p_ambient_material) const; std::unique_ptr<class Layer> mP_layer; //!< decorated layer diff --git a/Core/Multilayer/SSCApproximationStrategy.cpp b/Core/Multilayer/SSCApproximationStrategy.cpp index 2dfe648cca9052bab244a6d83bc9dcfa3c33bd48..5d10a75a1ff7144aadf6447a542cbf9b54a0cb57 100644 --- a/Core/Multilayer/SSCApproximationStrategy.cpp +++ b/Core/Multilayer/SSCApproximationStrategy.cpp @@ -16,7 +16,7 @@ #include "SSCApproximationStrategy.h" #include "Exceptions.h" -#include "FormFactorWrapper.h" +#include "FormFactorCoherentSum.h" #include "IFormFactor.h" #include "InterferenceFunctionRadialParaCrystal.h" #include "RealParameter.h" diff --git a/Tests/UnitTests/Core/Sample/FormFactorWrapperTest.h b/Tests/UnitTests/Core/Sample/FormFactorCoherentSumTest.h similarity index 64% rename from Tests/UnitTests/Core/Sample/FormFactorWrapperTest.h rename to Tests/UnitTests/Core/Sample/FormFactorCoherentSumTest.h index 7fbe0b3cd6479184ac7672b864a6136e69edb94a..7f7669ca26aa6916808beca608ba17cbceaedb4a 100644 --- a/Tests/UnitTests/Core/Sample/FormFactorWrapperTest.h +++ b/Tests/UnitTests/Core/Sample/FormFactorCoherentSumTest.h @@ -1,32 +1,32 @@ #ifndef FORMFACTORWRAPPERTEST_H #define FORMFACTORWRAPPERTEST_H -#include "FormFactorWrapper.h" +#include "FormFactorCoherentSum.h" #include "FormFactorTrivial.h" #include "Exceptions.h" -class FormFactorWrapperTest : public ::testing::Test +class FormFactorCoherentSumTest : public ::testing::Test { protected: - FormFactorWrapperTest() {} - virtual ~FormFactorWrapperTest() {} + FormFactorCoherentSumTest() {} + virtual ~FormFactorCoherentSumTest() {} }; -TEST_F(FormFactorWrapperTest, RelAbundance) +TEST_F(FormFactorCoherentSumTest, RelAbundance) { const double epsilon=1e-12; auto p_ff = new FormFactorTrivial(); - FormFactorWrapper ffw(p_ff, 1.0); + FormFactorCoherentSum ffw(p_ff, 1.0); EXPECT_EQ(1.0, ffw.relativeAbundance()); ffw.scaleRelativeAbundance(2.0); EXPECT_NEAR(0.5, ffw.relativeAbundance(), epsilon); EXPECT_THROW(ffw.scaleRelativeAbundance(0.0), Exceptions::LogicErrorException); } -TEST_F(FormFactorWrapperTest, FormFactor) +TEST_F(FormFactorCoherentSumTest, FormFactor) { auto p_ff = new FormFactorTrivial(); - FormFactorWrapper ffw(p_ff, 1.0); + FormFactorCoherentSum ffw(p_ff, 1.0); EXPECT_EQ(0.0, ffw.radialExtension()); ffw.scaleRelativeAbundance(2.0); EXPECT_EQ(0.0, ffw.radialExtension()); diff --git a/Tests/UnitTests/Core/Sample/testlist.h b/Tests/UnitTests/Core/Sample/testlist.h index bf797f16e5515a757f3be643ee012477b3a73359..d9edfba19c8d9cd98a203fed2c071d3696d710b2 100644 --- a/Tests/UnitTests/Core/Sample/testlist.h +++ b/Tests/UnitTests/Core/Sample/testlist.h @@ -1,7 +1,7 @@ // To renew this file, run /G/ba/dev-tools/code-tools/update-gtestlist.py <directory> #include "FormFactorBasicTest.h" -#include "FormFactorWrapperTest.h" +#include "FormFactorCoherentSumTest.h" #include "LayerTest.h" #include "MultiLayerTest.h" #include "ParticleCoreShellTest.h" diff --git a/auto/Wrap/doxygen_core.i b/auto/Wrap/doxygen_core.i index 835808640b3f03e236445aefdaa17a91d48ef33d..29f20c229fe2f5fe8463ebca5eb49cd4b081166f 100644 --- a/auto/Wrap/doxygen_core.i +++ b/auto/Wrap/doxygen_core.i @@ -4363,7 +4363,7 @@ Calculates and returns a polarized form factor calculation in DWBA. Information about particle form factor and abundance. -C++ includes: FormFactorWrapper.h +C++ includes: FormFactorCoherentSum.h "; %feature("docstring") FormFactorWrapper::FormFactorWrapper "FormFactorWrapper::FormFactorWrapper(IFormFactor *ff, double abundance)