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
50
53
64
67 BraggScatterer_sptr clone = m_scatterers->clone();
68
69 return std::dynamic_pointer_cast<CompositeBraggScatterer>(clone);
70}
71
74 m_scatterers->removeAllScatterers();
75
76 addScatterers(scatterers);
77}
78
82 m_scatterers->addScatterers(scatterers->getScatterers());
83
85}
86
90 m_centering.reset();
91
92 // First letter is centering
93 std::string centeringSymbol = spaceGroup->hmSymbol().substr(0, 1);
94
95 if (centeringSymbol == "R") {
96 centeringSymbol = "Robv";
97 }
98
99 const auto &reflectionConditions = getAllReflectionConditions();
100 for (auto &reflectionCondition : reflectionConditions) {
101 if (reflectionCondition->getSymbol() == centeringSymbol) {
102 m_centering = reflectionCondition;
103 break;
104 }
105 }
106}
107
110 if (!m_scatterers) {
111 throw std::runtime_error("Scatterer collection is a null pointer. Aborting.");
112 }
113
114 if (m_scatterers->existsProperty("UnitCell")) {
115 m_scatterers->setProperty("UnitCell", unitCellToStr(unitCell));
116 }
117}
118
125
126} // 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.
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.
UnitCell const & cell() const &
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