Skip to content

Commit

Permalink
Merge branch 'develop' into remove-hsolver-diagh
Browse files Browse the repository at this point in the history
  • Loading branch information
Cstandardlib authored Oct 22, 2024
2 parents ac9ee57 + efb83c8 commit 0effc77
Show file tree
Hide file tree
Showing 25 changed files with 48 additions and 143 deletions.
8 changes: 4 additions & 4 deletions docs/advanced/input_files/kpt.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ABACUS uses periodic boundary conditions for both crystals and finite systems. F

## Gamma-only Calculations

In ABACUS, we offer th option of running gamma-only calculations for LCAO basis by setting [gamma_only](./input-main.md#gamma_only) to be 1. Due to details of implementation, gamma-only calculation will be slightly faster than running a non gamma-only calculation and explicitly setting gamma point to be the only the k-point, but the results should be consistent.
In ABACUS, we offer the option of running gamma-only calculations for LCAO basis by setting [gamma_only](./input-main.md#gamma_only) to be 1. Due to details of implementation, gamma-only calculation will be slightly faster than running a non gamma-only calculation and explicitly setting gamma point to be the only the k-point, but the results should be consistent.

> If gamma_only is set to 1, the KPT file will be overwritten. So make sure to turn off gamma_only for multi-k calculations.
Expand All @@ -23,7 +23,7 @@ method to generate k-mesh, and the following is an example input k-point (`KPT`)
K_POINTS //keyword for start
0 //total number of k-point, `0' means generate automatically
Gamma //which kind of Monkhorst-Pack method, `Gamma' or `MP'
2 2 2 0 0 0 //first three number: subdivisions along recpri. vectors
2 2 2 0 0 0 //first three number: subdivisions along reciprocal vectors
//last three number: shift of the mesh
```

Expand Down Expand Up @@ -63,8 +63,8 @@ Direct //`Direct' or `Cartesian' coordinate
## Band structure calculations

ABACUS uses specified high-symmetry directions of the Brillouin zone for band structure
calculations. The third line of k-point file should start with Line or Line_Cartesian for
line mode. Line means the positions below are in Direct coordinates, while Line_Cartesian
calculations. The third line of k-point file should start with 'Line' or 'Line_Cartesian' for
line mode. 'Line' means the positions below are in Direct coordinates, while 'Line_Cartesian'
means in Cartesian coordinates:

```
Expand Down
1 change: 0 additions & 1 deletion source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ OBJS_IO=input_conv.o\
output.o\
print_info.o\
read_cube.o\
read_rho.o\
rhog_io.o\
read_exit_file.o\
read_wfc_pw.o\
Expand Down
62 changes: 29 additions & 33 deletions source/module_elecstate/module_charge/charge_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "module_elecstate/magnetism.h"
#include "module_hamilt_pw/hamilt_pwdft/global.h"
#include "module_hamilt_pw/hamilt_pwdft/parallel_grid.h"
#include "module_io/rho_io.h"
#include "module_io/cube_io.h"
#include "module_io/rhog_io.h"
#include "module_io/read_wfc_to_rho.h"
#ifdef USE_PAW
Expand Down Expand Up @@ -54,24 +54,22 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
std::stringstream ssc;
ssc << PARAM.globalv.global_readin_dir << "SPIN" << is + 1 << "_CHG.cube";
double& ef_tmp = eferm_iout.get_ef(is);
if (ModuleIO::read_rho(
if (ModuleIO::read_cube(
#ifdef __MPI
&(GlobalC::Pgrid),
& (GlobalC::Pgrid),
#endif
GlobalV::MY_RANK,
PARAM.inp.esolver_type,
GlobalV::RANK_IN_STOGROUP,
is,
GlobalV::ofs_running,
PARAM.inp.nspin,
ssc.str(),
this->rho[is],
this->rhopw->nx,
this->rhopw->ny,
this->rhopw->nz,
ef_tmp,
&(GlobalC::ucell),
this->prenspin))
(PARAM.inp.esolver_type == "sdft" ? GlobalV::RANK_IN_STOGROUP : GlobalV::MY_RANK),
is,
GlobalV::ofs_running,
PARAM.inp.nspin,
ssc.str(),
this->rho[is],
this->rhopw->nx,
this->rhopw->ny,
this->rhopw->nz,
ef_tmp,
& (GlobalC::ucell),
this->prenspin))
{
GlobalV::ofs_running << " Read in the charge density: " << ssc.str() << std::endl;
}
Expand Down Expand Up @@ -129,24 +127,22 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
GlobalV::ofs_running << " try to read kinetic energy density from file : " << ssc.str()
<< std::endl;
// mohan update 2012-02-10, sunliang update 2023-03-09
if (ModuleIO::read_rho(
if (ModuleIO::read_cube(
#ifdef __MPI
&(GlobalC::Pgrid),
& (GlobalC::Pgrid),
#endif
GlobalV::MY_RANK,
PARAM.inp.esolver_type,
GlobalV::RANK_IN_STOGROUP,
is,
GlobalV::ofs_running,
PARAM.inp.nspin,
ssc.str(),
this->kin_r[is],
this->rhopw->nx,
this->rhopw->ny,
this->rhopw->nz,
eferm_iout.ef,
&(GlobalC::ucell),
this->prenspin))
(PARAM.inp.esolver_type == "sdft" ? GlobalV::RANK_IN_STOGROUP : GlobalV::MY_RANK),
is,
GlobalV::ofs_running,
PARAM.inp.nspin,
ssc.str(),
this->kin_r[is],
this->rhopw->nx,
this->rhopw->ny,
this->rhopw->nz,
eferm_iout.ef,
& (GlobalC::ucell),
this->prenspin))
{
GlobalV::ofs_running << " Read in the kinetic energy density: " << ssc.str() << std::endl;
}
Expand Down
1 change: 0 additions & 1 deletion source/module_esolver/cal_edm_tddft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "module_io/cal_r_overlap_R.h"
#include "module_io/dipole_io.h"
#include "module_io/rho_io.h"
#include "module_io/td_current_io.h"
#include "module_io/write_HS.h"
#include "module_io/write_HS_R.h"
Expand Down
1 change: 0 additions & 1 deletion source/module_esolver/esolver_ks_lcao_tddft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "module_io/cal_r_overlap_R.h"
#include "module_io/dipole_io.h"
#include "module_io/rho_io.h"
#include "module_io/td_current_io.h"
#include "module_io/write_HS.h"
#include "module_io/write_HS_R.h"
Expand Down
1 change: 0 additions & 1 deletion source/module_esolver/esolver_ks_lcaopw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "module_io/berryphase.h"
#include "module_io/numerical_basis.h"
#include "module_io/numerical_descriptor.h"
#include "module_io/rho_io.h"
#include "module_io/to_wannier90_pw.h"
#include "module_io/winput.h"
#include "module_io/write_elecstat_pot.h"
Expand Down
1 change: 0 additions & 1 deletion source/module_esolver/lcao_gets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "module_hamilt_lcao/hamilt_lcaodft/operator_lcao/operator_lcao.h"
#include "module_hamilt_lcao/module_deltaspin/spin_constrain.h"
#include "module_io/read_wfc_nao.h"
#include "module_io/rho_io.h"
#include "module_io/write_elecstat_pot.h"
#include "module_io/write_wfc_nao.h"
#ifdef __EXX
Expand Down
1 change: 0 additions & 1 deletion source/module_esolver/lcao_nscf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "module_hamilt_lcao/hamilt_lcaodft/operator_lcao/operator_lcao.h"
#include "module_hamilt_lcao/module_deltaspin/spin_constrain.h"
#include "module_io/read_wfc_nao.h"
#include "module_io/rho_io.h"
#include "module_io/write_elecstat_pot.h"
#include "module_io/write_wfc_nao.h"
#ifdef __EXX
Expand Down
1 change: 0 additions & 1 deletion source/module_esolver/lcao_others.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "module_hamilt_lcao/hamilt_lcaodft/operator_lcao/operator_lcao.h"
#include "module_hamilt_lcao/module_deltaspin/spin_constrain.h"
#include "module_io/read_wfc_nao.h"
#include "module_io/rho_io.h"
#include "module_io/write_elecstat_pot.h"
#include "module_io/write_wfc_nao.h"
#ifdef __EXX
Expand Down
1 change: 0 additions & 1 deletion source/module_esolver/pw_fun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "module_io/berryphase.h"
#include "module_io/numerical_basis.h"
#include "module_io/numerical_descriptor.h"
#include "module_io/rho_io.h"
#include "module_io/to_wannier90_pw.h"
#include "module_io/winput.h"
#include "module_io/write_elecstat_pot.h"
Expand Down
1 change: 0 additions & 1 deletion source/module_esolver/pw_init_after_vc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "module_io/berryphase.h"
#include "module_io/numerical_basis.h"
#include "module_io/numerical_descriptor.h"
#include "module_io/rho_io.h"
#include "module_io/to_wannier90_pw.h"
#include "module_io/winput.h"
#include "module_io/write_elecstat_pot.h"
Expand Down
1 change: 0 additions & 1 deletion source/module_esolver/pw_init_globalc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "module_io/berryphase.h"
#include "module_io/numerical_basis.h"
#include "module_io/numerical_descriptor.h"
#include "module_io/rho_io.h"
#include "module_io/to_wannier90_pw.h"
#include "module_io/winput.h"
#include "module_io/write_elecstat_pot.h"
Expand Down
1 change: 0 additions & 1 deletion source/module_esolver/pw_nscf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "module_io/berryphase.h"
#include "module_io/numerical_basis.h"
#include "module_io/numerical_descriptor.h"
#include "module_io/rho_io.h"
#include "module_io/to_wannier90_pw.h"
#include "module_io/winput.h"
#include "module_io/write_elecstat_pot.h"
Expand Down
1 change: 0 additions & 1 deletion source/module_esolver/pw_others.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "module_io/berryphase.h"
#include "module_io/numerical_basis.h"
#include "module_io/numerical_descriptor.h"
#include "module_io/rho_io.h"
#include "module_io/to_wannier90_pw.h"
#include "module_io/winput.h"
#include "module_io/write_elecstat_pot.h"
Expand Down
1 change: 0 additions & 1 deletion source/module_esolver/set_matrix_grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "module_hamilt_lcao/hamilt_lcaodft/operator_lcao/operator_lcao.h"
#include "module_hamilt_pw/hamilt_pwdft/global.h"
#include "module_io/read_wfc_nao.h"
#include "module_io/rho_io.h"
#include "module_io/write_elecstat_pot.h"
#include "module_io/write_wfc_nao.h"
#include "module_parameter/parameter.h"
Expand Down
7 changes: 4 additions & 3 deletions source/module_hamilt_lcao/module_gint/gint_vl_gpu.cu
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ void gint_vl_gpu(hamilt::HContainer<double>* hRGint,
checkCuda(cudaStreamCreate(&streams[i]));
}

Cuda_Mem_Wrapper<double> grid_vlocal_g(hRGint->get_nnr(), 1, false);
const int nnrg = is_gamma_only ? hRGint->get_nnr() : gridt.nnrg;
Cuda_Mem_Wrapper<double> grid_vlocal_g(nnrg, 1, false);
grid_vlocal_g.memset_device_sync();

Cuda_Mem_Wrapper<double> dr_part(max_atom_per_z * 3, num_streams, true);
Expand Down Expand Up @@ -189,15 +190,15 @@ void gint_vl_gpu(hamilt::HContainer<double>* hRGint,
checkCuda(cudaMemcpy(
hRGint->get_wrapper(),
grid_vlocal_g.get_device_pointer(),
hRGint->get_nnr() * sizeof(double),
nnrg * sizeof(double),
cudaMemcpyDeviceToHost));
}
else
{
checkCuda(cudaMemcpy(
pvpR,
grid_vlocal_g.get_device_pointer(),
hRGint->get_nnr() * sizeof(double),
nnrg * sizeof(double),
cudaMemcpyDeviceToHost));
}
for (int i = 0; i < num_streams; i++)
Expand Down
4 changes: 4 additions & 0 deletions source/module_hsolver/diago_elpa_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ void DiagoElpaNative<T>::diag_pool(hamilt::MatrixBlock<T>& h_mat,
// elpa_init(20210430);
int success;
elpa_t handle = elpa_allocate(&success);
#ifdef _OPENMP
int num_threads = omp_get_max_threads();
#else
int num_threads = 1;
#endif
elpa_set(handle, "omp_threads", num_threads, &success);
elpa_set(handle, "na", (int)nFull, &success);
elpa_set(handle, "nev", (int)nev, &success);
Expand Down
1 change: 0 additions & 1 deletion source/module_io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ list(APPEND objects
output.cpp
print_info.cpp
read_cube.cpp
read_rho.cpp
rhog_io.cpp
read_exit_file.cpp
read_wfc_pw.cpp
Expand Down
2 changes: 0 additions & 2 deletions source/module_io/cube_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ bool read_cube(
const Parallel_Grid*const Pgrid,
#endif
const int my_rank,
const std::string esolver_type,
const int rank_in_stogroup,
const int is,
std::ofstream& ofs_running,
const int nspin,
Expand Down
7 changes: 2 additions & 5 deletions source/module_io/read_cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ bool ModuleIO::read_cube(
const Parallel_Grid*const Pgrid,
#endif
const int my_rank,
const std::string esolver_type,
const int rank_in_stogroup,
const int is,
std::ofstream& ofs_running,
const int nspin,
Expand Down Expand Up @@ -112,12 +110,11 @@ bool ModuleIO::read_cube(
}
}

const bool flag_read_rank = (my_rank == 0 || (esolver_type == "sdft" && rank_in_stogroup == 0));
#ifdef __MPI
if(nx == nx_read && ny == ny_read && nz == nz_read)
ModuleIO::read_cube_core_match(ifs, Pgrid, flag_read_rank, data, nx*ny, nz);
ModuleIO::read_cube_core_match(ifs, Pgrid, (my_rank == 0), data, nx * ny, nz);
else
ModuleIO::read_cube_core_mismatch(ifs, Pgrid, flag_read_rank, data, nx, ny, nz, nx_read, ny_read, nz_read);
ModuleIO::read_cube_core_mismatch(ifs, Pgrid, (my_rank == 0), data, nx, ny, nz, nx_read, ny_read, nz_read);
#else
ofs_running << " Read SPIN = " << is + 1 << " charge now." << std::endl;
if(nx == nx_read && ny == ny_read && nz == nz_read)
Expand Down
42 changes: 0 additions & 42 deletions source/module_io/read_rho.cpp

This file was deleted.

31 changes: 0 additions & 31 deletions source/module_io/rho_io.h

This file was deleted.

2 changes: 1 addition & 1 deletion source/module_io/test_serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ AddTest(
AddTest(
TARGET io_rho_io
LIBS parameter ${math_libs} base device cell_info
SOURCES rho_io_test.cpp ../read_cube.cpp ../write_cube.cpp ../read_rho.cpp ../output.cpp
SOURCES rho_io_test.cpp ../read_cube.cpp ../write_cube.cpp ../output.cpp
)

AddTest(
Expand Down
Loading

0 comments on commit 0effc77

Please sign in to comment.