Mantid
Loading...
Searching...
No Matches
CrystalStructure.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 +
8#include <algorithm>
9#include <stdexcept>
10
17
18#include <iomanip>
19
20namespace Mantid::Geometry {
21
22using namespace Mantid::Kernel;
23
26 const CompositeBraggScatterer_sptr &scatterers) {
28
29 addScatterers(scatterers);
30 setCell(unitCell);
32}
33
35CrystalStructure::CrystalStructure(const std::string &unitCellString, const std::string &spaceGroupString,
36 const std::string &scattererString) {
38
40 setCell(strToUnitCell(unitCellString));
41 setSpaceGroup(SpaceGroupFactory::Instance().createSpaceGroup(spaceGroupString));
42}
43
46
49 m_cell = cell;
50
52}
53
56
64
66}
67
70 BraggScatterer_sptr clone = m_scatterers->clone();
71
72 return std::dynamic_pointer_cast<CompositeBraggScatterer>(clone);
73}
74
77 m_scatterers->removeAllScatterers();
78
79 addScatterers(scatterers);
80}
81
85 size_t count = scatterers->nScatterers();
86
87 for (size_t i = 0; i < count; ++i) {
88 m_scatterers->addScatterer(scatterers->getScatterer(i));
89 }
90
92}
93
97 m_centering.reset();
98
99 // First letter is centering
100 std::string centering = spaceGroup->hmSymbol().substr(0, 1);
101
102 if (centering == "R") {
103 centering = "Robv";
104 }
105
106 const auto &reflectionConditions = getAllReflectionConditions();
107 for (auto &reflectionCondition : reflectionConditions) {
108 if (reflectionCondition->getSymbol() == centering) {
109 m_centering = reflectionCondition;
110 break;
111 }
112 }
113}
114
117 if (!m_scatterers) {
118 throw std::runtime_error("Scatterer collection is a null pointer. Aborting.");
119 }
120
121 if (m_scatterers->existsProperty("UnitCell")) {
122 m_scatterers->setProperty("UnitCell", unitCellToStr(unitCell));
123 }
124}
125
128 if (!m_scatterers) {
130 }
131}
132
133} // namespace Mantid::Geometry
int count
counter
Definition: Matrix.cpp:37
static CompositeBraggScatterer_sptr create()
Static method that creates a new instance of CompositeBraggScatterer and returns it (wrapped by a sma...
CompositeBraggScatterer_sptr getScatterers() const
Return a clone of the internal CompositeBraggScatterer instance.
ReflectionCondition_sptr m_centering
void setReflectionConditionFromSpaceGroup(const SpaceGroup_const_sptr &spaceGroup)
Tries to set the centering from the space group symbol or removes the current centering if creation f...
CrystalStructure(const UnitCell &unitCell, const SpaceGroup_const_sptr &spaceGroup, const CompositeBraggScatterer_sptr &scatterers)
SpaceGroup/Scatterers constructor.
void addScatterers(const CompositeBraggScatterer_sptr &scatterers)
Adds all scatterers in the supplied collection into the internal one (scatterers are copied).
CompositeBraggScatterer_sptr m_scatterers
void initializeScatterers()
Initializes the internal storage for scatterers.
void setScatterers(const CompositeBraggScatterer_sptr &scatterers)
Remove all scatterers and set the supplied ones as new scatterers.
UnitCell cell() const
Returns the unit cell of the structure.
ReflectionCondition_sptr centering() const
SpaceGroup_const_sptr spaceGroup() const
Returns the space group of the crystal structure.
void setSpaceGroup(const SpaceGroup_const_sptr &spaceGroup)
Assigns a new space group to the crystal structure.
void setCell(const UnitCell &cell)
Assigns a new unit cell.
void assignUnitCellToScatterers(const UnitCell &unitCell)
Assigns the cell to all scatterers.
SpaceGroup_const_sptr m_spaceGroup
Class to implement unit cell of crystals.
Definition: UnitCell.h:44
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
MANTID_GEOMETRY_DLL UnitCell strToUnitCell(const std::string &unitCellString)
Definition: UnitCell.cpp:896
MANTID_GEOMETRY_DLL std::string unitCellToStr(const UnitCell &unitCell)
Definition: UnitCell.cpp:886
std::shared_ptr< const SpaceGroup > SpaceGroup_const_sptr
Definition: SpaceGroup.h:82
std::shared_ptr< BraggScatterer > BraggScatterer_sptr
MANTID_GEOMETRY_DLL const ReflectionConditions & getAllReflectionConditions()
std::shared_ptr< CompositeBraggScatterer > CompositeBraggScatterer_sptr