ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
symmetry.h
Go to the documentation of this file.
1
5#ifndef SYMMETRY_H
6#define SYMMETRY_H
7
10#include "source_base/timer.h"
13#include "symm_basic.h"
14
15#include <vector>
16
17namespace ModuleSymmetry
18{
19
24{
25
26public:
27
29 {
30 this->epsilon = 1e-6;
31 };
33
38 static int symm_flag;
39 static bool symm_autoclose;
40 static bool pricell_loop;
41
56 void analy_sys(const Lattice& lat, Atom* atoms,
57 const int nat, const int ntype,
58 const std::vector<int>& iat2it,
59 const std::vector<int>& iat2ia,
60 const ModuleBase::IntArray& itia2iat,
61 std::ofstream& ofs_running,
62 const double symmetry_prec, const int nspin, const std::string& calculation,
63 const int* cal_symm_repr);
64
68
69 int ntype=0;
70 int nat =0;
71 std::vector<int> na;
72 std::vector<int> istart;
73 int itmin_type=0;
75
77 std::vector<double> newpos;
79 std::vector<double> rotpos;
80
81
82 std::vector<ModuleBase::Vector3<double>> ptrans;
83 int ncell=1;
84 std::vector<int> index;
85
86 double cel_const[6]={0.0};
87 double pcel_const[6]={0.0};
88 double pre_const[6]={0.0};
89
90 bool symflag_fft[48]={false};
91 int sym_test=0;
92 int pbrav=0;
93 int real_brav=0;
94 std::string ilattname;
95 std::string plattname;
96
100
111 int nrotk_anti = 0;
118 bool magnetic_nspin4 = false;
119
121 int nop=0;
122 int nrot=0;
123 int nrotk = -1;
124 int max_nrotk = -1;
125 int pgnumber=0;
126 int spgnumber=0;
127 std::string pgname;
128 std::string spgname;
129
132
133 bool all_mbl = true;
134
138 double* celconst,
139 const double symmetry_prec)const;
140
147 double* cel_const,
148 double* pre_const,
149 int& real_brav,
150 std::string& bravname,
151 const Atom* atoms,
152 bool convert_atoms,
153 double* newpos,
154 const double symmetry_prec)const;
155
156 void getgroup(int& nrot,
157 int& nrotk,
158 std::ofstream& ofs_running,
159 const int& nop,
163 double* pos, double* rotpos, int* index,
164 const int ntype, const int itmin_type, const int itmin_start,
165 int* istart, int* na)const;
166
167 bool checksym(const ModuleBase::Matrix3 &s,
169 double* pos, double* rotpos, int* index,
170 const int itmin_type, const int ntype, const int itmin_start,
171 int* istart, int* na)const;
172
174 void pricell(double* pos, const Atom* atoms);
175
177
186 void rho_symmetry(double *rho, const int &nr1, const int &nr2, const int &nr3);
187
203 int density_sym_ops(std::vector<ModuleBase::Matrix3>& kgmatrix_in,
204 std::vector<ModuleBase::Vector3<double>>& gtrans_in,
205 std::vector<double>& trs_inv) const;
206
222 void rhog_symmetry(std::complex<double> *rhogtot, int* ixyz2ipw, const int &nx,
223 const int &ny, const int &nz, const int & fftnx, const int &fftny, const int &fftnz,
224 const bool gamma_only_pw,
225 const ModuleBase::Matrix3* kgmatrix_in,
226 const ModuleBase::Vector3<double>* gtrans_in, const int nop);
227
256 void rhog_symmetry_nspin4(std::complex<double>* rhogtot_x, std::complex<double>* rhogtot_y,
257 std::complex<double>* rhogtot_z, const ModuleBase::Matrix3* wspin,
258 int* ixyz2ipw, const int &nx, const int &ny, const int &nz,
259 const int & fftnx, const int &fftny, const int &fftnz,
260 const double* trs_inv,
261 const ModuleBase::Matrix3* kgmatrix_in,
262 const ModuleBase::Vector3<double>* gtrans_in, const int nop);
263
271 void symmetrize_vec3_nat(double* v)const;
272
281 void symmetrize_mat3(ModuleBase::matrix& sigma, const Lattice& lat)const;
282
293 const int n, const ModuleBase::Matrix3 &a, const ModuleBase::Matrix3 &b)const;
294
305 const int n, const ModuleBase::Matrix3 &a, const ModuleBase::Matrix3 &b)const;
306
317 const int n, const ModuleBase::Matrix3 &a, const ModuleBase::Matrix3 &b)const;
318
326 void gmatrix_invmap(const ModuleBase::Matrix3* s, const int n, int* invmap) const;
327
336
337 int get_rotated_atom(int isym, int iat)const
338 {
339 if (!this->isym_rotiat_.empty()) { return this->isym_rotiat_[isym][iat]; }
340 else { return -1; }
341 }
342
344 int get_rotated_atom_anti(int j, int iat)const
345 {
346 if (!this->isym_rotiat_anti_.empty()) { return this->isym_rotiat_anti_[j][iat]; }
347 else { return -1; }
348 }
349
350 private:
351
353 std::vector<std::vector<int>> isym_rotiat_;
354
357 std::vector<std::vector<int>> isym_rotiat_anti_;
358
360 void set_atom_map(const Atom* atoms);
365 bool is_all_movable(const Atom* atoms, const std::vector<int>& iat2it,
366 const std::vector<int>& iat2ia) const;
367
368 // to be called in lattice_type
371
375 int& real_brav, double* cel_const, double* tmp_const, const double symmetry_prec)const;
376
379 bool magmom_same_check(const Atom* atoms)const;
380
384 void analyze_magnetic_group(const Atom* atoms,
385 const std::vector<int>& iat2it,
386 const std::vector<int>& iat2ia,
387 const ModuleBase::IntArray& itia2iat,
388 int& nrot_out, int& nrotk_out);
389
396 void analyze_magnetic_group_nspin4(const Atom* atoms,
397 const std::vector<int>& iat2it,
398 const std::vector<int>& iat2ia,
399 const ModuleBase::Matrix3& latvec);
400};
401
419 const int nat,
423 ModuleBase::matrix& force);
424}
425
426#endif
Atom class for storing atom information.
Atom class for storing atom information.
Definition atom_spec.h:14
Integer array.
Definition intarray.h:17
3x3 matrix and related mathamatical operations
Definition matrix3.h:15
3 elements vector
Definition vector3.h:21
Definition matrix.h:15
double epsilon
the precision of symmetry operation
Definition symm_basic.h:25
Symmetry_Basic()
Definition symm_basic.h:22
Symmetry analysis class.
Definition symmetry.h:24
bool is_all_movable(const Atom *atoms, const std::vector< int > &iat2it, const std::vector< int > &iat2ia) const
check if all the atoms are movable delta_pos symmetrization in relax is only meaningful when all the ...
Definition symmetry.cpp:367
void hermite_normal_form(const ModuleBase::Matrix3 &s, ModuleBase::Matrix3 &H, ModuleBase::Matrix3 &b) const
Compute Hermite normal form.
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
the number of pure point group rotations
Definition symmetry.h:122
int get_rotated_atom_anti(int j, int iat) const
atom map for the j-th ANTIUNITARY operation (spatial part gmatrix_anti[j]).
Definition symmetry.h:344
double pcel_const[6]
cel_const of primitive cell
Definition symmetry.h:87
ModuleBase::Vector3< double > p2
Definition symmetry.h:67
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
void analyze_magnetic_group(const Atom *atoms, const std::vector< int > &iat2it, const std::vector< int > &iat2ia, const ModuleBase::IntArray &itia2iat, int &nrot_out, int &nrotk_out)
Definition symm_magnetic.cpp:10
ModuleBase::Matrix3 kgmatrix[48]
the rotation matrices in reciprocal space
Definition symmetry.h:98
void gtrans_convert(const ModuleBase::Vector3< double > *va, ModuleBase::Vector3< double > *vb, const int n, const ModuleBase::Matrix3 &a, const ModuleBase::Matrix3 &b) const
Convert n translation-vectors from basis {a1, a2, a3} to {b1, b2, b3}.
Definition symmetry.cpp:207
ModuleBase::Vector3< double > a3
primitive cell vectors(might be changed during the process of the program)
Definition symmetry.h:66
std::vector< ModuleBase::Vector3< double > > ptrans
the translation vectors of the primitive cell in the input structure
Definition symmetry.h:82
void rho_symmetry(double *rho, const int &nr1, const int &nr2, const int &nr3)
Symmetrize the charge density, the forces, and the stress.
Definition symm_rho.cpp:113
std::vector< double > rotpos
positions of atoms after rotation
Definition symmetry.h:79
int get_rotated_atom(int isym, int iat) const
Definition symmetry.h:337
ModuleBase::Vector3< double > a2
Definition symmetry.h:66
Symmetry()
Definition symmetry.h:28
ModuleBase::Matrix3 gmatrix_anti[48]
Definition symmetry.h:108
std::vector< int > na
number of atoms for each species
Definition symmetry.h:71
void set_atom_map(const Atom *atoms)
set atom map for each symmetry operation
Definition symmetry.cpp:11
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 double symmetry_prec) const
Definition symmetry.cpp:287
ModuleBase::Vector3< double > a1
Definition symmetry.h:66
ModuleBase::Matrix3 plat
the primitive lattice
Definition symmetry.h:131
bool all_mbl
whether all the atoms are movable in all the directions
Definition symmetry.h:133
int ncell
the number of primitive cells within one supercell
Definition symmetry.h:83
std::vector< int > istart
start number of atom
Definition symmetry.h:72
ModuleBase::Vector3< double > s2
Definition symmetry.h:65
double cel_const[6]
Definition symmetry.h:86
std::string spgname
the Schoenflies name of the point group R in the space group {R|t}
Definition symmetry.h:128
std::vector< double > newpos
direct coordinates of atoms
Definition symmetry.h:77
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, const double symmetry_prec) const
Definition symm_lattice.cpp:283
int pgnumber
the serial number of point group
Definition symmetry.h:125
std::vector< std::vector< int > > isym_rotiat_
atom-map for each symmetry operation: isym_rotiat[isym][iat]=rotiat
Definition symmetry.h:353
ModuleBase::Vector3< double > s3
Definition symmetry.h:65
int density_sym_ops(std::vector< ModuleBase::Matrix3 > &kgmatrix_in, std::vector< ModuleBase::Vector3< double > > &gtrans_in, std::vector< double > &trs_inv) const
Assemble the spatial operations used to symmetrize the density.
Definition symm_magnetic.cpp:220
void get_shortest_latvec(ModuleBase::Vector3< double > &a1, ModuleBase::Vector3< double > &a2, ModuleBase::Vector3< double > &a3) const
Definition symmetry.cpp:238
bool magnetic_nspin4
Definition symmetry.h:118
void symmetrize_mat3(ModuleBase::matrix &sigma, const Lattice &lat) const
Symmetrize a 3*3 tensor.
Definition symmetry.cpp:158
int itmin_type
the type has smallest number of atoms
Definition symmetry.h:73
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, const bool gamma_only_pw, const ModuleBase::Matrix3 *kgmatrix_in, const ModuleBase::Vector3< double > *gtrans_in, const int nop)
Symmetrize charge density in reciprocal space.
Definition symm_rho.cpp:172
ModuleBase::Matrix3 gmatrix[48]
the rotation matrices for all space group operations
Definition symmetry.h:97
void analyze_magnetic_group_nspin4(const Atom *atoms, const std::vector< int > &iat2it, const std::vector< int > &iat2ia, const ModuleBase::Matrix3 &latvec)
Definition symm_magnetic.cpp:85
std::vector< int > index
Definition symmetry.h:84
std::string pgname
the Schoenflies name of the point group R in {R|0}
Definition symmetry.h:127
int itmin_start
Definition symmetry.h:74
int max_nrotk
record the maximum number of symmetry operations during cell-relax
Definition symmetry.h:124
int pbrav
ibrav of primitive cell
Definition symmetry.h:92
void symmetrize_vec3_nat(double *v) const
Symmetrize a vector3 with nat elements.
Definition symmetry.cpp:84
void gmatrix_invmap(const ModuleBase::Matrix3 *s, const int n, int *invmap) const
Compute inverse mapping of symmetry operations.
Definition symmetry.cpp:217
static bool pricell_loop
whether to loop primitive cell in rhog_symmetry, Only for AFM
Definition symmetry.h:40
std::string plattname
the bravais lattice type of the primitive cell
Definition symmetry.h:95
int real_brav
the real ibrav for the cell (pengfei Li 3-15-2022)
Definition symmetry.h:93
~Symmetry()
Definition symmetry.h:32
int sym_test
Definition symmetry.h:91
ModuleBase::Matrix3 optlat
the optimized-symmetry lattice
Definition symmetry.h:130
int nat
the number of all atoms
Definition symmetry.h:70
bool symflag_fft[48]
Definition symmetry.h:90
int standard_lat(ModuleBase::Vector3< double > &a, ModuleBase::Vector3< double > &b, ModuleBase::Vector3< double > &c, double *celconst, const double symmetry_prec) const
Definition symm_lattice.cpp:10
void analy_sys(const Lattice &lat, Atom *atoms, const int nat, const int ntype, const std::vector< int > &iat2it, const std::vector< int > &iat2ia, const ModuleBase::IntArray &itia2iat, std::ofstream &ofs_running, const double symmetry_prec, const int nspin, const std::string &calculation, const int *cal_symm_repr)
analyze the symmetry of the system
Definition symm_analysis.cpp:6
bool magmom_same_check(const Atom *atoms) const
Definition symm_magnetic.cpp:198
double pre_const[6]
cel_const of input configuration, first 3 is moduli of a1, a2, a3, last 3 is eular angle
Definition symmetry.h:88
int ntype
the number of atomic species
Definition symmetry.h:69
ModuleBase::Vector3< double > p3
primitive cell vectors
Definition symmetry.h:67
ModuleBase::Matrix3 kgmatrix_anti[48]
Definition symmetry.h:109
int nrotk_anti
Definition symmetry.h:111
static int symm_flag
symmetry flag for levels: -1 : no symmetry at all, k points would be total nks in KPT 0 : only basic ...
Definition symmetry.h:38
ModuleBase::Vector3< double > p1
Definition symmetry.h:67
std::string ilattname
the bravais lattice type of the supercell
Definition symmetry.h:94
void gmatrix_convert(const ModuleBase::Matrix3 *sa, ModuleBase::Matrix3 *sb, const int n, const ModuleBase::Matrix3 &a, const ModuleBase::Matrix3 &b) const
Convert n rotation-matrices from basis {a1, a2, a3} to {b1, b2, b3}.
Definition symmetry.cpp:196
ModuleBase::Vector3< double > s1
Definition symmetry.h:65
ModuleBase::Matrix3 symop[48]
the rotation matrices for the pure bravais lattice
Definition symmetry.h:120
void pricell(double *pos, const Atom *atoms)
primitive cell analysis
Definition symm_pricell.cpp:4
ModuleBase::Vector3< double > gtrans_anti[48]
Definition symmetry.h:110
int spgnumber
the serial number of point group in space group
Definition symmetry.h:126
int nrotk
the number of all space group operations, >0 means the nrotk has been analyzed
Definition symmetry.h:123
ModuleBase::Vector3< double > gtrans[48]
Definition symmetry.h:99
void gmatrix_convert_int(const ModuleBase::Matrix3 *sa, ModuleBase::Matrix3 *sb, const int n, const ModuleBase::Matrix3 &a, const ModuleBase::Matrix3 &b) const
Convert n integer rotation-matrices from basis {a1, a2, a3} to {b1, b2, b3}.
Definition symmetry.cpp:174
std::vector< std::vector< int > > isym_rotiat_anti_
Definition symmetry.h:357
int nop
the number of point group operations of the pure bravais lattice without basis
Definition symmetry.h:121
static bool symm_autoclose
controlled by INPUT
Definition symmetry.h:39
void rhog_symmetry_nspin4(std::complex< double > *rhogtot_x, std::complex< double > *rhogtot_y, std::complex< double > *rhogtot_z, const ModuleBase::Matrix3 *wspin, int *ixyz2ipw, const int &nx, const int &ny, const int &nz, const int &fftnx, const int &fftny, const int &fftnz, const double *trs_inv, const ModuleBase::Matrix3 *kgmatrix_in, const ModuleBase::Vector3< double > *gtrans_in, const int nop)
Symmetrize the nspin=4 (non-collinear/SOC) spin density in reciprocal space.
Definition symm_rho.cpp:332
Definition klist_io.h:13
void symmetrize_force_cartesian(Symmetry *symm, const int nat, const ModuleBase::Vector3< double > &a1, const ModuleBase::Vector3< double > &a2, const ModuleBase::Vector3< double > &a3, ModuleBase::matrix &force)
Symmetrize a per-atom Cartesian force vector in place.
Definition symmetry.cpp:118
Lattice information.
Definition unitcell_data.h:17
Basic symmetry operations class.
Data structures for unit cell information.