ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
symmetry.h
Go to the documentation of this file.
1#ifndef SYMMETRY_H
2#define SYMMETRY_H
3
6#include "source_base/timer.h"
9#include "source_io/output.h"
10#include "symmetry_basic.h"
11
12namespace ModuleSymmetry
13{
14
16{
17
18public:
19
21 {
22 this->epsilon = 1e-6;
23 };
25
26 //symmetry flag for levels
27 //-1 : no symmetry at all, k points would be total nks in KPT
28 //0 : only basic time-reversal symmetry is considered, point k and -k would fold to k
29 //1 : point group symmetry is considered
30 static int symm_flag;
31 static bool symm_autoclose; // controled by INPUT
32 static bool pricell_loop;
33
40 void analy_sys(const Lattice& lat, const Statistics& st, Atom* atoms, std::ofstream& ofs_running);
41
43 ModuleBase::Vector3<double> a1, a2, a3; //primitive cell vectors(might be changed during the process of the program)
44 ModuleBase::Vector3<double> p1, p2, p3; //primitive cell vectors
45
46 int ntype=0; //the number of atomic species
47 int nat =0; //the number of all atoms
48 int *na =nullptr;//number of atoms for each species
49 int *istart=nullptr; //start number of atom.
50 int itmin_type=0; //the type has smallest number of atoms
52
53 // direct coordinates of atoms.
54 double *newpos=nullptr;
55 // positions of atoms after rotation.
56 double *rotpos=nullptr;
57
58
59 std::vector<ModuleBase::Vector3<double>> ptrans; // the translation vectors of the primitive cell in the input structure
60 int ncell=1; //the number of primitive cells within one supercell
61 int *index=nullptr;
62
63 double cel_const[6]={0.0};
64 double pcel_const[6]={0.0}; //cel_const of primitive cell
65 double pre_const[6]={0.0}; //cel_const of input configuration, first 3 is moduli of a1, a2, a3, last 3 is eular angle
66
67 bool symflag_fft[48]={false};
68 int sym_test=0;
69 int pbrav=0; //ibrav of primitive cell
70 int real_brav=0; // the real ibrav for the cell pengfei Li 3-15-2022
71 std::string ilattname; //the bravais lattice type of the supercell
72 std::string plattname; //the bravais lattice type of the primitive cell
73
74 ModuleBase::Matrix3 gmatrix[48]; //the rotation matrices for all space group operations
75 ModuleBase::Matrix3 kgmatrix[48]; //the rotation matrices in reciprocal space
77
78 ModuleBase::Matrix3 symop[48]; //the rotation matrices for the pure bravais lattice
79 int nop=0; //the number of point group operations of the pure bravais lattice without basis
80 int nrot=0; //the number of pure point group rotations
81 int nrotk = -1; //the number of all space group operations, >0 means the nrotk has been analyzed
82 int max_nrotk = -1;
83 int pgnumber=0; //the serial number of point group
84 int spgnumber=0; //the serial number of point group in space group
85 std::string pgname; //the Schoenflies name of the point group R in {R|0}
86 std::string spgname; //the Schoenflies name of the point group R in the space group {R|t}
87
88 ModuleBase::Matrix3 optlat; //the optimized-symmetry lattice
89 ModuleBase::Matrix3 plat; //the primitive lattice
90
91 bool all_mbl = true;
92
96 double* celconst)const;
97
104 double* cel_const,
105 double* pre_const,
106 int& real_brav,
107 std::string& bravname,
108 const Atom* atoms,
109 bool convert_atoms,
110 double* newpos = nullptr)const;
111
112 void getgroup(int& nrot,
113 int& nrotk,
114 std::ofstream& ofs_running,
115 const int& nop,
119 double* pos, double* rotpos, int* index,
120 const int ntype, const int itmin_type, const int itmin_start,
121 int* istart, int* na)const;
122
123 bool checksym(const ModuleBase::Matrix3 &s,
125 double* pos, double* rotpos, int* index,
126 const int itmin_type, const int ntype, const int itmin_start,
127 int* istart, int* na)const;
128
130 void pricell(double* pos, const Atom* atoms);
131
135 void rho_symmetry(double *rho, const int &nr1, const int &nr2, const int &nr3);
136
137 void rhog_symmetry(std::complex<double> *rhogtot, int* ixyz2ipw, const int &nx,
138 const int &ny, const int &nz, const int & fftnx, const int &fftny, const int &fftnz);
139
141 void symmetrize_vec3_nat(double* v)const; // force
142
144 void symmetrize_mat3(ModuleBase::matrix& sigma, const Lattice& lat)const; // stress
145
146 //convert n rotation-matrices from sa on basis {a1, a2, a3} to sb on basis {b1, b2, b3}
148 const int n, const ModuleBase::Matrix3 &a, const ModuleBase::Matrix3 &b)const;
149
151 const int n, const ModuleBase::Matrix3 &a, const ModuleBase::Matrix3 &b)const;
152
153 //convert n translation-vectors from va on basis {a1, a2, a3} to vb on basis {b1, b2, b3}
155 const int n, const ModuleBase::Matrix3 &a, const ModuleBase::Matrix3 &b)const;
156
157 void gmatrix_invmap(const ModuleBase::Matrix3* s, const int n, int* invmap) const;
158
160
161 int get_rotated_atom(int isym, int iat)const
162 {
163 if (!this->isym_rotiat_.empty()) { return this->isym_rotiat_[isym][iat]; }
164 else { return -1; }
165 }
166
167 private:
168
170 std::vector<std::vector<int>> isym_rotiat_;
171
173 void set_atom_map(const Atom* atoms);
176 bool is_all_movable(const Atom* atoms, const Statistics& st)const;
177
178 // to be called in lattice_type
181
185 int& real_brav, double* cel_const, double* tmp_const)const;
186
189 bool magmom_same_check(const Atom* atoms)const;
190
194 void analyze_magnetic_group(const Atom* atoms, const Statistics& st, int& nrot_out, int& nrotk_out);
195};
196}
197
198#endif
Definition atom_spec.h:7
3x3 matrix and related mathamatical operations
Definition matrix3.h:19
3 elements vector
Definition vector3.h:22
Definition matrix.h:19
Definition symmetry_basic.h:14
double epsilon
the precision of symmetry operation
Definition symmetry_basic.h:20
Definition symmetry.h:16
void hermite_normal_form(const ModuleBase::Matrix3 &s, ModuleBase::Matrix3 &H, ModuleBase::Matrix3 &b) const
Definition symm_hermite.cpp:4
bool checksym(const ModuleBase::Matrix3 &s, ModuleBase::Vector3< double > &gtrans, double *pos, double *rotpos, int *index, const int itmin_type, const int ntype, const int itmin_start, int *istart, int *na) const
Definition symm_check.cpp:4
int nrot
Definition symmetry.h:80
double pcel_const[6]
Definition symmetry.h:64
ModuleBase::Vector3< double > p2
Definition symmetry.h:44
void getgroup(int &nrot, int &nrotk, std::ofstream &ofs_running, const int &nop, const ModuleBase::Matrix3 *symop, ModuleBase::Matrix3 *gmatrix, ModuleBase::Vector3< double > *gtrans, double *pos, double *rotpos, int *index, const int ntype, const int itmin_type, const int itmin_start, int *istart, int *na) const
Definition symm_getgroup.cpp:4
ModuleBase::Matrix3 kgmatrix[48]
Definition symmetry.h:75
void gtrans_convert(const ModuleBase::Vector3< double > *va, ModuleBase::Vector3< double > *vb, const int n, const ModuleBase::Matrix3 &a, const ModuleBase::Matrix3 &b) const
Definition symmetry.cpp:168
ModuleBase::Vector3< double > a3
Definition symmetry.h:43
int * index
Definition symmetry.h:61
std::vector< ModuleBase::Vector3< double > > ptrans
Definition symmetry.h:59
void rho_symmetry(double *rho, const int &nr1, const int &nr2, const int &nr3)
Definition symm_rho.cpp:7
int get_rotated_atom(int isym, int iat) const
Definition symmetry.h:161
ModuleBase::Vector3< double > a2
Definition symmetry.h:43
void analyze_magnetic_group(const Atom *atoms, const Statistics &st, int &nrot_out, int &nrotk_out)
Definition symm_magnetic.cpp:6
Symmetry()
Definition symmetry.h:20
void set_atom_map(const Atom *atoms)
set atom map for each symmetry operation
Definition symmetry.cpp:11
ModuleBase::Vector3< double > a1
Definition symmetry.h:43
ModuleBase::Matrix3 plat
Definition symmetry.h:89
bool all_mbl
whether all the atoms are movable in all the directions
Definition symmetry.h:91
int ncell
Definition symmetry.h:60
bool is_all_movable(const Atom *atoms, const Statistics &st) const
check if all the atoms are movable delta_pos symmetrization in relax is only meaningful when all the ...
Definition symmetry.cpp:328
int * na
Definition symmetry.h:48
ModuleBase::Vector3< double > s2
Definition symmetry.h:42
double cel_const[6]
Definition symmetry.h:63
std::string spgname
Definition symmetry.h:86
int pgnumber
Definition symmetry.h:83
std::vector< std::vector< int > > isym_rotiat_
atom-map for each symmetry operation: isym_rotiat[isym][iat]=rotiat
Definition symmetry.h:170
ModuleBase::Vector3< double > s3
Definition symmetry.h:42
void get_shortest_latvec(ModuleBase::Vector3< double > &a1, ModuleBase::Vector3< double > &a2, ModuleBase::Vector3< double > &a3) const
Definition symmetry.cpp:199
void lattice_type(ModuleBase::Vector3< double > &v1, ModuleBase::Vector3< double > &v2, ModuleBase::Vector3< double > &v3, ModuleBase::Vector3< double > &v01, ModuleBase::Vector3< double > &v02, ModuleBase::Vector3< double > &v03, double *cel_const, double *pre_const, int &real_brav, std::string &bravname, const Atom *atoms, bool convert_atoms, double *newpos=nullptr) const
Definition symm_lattice.cpp:284
void symmetrize_mat3(ModuleBase::matrix &sigma, const Lattice &lat) const
symmetrize a 3*3 tensor, which can be stress or variation of unitcell in cell-relax
Definition symmetry.cpp:119
int itmin_type
Definition symmetry.h:50
ModuleBase::Matrix3 gmatrix[48]
Definition symmetry.h:74
int standard_lat(ModuleBase::Vector3< double > &a, ModuleBase::Vector3< double > &b, ModuleBase::Vector3< double > &c, double *celconst) const
Definition symm_lattice.cpp:12
double * newpos
Definition symmetry.h:54
void rhog_symmetry(std::complex< double > *rhogtot, int *ixyz2ipw, const int &nx, const int &ny, const int &nz, const int &fftnx, const int &fftny, const int &fftnz)
Definition symm_rho.cpp:62
std::string pgname
Definition symmetry.h:85
double * rotpos
Definition symmetry.h:56
int itmin_start
Definition symmetry.h:51
int max_nrotk
record the maximum number of symmetry operations during cell-relax
Definition symmetry.h:82
int pbrav
Definition symmetry.h:69
void symmetrize_vec3_nat(double *v) const
symmetrize a vector3 with nat elements, which can be forces or variation of atom positions in relax
Definition symmetry.cpp:85
void gmatrix_invmap(const ModuleBase::Matrix3 *s, const int n, int *invmap) const
Definition symmetry.cpp:178
static bool pricell_loop
whether to loop primitive cell in rhog_symmetry, Only for AFM
Definition symmetry.h:32
std::string plattname
Definition symmetry.h:72
int real_brav
Definition symmetry.h:70
~Symmetry()
Definition symmetry.h:24
int sym_test
Definition symmetry.h:68
ModuleBase::Matrix3 optlat
Definition symmetry.h:88
int nat
Definition symmetry.h:47
bool symflag_fft[48]
Definition symmetry.h:67
bool magmom_same_check(const Atom *atoms) const
Definition symm_magnetic.cpp:77
double pre_const[6]
Definition symmetry.h:65
int ntype
Definition symmetry.h:46
ModuleBase::Vector3< double > p3
Definition symmetry.h:44
static int symm_flag
Definition symmetry.h:30
ModuleBase::Vector3< double > p1
Definition symmetry.h:44
std::string ilattname
Definition symmetry.h:71
void gmatrix_convert(const ModuleBase::Matrix3 *sa, ModuleBase::Matrix3 *sb, const int n, const ModuleBase::Matrix3 &a, const ModuleBase::Matrix3 &b) const
Definition symmetry.cpp:157
ModuleBase::Vector3< double > s1
Definition symmetry.h:42
ModuleBase::Matrix3 symop[48]
Definition symmetry.h:78
void pricell(double *pos, const Atom *atoms)
primitive cell analysis
Definition symm_pricell.cpp:4
void get_optlat(ModuleBase::Vector3< double > &v1, ModuleBase::Vector3< double > &v2, ModuleBase::Vector3< double > &v3, ModuleBase::Vector3< double > &w1, ModuleBase::Vector3< double > &w2, ModuleBase::Vector3< double > &w3, int &real_brav, double *cel_const, double *tmp_const) const
Definition symmetry.cpp:248
int * istart
Definition symmetry.h:49
int spgnumber
Definition symmetry.h:84
int nrotk
Definition symmetry.h:81
ModuleBase::Vector3< double > gtrans[48]
Definition symmetry.h:76
void gmatrix_convert_int(const ModuleBase::Matrix3 *sa, ModuleBase::Matrix3 *sb, const int n, const ModuleBase::Matrix3 &a, const ModuleBase::Matrix3 &b) const
Definition symmetry.cpp:135
void analy_sys(const Lattice &lat, const Statistics &st, Atom *atoms, std::ofstream &ofs_running)
analyze the symmetry of the system
Definition symm_analysis.cpp:6
int nop
Definition symmetry.h:79
static bool symm_autoclose
Definition symmetry.h:31
Definition symm_other.cpp:4
info of lattice
Definition unitcell_data.h:8
usefull data and index maps
Definition unitcell_data.h:47