Skip to content

Commit

Permalink
Refs #9993. Pointgroups now belong to a crystal system
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wedel committed Aug 5, 2014
1 parent 0f5d943 commit a85e800
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 0 deletions.
Expand Up @@ -25,11 +25,22 @@ namespace Geometry
class MANTID_GEOMETRY_DLL PointGroup
{
public:
enum CrystalSystem {
Triclinic,
Monoclinic,
Orthorhombic,
Tetragonal,
Hexagonal,
Trigonal,
Cubic
};

virtual ~PointGroup() {}
/// Name of the point group
virtual std::string getName() = 0;
/// Return true if the hkls are in same group
virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2) = 0;
virtual CrystalSystem crystalSystem() const = 0;

/// Returns a vector with all equivalent hkls
std::vector<Kernel::V3D> getEquivalents(const Kernel::V3D &hkl) const;
Expand Down Expand Up @@ -61,6 +72,7 @@ namespace Geometry
virtual std::string getName();
/// Return true if the hkls are equivalent.
virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2);
virtual PointGroup::CrystalSystem crystalSystem() const;
};

//------------------------------------------------------------------------
Expand All @@ -73,6 +85,7 @@ namespace Geometry
virtual std::string getName();
/// Return true if the hkls are equivalent.
virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2);
virtual PointGroup::CrystalSystem crystalSystem() const;
};

//------------------------------------------------------------------------
Expand All @@ -85,6 +98,7 @@ namespace Geometry
virtual std::string getName();
/// Return true if the hkls are equivalent.
virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2);
virtual PointGroup::CrystalSystem crystalSystem() const;
};

//------------------------------------------------------------------------
Expand All @@ -97,6 +111,7 @@ namespace Geometry
virtual std::string getName();
/// Return true if the hkls are equivalent.
virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2);
virtual PointGroup::CrystalSystem crystalSystem() const;
};

//------------------------------------------------------------------------
Expand All @@ -109,6 +124,7 @@ namespace Geometry
virtual std::string getName();
/// Return true if the hkls are equivalent.
virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2);
virtual PointGroup::CrystalSystem crystalSystem() const;
};

//------------------------------------------------------------------------
Expand All @@ -121,6 +137,7 @@ namespace Geometry
virtual std::string getName();
/// Return true if the hkls are equivalent.
virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2);
virtual PointGroup::CrystalSystem crystalSystem() const;
};

//------------------------------------------------------------------------
Expand All @@ -133,6 +150,7 @@ namespace Geometry
virtual std::string getName();
/// Return true if the hkls are equivalent.
virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2);
virtual PointGroup::CrystalSystem crystalSystem() const;
};

//------------------------------------------------------------------------
Expand All @@ -145,6 +163,7 @@ namespace Geometry
virtual std::string getName();
/// Return true if the hkls are equivalent.
virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2);
virtual PointGroup::CrystalSystem crystalSystem() const;
};

//------------------------------------------------------------------------
Expand All @@ -157,6 +176,7 @@ namespace Geometry
virtual std::string getName();
/// Return true if the hkls are equivalent.
virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2);
virtual PointGroup::CrystalSystem crystalSystem() const;
};

//------------------------------------------------------------------------
Expand All @@ -169,6 +189,7 @@ namespace Geometry
virtual std::string getName();
/// Return true if the hkls are equivalent.
virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2);
virtual PointGroup::CrystalSystem crystalSystem() const;
};

//------------------------------------------------------------------------
Expand All @@ -181,6 +202,7 @@ namespace Geometry
virtual std::string getName();
/// Return true if the hkls are equivalent.
virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2);
virtual PointGroup::CrystalSystem crystalSystem() const;
};

//------------------------------------------------------------------------
Expand All @@ -193,6 +215,7 @@ namespace Geometry
virtual std::string getName();
/// Return true if the hkls are equivalent.
virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2);
virtual PointGroup::CrystalSystem crystalSystem() const;
};

//------------------------------------------------------------------------
Expand All @@ -205,6 +228,7 @@ namespace Geometry
virtual std::string getName();
/// Return true if the hkls are equivalent.
virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2);
virtual PointGroup::CrystalSystem crystalSystem() const;
};


Expand All @@ -213,6 +237,11 @@ namespace Geometry

MANTID_GEOMETRY_DLL std::vector<PointGroup_sptr> getAllPointGroups();

typedef std::multimap<PointGroup::CrystalSystem, PointGroup_sptr> PointGroupCrystalSystemMap;
MANTID_GEOMETRY_DLL PointGroupCrystalSystemMap getPointGroupsByCrystalSystem();



} // namespace Mantid
} // namespace Geometry

Expand Down
77 changes: 77 additions & 0 deletions Code/Mantid/Framework/Geometry/src/Crystal/PointGroup.cpp
Expand Up @@ -169,6 +169,11 @@ namespace Geometry
return (hkl2 == V3D(h,k,l)) || (hkl2 == V3D(-h,-k,-l));
}

PointGroup::CrystalSystem PointGroupLaue1::crystalSystem() const
{
return Triclinic;
}

