9#include "MantidJson/Json.h"
16#include <boost/algorithm/string.hpp>
23using namespace Kernel;
86 std::shared_ptr<BoundedValidator<double>> uValidator = std::make_shared<BoundedValidator<double>>();
87 uValidator->setLower(0.0);
90 "Isotropic atomic displacement in Angstrom^2");
92 IValidator_sptr occValidator = std::make_shared<BoundedValidator<double>>(0.0, 1.0);
94 "Site occupancy, values on interval [0,1].");
102 if (propertyName ==
"Element") {
112 return exp(-2.0 * M_PI * M_PI *
getU() * dstar.
norm2());
132 : m_scattererString(
std::move(scattererString)) {}
137 std::vector<BraggScatterer_sptr> scatterers;
138 scatterers.reserve(tokens.
size());
139 std::transform(tokens.
cbegin(), tokens.
cend(), std::back_inserter(scatterers),
140 [
this](
const auto &token) { return getScatterer(token); });
147 std::vector<std::string> tokens;
148 boost::split(tokens, singleScatterer, boost::is_any_of(
" "));
150 if (tokens.size() < 4 || tokens.size() > 6) {
151 throw std::invalid_argument(
"Could not parse scatterer string: " + singleScatterer);
155 std::vector<std::string> properties = {
"Element",
"Position",
"Occupancy",
"U"};
158 for (
size_t i = 0; i < cleanScattererTokens.size(); ++i) {
159 root[properties[i]] = cleanScattererTokens[i];
162 std::string initString = Mantid::JsonHelpers::jsonToString(root);
164 return BraggScattererFactory::Instance().createScatterer(
"IsotropicAtomBraggScatterer", initString);
168std::vector<std::string>
170 std::vector<std::string> cleanTokens;
173 cleanTokens.emplace_back(tokens[0]);
176 cleanTokens.emplace_back(
"[" + tokens[1] +
"," + tokens[2] +
"," + tokens[3] +
"]");
178 for (
size_t i = 4; i < tokens.size(); ++i) {
179 cleanTokens.emplace_back(tokens[i]);
188 if (!isotropicAtom) {
189 throw std::invalid_argument(
"Printing function can only process IsotropicAtomBraggScatterer.");
192 std::string rawPositionString = isotropicAtom->getProperty(
"Position");
195 std::stringstream outStream;
196 outStream << isotropicAtom->getElement() <<
" " << positionComponents[0] <<
" " << positionComponents[1] <<
" "
197 << positionComponents[2] <<
" " << isotropicAtom->getOccupancy() <<
" " << isotropicAtom->getU();
199 return outStream.str();
#define DECLARE_BRAGGSCATTERER(classname)
This class provides an extension of BraggScatterer, suitable for scatterers that are part of a crysta...
UnitCell getCell() const
Returns the cell which is currently set.
std::vector< std::string > getCleanScattererTokens(const std::vector< std::string > &tokens) const
Converts tokens for getScatterer method so they can be processed by factory.
std::string m_scattererString
std::vector< BraggScatterer_sptr > operator()() const
Operator that returns vector of IsotropicAtomBraggScatterers.
BraggScatterer_sptr getScatterer(const std::string &singleScatterer) const
Returns IsotropicAtomBraggScatterer for string with format "Element x y z occupancy u_iso".
IsotropicAtomBraggScatterer calculates the structure factor for a given HKL using the following equat...
double getScatteringLength() const
Returns the scattering length of the stored element.
PhysicalConstants::NeutronAtom m_atom
void declareScattererProperties() override
Declares properties of this scatterer model.
void afterScattererPropertySet(const std::string &propertyName) override
After setting the element as a string, the corresponding.
double getOccupancy() const
Returns the occupancy.
void setElement(const std::string &element)
Tries to obtain element specific data for the given symbol using PhysicalConstants::getAtom.
BraggScatterer_sptr clone() const override
Clones the instance.
double getDebyeWallerFactor(const Kernel::V3D &hkl) const
Returns the Debye-Waller factor, using an isotropic atomic displacement and the stored unit cell.
double getU() const
Returns the isotropic atomic displacement parameter.
StructureFactor calculateStructureFactor(const Kernel::V3D &hkl) const override
Calculates the structure factor.
IsotropicAtomBraggScatterer()
Constructor which takes an element symbol, fractional coordinates, isotropic atomic displacement para...
const Kernel::DblMatrix & getB() const
Get the B-matrix.
Validator to check that a property is not left empty.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
std::string asString(bool withDefaultValues=false) const override
Return the property manager serialized as a string.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
void declareProperty(std::unique_ptr< Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
The concrete, templated class for properties.
@ TOK_TRIM
remove leading and trailing whitespace from tokens
std::size_t size() const noexcept
Get the total number of tokens.
ConstIterator cend() const
Const iterator referring to the past-the-end element in the container.
ConstIterator cbegin() const
Const iterator referring to first element in the container.
constexpr double scalar_prod(const V3D &v) const noexcept
Calculates the cross product.
constexpr double norm2() const noexcept
Vector length squared.
Struture to hold the common information for an atom.
const NeutronAtom neutron
Handle to class containing neutronic atomic properties.
std::shared_ptr< IsotropicAtomBraggScatterer > IsotropicAtomBraggScatterer_sptr
MANTID_GEOMETRY_DLL std::vector< std::string > getTokenizedPositionString(const std::string &position)
Returns components of comma-separated position string, cleaned from [ and ].
MANTID_GEOMETRY_DLL std::string getIsotropicAtomBraggScattererString(const BraggScatterer_sptr &scatterer)
std::shared_ptr< BraggScatterer > BraggScatterer_sptr
std::complex< double > StructureFactor
std::shared_ptr< IValidator > IValidator_sptr
A shared_ptr to an IValidator.
MANTID_KERNEL_DLL const Atom & getAtom(const uint16_t z_number, const uint16_t a_number=0)
double coh_scatt_length_real
The real part of the coherent scattering length in fm.