From 599398cc50bf7a112ea68dcce042b29c30d67e48 Mon Sep 17 00:00:00 2001 From: Walter Van Herck <w.van.herck@fz-juelich.de> Date: Tue, 10 Sep 2013 14:07:31 +0200 Subject: [PATCH] Merged form factor material decorators into FormFactorDecoratorMaterial (for both matrix and scalar materials); moved matrix evaluate to IFormFactor; removed FormFactorPol --- App/src/TestPolarizedDWBATerms.cpp | 15 ++- Core/Algorithms/src/LayerStrategyBuilder.cpp | 5 +- Core/Core.pro | 7 +- Core/FormFactors/inc/FormFactorDWBAPol.h | 14 ++- .../FormFactors/inc/FormFactorDWBAPolConstZ.h | 2 +- .../inc/FormFactorDecoratorFactor.h | 6 +- .../inc/FormFactorDecoratorMaterial.h | 59 +++++++++ .../inc/FormFactorDecoratorMatrixMaterial.h | 58 --------- .../FormFactorDecoratorMultiPositionFactor.h | 60 +--------- .../inc/FormFactorDecoratorScalarMaterial.h | 113 ------------------ Core/FormFactors/inc/FormFactorPol.h | 48 -------- Core/FormFactors/inc/FormFactorWeighted.h | 27 +---- Core/FormFactors/inc/FormFactors.h | 2 +- Core/FormFactors/inc/IFormFactor.h | 53 ++++++-- Core/FormFactors/src/FormFactorDWBAPol.cpp | 13 +- .../src/FormFactorDWBAPolConstZ.cpp | 2 +- .../src/FormFactorDecoratorMaterial.cpp | 97 +++++++++++++++ .../src/FormFactorDecoratorMatrixMaterial.cpp | 49 -------- Core/FormFactors/src/FormFactorPol.cpp | 33 ----- Core/FormFactors/src/FormFactorWeighted.cpp | 50 +------- Core/PythonAPI/src/MesoCrystal.pypp.cpp | 25 ---- Core/PythonAPI/src/Particle.pypp.cpp | 25 ---- Core/PythonAPI/src/ParticleCoreShell.pypp.cpp | 25 ---- Core/Samples/inc/LatticeBasis.h | 3 - Core/Samples/inc/Particle.h | 11 +- Core/Samples/src/LatticeBasis.cpp | 16 --- Core/Samples/src/Particle.cpp | 19 +-- Core/Samples/src/ParticleCoreShell.cpp | 4 +- Tests/UnitTests/TestCore/ParticleTest.h | 4 +- 29 files changed, 259 insertions(+), 586 deletions(-) create mode 100644 Core/FormFactors/inc/FormFactorDecoratorMaterial.h delete mode 100644 Core/FormFactors/inc/FormFactorDecoratorMatrixMaterial.h delete mode 100644 Core/FormFactors/inc/FormFactorDecoratorScalarMaterial.h delete mode 100644 Core/FormFactors/inc/FormFactorPol.h create mode 100644 Core/FormFactors/src/FormFactorDecoratorMaterial.cpp delete mode 100644 Core/FormFactors/src/FormFactorDecoratorMatrixMaterial.cpp delete mode 100644 Core/FormFactors/src/FormFactorPol.cpp diff --git a/App/src/TestPolarizedDWBATerms.cpp b/App/src/TestPolarizedDWBATerms.cpp index 6ca04382a69..14dab40a407 100644 --- a/App/src/TestPolarizedDWBATerms.cpp +++ b/App/src/TestPolarizedDWBATerms.cpp @@ -16,7 +16,7 @@ #include "TestPolarizedDWBATerms.h" #include "FormFactorDWBAPol.h" -#include "FormFactorDecoratorMatrixMaterial.h" +#include "FormFactorDecoratorMaterial.h" #include "FormFactorDWBA.h" #include "FormFactorCylinder.h" #include "LayerSpecularInfo.h" @@ -38,13 +38,12 @@ TestPolarizedDWBATerms::TestPolarizedDWBATerms() const IMaterial *p_ambient_material = MaterialManager::getHomogeneousMaterial( "ambient", complex_t(0.0, 0.0)); - FormFactorDecoratorMatrixMaterial *p_matrix_material_ff = - new FormFactorDecoratorMatrixMaterial(new FormFactorCylinder(1.0, 1.0)); - p_matrix_material_ff->setMaterial(p_particle_material); - p_matrix_material_ff->setAmbientMaterial(p_ambient_material); - mp_matrix_ff = new FormFactorDWBAPol(p_matrix_material_ff); - mp_scalar_ff = new FormFactorDWBA(new FormFactorCylinder( - 1.0, 1.0)); + FormFactorDecoratorMaterial *p_material_ff = + new FormFactorDecoratorMaterial(new FormFactorCylinder(1.0, 1.0)); + p_material_ff->setMaterial(p_particle_material); + p_material_ff->setAmbientMaterial(p_ambient_material); + mp_matrix_ff = new FormFactorDWBAPol(p_material_ff); + mp_scalar_ff = new FormFactorDWBA(p_material_ff->clone()); mp_specular_info = new LayerSpecularInfo(); initSpecularInfo(); mp_matrix_ff->setSpecularInfo(*mp_specular_info); diff --git a/Core/Algorithms/src/LayerStrategyBuilder.cpp b/Core/Algorithms/src/LayerStrategyBuilder.cpp index 83f5f2ffa85..79cb5220225 100644 --- a/Core/Algorithms/src/LayerStrategyBuilder.cpp +++ b/Core/Algorithms/src/LayerStrategyBuilder.cpp @@ -201,9 +201,8 @@ FormFactorInfo* LayerStrategyBuilder::createFormFactorInfoPol( P_particle_clone->setAmbientMaterial(p_ambient_material); // particle formfactor (includes scattering power) - FormFactorPol *ff_particle = P_particle_clone-> - createFormFactorMatrix(factor); - FormFactorPol *p_ff_framework(ff_particle); + IFormFactor *ff_particle = P_particle_clone->createFormFactor(factor); + IFormFactor *p_ff_framework(ff_particle); switch (m_sim_params.me_framework) { case SimulationParameters::BA: // Born Approximation diff --git a/Core/Core.pro b/Core/Core.pro index 5ffa113cd43..1aa7b05187d 100644 --- a/Core/Core.pro +++ b/Core/Core.pro @@ -90,7 +90,7 @@ SOURCES += \ FormFactors/src/FormFactorDWBAConstZ.cpp \ FormFactors/src/FormFactorDWBAPol.cpp \ FormFactors/src/FormFactorDWBAPolConstZ.cpp \ - FormFactors/src/FormFactorDecoratorMatrixMaterial.cpp \ + FormFactors/src/FormFactorDecoratorMaterial.cpp \ FormFactors/src/FormFactorDecoratorTransformation.cpp \ FormFactors/src/FormFactorEllipsoid.cpp \ FormFactors/src/FormFactorFullSphere.cpp \ @@ -99,7 +99,6 @@ SOURCES += \ FormFactors/src/FormFactorHemiSpheroid.cpp \ FormFactors/src/FormFactorLorentz.cpp \ FormFactors/src/FormFactorParallelepiped.cpp \ - FormFactors/src/FormFactorPol.cpp \ FormFactors/src/FormFactorPrism3.cpp \ FormFactors/src/FormFactorPrism6.cpp \ FormFactors/src/FormFactorPyramid.cpp \ @@ -248,10 +247,9 @@ HEADERS += \ FormFactors/inc/FormFactorDWBAPolConstZ.h \ FormFactors/inc/FormFactorDecoratorDebyeWaller.h \ FormFactors/inc/FormFactorDecoratorFactor.h \ - FormFactors/inc/FormFactorDecoratorMatrixMaterial.h \ + FormFactors/inc/FormFactorDecoratorMaterial.h \ FormFactors/inc/FormFactorDecoratorMultiPositionFactor.h \ FormFactors/inc/FormFactorDecoratorPositionFactor.h \ - FormFactors/inc/FormFactorDecoratorScalarMaterial.h \ FormFactors/inc/FormFactorDecoratorTransformation.h \ FormFactors/inc/FormFactorEllipsoid.h \ FormFactors/inc/FormFactorFullSphere.h \ @@ -260,7 +258,6 @@ HEADERS += \ FormFactors/inc/FormFactorHemiSpheroid.h \ FormFactors/inc/FormFactorLorentz.h \ FormFactors/inc/FormFactorParallelepiped.h \ - FormFactors/inc/FormFactorPol.h \ FormFactors/inc/FormFactorPrism3.h \ FormFactors/inc/FormFactorPrism6.h \ FormFactors/inc/FormFactorPyramid.h \ diff --git a/Core/FormFactors/inc/FormFactorDWBAPol.h b/Core/FormFactors/inc/FormFactorDWBAPol.h index c62aee0f3e3..f603191b980 100644 --- a/Core/FormFactors/inc/FormFactorDWBAPol.h +++ b/Core/FormFactors/inc/FormFactorDWBAPol.h @@ -16,18 +16,24 @@ #ifndef FORMFACTORDWBAPOL_H_ #define FORMFACTORDWBAPOL_H_ -#include "FormFactorPol.h" +#include "IFormFactor.h" +#include "LayerSpecularInfo.h" //! Evaluates a coherent sum of the 16 matrix DWBA terms in a polarized form factor -class FormFactorDWBAPol : public FormFactorPol +class FormFactorDWBAPol : public IFormFactor { public: - FormFactorDWBAPol(FormFactorPol *p_form_factor); + FormFactorDWBAPol(IFormFactor *p_form_factor); virtual ~FormFactorDWBAPol(); virtual FormFactorDWBAPol *clone() const; + //! Throws exception + virtual complex_t evaluate( + const cvector_t& k_i, const Bin1DCVector& k_f_bin, + double alpha_i, double alpha_f) const; + //! Calculates and returns a polarized form factor calculation in DWBA virtual Eigen::Matrix2cd evaluatePol(const cvector_t& k_i, const Bin1DCVector& k_f1_bin, const Bin1DCVector& k_f2_bin, @@ -46,7 +52,7 @@ protected: double phi_f) const; //! The matrix form factor for BA - FormFactorPol *mp_form_factor; + IFormFactor *mp_form_factor; //! The reflection/transmission coefficients in the layer LayerSpecularInfo *mp_specular_info; diff --git a/Core/FormFactors/inc/FormFactorDWBAPolConstZ.h b/Core/FormFactors/inc/FormFactorDWBAPolConstZ.h index 09e40a76062..edd114dc4b4 100644 --- a/Core/FormFactors/inc/FormFactorDWBAPolConstZ.h +++ b/Core/FormFactors/inc/FormFactorDWBAPolConstZ.h @@ -23,7 +23,7 @@ class FormFactorDWBAPolConstZ : public FormFactorDWBAPol { public: - FormFactorDWBAPolConstZ(FormFactorPol *p_formfactor, double depth=0.0); + FormFactorDWBAPolConstZ(IFormFactor *p_formfactor, double depth=0.0); virtual ~FormFactorDWBAPolConstZ(); virtual FormFactorDWBAPolConstZ *clone() const; diff --git a/Core/FormFactors/inc/FormFactorDecoratorFactor.h b/Core/FormFactors/inc/FormFactorDecoratorFactor.h index 64d70b1a81a..4438004be39 100644 --- a/Core/FormFactors/inc/FormFactorDecoratorFactor.h +++ b/Core/FormFactors/inc/FormFactorDecoratorFactor.h @@ -18,7 +18,7 @@ #include "IFormFactorDecorator.h" -//! ? +//! Decorates a form factor with a constant factor class FormFactorDecoratorFactor : public IFormFactorDecorator { @@ -27,7 +27,9 @@ class FormFactorDecoratorFactor : public IFormFactorDecorator virtual FormFactorDecoratorFactor *clone() const; virtual ~FormFactorDecoratorFactor() {} - virtual complex_t evaluate(const cvector_t& k_i, const Bin1DCVector& k_f_bin, double alpha_i, double alpha_f) const; + //! Evaluate the formfactor for scalar calculations + virtual complex_t evaluate(const cvector_t& k_i, + const Bin1DCVector& k_f_bin, double alpha_i, double alpha_f) const; virtual int getNumberOfStochasticParameters() const; diff --git a/Core/FormFactors/inc/FormFactorDecoratorMaterial.h b/Core/FormFactors/inc/FormFactorDecoratorMaterial.h new file mode 100644 index 00000000000..1b21f66ca0c --- /dev/null +++ b/Core/FormFactors/inc/FormFactorDecoratorMaterial.h @@ -0,0 +1,59 @@ +// ************************************************************************** // +// +// BornAgain: simulate and fit scattering at grazing incidence +// +//! @file FormFactors/inc/FormFactorDecoratorMaterial.h +//! @brief Defines class FormFactorDecoratorMaterial. +//! +//! @homepage http://apps.jcns.fz-juelich.de/BornAgain +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2013 +//! @authors Scientific Computing Group at MLZ Garching +//! @authors C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke +// +// ************************************************************************** // + +#ifndef FORMFACTORDECORATORMATERIAL_H_ +#define FORMFACTORDECORATORMATERIAL_H_ + +#include "FormFactorDecoratorFactor.h" +#include "HomogeneousMaterial.h" + +//! Decorates a scalar form factor with the correct factor for the material's +//! refractive index and that of its surrounding material + +class FormFactorDecoratorMaterial : public FormFactorDecoratorFactor +{ + public: + FormFactorDecoratorMaterial(IFormFactor *p_form_factor, + complex_t wavevector_scattering_factor=1.0); + virtual ~FormFactorDecoratorMaterial(); + + virtual FormFactorDecoratorMaterial *clone() const; + + //! Sets the material of the scatterer + virtual void setMaterial(const IMaterial *p_material); + + //! Retrieves the refractive index of the ambient material + virtual complex_t getAmbientRefractiveIndex() const; + +#ifndef GCCXML_SKIP_THIS + //! Returns scattering amplitude for matrix interactions + virtual Eigen::Matrix2cd evaluatePol(const cvector_t& k_i, + const Bin1DCVector& k_f1_bin, const Bin1DCVector& k_f2_bin, + double alpha_i, double alpha_f, double phi_f) const; +#endif + + //! Sets the ambient material + virtual void setAmbientMaterial(const IMaterial *p_material); + private: + complex_t getRefractiveIndexFactor() const; + + complex_t m_wavevector_scattering_factor; + const IMaterial *mp_material; + const IMaterial *mp_ambient_material; +}; + +#endif /* FORMFACTORDECORATORMATERIAL_H_ */ + + diff --git a/Core/FormFactors/inc/FormFactorDecoratorMatrixMaterial.h b/Core/FormFactors/inc/FormFactorDecoratorMatrixMaterial.h deleted file mode 100644 index 6e1f5c23537..00000000000 --- a/Core/FormFactors/inc/FormFactorDecoratorMatrixMaterial.h +++ /dev/null @@ -1,58 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file FormFactors/inc/FormFactorDecoratorMatrixMaterial.h -//! @brief Defines class FormFactorDecoratorMatrixMaterial. -//! -//! @homepage http://apps.jcns.fz-juelich.de/BornAgain -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2013 -//! @authors Scientific Computing Group at MLZ Garching -//! @authors C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke -// -// ************************************************************************** // - -#ifndef FORMFACTORDECORATORMATRIXMATERIAL_H_ -#define FORMFACTORDECORATORMATRIXMATERIAL_H_ - -#include "FormFactorPol.h" -#include "HomogeneousMagneticMaterial.h" - -//! Evaluates a polarized form factor (which is a 2x2 matrix) - -class BA_CORE_API_ FormFactorDecoratorMatrixMaterial : public FormFactorPol -{ -public: - FormFactorDecoratorMatrixMaterial(IFormFactor *p_formfactor, - complex_t wavevector_scattering_factor=1.0) - : mp_formfactor(p_formfactor) - , mp_material(0), mp_ambient_material(0) - , m_wavevector_scattering_factor(wavevector_scattering_factor) {} - virtual ~FormFactorDecoratorMatrixMaterial(); - - virtual FormFactorDecoratorMatrixMaterial *clone() const; - -#ifndef GCCXML_SKIP_THIS - //! Calculates and returns a polarized form factor calculation in DWBA - virtual Eigen::Matrix2cd evaluatePol(const cvector_t& k_i, - const Bin1DCVector& k_f1_bin, const Bin1DCVector& k_f2_bin, - double alpha_i, double alpha_f, double phi_f) const; -#endif - //! Sets the material of the scatterer - void setMaterial(const IMaterial *p_material) { - mp_material = p_material; - } - - //! Sets the material of the surrounding structure - virtual void setAmbientMaterial(const IMaterial *p_material) { - mp_ambient_material = p_material; - } -protected: - IFormFactor *mp_formfactor; - const IMaterial *mp_material; - const IMaterial *mp_ambient_material; - complex_t m_wavevector_scattering_factor; -}; - -#endif /* FORMFACTORDECORATORMATRIXMATERIAL_H_ */ diff --git a/Core/FormFactors/inc/FormFactorDecoratorMultiPositionFactor.h b/Core/FormFactors/inc/FormFactorDecoratorMultiPositionFactor.h index bb3e0441eab..b679457b1a9 100644 --- a/Core/FormFactors/inc/FormFactorDecoratorMultiPositionFactor.h +++ b/Core/FormFactors/inc/FormFactorDecoratorMultiPositionFactor.h @@ -29,38 +29,18 @@ public: virtual complex_t evaluate(const cvector_t& k_i, const Bin1DCVector& k_f_bin, double alpha_i, double alpha_f) const; - virtual int getNumberOfStochasticParameters() const { - return mp_form_factor->getNumberOfStochasticParameters(); - } - -private: - complex_t getPositionsFactor(cvector_t q) const; - std::vector<kvector_t> m_positions; -}; - -class FormFactorDecoratorMultiPositionFactorMat : public FormFactorPol -{ -public: - FormFactorDecoratorMultiPositionFactorMat(const FormFactorPol& form_factor, - std::vector<kvector_t> positions); - virtual ~FormFactorDecoratorMultiPositionFactorMat() { - delete mp_form_factor; - } - virtual FormFactorDecoratorMultiPositionFactorMat *clone() const; - - virtual int getNumberOfStochasticParameters() const { - return mp_form_factor->getNumberOfStochasticParameters(); - } - //! Calculates and returns a polarized form factor calculation in DWBA virtual Eigen::Matrix2cd evaluatePol(const cvector_t& k_i, const Bin1DCVector& k_f1_bin, const Bin1DCVector& k_f2_bin, double alpha_i, double alpha_f, double phi_f) const; + virtual int getNumberOfStochasticParameters() const { + return mp_form_factor->getNumberOfStochasticParameters(); + } + private: complex_t getPositionsFactor(cvector_t q) const; std::vector<kvector_t> m_positions; - FormFactorPol *mp_form_factor; }; inline FormFactorDecoratorMultiPositionFactor:: @@ -87,35 +67,7 @@ inline complex_t FormFactorDecoratorMultiPositionFactor::evaluate( alpha_i, alpha_f); } -inline complex_t FormFactorDecoratorMultiPositionFactor::getPositionsFactor( - cvector_t q) const -{ - complex_t result; - for (size_t i=0; i<m_positions.size(); ++i) { - complex_t qr = q.x()*m_positions[i].x() + q.y()*m_positions[i].y() - + q.z()*m_positions[i].z(); - result += std::exp(complex_t(0.0, 1.0)*qr); - } - return result; -} - -inline FormFactorDecoratorMultiPositionFactorMat:: -FormFactorDecoratorMultiPositionFactorMat( - const FormFactorPol& form_factor, std::vector<kvector_t> positions) -: m_positions(positions) -, mp_form_factor(form_factor.clone()) -{ - setName("FormFactorDecoratorMultiPositionFactorMat"); -} - -inline FormFactorDecoratorMultiPositionFactorMat* -FormFactorDecoratorMultiPositionFactorMat::clone() const -{ - return new FormFactorDecoratorMultiPositionFactorMat( - *mp_form_factor, m_positions); -} - -inline Eigen::Matrix2cd FormFactorDecoratorMultiPositionFactorMat::evaluatePol( +inline Eigen::Matrix2cd FormFactorDecoratorMultiPositionFactor::evaluatePol( const cvector_t& k_i, const Bin1DCVector& k_f1_bin, const Bin1DCVector& k_f2_bin, double alpha_i, double alpha_f, double phi_f) const @@ -125,7 +77,7 @@ inline Eigen::Matrix2cd FormFactorDecoratorMultiPositionFactorMat::evaluatePol( k_f2_bin, alpha_i, alpha_f, phi_f); } -inline complex_t FormFactorDecoratorMultiPositionFactorMat::getPositionsFactor( +inline complex_t FormFactorDecoratorMultiPositionFactor::getPositionsFactor( cvector_t q) const { complex_t result; diff --git a/Core/FormFactors/inc/FormFactorDecoratorScalarMaterial.h b/Core/FormFactors/inc/FormFactorDecoratorScalarMaterial.h deleted file mode 100644 index 83403ab258f..00000000000 --- a/Core/FormFactors/inc/FormFactorDecoratorScalarMaterial.h +++ /dev/null @@ -1,113 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file FormFactors/inc/FormFactorDecoratorScalarMaterial.h -//! @brief Defines class FormFactorDecoratorScalarMaterial. -//! -//! @homepage http://apps.jcns.fz-juelich.de/BornAgain -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2013 -//! @authors Scientific Computing Group at MLZ Garching -//! @authors C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke -// -// ************************************************************************** // - -#ifndef FORMFACTORDECORATORSCALARMATERIAL_H_ -#define FORMFACTORDECORATORSCALARMATERIAL_H_ - -#include "FormFactorDecoratorFactor.h" -#include "HomogeneousMaterial.h" - -//! Decorates a scalar form factor with the correct factor for the material's -//! refractive index and that of its surrounding material - -class FormFactorDecoratorScalarMaterial : public FormFactorDecoratorFactor -{ - public: - FormFactorDecoratorScalarMaterial(IFormFactor *p_form_factor, - complex_t wavevector_scattering_factor=1.0); - ~FormFactorDecoratorScalarMaterial(); - - FormFactorDecoratorScalarMaterial *clone() const; - - //! Sets the material of the scatterer - void setMaterial(const IMaterial *p_material); - - //! Retrieves the refractive index of the ambient material - virtual complex_t getAmbientRefractiveIndex() const { - if (mp_ambient_material) { - return mp_ambient_material->getRefractiveIndex(); - } - return 1.0; - } - - //! Sets the ambient material - virtual void setAmbientMaterial(const IMaterial *p_material); - private: - complex_t getRefractiveIndexFactor() const; - - complex_t m_wavevector_scattering_factor; - const IMaterial *mp_material; - const IMaterial *mp_ambient_material; -}; - -inline FormFactorDecoratorScalarMaterial::FormFactorDecoratorScalarMaterial( - IFormFactor* p_form_factor, complex_t wavevector_scattering_factor) -: FormFactorDecoratorFactor(p_form_factor, 1.0) -, m_wavevector_scattering_factor(wavevector_scattering_factor) -, mp_material(0) -, mp_ambient_material(0) -{ - setName("FormFactorDecoratorScalarMaterial"); -} - -inline FormFactorDecoratorScalarMaterial::~FormFactorDecoratorScalarMaterial() -{ -} - -inline FormFactorDecoratorScalarMaterial* -FormFactorDecoratorScalarMaterial::clone() const -{ - FormFactorDecoratorScalarMaterial *result = - new FormFactorDecoratorScalarMaterial(mp_form_factor->clone(), - m_wavevector_scattering_factor); - result->setMaterial(mp_material); - result->setAmbientMaterial(mp_ambient_material); - result->setName(getName()); - return result; -} - -inline void FormFactorDecoratorScalarMaterial::setMaterial( - const IMaterial* p_material) -{ - if (p_material) { - mp_material = p_material; - } - m_factor = getRefractiveIndexFactor(); -} - -inline void FormFactorDecoratorScalarMaterial::setAmbientMaterial( - const IMaterial *p_material) -{ - if (p_material) { - mp_ambient_material = p_material; - } - m_factor = getRefractiveIndexFactor(); -} - -inline complex_t -FormFactorDecoratorScalarMaterial::getRefractiveIndexFactor() const -{ - if (mp_material && mp_ambient_material) { - complex_t particle_index = mp_material->getRefractiveIndex(); - complex_t ambient_index = mp_ambient_material->getRefractiveIndex(); - return m_wavevector_scattering_factor * - (particle_index*particle_index - ambient_index*ambient_index); - } - else return m_wavevector_scattering_factor; -} - -#endif /* FORMFACTORDECORATORSCALARMATERIAL_H_ */ - - diff --git a/Core/FormFactors/inc/FormFactorPol.h b/Core/FormFactors/inc/FormFactorPol.h deleted file mode 100644 index df9437a2fc2..00000000000 --- a/Core/FormFactors/inc/FormFactorPol.h +++ /dev/null @@ -1,48 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file FormFactors/inc/FormFactorPol.h -//! @brief Defines class FormFactorPol. -//! -//! @homepage http://apps.jcns.fz-juelich.de/BornAgain -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2013 -//! @authors Scientific Computing Group at MLZ Garching -//! @authors C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke -// -// ************************************************************************** // - -#ifndef FORMFACTORPOL_H_ -#define FORMFACTORPOL_H_ - -#include "IFormFactorDecorator.h" -#include "LayerSpecularInfo.h" - -#ifndef GCCXML_SKIP_THIS -#include <Eigen/Core> -#endif - -//! Evaluates a polarized form factor (which is a 2x2 matrix) - -class BA_CORE_API_ FormFactorPol : public IFormFactor -{ -public: - FormFactorPol() {} - virtual ~FormFactorPol(); - - virtual FormFactorPol *clone() const=0; - - // Scalar evaluate throws exception - virtual complex_t evaluate(const cvector_t& k_i, - const Bin1DCVector& k_f_bin, double alpha_i, double alpha_f) const; - -#ifndef GCCXML_SKIP_THIS - //! Calculates and returns a polarized form factor calculation in DWBA - virtual Eigen::Matrix2cd evaluatePol(const cvector_t& k_i, - const Bin1DCVector& k_f1_bin, const Bin1DCVector& k_f2_bin, - double alpha_i, double alpha_f, double phi_f) const=0; -#endif -}; - -#endif /* FORMFACTORPOL_H_ */ diff --git a/Core/FormFactors/inc/FormFactorWeighted.h b/Core/FormFactors/inc/FormFactorWeighted.h index 21407ffadfd..bcf5f96e8ce 100644 --- a/Core/FormFactors/inc/FormFactorWeighted.h +++ b/Core/FormFactors/inc/FormFactorWeighted.h @@ -17,7 +17,6 @@ #define FORMFACTORWEIGHTED_H_ #include "IFormFactor.h" -#include "FormFactorPol.h" //! Coherent sum of different form factors with different weights //! (for scalar form factors) @@ -33,28 +32,8 @@ class FormFactorWeighted : public IFormFactor virtual void setAmbientMaterial(const IMaterial *p_material); - virtual complex_t evaluate(const cvector_t& k_i, const Bin1DCVector& k_f_bin, double alpha_i, double alpha_f) const; - - virtual int getNumberOfStochasticParameters() const; - - protected: - std::vector<IFormFactor *> m_form_factors; - std::vector<double> m_weights; -}; - -//! Coherent sum of different form factors with different weights -//! (for matrix form factors) - -class FormFactorWeightedMat : public FormFactorPol -{ - public: - FormFactorWeightedMat(); - virtual ~FormFactorWeightedMat(); - virtual FormFactorWeightedMat *clone() const; - - void addFormFactor(const FormFactorPol& form_factor, double weight=1.0); - - virtual void setAmbientMaterial(const IMaterial *p_material); + virtual complex_t evaluate(const cvector_t& k_i, + const Bin1DCVector& k_f_bin, double alpha_i, double alpha_f) const; //! Calculates and returns a polarized form factor calculation in DWBA virtual Eigen::Matrix2cd evaluatePol(const cvector_t& k_i, @@ -64,7 +43,7 @@ class FormFactorWeightedMat : public FormFactorPol virtual int getNumberOfStochasticParameters() const; protected: - std::vector<FormFactorPol *> m_form_factors; + std::vector<IFormFactor *> m_form_factors; std::vector<double> m_weights; }; diff --git a/Core/FormFactors/inc/FormFactors.h b/Core/FormFactors/inc/FormFactors.h index c0d95efb2aa..d2d0426fae7 100644 --- a/Core/FormFactors/inc/FormFactors.h +++ b/Core/FormFactors/inc/FormFactors.h @@ -24,7 +24,7 @@ #include "FormFactorDecoratorFactor.h" #include "FormFactorDecoratorMultiPositionFactor.h" #include "FormFactorDecoratorPositionFactor.h" -#include "FormFactorDecoratorScalarMaterial.h" +#include "FormFactorDecoratorMaterial.h" #include "FormFactorDecoratorTransformation.h" #include "FormFactorDWBA.h" #include "FormFactorDWBAConstZ.h" diff --git a/Core/FormFactors/inc/IFormFactor.h b/Core/FormFactors/inc/IFormFactor.h index 253e634407a..234de7c53c6 100644 --- a/Core/FormFactors/inc/IFormFactor.h +++ b/Core/FormFactors/inc/IFormFactor.h @@ -21,7 +21,11 @@ #include "ISample.h" #include "Bin.h" -//! The basic interface for formfactors. +#ifndef GCCXML_SKIP_THIS +#include <Eigen/Core> +#endif + +//! The basic interface for form factors. class BA_CORE_API_ IFormFactor : public ISample { @@ -32,11 +36,13 @@ class BA_CORE_API_ IFormFactor : public ISample virtual IFormFactor *clone() const=0; //! Calls the ISampleVisitor's visit method - virtual void accept(ISampleVisitor *p_visitor) const { p_visitor->visit(this); } + virtual void accept(ISampleVisitor *p_visitor) const { + p_visitor->visit(this); + } - //! Passes the refractive index of the ambient material in which this particle is embedded. - virtual void setAmbientMaterial(const IMaterial *p_material) - { + //! Passes the refractive index of the ambient material in which this + //! particle is embedded. + virtual void setAmbientMaterial(const IMaterial *p_material) { (void)p_material; // to prevent unused-variable warning } @@ -49,22 +55,37 @@ class BA_CORE_API_ IFormFactor : public ISample const cvector_t& k_i, const Bin1DCVector& k_f_bin, double alpha_i, double alpha_f) const=0; +#ifndef GCCXML_SKIP_THIS + //! Returns scattering amplitude for matrix interactions + //! @param k_i incoming wavevector + //! @param k_f1_bin outgoing wavevector bin for first eigenmode + //! @param k_f2_bin outgoing wavevector bin for second eigenmode + //! @param alpha_i incident inclination angle wrt scattering surface + //! @param alpha_f outgoing inclination angle wrt scattering surface + //! @param phi_f outgoing azimuthal angle wrt scattering surface + virtual Eigen::Matrix2cd evaluatePol(const cvector_t& k_i, + const Bin1DCVector& k_f1_bin, const Bin1DCVector& k_f2_bin, + double alpha_i, double alpha_f, double phi_f) const; +#endif + //! Returns number of variable/stochastic parameters virtual int getNumberOfStochasticParameters() const { return 0; } - //! Returns the total volume of the particle to which this formfactor belongs + //! Returns the total volume of the particle of this form factor's shape virtual double getVolume() const; - //! Returns the total height of the particle to which this formfactor belongs + //! Returns the total height of the particle of this form factor's shape virtual double getHeight() const; - //! Returns the total radial size of the particle to which this formfactor belongs + //! Returns the total radial size of the particle of this form factor's shape virtual double getRadius() const; - //! Returns true if the formfactor is constructed as an average over multiple simple ones + //! Returns true if the form factor is constructed as an average over + //! multiple simple ones virtual bool isDistributedFormFactor() const { return false; } - //! retrieve a list of simple formfactors and their probabilities when the formfactor is a distributed one + //! retrieve a list of simple form factors and their probabilities when the + //! form factor is a distributed one virtual void createDistributedFormFactors( std::vector<IFormFactor *>& form_factors, std::vector<double>& probabilities, @@ -75,6 +96,18 @@ class BA_CORE_API_ IFormFactor : public ISample } }; +#ifndef GCCXML_SKIP_THIS +inline Eigen::Matrix2cd IFormFactor::evaluatePol(const cvector_t& k_i, + const Bin1DCVector& k_f1_bin, const Bin1DCVector& k_f2_bin, + double alpha_i, double alpha_f, double phi_f) const +{ + (void)k_f2_bin; + (void)phi_f; + Eigen::Matrix2cd unit_matrix = Eigen::Matrix2cd::Identity(); + return evaluate(k_i, k_f1_bin, alpha_i, alpha_f) * unit_matrix; +} +#endif + inline double IFormFactor::getVolume() const { cvector_t zero; diff --git a/Core/FormFactors/src/FormFactorDWBAPol.cpp b/Core/FormFactors/src/FormFactorDWBAPol.cpp index 966c5a25c8a..be582b484cb 100644 --- a/Core/FormFactors/src/FormFactorDWBAPol.cpp +++ b/Core/FormFactors/src/FormFactorDWBAPol.cpp @@ -16,7 +16,7 @@ #include "FormFactorDWBAPol.h" #include "Exceptions.h" -FormFactorDWBAPol::FormFactorDWBAPol(FormFactorPol* p_form_factor) +FormFactorDWBAPol::FormFactorDWBAPol(IFormFactor* p_form_factor) : mp_form_factor(p_form_factor) , mp_specular_info(0) { @@ -36,6 +36,17 @@ FormFactorDWBAPol* FormFactorDWBAPol::clone() const return p_result; } +complex_t FormFactorDWBAPol::evaluate(const cvector_t& k_i, + const Bin1DCVector& k_f_bin, double alpha_i, double alpha_f) const +{ + (void)k_i; + (void)k_f_bin; + (void)alpha_i; + (void)alpha_f; + throw NotImplementedException("FormFactorDWBAPol::evaluate: " + "should never be called for matrix interactions"); +} + Eigen::Matrix2cd FormFactorDWBAPol::evaluatePol(const cvector_t& k_i, const Bin1DCVector& k_f1_bin, const Bin1DCVector& k_f2_bin, double alpha_i, double alpha_f, double phi_f) const diff --git a/Core/FormFactors/src/FormFactorDWBAPolConstZ.cpp b/Core/FormFactors/src/FormFactorDWBAPolConstZ.cpp index 578a86d13ff..0806c35d30a 100644 --- a/Core/FormFactors/src/FormFactorDWBAPolConstZ.cpp +++ b/Core/FormFactors/src/FormFactorDWBAPolConstZ.cpp @@ -15,7 +15,7 @@ #include "FormFactorDWBAPolConstZ.h" -FormFactorDWBAPolConstZ::FormFactorDWBAPolConstZ(FormFactorPol* p_formfactor, +FormFactorDWBAPolConstZ::FormFactorDWBAPolConstZ(IFormFactor* p_formfactor, double depth) : FormFactorDWBAPol(p_formfactor) , m_depth(depth) diff --git a/Core/FormFactors/src/FormFactorDecoratorMaterial.cpp b/Core/FormFactors/src/FormFactorDecoratorMaterial.cpp new file mode 100644 index 00000000000..2dd91666c07 --- /dev/null +++ b/Core/FormFactors/src/FormFactorDecoratorMaterial.cpp @@ -0,0 +1,97 @@ +// ************************************************************************** // +// +// BornAgain: simulate and fit scattering at grazing incidence +// +//! @file FormFactorDecoratorMaterial.cpp +//! @brief Defines class . +//! +//! @homepage http://apps.jcns.fz-juelich.de/BornAgain +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2013 +//! @authors Scientific Computing Group at MLZ Garching +//! @authors C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke +// +// ************************************************************************** // + +#include "FormFactorDecoratorMaterial.h" + +FormFactorDecoratorMaterial::FormFactorDecoratorMaterial( + IFormFactor* p_form_factor, complex_t wavevector_scattering_factor) +: FormFactorDecoratorFactor(p_form_factor, 1.0) +, m_wavevector_scattering_factor(wavevector_scattering_factor) +, mp_material(0) +, mp_ambient_material(0) +{ + setName("FormFactorDecoratorMaterial"); +} + +FormFactorDecoratorMaterial::~FormFactorDecoratorMaterial() +{ +} + +FormFactorDecoratorMaterial *FormFactorDecoratorMaterial::clone() const +{ + FormFactorDecoratorMaterial *result = + new FormFactorDecoratorMaterial(mp_form_factor->clone(), + m_wavevector_scattering_factor); + result->setMaterial(mp_material); + result->setAmbientMaterial(mp_ambient_material); + result->setName(getName()); + return result; +} + +void FormFactorDecoratorMaterial::setMaterial(const IMaterial* p_material) +{ + if (p_material) { + mp_material = p_material; + } + m_factor = getRefractiveIndexFactor(); +} + +complex_t FormFactorDecoratorMaterial::getAmbientRefractiveIndex() const +{ + if (mp_ambient_material) { + return mp_ambient_material->getRefractiveIndex(); + } + return 1.0; +} + +Eigen::Matrix2cd FormFactorDecoratorMaterial::evaluatePol(const cvector_t& k_i, + const Bin1DCVector& k_f1_bin, const Bin1DCVector& k_f2_bin, + double alpha_i, double alpha_f, double phi_f) const +{ + (void)k_f2_bin; + (void)phi_f; + // the conjugated linear part of time reversal operator T + // (T=UK with K complex conjugate operator and U is linear) + Eigen::Matrix2cd time_reverse_conj = Eigen::Matrix2cd::Zero(); + time_reverse_conj(0,1) = 1.0; + time_reverse_conj(1,0) = -1.0; + // the interaction and time reversal taken together: + double k_mag2 = std::abs(k_i.magxy2())/std::cos(alpha_i)/std::cos(alpha_i); + Eigen::Matrix2cd V_eff = m_wavevector_scattering_factor * time_reverse_conj + * (mp_material->getScatteringMatrix(k_mag2) - + mp_ambient_material->getScatteringMatrix(k_mag2)); + return mp_form_factor->evaluate(k_i, k_f1_bin, alpha_i, alpha_f) * V_eff; +} + +void FormFactorDecoratorMaterial::setAmbientMaterial( + const IMaterial *p_material) +{ + if (p_material) { + mp_ambient_material = p_material; + } + m_factor = getRefractiveIndexFactor(); +} + +complex_t FormFactorDecoratorMaterial::getRefractiveIndexFactor() const +{ + if (mp_material && mp_ambient_material) { + complex_t particle_index = mp_material->getRefractiveIndex(); + complex_t ambient_index = mp_ambient_material->getRefractiveIndex(); + return m_wavevector_scattering_factor * + (particle_index*particle_index - ambient_index*ambient_index); + } + else return m_wavevector_scattering_factor; +} + diff --git a/Core/FormFactors/src/FormFactorDecoratorMatrixMaterial.cpp b/Core/FormFactors/src/FormFactorDecoratorMatrixMaterial.cpp deleted file mode 100644 index c14396c60c5..00000000000 --- a/Core/FormFactors/src/FormFactorDecoratorMatrixMaterial.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file FormFactors/src/FormFactorDecoratorMatrixMaterial.cpp -//! @brief Implements class FormFactorDecoratorMatrixMaterial. -//! -//! @homepage http://apps.jcns.fz-juelich.de/BornAgain -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2013 -//! @authors Scientific Computing Group at MLZ Garching -//! @authors C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke -// -// ************************************************************************** // - -#include "FormFactorDecoratorMatrixMaterial.h" - -FormFactorDecoratorMatrixMaterial::~FormFactorDecoratorMatrixMaterial() -{ -} - -FormFactorDecoratorMatrixMaterial* FormFactorDecoratorMatrixMaterial::clone() const -{ - FormFactorDecoratorMatrixMaterial *p_result = new FormFactorDecoratorMatrixMaterial( - mp_formfactor->clone(), m_wavevector_scattering_factor); - p_result->setName(getName()); - p_result->setMaterial(mp_material); - p_result->setAmbientMaterial(mp_ambient_material); - return p_result; -} - -Eigen::Matrix2cd FormFactorDecoratorMatrixMaterial::evaluatePol(const cvector_t& k_i, - const Bin1DCVector& k_f1_bin, const Bin1DCVector& k_f2_bin, - double alpha_i, double alpha_f, double phi_f) const -{ - (void)k_f2_bin; - (void)phi_f; - // the conjugated linear part of time reversal operator T - // (T=UK with K complex conjugate operator and U is linear) - Eigen::Matrix2cd time_reverse_conj = Eigen::Matrix2cd::Zero(); - time_reverse_conj(0,1) = 1.0; - time_reverse_conj(1,0) = -1.0; - // the interaction and time reversal taken together: - double k_mag2 = std::abs(k_i.magxy2())/std::cos(alpha_i)/std::cos(alpha_i); - Eigen::Matrix2cd V_eff = m_wavevector_scattering_factor * time_reverse_conj - * (mp_material->getScatteringMatrix(k_mag2) - - mp_ambient_material->getScatteringMatrix(k_mag2)); - return mp_formfactor->evaluate(k_i, k_f1_bin, alpha_i, alpha_f) * V_eff; -} diff --git a/Core/FormFactors/src/FormFactorPol.cpp b/Core/FormFactors/src/FormFactorPol.cpp deleted file mode 100644 index 983e070214b..00000000000 --- a/Core/FormFactors/src/FormFactorPol.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file FormFactors/src/FormFactorPol.cpp -//! @brief Implements class FormFactorPol. -//! -//! @homepage http://apps.jcns.fz-juelich.de/BornAgain -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2013 -//! @authors Scientific Computing Group at MLZ Garching -//! @authors C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke -// -// ************************************************************************** // - -#include "FormFactorPol.h" - -FormFactorPol::~FormFactorPol() -{ -} - -complex_t FormFactorPol::evaluate(const cvector_t& k_i, - const Bin1DCVector& k_f_bin, double alpha_i, double alpha_f) const -{ - (void)k_i; - (void)k_f_bin; - (void)alpha_i; - (void)alpha_f; - throw Exceptions::NotImplementedException("FormFactorPol::evaluate:" - " scalar evaluate should never be called for matrix ff"); -} - - diff --git a/Core/FormFactors/src/FormFactorWeighted.cpp b/Core/FormFactors/src/FormFactorWeighted.cpp index c8d196af10d..2ce1e683897 100644 --- a/Core/FormFactors/src/FormFactorWeighted.cpp +++ b/Core/FormFactors/src/FormFactorWeighted.cpp @@ -61,52 +61,7 @@ complex_t FormFactorWeighted::evaluate(const cvector_t& k_i, const Bin1DCVector& return result; } -int FormFactorWeighted::getNumberOfStochasticParameters() const -{ - int result=0; - for (size_t index=0; index<m_form_factors.size(); ++index) { - result += m_form_factors[index]->getNumberOfStochasticParameters(); - } - return result; -} - -FormFactorWeightedMat::FormFactorWeightedMat() -{ - setName("FormFactorWeightedMat"); -} - -FormFactorWeightedMat::~FormFactorWeightedMat() -{ - for (size_t index=0; index<m_form_factors.size(); ++index) { - delete m_form_factors[index]; - } -} - -FormFactorWeightedMat* FormFactorWeightedMat::clone() const -{ - FormFactorWeightedMat *result = new FormFactorWeightedMat(); - for (size_t index=0; index<m_form_factors.size(); ++index) { - result->addFormFactor(*m_form_factors[index], m_weights[index]); - } - result->setName(getName()); - return result; -} - -void FormFactorWeightedMat::addFormFactor(const FormFactorPol& form_factor, - double weight) -{ - m_form_factors.push_back(form_factor.clone()); - m_weights.push_back(weight); -} - -void FormFactorWeightedMat::setAmbientMaterial(const IMaterial* p_material) -{ - for (size_t index=0; index<m_form_factors.size(); ++index) { - m_form_factors[index]->setAmbientMaterial(p_material); - } -} - -Eigen::Matrix2cd FormFactorWeightedMat::evaluatePol(const cvector_t& k_i, +Eigen::Matrix2cd FormFactorWeighted::evaluatePol(const cvector_t& k_i, const Bin1DCVector& k_f1_bin, const Bin1DCVector& k_f2_bin, double alpha_i, double alpha_f, double phi_f) const { @@ -119,7 +74,7 @@ Eigen::Matrix2cd FormFactorWeightedMat::evaluatePol(const cvector_t& k_i, return result; } -int FormFactorWeightedMat::getNumberOfStochasticParameters() const +int FormFactorWeighted::getNumberOfStochasticParameters() const { int result=0; for (size_t index=0; index<m_form_factors.size(); ++index) { @@ -127,3 +82,4 @@ int FormFactorWeightedMat::getNumberOfStochasticParameters() const } return result; } + diff --git a/Core/PythonAPI/src/MesoCrystal.pypp.cpp b/Core/PythonAPI/src/MesoCrystal.pypp.cpp index 9771b8467dd..ec1cffea82e 100644 --- a/Core/PythonAPI/src/MesoCrystal.pypp.cpp +++ b/Core/PythonAPI/src/MesoCrystal.pypp.cpp @@ -49,18 +49,6 @@ struct MesoCrystal_wrapper : MesoCrystal, bp::wrapper< MesoCrystal > { IParameterized::clearParameterPool( ); } - virtual ::FormFactorPol * createFormFactorMatrix( ::complex_t wavevector_scattering_factor ) const { - if( bp::override func_createFormFactorMatrix = this->get_override( "createFormFactorMatrix" ) ) - return func_createFormFactorMatrix( wavevector_scattering_factor ); - else{ - return this->Particle::createFormFactorMatrix( wavevector_scattering_factor ); - } - } - - ::FormFactorPol * default_createFormFactorMatrix( ::complex_t wavevector_scattering_factor ) const { - return Particle::createFormFactorMatrix( wavevector_scattering_factor ); - } - virtual ::ParameterPool * createParameterTree( ) const { if( bp::override func_createParameterTree = this->get_override( "createParameterTree" ) ) return func_createParameterTree( ); @@ -205,19 +193,6 @@ void register_MesoCrystal_class(){ , clearParameterPool_function_type(&::IParameterized::clearParameterPool) , default_clearParameterPool_function_type(&MesoCrystal_wrapper::default_clearParameterPool) ); - } - { //::Particle::createFormFactorMatrix - - typedef ::FormFactorPol * ( ::Particle::*createFormFactorMatrix_function_type )( ::complex_t ) const; - typedef ::FormFactorPol * ( MesoCrystal_wrapper::*default_createFormFactorMatrix_function_type )( ::complex_t ) const; - - MesoCrystal_exposer.def( - "createFormFactorMatrix" - , createFormFactorMatrix_function_type(&::Particle::createFormFactorMatrix) - , default_createFormFactorMatrix_function_type(&MesoCrystal_wrapper::default_createFormFactorMatrix) - , ( bp::arg("wavevector_scattering_factor") ) - , bp::return_value_policy< bp::manage_new_object >() ); - } { //::IParameterized::createParameterTree diff --git a/Core/PythonAPI/src/Particle.pypp.cpp b/Core/PythonAPI/src/Particle.pypp.cpp index 6ee5d29d2c1..121031657ed 100644 --- a/Core/PythonAPI/src/Particle.pypp.cpp +++ b/Core/PythonAPI/src/Particle.pypp.cpp @@ -68,18 +68,6 @@ struct Particle_wrapper : Particle, bp::wrapper< Particle > { return Particle::createFormFactor( wavevector_scattering_factor ); } - virtual ::FormFactorPol * createFormFactorMatrix( ::complex_t wavevector_scattering_factor ) const { - if( bp::override func_createFormFactorMatrix = this->get_override( "createFormFactorMatrix" ) ) - return func_createFormFactorMatrix( wavevector_scattering_factor ); - else{ - return this->Particle::createFormFactorMatrix( wavevector_scattering_factor ); - } - } - - ::FormFactorPol * default_createFormFactorMatrix( ::complex_t wavevector_scattering_factor ) const { - return Particle::createFormFactorMatrix( wavevector_scattering_factor ); - } - virtual ::IMaterial const * getMaterial( ) const { if( bp::override func_getMaterial = this->get_override( "getMaterial" ) ) return func_getMaterial( ); @@ -276,19 +264,6 @@ void register_Particle_class(){ , ( bp::arg("wavevector_scattering_factor") ) , bp::return_value_policy< bp::manage_new_object >() ); - } - { //::Particle::createFormFactorMatrix - - typedef ::FormFactorPol * ( ::Particle::*createFormFactorMatrix_function_type )( ::complex_t ) const; - typedef ::FormFactorPol * ( Particle_wrapper::*default_createFormFactorMatrix_function_type )( ::complex_t ) const; - - Particle_exposer.def( - "createFormFactorMatrix" - , createFormFactorMatrix_function_type(&::Particle::createFormFactorMatrix) - , default_createFormFactorMatrix_function_type(&Particle_wrapper::default_createFormFactorMatrix) - , ( bp::arg("wavevector_scattering_factor") ) - , bp::return_value_policy< bp::manage_new_object >() ); - } { //::Particle::getMaterial diff --git a/Core/PythonAPI/src/ParticleCoreShell.pypp.cpp b/Core/PythonAPI/src/ParticleCoreShell.pypp.cpp index 875049d6fe0..6482b19436a 100644 --- a/Core/PythonAPI/src/ParticleCoreShell.pypp.cpp +++ b/Core/PythonAPI/src/ParticleCoreShell.pypp.cpp @@ -49,18 +49,6 @@ struct ParticleCoreShell_wrapper : ParticleCoreShell, bp::wrapper< ParticleCoreS IParameterized::clearParameterPool( ); } - virtual ::FormFactorPol * createFormFactorMatrix( ::complex_t wavevector_scattering_factor ) const { - if( bp::override func_createFormFactorMatrix = this->get_override( "createFormFactorMatrix" ) ) - return func_createFormFactorMatrix( wavevector_scattering_factor ); - else{ - return this->Particle::createFormFactorMatrix( wavevector_scattering_factor ); - } - } - - ::FormFactorPol * default_createFormFactorMatrix( ::complex_t wavevector_scattering_factor ) const { - return Particle::createFormFactorMatrix( wavevector_scattering_factor ); - } - virtual ::ParameterPool * createParameterTree( ) const { if( bp::override func_createParameterTree = this->get_override( "createParameterTree" ) ) return func_createParameterTree( ); @@ -205,19 +193,6 @@ void register_ParticleCoreShell_class(){ , clearParameterPool_function_type(&::IParameterized::clearParameterPool) , default_clearParameterPool_function_type(&ParticleCoreShell_wrapper::default_clearParameterPool) ); - } - { //::Particle::createFormFactorMatrix - - typedef ::FormFactorPol * ( ::Particle::*createFormFactorMatrix_function_type )( ::complex_t ) const; - typedef ::FormFactorPol * ( ParticleCoreShell_wrapper::*default_createFormFactorMatrix_function_type )( ::complex_t ) const; - - ParticleCoreShell_exposer.def( - "createFormFactorMatrix" - , createFormFactorMatrix_function_type(&::Particle::createFormFactorMatrix) - , default_createFormFactorMatrix_function_type(&ParticleCoreShell_wrapper::default_createFormFactorMatrix) - , ( bp::arg("wavevector_scattering_factor") ) - , bp::return_value_policy< bp::manage_new_object >() ); - } { //::IParameterized::createParameterTree diff --git a/Core/Samples/inc/LatticeBasis.h b/Core/Samples/inc/LatticeBasis.h index 485947b0e9a..6d0419f94f6 100644 --- a/Core/Samples/inc/LatticeBasis.h +++ b/Core/Samples/inc/LatticeBasis.h @@ -45,9 +45,6 @@ public: virtual IFormFactor* createFormFactor( complex_t wavevector_scattering_factor) const; - virtual FormFactorPol* createFormFactorMatrix( - complex_t wavevector_scattering_factor) const; - //! Returns number of different particles size_t getNbrParticles() const {return m_particles.size(); } diff --git a/Core/Samples/inc/Particle.h b/Core/Samples/inc/Particle.h index ece024dcffc..f541194e7ef 100644 --- a/Core/Samples/inc/Particle.h +++ b/Core/Samples/inc/Particle.h @@ -17,8 +17,7 @@ #define PARTICLE_H #include "ICompositeSample.h" -#include "FormFactorDecoratorMatrixMaterial.h" -#include "FormFactorDecoratorScalarMaterial.h" +#include "FormFactorDecoratorMaterial.h" #include "FormFactorDecoratorTransformation.h" #include "HomogeneousMaterial.h" @@ -51,18 +50,12 @@ class BA_CORE_API_ Particle : public ICompositeSample mp_ambient_material = p_material; } - //! Create a scalar form factor which includes the particle's shape, + //! Create a form factor which includes the particle's shape, //! material, ambient material, an optional transformation and an extra //! scattering factor virtual IFormFactor* createFormFactor( complex_t wavevector_scattering_factor) const; - //! Create a matrix form factor which includes the particle's shape, - //! material, ambient material, an optional transformation and an extra - //! scattering factor - virtual FormFactorPol* createFormFactorMatrix( - complex_t wavevector_scattering_factor) const; - //! Sets _material_ and _thickness_. virtual void setMaterial(const IMaterial* p_material) { mp_material = p_material; diff --git a/Core/Samples/src/LatticeBasis.cpp b/Core/Samples/src/LatticeBasis.cpp index 6052cf4823e..35844204252 100644 --- a/Core/Samples/src/LatticeBasis.cpp +++ b/Core/Samples/src/LatticeBasis.cpp @@ -101,22 +101,6 @@ IFormFactor* LatticeBasis::createFormFactor( return p_ff; } -FormFactorPol* LatticeBasis::createFormFactorMatrix( - complex_t wavevector_scattering_factor) const -{ - //TODO: replace with matrix versions - FormFactorWeightedMat *p_ff = new FormFactorWeightedMat(); - for (size_t index=0; index<m_particles.size(); ++index) { - FormFactorPol *p_particle_ff = m_particles[index]->createFormFactorMatrix( - wavevector_scattering_factor); - FormFactorDecoratorMultiPositionFactorMat pos_ff(*p_particle_ff, m_positions_vector[index]); - p_ff->addFormFactor(pos_ff); - delete p_particle_ff; - } - p_ff->setAmbientMaterial(mp_ambient_material); - return p_ff; -} - std::vector<DiffuseParticleInfo *> LatticeBasis::createDiffuseParticleInfos() const { std::vector<DiffuseParticleInfo *> result; diff --git a/Core/Samples/src/Particle.cpp b/Core/Samples/src/Particle.cpp index 2bd3178c1ff..dea932a2752 100644 --- a/Core/Samples/src/Particle.cpp +++ b/Core/Samples/src/Particle.cpp @@ -106,23 +106,8 @@ IFormFactor* Particle::createFormFactor( if (!p_transformed_ff) { return 0; } - FormFactorDecoratorScalarMaterial *p_ff = - new FormFactorDecoratorScalarMaterial( - p_transformed_ff, wavevector_scattering_factor); - p_ff->setMaterial(mp_material); - p_ff->setAmbientMaterial(mp_ambient_material); - return p_ff; -} - -FormFactorPol* Particle::createFormFactorMatrix( - complex_t wavevector_scattering_factor) const -{ - IFormFactor *p_transformed_ff = createTransformedFormFactor(); - if (!p_transformed_ff) { - return 0; - } - FormFactorDecoratorMatrixMaterial *p_ff = - new FormFactorDecoratorMatrixMaterial( + FormFactorDecoratorMaterial *p_ff = + new FormFactorDecoratorMaterial( p_transformed_ff, wavevector_scattering_factor); p_ff->setMaterial(mp_material); p_ff->setAmbientMaterial(mp_ambient_material); diff --git a/Core/Samples/src/ParticleCoreShell.cpp b/Core/Samples/src/ParticleCoreShell.cpp index 985a6091de4..81667354e4e 100644 --- a/Core/Samples/src/ParticleCoreShell.cpp +++ b/Core/Samples/src/ParticleCoreShell.cpp @@ -54,13 +54,13 @@ IFormFactor *ParticleCoreShell::createFormFactor( complex_t wavevector_scattering_factor) const { FormFactorWeighted *p_result = new FormFactorWeighted; - FormFactorDecoratorScalarMaterial ff_shell(mp_shell-> + FormFactorDecoratorMaterial ff_shell(mp_shell-> getSimpleFormFactor()->clone(), wavevector_scattering_factor); ff_shell.setMaterial(mp_shell->getMaterial()); ff_shell.setAmbientMaterial(mp_ambient_material); p_result->addFormFactor(ff_shell, 1.0); - FormFactorDecoratorScalarMaterial ff_core(mp_core->getSimpleFormFactor()-> + FormFactorDecoratorMaterial ff_core(mp_core->getSimpleFormFactor()-> clone(), wavevector_scattering_factor); ff_core.setMaterial(mp_core->getMaterial()); diff --git a/Tests/UnitTests/TestCore/ParticleTest.h b/Tests/UnitTests/TestCore/ParticleTest.h index 42c839fd0cc..ffa536e1e88 100644 --- a/Tests/UnitTests/TestCore/ParticleTest.h +++ b/Tests/UnitTests/TestCore/ParticleTest.h @@ -57,10 +57,10 @@ TEST_F(ParticleTest, ParticleConstructors) EXPECT_EQ("FormFactorFullSphere", p2->getSimpleFormFactor()->getName()); EXPECT_EQ(1, p2->getSimpleFormFactor()->getRadius()); EXPECT_FALSE(p2->hasDistributedFormFactor()); - EXPECT_TRUE(dynamic_cast<FormFactorDecoratorScalarMaterial *>( + EXPECT_TRUE(dynamic_cast<FormFactorDecoratorMaterial *>( p2->createFormFactor(1.0))); EXPECT_EQ(complex_t(1,0), - dynamic_cast<FormFactorDecoratorScalarMaterial *>( + dynamic_cast<FormFactorDecoratorMaterial *>( p2->createFormFactor(1.0))->getAmbientRefractiveIndex()); delete p2; -- GitLab