PointGroupLaue2::PointGroupLaue2()
{
addSymmetryOperation(boost::make_shared<const SymOpRotationTwoFoldY>());
Expand All @@ -191,6 +196,11 @@ namespace Geometry
return (hkl2 == V3D(h,k,l)) || (hkl2 == V3D(-h,-k,-l)) || (hkl2 == V3D(-h,k,-l)) || (hkl2 == V3D(h,-k,l));
}

PointGroup::CrystalSystem PointGroupLaue2::crystalSystem() const
{
return Monoclinic;
}

PointGroupLaue3::PointGroupLaue3()
{
addSymmetryOperation(boost::make_shared<const SymOpRotationTwoFoldZ>());
Expand All @@ -213,6 +223,11 @@ namespace Geometry
return (hkl2 == V3D(h,k,l)) || (hkl2 == V3D(-h,-k,l)) || (hkl2 == V3D(-h,-k,-l)) || (hkl2 == V3D(h,k,-l));
}

PointGroup::CrystalSystem PointGroupLaue3::crystalSystem() const
{
return Monoclinic;
}

PointGroupLaue4::PointGroupLaue4()
{
addSymmetryOperation(boost::make_shared<const SymOpRotationTwoFoldX>());
Expand All @@ -238,6 +253,11 @@ namespace Geometry
|| (hkl2 == V3D(h,-k,l)) || (hkl2 == V3D(-h,k,l));
}

PointGroup::CrystalSystem PointGroupLaue4::crystalSystem() const
{
return Orthorhombic;
}

PointGroupLaue5::PointGroupLaue5()
{
addSymmetryOperation(boost::make_shared<const SymOpRotationFourFoldZ>());
Expand All @@ -262,6 +282,11 @@ namespace Geometry
|| (hkl2 == V3D(k,-h,-l)) || (hkl2 == V3D(-k,h,-l));
}

PointGroup::CrystalSystem PointGroupLaue5::crystalSystem() const
{
return Tetragonal;
}

PointGroupLaue6::PointGroupLaue6()
{
addSymmetryOperation(boost::make_shared<const SymOpRotationFourFoldZ>());
Expand Down Expand Up @@ -290,6 +315,11 @@ namespace Geometry
|| (hkl2 == V3D(k,h,l));
}

PointGroup::CrystalSystem PointGroupLaue6::crystalSystem() const
{
return Tetragonal;
}

PointGroupLaue7::PointGroupLaue7()
{
addSymmetryOperation(boost::make_shared<const SymOpRotationThreeFoldZHexagonal>());
Expand All @@ -313,6 +343,11 @@ namespace Geometry
|| (hkl2 == V3D(-h,-k,-l)) || (hkl2 == V3D(k,-h+k,-l)) || (hkl2 == V3D(h-k,h,-l));
}

PointGroup::CrystalSystem PointGroupLaue7::crystalSystem() const
{
return Trigonal;
}

PointGroupLaue8::PointGroupLaue8()
{
addSymmetryOperation(boost::make_shared<const SymOpRotationThreeFoldZHexagonal>());
Expand All @@ -339,6 +374,11 @@ namespace Geometry
|| (hkl2 == V3D(k,h,l)) || (hkl2 == V3D(h-k,-k,l)) || (hkl2 == V3D(-h,-h+k,l));
}

PointGroup::CrystalSystem PointGroupLaue8::crystalSystem() const
{
return Trigonal;
}

PointGroupLaue9::PointGroupLaue9()
{
addSymmetryOperation(boost::make_shared<const SymOpRotationThreeFoldZHexagonal>());
Expand All @@ -365,6 +405,11 @@ namespace Geometry
|| (hkl2 == V3D(k,h,l)) || (hkl2 == V3D(h-k,-k,l)) || (hkl2 == V3D(-h,-h+k,l));
}

PointGroup::CrystalSystem PointGroupLaue9::crystalSystem() const
{
return Trigonal;
}

PointGroupLaue10::PointGroupLaue10()
{
addSymmetryOperation(boost::make_shared<const SymOpRotationSixFoldZHexagonal>());
Expand All @@ -390,6 +435,11 @@ namespace Geometry
|| (hkl2 == V3D(h,k,-l)) || (hkl2 == V3D(-k,h-k,-l)) || (hkl2 == V3D(-h+k,-h,-l));
}

PointGroup::CrystalSystem PointGroupLaue10::crystalSystem() const
{
return Hexagonal;
}

PointGroupLaue11::PointGroupLaue11()
{
addSymmetryOperation(boost::make_shared<const SymOpRotationSixFoldZHexagonal>());
Expand Down Expand Up @@ -420,6 +470,11 @@ namespace Geometry
|| (hkl2 == V3D(k,h,l)) || (hkl2 == V3D(h-k,-k,l)) || (hkl2 == V3D(-h,-h+k,l));
}

PointGroup::CrystalSystem PointGroupLaue11::crystalSystem() const
{
return Hexagonal;
}

