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
53
56
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 m_scatterers->addScatterers(scatterers->getScatterers());
86
88}
89
93 m_centering.reset();
94
95 // First letter is centering
96 std::string centeringSymbol = spaceGroup->hmSymbol().substr(0, 1);
97
98 if (centeringSymbol == "R") {
99 centeringSymbol = "Robv";
100 }
101
102 const auto &reflectionConditions = getAllReflectionConditions();
103 for (auto &reflectionCondition : reflectionConditions) {
104 if (reflectionCondition->getSymbol() == centeringSymbol) {
105 m_centering = reflectionCondition;
106 break;
107 }
108 }
109}
110
113 if (!m_scatterers) {
114 throw std::runtime_error("Scatterer collection is a null pointer. Aborting.");
115 }
116
117 if (m_scatterers->existsProperty("UnitCell")) {
118 m_scatterers->setProperty("UnitCell", unitCellToStr(unitCell));
119 }
120}
121
128
129} // namespace Mantid::Geometry
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.
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.
Class to implement unit cell of crystals.
Definition UnitCell.h:44
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