diff --git a/Core/FormFactors/inc/FormFactorCrystal.h b/Core/FormFactors/inc/FormFactorCrystal.h index ac3967a04a2dee69847f2ab75601620b1cd2e08a..eaf7d37005e57d8c0a417856ad49d11326abd70c 100644 --- a/Core/FormFactors/inc/FormFactorCrystal.h +++ b/Core/FormFactors/inc/FormFactorCrystal.h @@ -33,9 +33,7 @@ public: virtual void setAmbientRefractiveIndex(complex_t refractive_index); - //! propagate the bin sizes to the form factor to possibly enable large bin size approximations virtual void setBinSizes(double delta_qy, double delta_qz) { - IFormFactor::setBinSizes(delta_qy, delta_qz); mp_basis_form_factor->setBinSizes(delta_qy, delta_qz); mp_meso_form_factor->setBinSizes(delta_qy, delta_qz); } diff --git a/Core/FormFactors/inc/IFormFactor.h b/Core/FormFactors/inc/IFormFactor.h index ca18cfcec63e7b39c5e9ac3bf80f8225fbf9b70d..1b40c1eb3cb65eb3f413fe20c9fb0cefcf87ff7c 100644 --- a/Core/FormFactors/inc/IFormFactor.h +++ b/Core/FormFactors/inc/IFormFactor.h @@ -29,7 +29,7 @@ class IFormFactor : public ISample { public: - IFormFactor() : m_use_large_bin_approximation(false), m_bin_qy(0.0), m_bin_qz(0.0) {} + IFormFactor() {} virtual ~IFormFactor() {} //! create a clone of this formfactor @@ -47,7 +47,7 @@ public: virtual int getNumberOfStochasticParameters() const { return 0; } //! propagate the bin sizes to the form factor to possibly enable large bin size approximations - virtual void setBinSizes(double delta_qy, double delta_qz); + virtual void setBinSizes(double delta_qy, double delta_qz)=0; //! get the total volume of the particle to which this formfactor belongs virtual double getVolume() const; @@ -71,24 +71,8 @@ public: //! static method to calculate bin sizes in reciprocal space static double CalculateBinSize(double lambda, double phi_range, size_t n_phi); - -protected: - bool m_use_large_bin_approximation; //!< indicates if large bin size approximation should be used - double m_bin_qy, m_bin_qz; //!< the sizes of the bins in q space }; -inline void IFormFactor::setBinSizes(double delta_qy, double delta_qz) -{ - m_bin_qy = delta_qy; - m_bin_qz = delta_qz; - if (m_bin_qy > M_PI/2.0/getRadius() || m_bin_qz > M_PI/2.0/getHeight()) { - m_use_large_bin_approximation = true; - } - else { - m_use_large_bin_approximation = false; - } -} - inline double IFormFactor::getVolume() const { cvector_t zero; diff --git a/Core/FormFactors/inc/IFormFactorBorn.h b/Core/FormFactors/inc/IFormFactorBorn.h index ccf77935abb3e5a5ed1974298b3c9ece258b23b1..05390ca00c25bd284c41701e09bf70179eaca726 100644 --- a/Core/FormFactors/inc/IFormFactorBorn.h +++ b/Core/FormFactors/inc/IFormFactorBorn.h @@ -27,12 +27,14 @@ class IFormFactorBorn : public IFormFactor { public: - IFormFactorBorn() {} + IFormFactorBorn(); virtual ~IFormFactorBorn() {} virtual IFormFactorBorn *clone() const=0; virtual complex_t evaluate(const cvector_t &k_i, const cvector_t &k_f, double alpha_i, double alpha_f) const; + virtual void setBinSizes(double delta_qy, double delta_qz); + //! evaluate scattering amplitude for large bin sizes virtual complex_t evaluateForLargeBins(const cvector_t &q) const; protected: @@ -42,6 +44,10 @@ protected: //! override volume getter to avoid infinite loop caused by big bin approximation virtual double getVolume() const; + + bool m_use_large_bin_approximation_radial; //!< indicates if large bin size approximation should be used in the qx-qy direction + bool m_use_large_bin_approximation_z; //!< indicates if large bin size approximation should be used in the qz direction + double m_bin_qy, m_bin_qz; //!< the sizes of the bins in q space private: double bigRadialPart(double qR, void *params) const; double bigZPart(double qH2) const; @@ -51,7 +57,7 @@ inline complex_t IFormFactorBorn::evaluate(const cvector_t &k_i, const cvector_t { (void)alpha_i; (void)alpha_f; - if (m_use_large_bin_approximation) { + if (m_use_large_bin_approximation_radial || m_use_large_bin_approximation_z) { return evaluateForLargeBins(k_i - k_f); } return evaluate_for_q(k_i - k_f); diff --git a/Core/FormFactors/inc/IFormFactorDecorator.h b/Core/FormFactors/inc/IFormFactorDecorator.h index 7208ae5e375331a4df206e3f5755f8e3edee082b..65f8920cbf5da02b16c9ef0cdff23aa1b9c0abdc 100644 --- a/Core/FormFactors/inc/IFormFactorDecorator.h +++ b/Core/FormFactors/inc/IFormFactorDecorator.h @@ -56,8 +56,7 @@ inline void IFormFactorDecorator::setAmbientRefractiveIndex(complex_t refractive inline void IFormFactorDecorator::setBinSizes(double delta_qy, double delta_qz) { - IFormFactor::setBinSizes(delta_qy, delta_qz); - mp_form_factor->setBinSizes(delta_qy, delta_qz); + if (mp_form_factor) mp_form_factor->setBinSizes(delta_qy, delta_qz); } inline double IFormFactorDecorator::getVolume() const diff --git a/Core/FormFactors/src/IFormFactorBorn.cpp b/Core/FormFactors/src/IFormFactorBorn.cpp index a93fb0abd878798a717a749864efc5821a29e897..430953ce1ca2cda52b057a006e20089bc594c0b5 100644 --- a/Core/FormFactors/src/IFormFactorBorn.cpp +++ b/Core/FormFactors/src/IFormFactorBorn.cpp @@ -1,5 +1,23 @@ #include "IFormFactorBorn.h" +void IFormFactorBorn::setBinSizes(double delta_qy, double delta_qz) +{ + m_bin_qy = delta_qy; + m_bin_qz = delta_qz; + if (m_bin_qy > M_PI/2.0/getRadius()) { + m_use_large_bin_approximation_radial = true; + } + else { + m_use_large_bin_approximation_radial = false; + } + if (m_bin_qz > M_PI/2.0/getHeight()) { + m_use_large_bin_approximation_z = true; + } + else { + m_use_large_bin_approximation_z = false; + } +} + double IFormFactorBorn::bigRadialPart(double qR, void *params) const { (void)params; @@ -9,6 +27,14 @@ double IFormFactorBorn::bigRadialPart(double qR, void *params) const return a/(1.0 + std::pow(std::abs(b*qR),3.0)); } +IFormFactorBorn::IFormFactorBorn() +: m_use_large_bin_approximation_radial(false) +, m_use_large_bin_approximation_z(false) +, m_bin_qy(0.0) +, m_bin_qz(0.0) +{ +} + double IFormFactorBorn::bigZPart(double qH2) const { if (qH2<Numeric::double_epsilon) return qH2;