6 #include <boost/filesystem.hpp>
7 #include <boost/filesystem/fstream.hpp>
28 #include "casm/external/Eigen/src/Core/Matrix.h"
42 if (!fs::exists(filepath)) {
43 err_log() <<
"Error in Structure::Structure(const fs::path &filepath)."
45 err_log() <<
" File does not exist at: " << filepath << std::endl;
48 fs::ifstream infile(filepath);
60 : m_structure_ptr(RHS.m_structure_ptr) {
94 for (
const xtal::SymOp &op : factor_group_operations) {
138 const std::string dof_name)
const {
153 std::vector<std::map<DoFKey, SymGroupRepID>>(this->
basis().size());
163 std::string clr(100,
' ');
165 err_log() <<
"ERROR in generate_basis_permutation_representation"
167 err_log() <<
"Factor group is empty." << std::endl;
172 std::vector<UnitCellCoord> sitemap;
178 for (
auto const &dof :
basis()[b].dofs()) {
201 auto const &dofref_to =
basis()[sitemap[b].sublattice()].occupant_dof();
202 auto const &dofref_from =
basis()[b].occupant_dof();
208 if (symrep_from.is_identity()) {
212 for (s2 = 0; s2 <
s; ++s2) {
224 throw std::runtime_error(
225 "In Structure::_generate_basis_symreps(), Sites originally "
226 "identified as equivalent cannot be mapped by symmetry.");
230 for (
Index from_b = 0; from_b <
basis().size(); ++from_b) {
231 if (!
basis()[from_b].has_dof(dof_key))
continue;
235 Index to_b = sitemap[from_b].sublattice();
252 throw std::runtime_error(
253 "While generating symmetry representation for local DoF \"" +
255 "\", a symmetry operation was identified that invalidates the "
256 "degree of freedom. " +
257 "Degrees of freedom must be fully specified before performing "
258 "symmetry analyses.");
277 err_log() <<
"ERROR in generate_global_dof_representations" << std::endl;
278 err_log() <<
"Factor group is empty." << std::endl;
281 for (
auto const &name_dof_pr : this->
structure().global_dofs()) {
282 std::string dof_name = name_dof_pr.first;
294 if (!dof_equals(transformed_dof)) {
295 throw std::runtime_error(
296 "While generating symmetry representation for global DoF \"" +
298 "\", a symmetry operation was identified that invalidates the "
299 "degree of freedom. " +
300 "Degrees of freedom must be fully specified before performing "
301 "symmetry analyses.");
307 }
catch (std::runtime_error &e) {
308 throw std::runtime_error(std::string(e.what()) +
309 " Attempted to make representation for " +
323 const Structure &struc, std::vector<xtal::Molecule> mol_list) {
324 std::vector<std::vector<Index>> converter(struc.
basis().size());
326 for (
Index i = 0; i < struc.
basis().size(); i++) {
327 converter[i].resize(struc.
basis()[i].occupant_dof().size());
329 for (
Index j = 0; j < struc.
basis()[i].occupant_dof().size(); j++) {
342 const Structure &struc, std::vector<std::string> mol_name_list) {
343 std::vector<std::vector<Index>> converter(struc.
basis().size());
345 for (
Index i = 0; i < struc.
basis().size(); i++) {
346 converter[i].resize(struc.
basis()[i].occupant_dof().size());
348 for (
Index j = 0; j < struc.
basis()[i].occupant_dof().size(); j++) {
350 mol_name_list, struc.
basis()[i].occupant_dof()[j].name());
364 const Structure &struc, std::vector<std::string> mol_name_list) {
365 std::vector<std::vector<Index>> converter_inv(struc.
basis().size());
367 for (
Index i = 0; i < struc.
basis().size(); i++) {
368 converter_inv[i].resize(mol_name_list.size());
370 std::vector<std::string> site_occ_name_list;
371 for (
Index j = 0; j < struc.
basis()[i].occupant_dof().size(); j++) {
372 site_occ_name_list.push_back(struc.
basis()[i].occupant_dof()[j].name());
375 for (
Index j = 0; j < mol_name_list.size(); j++) {
376 converter_inv[i][j] =
381 return converter_inv;
385 std::map<DoFKey, DoFSetInfo> result;
387 result.emplace(dof.first,
397 std::map<DoFKey, std::vector<DoFSetInfo>> result;
400 std::vector<CASM::DoFSetInfo> tresult(
401 _struc.
basis().size(),
406 for (
Index b = 0; b < _struc.
basis().size(); ++b) {
407 if (_struc.
basis()[b].has_dof(type)) {
408 const auto &dofset = _struc.
basis()[b].dof(type);
414 result.emplace(type, std::move(tresult));
420 Lattice const &super_lattice) {
424 std::map<DoFKey, SymGroupRepID> global_dof_symrep_IDs;
426 global_dof_symrep_IDs.emplace(
431 std::map<DoFKey, std::vector<SymGroupRepID>> local_dof_symrep_IDs;
433 std::vector<SymGroupRepID> treps(prim.
basis().size());
434 for (
Index b = 0; b < prim.
basis().size(); ++b) {
435 if (prim.
basis()[b].has_dof(key))
438 local_dof_symrep_IDs.emplace(std::make_pair(key, std::move(treps)));
std::set< std::string > & s
Specifies traits of (possibly) anisotropic crystal properties.
Class for checking equivalence of two DoFSet objects, with respect to symmetry transformations.
Eigen::MatrixXd const & U() const
SymGroupRepID allocate_representation() const
Add a new empty representation.
void sort()
Sort SymOp in the SymGroup.
void set_rep(SymGroupRepID _rep_ID, SymOpRepresentation const &_op_rep, Index op_index) const
const SymGroup & point_group() const
void push_back(const SymOp &op)
SymGroupRep const & representation(SymGroupRepID i) const
Const access of alternate Representations of a SymGroup.
Class for checking equivalence of two OccupantDoF objects, with respect to symmetry transformations.
Permutation const & perm() const
Permutation inverse() const
Construct permutation that undoes the permutation performed by 'this'.
bool is_identity() const
Checks whether permutation is identity (i.e., m_perm_aray[i]==i for all i)
Structure specifies the lattice and atomic basis of a crystal.
SymGroupRepID m_basis_perm_rep_ID
This holds the representation id of the permutation representation.
std::vector< SymGroupRepID > m_occupant_symrep_IDs
Hold the SymRepIDs for the occupant DoF, one for each of the basis sites.
const xtal::BasicStructure & structure() const
std::vector< std::map< DoFKey, SymGroupRepID > > site_dof_symrep_IDs() const
void _generate_global_symreps()
Obtain global dof symreps of factor_group.
const SymGroup & point_group() const
const Lattice & lattice() const
SymGroupRep const * basis_permutation_symrep() const
std::shared_ptr< const xtal::BasicStructure > m_structure_ptr
MasterSymGroup m_factor_group
const std::vector< xtal::Site > & basis() const
void generate_factor_group()
void _generate_basis_symreps()
SymGroupRepID global_dof_symrep_ID(const std::string dof_name) const
void _reset_site_dof_symrep_IDs()
std::vector< std::map< DoFKey, SymGroupRepID > > m_site_dof_symrep_IDs
void copy_attributes_from(const Structure &RHS)
copy all non-derived members
Structure & operator=(const Structure &RHS)
const MasterSymGroup & factor_group() const
SymGroupRepID basis_permutation_symrep_ID() const
std::unordered_map< std::string, SymGroupRepID > m_global_dof_symrep_IDs
std::vector< SymGroupRepID > occupant_symrep_IDs() const
void _reset_occupant_symrep_IDs()
A class that collects all symmetry information for for performing symmetry transformations on the sit...
SymBasisPermute describes how a symmetry operation permutes atoms in a basis.
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
void set_lattice(const Lattice &new_lat)
Lattice used for periodic comparisons (for instance, to generate multiplcation table)
SymGroupRep is an alternative representation of a SymGroup for something other than real space....
Type-safe ID object for communicating and accessing Symmetry representation info.
static SymGroupRepID identity(Index dim)
Static function to construct an ID for identity representations.
Generalized symmetry matrix representation for arbitrary dimension Can be used to describe applicatio...
SymPermutation describes how a symmetry operation permutes a list of 'things' For example,...
BasicStructure specifies the lattice and atomic basis of a crystal.
std::map< DoFKey, DoFSet > const & global_dofs() const
static BasicStructure from_poscar_stream(std::istream &poscar_stream, double tol=TOL)
Eigen::MatrixXd const & basis() const
Matrix that relates DoFSet variables to a conventional coordiante system.
std::vector< DoFKey > continuous_local_dof_types(BasicStructure const &_struc)
std::vector< UnitCellCoord > symop_site_map(SymOp const &_op, BasicStructure const &_struc)
To which site a SymOp transforms each basis site.
std::vector< DoFKey > global_dof_types(BasicStructure const &_struc)
ConfigIO::GenericConfigFormatter< jsonParser > structure()
xtal::Coordinate copy_apply(const xtal::SymOp &op, xtal::Coordinate coord)
Copy and apply SymOp to a Coordinate.
std::vector< SymOp > make_factor_group(const BasicStructure &struc, double tol=TOL)
Eigen::MatrixXd dofset_transformation_matrix(const Eigen::MatrixXd &from_basis, const Eigen::MatrixXd &to_basis, double tol)
Create the symmtery representation for going from one basis to another.
std::vector< SymOp > SymOpVector
Index find_index(Iterator begin, Iterator end, const T &value)
Equivalent to std::distance(begin, std::find(begin, end, value))
std::vector< std::vector< Index > > make_index_converter(const Structure &struc, std::vector< xtal::Molecule > mol_list)
std::vector< std::vector< Index > > make_index_converter_inverse(const Structure &struc, std::vector< std::string > mol_name_list)
std::map< DoFKey, std::vector< CASM::DoFSetInfo > > local_dof_info(Structure const &_struc)
SupercellSymInfo make_supercell_sym_info(Structure const &prim, Lattice const &super_lattice)
INDEX_TYPE Index
For long integer indexing:
std::map< DoFKey, CASM::DoFSetInfo > global_dof_info(Structure const &_struc)