Skip to content

Commit f67dbd0

Browse files
authored
Merge branch 'develop' into cell
2 parents 196dc80 + 6df9240 commit f67dbd0

File tree

101 files changed

+684
-469
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+684
-469
lines changed

docs/advanced/elec_properties/hs_matrix.md

+5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ We also offer the option of only calculating the overlap matrix without running
6161

6262
A file named `SR.csr` will be generated in the working directory, which contains the overlap matrix.
6363

64+
> When `nspin` is set to 1 or 2, the dimension of the overlap matrix is nlocal $\times$ nlocal, where nlocal is the total number of numerical atomic orbitals.
65+
These numerical atomic orbitals are ordered from outer to inner loop as atom, angular quantum number $l$, zeta (multiple radial orbitals corresponding to each $l$), and magnetic quantum number $m$.
66+
When `nspin` is set to 4, the dimension of the overlap matrix is (2 $\times$ nlocal) $\times$ (2 $\times$ nlocal). In this case, the numerical atomic orbitals are ordered from outer to inner loop as atom, angular quantum number $l$, zeta (multiple radial orbitals corresponding to each $l$), magnetic quantum number $m$, and npol (index of spin, ranges from 0 to 1).
67+
68+
6469
## examples
6570
We provide [examples](https://github.com/deepmodeling/abacus-develop/tree/develop/examples/matrix_hs) of outputting the matrices. There are four examples:
6671

docs/advanced/elec_properties/position_matrix.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@ Each file or each section of the appended file starts with "STEP: " followed by
1818

1919
Each block here contains the matrix for the corresponding cell. There are three columns in each block, giving the matrix elements in x, y, z directions, respectively. There are altogether nbasis * nbasis lines in each block, which emulates the matrix elements.
2020

21-
In molecular dynamics (MD) calculations, if [out_app_flag](../input_files/input-main.md#out_app_flag) is set to true, then `data-rR-tr` is written in an append manner. Otherwise, output files will be put in a separate directory, `matrix`, and named as `$x`_data-rR-tr, where `$x` is the number of MD step. In addition, The output frequency is controlled by [out_interval](../input_files/input-main.md#out_interval). For example, if we are running a 10-step MD with out_interval = 3, then `$x` will be 0, 3, 6, and 9.
21+
In molecular dynamics (MD) calculations, if [out_app_flag](../input_files/input-main.md#out_app_flag) is set to true, then `data-rR-tr` is written in an append manner. Otherwise, output files will be put in a separate directory, `matrix`, and named as `$x`_data-rR-tr, where `$x` is the number of MD step. In addition, the output frequency is controlled by [out_interval](../input_files/input-main.md#out_interval). For example, if we are running a 10-step MD with out_interval = 3, then `$x` will be 0, 3, 6, and 9.
22+
23+
## get_S
24+
We also offer the option of only calculating the position matrix without running SCF. For that purpose, in `INPUT` file we need to set the keyword [calculation](../input_files/input-main.md#calculation) to `get_S`, and [out_mat_r](../input_files/input-main.md#out_mat_r) to `true`.

docs/advanced/input_files/input-main.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,7 @@ These variables are used to control the output of properties.
17201720

17211721
- **Type**: Boolean
17221722
- **Availability**: Numerical atomic orbital basis (not gamma-only algorithm)
1723-
- **Description**: Whether to print the matrix representation of the position matrix (in Bohr) into a file named `data-rR-tr` in the directory `OUT.${suffix}`. For more information, please refer to [position_matrix.md](../elec_properties/position_matrix.md#extracting-position-matrices).
1723+
- **Description**: Whether to print the matrix representation of the position matrix (in Bohr) into a file named `data-rR-tr` in the directory `OUT.${suffix}`. If [calculation](#calculation) is set to `get_S`, the position matrix can be obtained without scf iterations. For more information, please refer to [position_matrix.md](../elec_properties/position_matrix.md#extracting-position-matrices).
17241724
- **Default**: False
17251725

17261726
### out_mat_hs2

source/Makefile.Objects

-1
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ OBJS_SURCHEM=surchem.o\
438438
cal_totn.o\
439439
cal_vcav.o\
440440
cal_vel.o\
441-
corrected_energy.o\
442441
minimize_cg.o\
443442
sol_force.o\
444443

source/driver.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ Driver::Driver()
1919

2020
Driver::~Driver()
2121
{
22-
// Release the device memory within singleton object GlobalC::ppcell
23-
// before the main function exits.
24-
GlobalC::ppcell.release_memory();
2522
}
2623

2724
void Driver::init()

source/module_cell/cell_index.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* the maximum L of a given atom, the number of chi of a given atom and a given L, the atom label of a given atom,
1313
* etc. The class provides the interface to get the information of the atoms and orbitals indices in the unit cell. It
1414
* also provides the interface to write the orbital information into a file. It is now used only in the Output_Mulliken
15-
* class. However, it is supposed to be able to replace GlobalC::ucell in LCAO codes where only cell indices are needed.
15+
* class. However, it is supposed to be able to replace ucell in LCAO codes where only cell indices are needed.
1616
* Take care that the three key vectors atomCounts, lnchiCounts, and atomLabels should be set from the UnitCell class.
1717
* It depends on nspin because the functions get_nw() and get_iwt() are related to nspin, and can
1818
* be used in the LCAO Hamiltonian construction.

source/module_cell/klist.cpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ int K_Vectors::get_ik_global(const int& ik, const int& nkstot)
5959
}
6060
}
6161

62-
void K_Vectors::set(const ModuleSymmetry::Symmetry& symm,
62+
void K_Vectors::set(const UnitCell& ucell,
63+
const ModuleSymmetry::Symmetry& symm,
6364
const std::string& k_file_name,
6465
const int& nspin_in,
6566
const ModuleBase::Matrix3& reciprocal_vec,
@@ -93,7 +94,7 @@ void K_Vectors::set(const ModuleSymmetry::Symmetry& symm,
9394
this->nspin = (this->nspin == 4) ? 1 : this->nspin;
9495

9596
// read KPT file and generate K-point grid
96-
bool read_succesfully = this->read_kpoints(k_file_name);
97+
bool read_succesfully = this->read_kpoints(ucell,k_file_name);
9798
#ifdef __MPI
9899
Parallel_Common::bcast_bool(read_succesfully);
99100
#endif
@@ -113,7 +114,7 @@ void K_Vectors::set(const ModuleSymmetry::Symmetry& symm,
113114
{
114115
bool match = true;
115116
// calculate kpoints in IBZ and reduce kpoints according to symmetry
116-
this->ibz_kpoint(symm, ModuleSymmetry::Symmetry::symm_flag, skpt1, GlobalC::ucell, match);
117+
this->ibz_kpoint(symm, ModuleSymmetry::Symmetry::symm_flag, skpt1, ucell, match);
117118
#ifdef __MPI
118119
Parallel_Common::bcast_bool(match);
119120
#endif
@@ -128,7 +129,7 @@ void K_Vectors::set(const ModuleSymmetry::Symmetry& symm,
128129
std::cout << "Automatically set symmetry to 0 and continue ..." << std::endl;
129130
ModuleSymmetry::Symmetry::symm_flag = 0;
130131
match = true;
131-
this->ibz_kpoint(symm, ModuleSymmetry::Symmetry::symm_flag, skpt1, GlobalC::ucell, match);
132+
this->ibz_kpoint(symm, ModuleSymmetry::Symmetry::symm_flag, skpt1, ucell, match);
132133
} else {
133134
ModuleBase::WARNING_QUIT("K_Vectors::ibz_kpoint",
134135
"Possible solutions: \n \
@@ -209,7 +210,8 @@ void K_Vectors::renew(const int& kpoint_number)
209210

210211
// Read the KPT file, which contains K-point coordinates, weights, and grid size information
211212
// Generate K-point grid according to different parameters of the KPT file
212-
bool K_Vectors::read_kpoints(const std::string& fn)
213+
bool K_Vectors::read_kpoints(const UnitCell& ucell,
214+
const std::string& fn)
213215
{
214216
ModuleBase::TITLE("K_Vectors", "read_kpoints");
215217
if (GlobalV::MY_RANK != 0)
@@ -236,16 +238,16 @@ bool K_Vectors::read_kpoints(const std::string& fn)
236238
ModuleBase::WARNING_QUIT("K_Vectors", "kspacing should > 0");
237239
};
238240
// number of K points = max(1,int(|bi|/KSPACING+1))
239-
ModuleBase::Matrix3 btmp = GlobalC::ucell.G;
241+
ModuleBase::Matrix3 btmp = ucell.G;
240242
double b1 = sqrt(btmp.e11 * btmp.e11 + btmp.e12 * btmp.e12 + btmp.e13 * btmp.e13);
241243
double b2 = sqrt(btmp.e21 * btmp.e21 + btmp.e22 * btmp.e22 + btmp.e23 * btmp.e23);
242244
double b3 = sqrt(btmp.e31 * btmp.e31 + btmp.e32 * btmp.e32 + btmp.e33 * btmp.e33);
243245
int nk1
244-
= std::max(1, static_cast<int>(b1 * ModuleBase::TWO_PI / PARAM.inp.kspacing[0] / GlobalC::ucell.lat0 + 1));
246+
= std::max(1, static_cast<int>(b1 * ModuleBase::TWO_PI / PARAM.inp.kspacing[0] / ucell.lat0 + 1));
245247
int nk2
246-
= std::max(1, static_cast<int>(b2 * ModuleBase::TWO_PI / PARAM.inp.kspacing[1] / GlobalC::ucell.lat0 + 1));
248+
= std::max(1, static_cast<int>(b2 * ModuleBase::TWO_PI / PARAM.inp.kspacing[1] / ucell.lat0 + 1));
247249
int nk3
248-
= std::max(1, static_cast<int>(b3 * ModuleBase::TWO_PI / PARAM.inp.kspacing[2] / GlobalC::ucell.lat0 + 1));
250+
= std::max(1, static_cast<int>(b3 * ModuleBase::TWO_PI / PARAM.inp.kspacing[2] / ucell.lat0 + 1));
249251

250252
GlobalV::ofs_warning << " Generate k-points file according to KSPACING: " << fn << std::endl;
251253
std::ofstream ofs(fn.c_str());

source/module_cell/klist.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ class K_Vectors
5050
* it will output a warning and suggest possible solutions.
5151
* @note Only available for nspin = 1 or 2 or 4.
5252
*/
53-
void set(const ModuleSymmetry::Symmetry& symm,
53+
void set(const UnitCell& ucell,
54+
const ModuleSymmetry::Symmetry& symm,
5455
const std::string& k_file_name,
5556
const int& nspin,
5657
const ModuleBase::Matrix3& reciprocal_vec,
@@ -204,7 +205,8 @@ class K_Vectors
204205
* @note If the k-points type is Line mode and the symmetry flag is 1, it will quit with a warning.
205206
* @note If the number of k-points is greater than 100000, it will quit with a warning.
206207
*/
207-
bool read_kpoints(const std::string& fn); // return 0: something wrong.
208+
bool read_kpoints(const UnitCell& ucell,
209+
const std::string& fn); // return 0: something wrong.
208210

209211
/**
210212
* @brief Adds k-points linearly between special points.

0 commit comments

Comments
 (0)