Skip to content
Snippets Groups Projects
Commit 338373bf authored by Ganeva, Marina's avatar Ganeva, Marina
Browse files

Merge branch 'ripple2analytical' into develop

parents e721993d 22a85fd0
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,7 @@ class BA_CORE_API_ FormFactorRipple2 : public IFormFactorBorn
public:
FormFactorRipple2(double width, double height, double length, double asymetry);
~FormFactorRipple2() { delete m_integrator; }
~FormFactorRipple2() { }
virtual FormFactorRipple2 *clone() const;
......@@ -45,7 +45,6 @@ public:
virtual complex_t evaluate_for_q(const cvector_t& q) const;
private:
complex_t Integrand(double Z, void* params) const;
virtual void init_parameters();
......@@ -54,8 +53,6 @@ private:
double m_length;
double m_d;
mutable cvector_t m_q;
MemberComplexFunctionIntegrator<FormFactorRipple2> *m_integrator;
};
#endif // FORMFACTORSPHERE_H
......
......@@ -32,11 +32,6 @@ FormFactorRipple2::FormFactorRipple2(double width, double height, double length,
assert(m_width >= 2.*m_d);
assert(m_height > 0);
init_parameters();
MemberComplexFunctionIntegrator<FormFactorRipple2>::mem_function p_mf =
& FormFactorRipple2::Integrand;
m_integrator =
new MemberComplexFunctionIntegrator<FormFactorRipple2>(p_mf, this);
}
void FormFactorRipple2::init_parameters()
......@@ -56,23 +51,33 @@ FormFactorRipple2 *FormFactorRipple2::clone() const
}
//! Integrand for complex formfactor.
complex_t FormFactorRipple2::Integrand(double Z, void* params) const
{
(void)params; // to avoid unused-variable warning
complex_t p1 = (1.0-Z/m_height)*MathFunctions::Sinc(m_q.y()*m_width*0.5*(1.0-Z/m_height));
return p1*std::exp(complex_t(0.0, 1.0)*(-1.0*m_q.y()*m_d*(1-Z/m_height) + m_q.z()*Z));
}
//! Complex formfactor.
complex_t FormFactorRipple2::evaluate_for_q(const cvector_t& q) const
{
m_q = q;
complex_t factor = m_length*MathFunctions::Sinc(m_q.x()*m_length*0.5)*m_width;
complex_t integral = m_integrator->integrate(0, m_height);
return factor*integral;
complex_t result = 0;
complex_t iqzH = complex_t(0.0, 1.0)*m_q.z()*m_height;
complex_t iqyW = complex_t(0.0, 1.0)*m_q.y()*m_width;
complex_t aaa = 2.0*(m_d*m_q.y() + m_height*m_q.z());
if (0.0==m_q.y() and 0.0==m_q.z())
result = m_height*0.5;
else if (0.0==m_q.y())
result = (1.0 - std::exp(iqzH) + iqzH)/(m_height*m_q.z()*m_q.z());
else if (1.0 == aaa/(m_q.y()*m_width))
result = m_height*std::exp(iqzH)*(1.0 - std::exp(-1.0*iqyW) - iqyW)/(m_q.y()*m_q.y()*m_width*m_width);
else if (-1.0 == aaa/(m_q.y()*m_width))
result = m_height*std::exp(iqzH)*(1.0 - std::exp(-1.0*iqyW) + iqyW)/(m_q.y()*m_q.y()*m_width*m_width);
else {
complex_t iHqzdqy = complex_t(0.0, 1.0)*(m_q.z()*m_height + m_q.y()*m_d);
complex_t Hqzdqy = m_q.z()*m_height + m_q.y()*m_d;
result = std::cos(m_q.y()*m_width*0.5) + 2.0*iHqzdqy*std::sin(m_q.y()*m_width*0.5)/(m_width*m_q.y());
result = result*std::exp(-1.0*iHqzdqy) - 1.0;
result = result*4.0*m_height*std::exp(iqzH)/(4.0*Hqzdqy*Hqzdqy - m_q.y()*m_q.y()*m_width*m_width);
}
return factor*result;
}
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