9#include "MantidJson/Json.h"
16#include <boost/algorithm/string.hpp>
23using namespace Kernel;
92 std::shared_ptr<BoundedValidator<double>> uValidator = std::make_shared<BoundedValidator<double>>();
93 uValidator->setLower(0.0);
96 "Isotropic atomic displacement in Angstrom^2");
98 IValidator_sptr occValidator = std::make_shared<BoundedValidator<double>>(0.0, 1.0);
100 "Site occupancy, values on interval [0,1].");
108 if (propertyName ==
"Element") {
118 return exp(-2.0 * M_PI * M_PI *
getU() * dstar.
norm2());
138 : m_scattererString(
std::move(scattererString)) {}
143 std::vector<BraggScatterer_sptr> scatterers;
144 scatterers.reserve(tokens.
size());
145 std::transform(tokens.
cbegin(), tokens.
cend(), std::back_inserter(scatterers),
146 [
this](
const auto &token) { return getScatterer(token); });
153 std::vector<std::string> tokens;
154 boost::split(tokens, singleScatterer, boost::is_any_of(
" "));
156 if (tokens.size() < 4 || tokens.size() > 6) {
157 throw std::invalid_argument(
"Could not parse scatterer string: " + singleScatterer);
161 std::vector<std::string> properties = {
"Element",
"Position",
"Occupancy",
"U"};
164 for (
size_t i = 0; i < cleanScattererTokens.size(); ++i) {
165 root[properties[i]] = cleanScattererTokens[i];
168 std::string initString = Mantid::JsonHelpers::jsonToString(root);
174std::vector<std::string>
176 std::vector<std::string> cleanTokens;
179 cleanTokens.emplace_back(tokens[0]);
182 cleanTokens.emplace_back(
"[" + tokens[1] +
"," + tokens[2] +
"," + tokens[3] +
"]");
184 for (
size_t i = 4; i < tokens.size(); ++i) {
185 cleanTokens.emplace_back(tokens[i]);
194 if (!isotropicAtom) {
195 throw std::invalid_argument(
"Printing function can only process IsotropicAtomBraggScatterer.");
198 std::string rawPositionString = isotropicAtom->getProperty(
"Position");
201 std::stringstream outStream;
202 outStream << isotropicAtom->getElement() <<
" " << positionComponents[0] <<
" " << positionComponents[1] <<
" "
203 << positionComponents[2] <<
" " << isotropicAtom->getOccupancy() <<
" " << isotropicAtom->getU();
205 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...
std::string getElement() const
Returns the string representation of the contained element.
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.
PhysicalConstants::NeutronAtom getNeutronAtom() const
Returns the internally stored NeutronAtom that holds element specific data.
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.
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.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
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.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
@ 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 std::string symbol
The atomic symbol. In other words the one or two character abbreviation.
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)
Structure to store neutronic scattering information for the various elements.
double coh_scatt_length_real
The real part of the coherent scattering length in fm.