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 "symmetry_basic.h"
10
11namespace ModuleSymmetry
12{
13
15{
16
17public:
18
20 {
21 this->epsilon = 1e-6;
22 };
24
25 //symmetry flag for levels
26 //-1 : no symmetry at all, k points would be total nks in KPT
27 //0 : only basic time-reversal symmetry is considered, point k and -k would fold to k
28 //1 : point group symmetry is considered
29 static int symm_flag;
30 static bool symm_autoclose; // controled by INPUT
31 static bool pricell_loop;
32
39 void analy_sys(const Lattice& lat, const Statistics& st, Atom* atoms, std::ofstream& ofs_running);
40
42 ModuleBase::Vector3<double> a1, a2, a3; //primitive cell vectors(might be changed during the process of the program)
43 ModuleBase::Vector3<double> p1, p2, p3; //primitive cell vectors
44
45 int ntype=0; //the number of atomic species
46 int nat =0; //the number of all atoms
47 int *na =nullptr;//number of atoms for each species
48 int *istart=nullptr; //start number of atom.
49 int itmin_type=0; //the type has smallest number of atoms
51
52 // direct coordinates of atoms.
53 double *newpos=nullptr;
54 // positions of atoms after rotation.
55 double *rotpos=nullptr;
56
57
58 std::vector<ModuleBase::Vector3<double>> ptrans; // the translation vectors of the primitive cell in the input structure
59 int ncell=1; //the number of primitive cells within one supercell
60 int *index=nullptr;
61
62 double cel_const[6]={0.0};
63 double pcel_const[6]={0.0}; //cel_const of primitive cell
64 double pre_const[6]={0.0}; //cel_const of input configuration, first 3 is moduli of a1, a2, a3, last 3 is eular angle
65
66 bool symflag_fft[48]={false};
67 int sym_test=0;
68 int pbrav=0; //ibrav of primitive cell
69 int real_brav=0; // the real ibrav for the cell pengfei Li 3-15-2022
70 std::string ilattname; //the bravais lattice type of the supercell
71 std::string plattname; //the bravais lattice type of the primitive cell
72
73 ModuleBase::Matrix3 gmatrix[48]; //the rotation matrices for all space group operations
74 ModuleBase::Matrix3 kgmatrix[48]; //the rotation matrices in reciprocal space
76
77 ModuleBase::Matrix3 symop[48]; //the rotation matrices for the pure bravais lattice
78 int nop=0; //the number of point group operations of the pure bravais lattice without basis
79 int nrot=0; //the number of pure point group rotations
80 int nrotk = -1; //the number of all space group operations, >0 means the nrotk has been analyzed
81 int max_nrotk = -1;
82 int pgnumber=0; //the serial number of point group
83 int spgnumber=0; //the serial number of point group in space group
84 std::string pgname; //the Schoenflies name of the point group R in {R|0}
85 std::string spgname; //the Schoenflies name of the point group R in the space group {R|t}
86
87 ModuleBase::Matrix3 optlat; //the optimized-symmetry lattice
88 ModuleBase::Matrix3 plat; //the primitive lattice
89
90 bool all_mbl = true;
91
95 double* celconst)const;
96
103 double* cel_const,
104 double* pre_const,
105 int& real_brav,
106 std::string& bravname,
107 const Atom* atoms,
108 bool convert_atoms,
109 double* newpos = nullptr)const;
110
111 void getgroup(int& nrot,
112 int& nrotk,
113 std::ofstream& ofs_running,
114 const int& nop,
118 double* pos, double* rotpos, int* index,
119 const int ntype, const int itmin_type, const int itmin_start,
120 int* istart, int* na)const;
121
122 bool checksym(const ModuleBase::Matrix3 &s,
124 double* pos, double* rotpos, int* index,
125 const int itmin_type, const int ntype, const int itmin_start,
126 int* istart, int* na)const;
127
129 void pricell(double* pos, const Atom* atoms);
130
134 void rho_symmetry(double *rho, const int &nr1, const int &nr2, const int &nr3);
135
136 void rhog_symmetry(std::complex<double> *rhogtot, int* ixyz2ipw, const int &nx,
137 const int &ny, const int &nz, const int & fftnx, const int &fftny, const int &fftnz);
138
140 void symmetrize_vec3_nat(double* v)const; // force
141
143 void symmetrize_mat3(ModuleBase::matrix& sigma, const Lattice& lat)const; // stress
144
145 //convert n rotation-matrices from sa on basis {a1, a2, a3} to sb on basis {b1, b2, b3}
147 const int n, const ModuleBase::Matrix3 &a, const ModuleBase::Matrix3 &b)const;
148
150 const int n, const ModuleBase::Matrix3 &a, const ModuleBase::Matrix3 &b)const;
151
152 //convert n translation-vectors from va on basis {a1, a2, a3} to vb on basis {b1, b2, b3}
154 const int n, const ModuleBase::Matrix3 &a, const ModuleBase::Matrix3 &b)const;
155
156 void gmatrix_invmap(const ModuleBase::Matrix3* s, const int n, int* invmap) const;
157
159
160 int get_rotated_atom(int isym, int iat)const
161 {
162 if (!this->isym_rotiat_.empty()) { return this->isym_rotiat_[isym][iat]; }
163 else { return -1; }
164 }
165
166 private:
167
169 std::vector<std::vector<int>> isym_rotiat_;
170
172 void set_atom_map(const Atom* atoms);
175 bool is_all_movable(const Atom* atoms, const Statistics& st)const;
176
177 // to be called in lattice_type
180
184 int& real_brav, double* cel_const, double* tmp_const)const;
185
188 bool magmom_same_check(const Atom* atoms)const;
189
193 void analyze_magnetic_group(const Atom* atoms, const Statistics& st, int& nrot_out, int& nrotk_out);
194};
195}
196
197#endif
Definition atom_spec.h:6
3x3 matrix and related mathamatical operations
Definition matrix3.h:19
3 elements vector
Definition vector3.h:24
Definition matrix.h:18
Definition symmetry_basic.h:14
double epsilon
the precision of symmetry operation
Definition symmetry_basic.h:20
Definition symmetry.h:15
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:79
double pcel_const[6]
Definition symmetry.h:63
ModuleBase::Vector3< double > p2
Definition symmetry.h:43
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:74
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:42
int * index
Definition symmetry.h:60
std::vector< ModuleBase::Vector3< double > > ptrans
Definition symmetry.h:58
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:160
ModuleBase::Vector3< double > a2
Definition symmetry.h:42
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:19
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:42
ModuleBase::Matrix3 plat
Definition symmetry.h:88
bool all_mbl
whether all the atoms are movable in all the directions
Definition symmetry.h:90
int ncell
Definition symmetry.h:59
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:47
ModuleBase::Vector3< double > s2
Definition symmetry.h:41
double cel_const[6]
Definition symmetry.h:62
std::string spgname
Definition symmetry.h:85
int pgnumber
Definition symmetry.h:82
std::vector< std::vector< int > > isym_rotiat_
atom-map for each symmetry operation: isym_rotiat[isym][iat]=rotiat
Definition symmetry.h:169
ModuleBase::Vector3< double > s3
Definition symmetry.h:41
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:49
ModuleBase::Matrix3 gmatrix[48]
Definition symmetry.h:73
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:53
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:66
std::string pgname
Definition symmetry.h:84
double * rotpos
Definition symmetry.h:55
int itmin_start
Definition symmetry.h:50
int max_nrotk
record the maximum number of symmetry operations during cell-relax
Definition symmetry.h:81
int pbrav
Definition symmetry.h:68
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:31
std::string plattname
Definition symmetry.h:71
int real_brav
Definition symmetry.h:69
~Symmetry()
Definition symmetry.h:23
int sym_test
Definition symmetry.h:67
ModuleBase::Matrix3 optlat
Definition symmetry.h:87
int nat
Definition symmetry.h:46
bool symflag_fft[48]
Definition symmetry.h:66
bool magmom_same_check(const Atom *atoms) const
Definition symm_magnetic.cpp:77
double pre_const[6]
Definition symmetry.h:64
int ntype
Definition symmetry.h:45
ModuleBase::Vector3< double > p3
Definition symmetry.h:43
static int symm_flag
Definition symmetry.h:29
ModuleBase::Vector3< double > p1
Definition symmetry.h:43
std::string ilattname
Definition symmetry.h:70
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:41
ModuleBase::Matrix3 symop[48]
Definition symmetry.h:77
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:48
int spgnumber
Definition symmetry.h:83
int nrotk
Definition symmetry.h:80
ModuleBase::Vector3< double > gtrans[48]
Definition symmetry.h:75
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:7
int nop
Definition symmetry.h:78
static bool symm_autoclose
Definition symmetry.h:30
Definition symm_other.cpp:4
info of lattice
Definition unitcell_data.h:8
usefull data and index maps
Definition unitcell_data.h:47