diff --git a/Code/Mantid/Framework/Crystal/inc/MantidCrystal/SortHKL.h b/Code/Mantid/Framework/Crystal/inc/MantidCrystal/SortHKL.h index b0860650b2c2ff917e7dab48331f0800c04575aa..ec0be7d901f53915830ccf50a3bf6560f89287a8 100644 --- a/Code/Mantid/Framework/Crystal/inc/MantidCrystal/SortHKL.h +++ b/Code/Mantid/Framework/Crystal/inc/MantidCrystal/SortHKL.h @@ -3,6 +3,7 @@ #include "MantidKernel/System.h" #include "MantidAPI/Algorithm.h" +#include "MantidGeometry/Crystal/PointGroup.h" namespace Mantid { @@ -29,6 +30,8 @@ namespace Crystal virtual const std::string category() const { return "Crystal;DataHandling\\Text";} private: + /// Point Groups possible + std::vector<Mantid::Geometry::PointGroup_sptr> m_pointGroups; /// Sets documentation strings for this algorithm virtual void initDocs(); /// Initialise the properties diff --git a/Code/Mantid/Framework/Crystal/src/SortHKL.cpp b/Code/Mantid/Framework/Crystal/src/SortHKL.cpp index 7362d0e5bd7b893f94c5445785af0683336b84dc..72765052b660324c9250f536e30a82c8f65d84e5 100644 --- a/Code/Mantid/Framework/Crystal/src/SortHKL.cpp +++ b/Code/Mantid/Framework/Crystal/src/SortHKL.cpp @@ -8,6 +8,7 @@ #include "MantidDataObjects/Peak.h" #include "MantidDataObjects/PeaksWorkspace.h" #include "MantidGeometry/Instrument/RectangularDetector.h" +#include "MantidGeometry/Crystal/PointGroup.h" #include "MantidKernel/Strings.h" #include "MantidKernel/System.h" #include "MantidKernel/Utils.h" @@ -37,6 +38,7 @@ namespace Crystal */ SortHKL::SortHKL() { + m_pointGroups = getAllPointGroups(); } //---------------------------------------------------------------------------------------------- @@ -62,6 +64,12 @@ namespace Crystal { declareProperty(new WorkspaceProperty<PeaksWorkspace>("InputWorkspace","",Direction::InOut), "An input PeaksWorkspace with an instrument."); + std::vector<std::string> propOptions; + for (size_t i=0; i<m_pointGroups.size(); ++i) + propOptions.push_back( m_pointGroups[i]->getName() ); + declareProperty("PointGroup", propOptions[0],new ListValidator(propOptions), + "Which point group applies to this crystal?"); + declareProperty(new WorkspaceProperty<API::ITableWorkspace>("DuplicatesStatisticsTable","Statistics",Direction::Output)); } @@ -73,6 +81,14 @@ namespace Crystal { PeaksWorkspace_sptr peaksW = getProperty("InputWorkspace"); + //Use the primitive by default + PointGroup_sptr pointGroup(new PointGroupLaue1()); + //Get it from the property + std::string pointGroupName = getPropertyValue("PointGroup"); + for (size_t i=0; i<m_pointGroups.size(); ++i) + if (m_pointGroups[i]->getName() == pointGroupName) + pointGroup = m_pointGroups[i]; + API::ITableWorkspace_sptr t = WorkspaceFactory::Instance().createTable("TableWorkspace"); t->addColumn("double","h"); t->addColumn("double","k"); @@ -115,7 +131,7 @@ namespace Crystal Peak & peak2 = peaksW->getPeaks()[i]; V3D hkl2 = peak2.getHKL(); std::string bank2 = peak2.getBankName(); - if (hkl1 == hkl2 && bank1.compare(bank2) == 0) + if (pointGroup->isEquivalent(hkl1,hkl2) && bank1.compare(bank2) == 0) { data.push_back(peak2.getIntensity()); err.push_back(peak2.getSigmaIntensity()); diff --git a/Code/Mantid/Framework/Geometry/CMakeLists.txt b/Code/Mantid/Framework/Geometry/CMakeLists.txt index 761efc023cd4bf01f83ea801db9a4837ff825b84..bdcf29dff5224f45445195923b305dc801e19cf7 100644 --- a/Code/Mantid/Framework/Geometry/CMakeLists.txt +++ b/Code/Mantid/Framework/Geometry/CMakeLists.txt @@ -3,6 +3,7 @@ set ( SRC_FILES src/Crystal/IndexingUtils.cpp src/Crystal/ReducedCell.cpp src/Crystal/OrientedLattice.cpp + src/Crystal/PointGroup.cpp src/Crystal/ReflectionCondition.cpp src/Crystal/UnitCell.cpp src/IObjComponent.cpp @@ -96,6 +97,7 @@ set ( INC_FILES inc/MantidGeometry/Crystal/IndexingUtils.h inc/MantidGeometry/Crystal/ReducedCell.h inc/MantidGeometry/Crystal/OrientedLattice.h + inc/MantidGeometry/Crystal/PointGroup.h inc/MantidGeometry/Crystal/ReflectionCondition.h inc/MantidGeometry/Crystal/UnitCell.h inc/MantidGeometry/DllConfig.h diff --git a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/PointGroup.h b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/PointGroup.h new file mode 100644 index 0000000000000000000000000000000000000000..d523bde9a65a567e70893af4cd218b81ee7fb946 --- /dev/null +++ b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/PointGroup.h @@ -0,0 +1,197 @@ +#ifndef MANTID_GEOMETRY_POINTGROUP_H_ +#define MANTID_GEOMETRY_POINTGROUP_H_ + +#include "MantidGeometry/DllConfig.h" +#include "MantidKernel/V3D.h" +#include <boost/shared_ptr.hpp> +#include <vector> +#include <string> + +namespace Mantid +{ +namespace Geometry +{ + + using Kernel::V3D; + /** A class containing the Point Groups for a crystal. + * + * @author Vickie Lynch + * @date 2012-02-02 + */ + class MANTID_GEOMETRY_DLL PointGroup + { + public: + PointGroup() {} + virtual ~PointGroup() {} + /// Name of the point group + virtual std::string getName() = 0; + /// Return true if the hkls are in same group + virtual bool isEquivalent(V3D hkl, V3D hkl2) = 0; + }; + + //------------------------------------------------------------------------ + /** -1 (Triclinic) PointGroup */ + class MANTID_GEOMETRY_DLL PointGroupLaue1 : public PointGroup + { + public: + /// Name of the point group + virtual std::string getName() { return "-1 (Triclinic)"; } + /// Return true if the hkls are equivalent. + virtual bool isEquivalent(V3D hkl, V3D hkl2) + { double h=hkl[0];double k=hkl[1];double l=hkl[2]; return (hkl2 == V3D(h,k,l)) || (hkl2 == V3D(-h,-k,-l)); } + }; + + //------------------------------------------------------------------------ + /** 1 2/m 1 (Monoclinic, unique axis b) PointGroup */ + class MANTID_GEOMETRY_DLL PointGroupLaue2 : public PointGroup + { + public: + /// Name of the point group + virtual std::string getName() { return "1 2/m 1 (Monoclinic, unique axis b)"; } + /// Return true if the hkls are equivalent. + virtual bool isEquivalent(V3D hkl, V3D hkl2) + { double h=hkl[0];double k=hkl[1];double l=hkl[2]; return (hkl2 == V3D(h,k,l)) || (hkl2 == V3D(-h,-k,-l)) || (hkl2 == V3D(-h,k,-l)) || (hkl2 == V3D(h,-k,l)); } + }; + + //------------------------------------------------------------------------ + /** 1 1 2/m (Monoclinic, unique axis c) PointGroup */ + class MANTID_GEOMETRY_DLL PointGroupLaue3 : public PointGroup + { + public: + /// Name of the point group + virtual std::string getName() { return "1 1 2/m (Monoclinic, unique axis c)"; } + /// Return true if the hkls are equivalent. + virtual bool isEquivalent(V3D hkl, V3D hkl2) + { double h=hkl[0];double k=hkl[1];double l=hkl[2]; return (hkl2 == V3D(h,k,l)) || (hkl2 == V3D(-h,-k,l)) || (hkl2 == V3D(-h,-k,-l)) || (hkl2 == V3D(h,k,-l)); } + }; + + //------------------------------------------------------------------------ + /** mmm (Orthorombic) PointGroup */ + class MANTID_GEOMETRY_DLL PointGroupLaue4 : public PointGroup + { + public: + /// Name of the point group + virtual std::string getName() { return "mmm (Orthorombic)"; } + /// Return true if the hkls are equivalent. + virtual bool isEquivalent(V3D hkl, V3D hkl2) + { double h=hkl[0];double k=hkl[1];double l=hkl[2]; return (hkl2 == V3D(h,k,l)) || (hkl2 == V3D(-h,-k,l)) || (hkl2 == V3D(-h,k,-l)) || (hkl2 == V3D(h,-k,-l)) || (hkl2 == V3D(-h,-k,-l)) || (hkl2 == V3D(h,k,-l)) || (hkl2 == V3D(h,-k,l)) || (hkl2 == V3D(-h,k,l)); } + }; + + //------------------------------------------------------------------------ + /** 4/m (Tetragonal) PointGroup */ + class MANTID_GEOMETRY_DLL PointGroupLaue5 : public PointGroup + { + public: + /// Name of the point group + virtual std::string getName() { return "4/m (Tetragonal)"; } + /// Return true if the hkls are equivalent. + virtual bool isEquivalent(V3D hkl, V3D hkl2) + { double h=hkl[0];double k=hkl[1];double l=hkl[2]; return (hkl2 == V3D(h,k,l)) || (hkl2 == V3D(-h,-k,l)) || (hkl2 == V3D(-k,h,l)) || (hkl2 == V3D(k,-h,l)) || (hkl2 == V3D(-h,-k,-l)) || (hkl2 == V3D(h,k,-l)) || (hkl2 == V3D(k,-h,-l)) || (hkl2 == V3D(-k,h,-l)); } + }; + + //------------------------------------------------------------------------ + /** 4/mmm (Tetragonal) PointGroup */ + class MANTID_GEOMETRY_DLL PointGroupLaue6 : public PointGroup + { + public: + /// Name of the point group + virtual std::string getName() { return "4/mmm (Tetragonal)"; } + /// Return true if the hkls are equivalent. + virtual bool isEquivalent(V3D hkl, V3D hkl2) + { double h=hkl[0];double k=hkl[1];double l=hkl[2]; return (hkl2 == V3D(h,k,l)) || (hkl2 == V3D(-h,-k,l)) || (hkl2 == V3D(-k,h,l)) || (hkl2 == V3D(k,-h,l)) || (hkl2 == V3D(-h,k,-l)) || (hkl2 == V3D(h,-k,-l)) || (hkl2 == V3D(k,h,-l)) || (hkl2 == V3D(-k,-h,-l)) || (hkl2 == V3D(-h,-k,-l)) || (hkl2 == V3D(h,k,-l)) || (hkl2 == V3D(k,-h,-l)) || (hkl2 == V3D(-k,h,-l)) || (hkl2 == V3D(h,-k,l)) || (hkl2 == V3D(-h,k,l)) || (hkl2 == V3D(-k,-h,l)) || (hkl2 == V3D(k,h,l)); } + }; + + //------------------------------------------------------------------------ + /** -3 (Trigonal - Hexagonal) PointGroup */ + class MANTID_GEOMETRY_DLL PointGroupLaue7 : public PointGroup + { + public: + /// Name of the point group + virtual std::string getName() { return "-3 (Trigonal - Hexagonal)"; } + /// Return true if the hkls are equivalent. + virtual bool isEquivalent(V3D hkl, V3D hkl2) + { double h=hkl[0];double k=hkl[1];double l=hkl[2]; return (hkl2 == V3D(h,k,l)) || (hkl2 == V3D(-k,h-k,l)) || (hkl2 == V3D(-h+k,-h,l)) || (hkl2 == V3D(-h,-k,-l)) || (hkl2 == V3D(k,-h+k,-l)) || (hkl2 == V3D(h-k,h,-l)); } + }; + + //------------------------------------------------------------------------ + /** -3m1 (Trigonal - Rhombohedral) PointGroup */ + class MANTID_GEOMETRY_DLL PointGroupLaue8 : public PointGroup + { + public: + /// Name of the point group + virtual std::string getName() { return "-3m1 (Trigonal - Rhombohedral)"; } + /// Return true if the hkls are equivalent. + virtual bool isEquivalent(V3D hkl, V3D hkl2) + { double h=hkl[0];double k=hkl[1];double l=hkl[2]; return (hkl2 == V3D(h,k,l)) || (hkl2 == V3D(-k,h-k,l)) || (hkl2 == V3D(-h+k,-h,l)) || (hkl2 == V3D(-k,-h,-l)) || (hkl2 == V3D(-h+k,k,-l)) || (hkl2 == V3D(h,h-k,-l)) || (hkl2 == V3D(-h,-k,-l)) || (hkl2 == V3D(k,-h+k,-l)) || (hkl2 == V3D(h-k,h,-l)) || (hkl2 == V3D(k,h,l)) || (hkl2 == V3D(h-k,-k,l)) || (hkl2 == V3D(-h,-h+k,l)); } + }; + + //------------------------------------------------------------------------ + /** -31m (Trigonal - Rhombohedral) PointGroup */ + class MANTID_GEOMETRY_DLL PointGroupLaue9 : public PointGroup + { + public: + /// Name of the point group + virtual std::string getName() { return "-31m (Trigonal - Rhombohedral)"; } + /// Return true if the hkls are equivalent. + virtual bool isEquivalent(V3D hkl, V3D hkl2) + { double h=hkl[0];double k=hkl[1];double l=hkl[2]; return (hkl2 == V3D(h,k,l)) || (hkl2 == V3D(-k,h-k,l)) || (hkl2 == V3D(-h+k,-h,l)) || (hkl2 == V3D(k,h,-l)) || (hkl2 == V3D(h-k,-k,-l)) || (hkl2 == V3D(-h,-h+k,-l)) || (hkl2 == V3D(-h,-k,-l)) || (hkl2 == V3D(k,-h+k,-l)) || (hkl2 == V3D(h-k,h,-l)) || (hkl2 == V3D(-k,-h,l)) || (hkl2 == V3D(-h+k,k,l)) || (hkl2 == V3D(h,h-k,l)); } + }; + + //------------------------------------------------------------------------ + /** 6/m (Hexagonal) PointGroup */ + class MANTID_GEOMETRY_DLL PointGroupLaue10 : public PointGroup + { + public: + /// Name of the point group + virtual std::string getName() { return "6/m (Hexagonal)"; } + /// Return true if the hkls are equivalent. + virtual bool isEquivalent(V3D hkl, V3D hkl2) + { double h=hkl[0];double k=hkl[1];double l=hkl[2]; return (hkl2 == V3D(h,k,l)) || (hkl2 == V3D(-k,h-k,l)) || (hkl2 == V3D(-h+k,-h,l)) || (hkl2 == V3D(-h,-k,l)) || (hkl2 == V3D(k,-h+k,l)) || (hkl2 == V3D(h-k,h,l)) || (hkl2 == V3D(-h,-k,-l)) || (hkl2 == V3D(k,-h+k,-l)) || (hkl2 == V3D(h-k,h,-l)) || (hkl2 == V3D(h,k,-l)) || (hkl2 == V3D(-k,h-k,-l)) || (hkl2 == V3D(-h+k,-h,-l)); } + }; + + //------------------------------------------------------------------------ + /** 6/mmm (Hexagonal) PointGroup */ + class MANTID_GEOMETRY_DLL PointGroupLaue11 : public PointGroup + { + public: + /// Name of the point group + virtual std::string getName() { return "6/mmm (Hexagonal)"; } + /// Return true if the hkls are equivalent. + virtual bool isEquivalent(V3D hkl, V3D hkl2) + { double h=hkl[0];double k=hkl[1];double l=hkl[2]; return (hkl2 == V3D(h,k,l)) || (hkl2 == V3D(-k,h-k,l)) || (hkl2 == V3D(-h+k,-h,l)) || (hkl2 == V3D(-h,-k,l)) || (hkl2 == V3D(k,-h+k,l)) || (hkl2 == V3D(h-k,h,l)) || (hkl2 == V3D(k,h,-l)) || (hkl2 == V3D(h-k,-k,-l)) || (hkl2 == V3D(-h,-h+k,-l)) || (hkl2 == V3D(-k,-h,-l)) || (hkl2 == V3D(-h+k,k,-l)) || (hkl2 == V3D(h,h-k,-l)) || (hkl2 == V3D(-h,-k,-l)) || (hkl2 == V3D(k,-h+k,-l)) || (hkl2 == V3D(h-k,h,-l)) || (hkl2 == V3D(h,k,-l)) || (hkl2 == V3D(-k,h-k,-l)) || (hkl2 == V3D(-h+k,-h,-l)) || (hkl2 == V3D(-k,-h,l)) || (hkl2 == V3D(-h+k,k,l)) || (hkl2 == V3D(h,h-k,l)) || (hkl2 == V3D(k,h,l)) || (hkl2 == V3D(h-k,-k,l)) || (hkl2 == V3D(-h,-h+k,l)); } + }; + + //------------------------------------------------------------------------ + /** m-3 (Cubic) PointGroup */ + class MANTID_GEOMETRY_DLL PointGroupLaue12 : public PointGroup + { + public: + /// Name of the point group + virtual std::string getName() { return "m-3 (Cubic)"; } + /// Return true if the hkls are equivalent. + virtual bool isEquivalent(V3D hkl, V3D hkl2) + { double h=hkl[0];double k=hkl[1];double l=hkl[2]; return (hkl2 == V3D(h,k,l)) || (hkl2 == V3D(-h,-k,l)) || (hkl2 == V3D(-h,k,-l)) || (hkl2 == V3D(h,-k,-l)) || (hkl2 == V3D(l,h,k)) || (hkl2 == V3D(l,-h,-k)) || (hkl2 == V3D(-l,-h,k)) || (hkl2 == V3D(-l,h,-k)) || (hkl2 == V3D(k,l,h)) || (hkl2 == V3D(-k,l,-h)) || (hkl2 == V3D(k,-l,-h)) || (hkl2 == V3D(-k,-l,h)) || (hkl2 == V3D(-h,-k,-l)) || (hkl2 == V3D(h,k,-l)) || (hkl2 == V3D(h,-k,l)) || (hkl2 == V3D(-h,k,l)) || (hkl2 == V3D(-l,-h,-k)) || (hkl2 == V3D(-l,h,k)) || (hkl2 == V3D(l,h,-k)) || (hkl2 == V3D(l,-h,k)) || (hkl2 == V3D(-k,-l,-h)) || (hkl2 == V3D(k,-l,h)) || (hkl2 == V3D(-k,l,h)) || (hkl2 == V3D(k,l,-h)); } + }; + + //------------------------------------------------------------------------ + /** m-3m (Cubic) PointGroup */ + class MANTID_GEOMETRY_DLL PointGroupLaue13 : public PointGroup + { + public: + /// Name of the point group + virtual std::string getName() { return "m-3m (Cubic)"; } + /// Return true if the hkls are equivalent. + virtual bool isEquivalent(V3D hkl, V3D hkl2) + { double h=hkl[0];double k=hkl[1];double l=hkl[2]; return (hkl2 == V3D(h,k,l)) || (hkl2 == V3D(-h,-k,l)) || (hkl2 == V3D(-h,k,-l)) || (hkl2 == V3D(h,-k,-l)) || (hkl2 == V3D(l,h,k)) || (hkl2 == V3D(l,-h,-k)) || (hkl2 == V3D(-l,-h,k)) || (hkl2 == V3D(-l,h,-k)) || (hkl2 == V3D(k,l,h)) || (hkl2 == V3D(-k,l,-h)) || (hkl2 == V3D(k,-l,-h)) || (hkl2 == V3D(-k,-l,h)) || (hkl2 == V3D(k,h,-l)) || (hkl2 == V3D(-k,-h,-l)) || (hkl2 == V3D(k,-h,l)) || (hkl2 == V3D(-k,h,l)) || (hkl2 == V3D(h,l,-k)) || (hkl2 == V3D(-h,l,k)) || (hkl2 == V3D(-h,-l,-k)) || (hkl2 == V3D(h,-l,k)) || (hkl2 == V3D(l,k,-h)) || (hkl2 == V3D(l,-k,h)) || (hkl2 == V3D(-l,k,h)) || (hkl2 == V3D(-l,-k,-h)) || (hkl2 == V3D(-h,-k,-l)) || (hkl2 == V3D(h,k,-l)) || (hkl2 == V3D(h,-k,l)) || (hkl2 == V3D(-h,k,l)) || (hkl2 == V3D(-l,-h,-k)) || (hkl2 == V3D(-l,h,k)) || (hkl2 == V3D(l,h,-k)) || (hkl2 == V3D(l,-h,k)) || (hkl2 == V3D(-k,-l,-h)) || (hkl2 == V3D(k,-l,h)) || (hkl2 == V3D(-k,l,h)) || (hkl2 == V3D(k,l,-h)) || (hkl2 == V3D(-k,-h,l)) || (hkl2 == V3D(k,h,l)) || (hkl2 == V3D(-k,h,-l)) || (hkl2 == V3D(k,-h,-l)) || (hkl2 == V3D(-h,-l,k)) || (hkl2 == V3D(h,-l,-k)) || (hkl2 == V3D(h,l,k)) || (hkl2 == V3D(-h,l,-k)) || (hkl2 == V3D(-l,-k,h)) || (hkl2 == V3D(-l,k,-h)) || (hkl2 == V3D(l,-k,-h)) || (hkl2 == V3D(l,k,h)); } + }; + + + /// Shared pointer to a PointGroup + typedef boost::shared_ptr<PointGroup> PointGroup_sptr; + + MANTID_GEOMETRY_DLL std::vector<PointGroup_sptr> getAllPointGroups(); + +} // namespace Mantid +} // namespace Geometry + +#endif /* MANTID_GEOMETRY_POINTGROUP_H_ */ diff --git a/Code/Mantid/Framework/Geometry/src/Crystal/PointGroup.cpp b/Code/Mantid/Framework/Geometry/src/Crystal/PointGroup.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bb65c429c7ad0f1abcc866ce58ecaa794118c2b1 --- /dev/null +++ b/Code/Mantid/Framework/Geometry/src/Crystal/PointGroup.cpp @@ -0,0 +1,34 @@ +#include "MantidGeometry/Crystal/PointGroup.h" +#include "MantidKernel/System.h" + +namespace Mantid +{ +namespace Geometry +{ + + /** @return a vector with all possible PointGroup objects */ + std::vector<PointGroup_sptr> getAllPointGroups() + { + std::vector<PointGroup_sptr> out; + out.push_back(PointGroup_sptr(new PointGroupLaue1() )); + out.push_back(PointGroup_sptr(new PointGroupLaue2() )); + out.push_back(PointGroup_sptr(new PointGroupLaue3() )); + out.push_back(PointGroup_sptr(new PointGroupLaue4() )); + out.push_back(PointGroup_sptr(new PointGroupLaue5() )); + out.push_back(PointGroup_sptr(new PointGroupLaue6() )); + out.push_back(PointGroup_sptr(new PointGroupLaue7() )); + out.push_back(PointGroup_sptr(new PointGroupLaue8() )); + out.push_back(PointGroup_sptr(new PointGroupLaue9() )); + out.push_back(PointGroup_sptr(new PointGroupLaue10() )); + out.push_back(PointGroup_sptr(new PointGroupLaue11() )); + out.push_back(PointGroup_sptr(new PointGroupLaue12() )); + out.push_back(PointGroup_sptr(new PointGroupLaue13() )); + return out; + } + + + + +} // namespace Mantid +} // namespace Geometry +