PointGroupLaue12::PointGroupLaue12()
{
addSymmetryOperation(boost::make_shared<const SymOpRotationThreeFold111>());
Expand Down Expand Up @@ -451,6 +506,11 @@ namespace Geometry
|| (hkl2 == V3D(k,-l,h)) || (hkl2 == V3D(-k,l,h)) || (hkl2 == V3D(k,l,-h));
}

PointGroup::CrystalSystem PointGroupLaue12::crystalSystem() const
{
return Cubic;
}

PointGroupLaue13::PointGroupLaue13()
{
addSymmetryOperation(boost::make_shared<const SymOpRotationThreeFold111>());
Expand Down Expand Up @@ -490,6 +550,11 @@ namespace Geometry
|| (hkl2 == V3D(-l,k,-h)) || (hkl2 == V3D(l,-k,-h)) || (hkl2 == V3D(l,k,h));
}

PointGroup::CrystalSystem PointGroupLaue13::crystalSystem() const
{
return Cubic;
}

/** @return a vector with all possible PointGroup objects */
std::vector<PointGroup_sptr> getAllPointGroups()
{
Expand All @@ -510,6 +575,18 @@ namespace Geometry
return out;
}

PointGroupCrystalSystemMap getPointGroupsByCrystalSystem()
{
PointGroupCrystalSystemMap map;

std::vector<PointGroup_sptr> pointGroups = getAllPointGroups();
for(size_t i = 0; i < pointGroups.size(); ++i) {
map.insert(std::make_pair(pointGroups[i]->crystalSystem(), pointGroups[i]));
}

return map;
}



} // namespace Mantid
Expand Down
41 changes: 41 additions & 0 deletions Code/Mantid/Framework/Geometry/test/PointGroupTest.h
Expand Up @@ -182,6 +182,46 @@ class PointGroupTest : public CxxTest::TestSuite
TS_ASSERT_DIFFERS(matrices[0], matrices[1]);
}

void testCrystalSystems()
{
std::map<std::string, PointGroup::CrystalSystem> crystalSystemsMap;
crystalSystemsMap["-1 (Triclinic)"] = PointGroup::Triclinic;
crystalSystemsMap["1 2/m 1 (Monoclinic, unique axis b)"] = PointGroup::Monoclinic;
crystalSystemsMap["1 1 2/m (Monoclinic, unique axis c)"] = PointGroup::Monoclinic;
crystalSystemsMap["mmm (Orthorombic)"] = PointGroup::Orthorhombic;
crystalSystemsMap["4/m (Tetragonal)"] = PointGroup::Tetragonal;
crystalSystemsMap["4/mmm (Tetragonal)"] = PointGroup::Tetragonal;
crystalSystemsMap["-3 (Trigonal - Hexagonal)"] = PointGroup::Trigonal;
crystalSystemsMap["-3m1 (Trigonal - Rhombohedral)"] = PointGroup::Trigonal;
crystalSystemsMap["-31m (Trigonal - Rhombohedral)"] = PointGroup::Trigonal;
crystalSystemsMap["6/m (Hexagonal)"] = PointGroup::Hexagonal;
crystalSystemsMap["6/mmm (Hexagonal)"] = PointGroup::Hexagonal;
crystalSystemsMap["m-3 (Cubic)"] = PointGroup::Cubic;
crystalSystemsMap["m-3m (Cubic)"] = PointGroup::Cubic;

std::vector<PointGroup_sptr> pointgroups = getAllPointGroups();

for(size_t i = 0; i < pointgroups.size(); ++i) {
TSM_ASSERT_EQUALS(pointgroups[i]->getName() + ": Unexpected crystal system.", pointgroups[i]->crystalSystem(), crystalSystemsMap[pointgroups[i]->getName()]);
}
}

void testCrystalSystemMap()
{
std::vector<PointGroup_sptr> pointgroups = getAllPointGroups();
PointGroupCrystalSystemMap pgMap = getPointGroupsByCrystalSystem();

TS_ASSERT_EQUALS(pointgroups.size(), pgMap.size());

TS_ASSERT_EQUALS(pgMap.count(PointGroup::Triclinic), 1);
TS_ASSERT_EQUALS(pgMap.count(PointGroup::Monoclinic), 2);
TS_ASSERT_EQUALS(pgMap.count(PointGroup::Orthorhombic), 1);
TS_ASSERT_EQUALS(pgMap.count(PointGroup::Tetragonal), 2);
TS_ASSERT_EQUALS(pgMap.count(PointGroup::Trigonal), 3);
TS_ASSERT_EQUALS(pgMap.count(PointGroup::Hexagonal), 2);
TS_ASSERT_EQUALS(pgMap.count(PointGroup::Cubic), 2);
}

private:
class TestablePointGroup : public PointGroup
{
Expand All @@ -194,6 +234,7 @@ class PointGroupTest : public CxxTest::TestSuite

MOCK_METHOD0(getName, std::string());
MOCK_METHOD2(isEquivalent, bool(V3D hkl, V3D hkl2));
MOCK_CONST_METHOD0(crystalSystem, PointGroup::CrystalSystem());
};

};
Expand Down

0 comments on commit a85e800

Please sign in to comment.