Mantid
Loading...
Searching...
No Matches
StructureFactorCalculatorSummation.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
9
10#include <iomanip>
11
12namespace Mantid::Geometry {
13
14using namespace Kernel;
15
17 : StructureFactorCalculator(), m_unitCellScatterers(CompositeBraggScatterer::create()) {}
18
21 return m_unitCellScatterers->calculateStructureFactor(hkl);
22}
23
26 updateUnitCellScatterers(crystalStructure);
27}
28
39 m_unitCellScatterers->removeAllScatterers();
40
41 CompositeBraggScatterer_sptr scatterersInAsymmetricUnit = crystalStructure.getScatterers();
42 SpaceGroup_const_sptr spaceGroup = crystalStructure.spaceGroup();
43
44 if (spaceGroup) {
45 std::vector<BraggScatterer_sptr> braggScatterers;
46 braggScatterers.reserve(scatterersInAsymmetricUnit->nScatterers() * spaceGroup->order());
47
48 for (size_t i = 0; i < scatterersInAsymmetricUnit->nScatterers(); ++i) {
50 std::dynamic_pointer_cast<BraggScattererInCrystalStructure>(scatterersInAsymmetricUnit->getScatterer(i));
51
52 if (current) {
53 std::vector<V3D> positions = spaceGroup->getEquivalentPositions(current->getPosition());
54
55 for (auto &position : positions) {
56 BraggScatterer_sptr clone = current->clone();
57 clone->setProperty("Position", getV3DasString(position));
58
59 braggScatterers.emplace_back(clone);
60 }
61 }
62 }
63
64 m_unitCellScatterers->setScatterers(braggScatterers);
65 }
66}
67
70 std::ostringstream posStream;
71 posStream << std::setprecision(17);
72 posStream << point;
73
74 return posStream.str();
75}
76
77} // namespace Mantid::Geometry
double position
Definition: GetAllEi.cpp:154
CompositeBraggScatterer accumulates scatterers, for easier calculation of structure factors.
Three components are required to describe a crystal structure:
CompositeBraggScatterer_sptr getScatterers() const
Return a clone of the internal CompositeBraggScatterer instance.
SpaceGroup_const_sptr spaceGroup() const
Returns the space group of the crystal structure.
void updateUnitCellScatterers(const CrystalStructure &crystalStructure)
Rebuilds the internal list of scatterers.
std::string getV3DasString(const Kernel::V3D &point) const
Return V3D as string without losing precision.
void crystalStructureSetHook(const CrystalStructure &crystalStructure) override
Calls updateUnitCellScatterers() to rebuild the complete list of scatterers.
StructureFactor getF(const Kernel::V3D &hkl) const override
Returns the structure factor obtained from the stored scatterers.
Class for 3D vectors.
Definition: V3D.h:34
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
std::shared_ptr< BraggScattererInCrystalStructure > BraggScattererInCrystalStructure_sptr
std::shared_ptr< const SpaceGroup > SpaceGroup_const_sptr
Definition: SpaceGroup.h:82
std::shared_ptr< BraggScatterer > BraggScatterer_sptr
std::shared_ptr< CompositeBraggScatterer > CompositeBraggScatterer_sptr
std::complex< double > StructureFactor