1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/SoftParticle/FuzzySphere.cpp
//! @brief Implements class FuzzySphere.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "Sample/SoftParticle/FuzzySphere.h"
#include "Base/Util/Assert.h"
#include "Sample/LibFF/SomeFormfactor.h"
#include "Sample/Shape/TruncatedEllipsoidNet.h"
FuzzySphere::FuzzySphere(const std::vector<double> P)
: IFormfactor(P)
, m_radius(m_P[0])
, m_sigma(m_P[1])
{
validateOrThrow();
}
FuzzySphere::FuzzySphere(double mean, double sigma)
: FuzzySphere(std::vector<double>{mean, sigma})
{
}
complex_t FuzzySphere::formfactor(C3 q) const
{
ASSERT(m_validated);
double q2 = std::norm(q.x()) + std::norm(q.y()) + std::norm(q.z());
double dw = std::exp(-q2 * m_sigma * m_sigma / 2.0);
return dw * SampleUtil::someff::ffSphere(q, m_radius);
}
std::string FuzzySphere::validate() const
{
std::vector<std::string> errs;
requestGt0(errs, m_radius, "radius");
requestGt0(errs, m_sigma, "sigma");
if (!errs.empty())
return jointError(errs);
m_shape3D =
std::make_unique<TruncatedEllipsoidNet>(m_radius, m_radius, m_radius, 2 * m_radius, 0);
m_validated = true;
return "";
}
bool FuzzySphere::contains(const R3&) const
{
throw std::runtime_error("Soft particle cannot be used as mesocrystal outer shape");
}
|