Skip to content
Snippets Groups Projects
Commit 7746374c authored by Federico Montesino Pouzols's avatar Federico Montesino Pouzols
Browse files

Merge pull request #13945 from mantidproject/13924_fix_poldi_fit_peaks2d_crystal_systems

PoldiFitPeaks2D should use hexagonal lattice in Pawley fit for trigonal structures in hexagonal setting
parents e488b834 c4a3f5b5
No related merge requests found
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "MantidAPI/Algorithm.h" #include "MantidAPI/Algorithm.h"
#include "MantidAPI/IFunction.h" #include "MantidAPI/IFunction.h"
#include "MantidAPI/IPeakFunction.h" #include "MantidAPI/IPeakFunction.h"
#include "MantidGeometry/Crystal/PointGroup.h"
#include "MantidKernel/Matrix.h" #include "MantidKernel/Matrix.h"
...@@ -104,6 +105,9 @@ protected: ...@@ -104,6 +105,9 @@ protected:
getFunctionPawley(std::string profileFunctionName, getFunctionPawley(std::string profileFunctionName,
const PoldiPeakCollection_sptr &peakCollection); const PoldiPeakCollection_sptr &peakCollection);
std::string getCrystalSystemFromPointGroup(
const Geometry::PointGroup_sptr &pointGroup) const;
std::string std::string
getRefinedStartingCell(const std::string &initialCell, getRefinedStartingCell(const std::string &initialCell,
const std::string &crystalSystem, const std::string &crystalSystem,
......
...@@ -546,8 +546,7 @@ Poldi2DFunction_sptr PoldiFitPeaks2D::getFunctionPawley( ...@@ -546,8 +546,7 @@ Poldi2DFunction_sptr PoldiFitPeaks2D::getFunctionPawley(
"peaks do not have point group."); "peaks do not have point group.");
} }
std::string crystalSystem = std::string crystalSystem = getCrystalSystemFromPointGroup(pointGroup);
getCrystalSystemAsString(pointGroup->crystalSystem());
pawleyFunction->setCrystalSystem(crystalSystem); pawleyFunction->setCrystalSystem(crystalSystem);
UnitCell cell = peakCollection->unitCell(); UnitCell cell = peakCollection->unitCell();
...@@ -575,6 +574,35 @@ Poldi2DFunction_sptr PoldiFitPeaks2D::getFunctionPawley( ...@@ -575,6 +574,35 @@ Poldi2DFunction_sptr PoldiFitPeaks2D::getFunctionPawley(
return mdFunction; return mdFunction;
} }
/**
* Returns the crystal system for the specified point group
*
* This function simply uses Geometry::getCrystalSystemAsString(), except when
* the crystal system is trigonal but the point group uses hexagonal axes. In
* that case this function returns the string for PointGroup::Hexagonal.
*
* @param pointGroup :: The point group for which to find the crystal system
* @return The crystal system for the point group
*/
std::string PoldiFitPeaks2D::getCrystalSystemFromPointGroup(
const PointGroup_sptr &pointGroup) const {
if (!pointGroup) {
throw std::invalid_argument(
"Cannot return crystal system for null PointGroup.");
}
PointGroup::CrystalSystem crystalSystem = pointGroup->crystalSystem();
if (crystalSystem == PointGroup::Trigonal) {
if (pointGroup->getCoordinateSystem() ==
Group::CoordinateSystem::Hexagonal) {
return getCrystalSystemAsString(PointGroup::Hexagonal);
}
}
return getCrystalSystemAsString(crystalSystem);
}
/** /**
* Tries to refine the initial cell using the supplied peaks * Tries to refine the initial cell using the supplied peaks
* *
......
...@@ -433,6 +433,40 @@ public: ...@@ -433,6 +433,40 @@ public:
TS_ASSERT_EQUALS(refinedCell, "5 5 5 90 90 90"); TS_ASSERT_EQUALS(refinedCell, "5 5 5 90 90 90");
} }
void testGetCrystalSystemFromPointGroup() {
TestablePoldiFitPeaks2D alg;
auto pgCubic = PointGroupFactory::Instance().createPointGroup("m-3m");
TS_ASSERT_EQUALS(alg.getCrystalSystemFromPointGroup(pgCubic), "Cubic");
auto pgTetra = PointGroupFactory::Instance().createPointGroup("4/mmm");
TS_ASSERT_EQUALS(alg.getCrystalSystemFromPointGroup(pgTetra), "Tetragonal");
auto pgOrtho = PointGroupFactory::Instance().createPointGroup("mmm");
TS_ASSERT_EQUALS(alg.getCrystalSystemFromPointGroup(pgOrtho),
"Orthorhombic");
auto pgMono = PointGroupFactory::Instance().createPointGroup("2/m");
TS_ASSERT_EQUALS(alg.getCrystalSystemFromPointGroup(pgMono), "Monoclinic");
auto pgTric = PointGroupFactory::Instance().createPointGroup("-1");
TS_ASSERT_EQUALS(alg.getCrystalSystemFromPointGroup(pgTric), "Triclinic");
auto pgHex = PointGroupFactory::Instance().createPointGroup("6/mmm");
TS_ASSERT_EQUALS(alg.getCrystalSystemFromPointGroup(pgHex), "Hexagonal");
auto pgTrigRh = PointGroupFactory::Instance().createPointGroup("-3m r");
TS_ASSERT_EQUALS(alg.getCrystalSystemFromPointGroup(pgTrigRh), "Trigonal");
auto pgTrigHex = PointGroupFactory::Instance().createPointGroup("-3m");
TS_ASSERT_EQUALS(alg.getCrystalSystemFromPointGroup(pgTrigHex),
"Hexagonal");
PointGroup_sptr invalid;
TS_ASSERT_THROWS(alg.getCrystalSystemFromPointGroup(invalid),
std::invalid_argument);
}
private: private:
PoldiInstrumentAdapter_sptr m_instrument; PoldiInstrumentAdapter_sptr m_instrument;
PoldiTimeTransformer_sptr m_timeTransformer; PoldiTimeTransformer_sptr m_timeTransformer;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment