Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions source/module_hamilt_lcao/hamilt_lcaodft/LCAO_gen_fixedH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void LCAO_gen_fixedH::build_ST_new(const char& dtype, const bool& calc_deri, con
// according to global2local_row and global2local_col
// the last paramete: 1 for Sloc, 2 for Hloc
// and 3 for Hloc_fixed.
this->LM->set_HSgamma(iw1_all, iw2_all, olm[0], dtype, HSloc);
this->LM->set_HSgamma(iw1_all, iw2_all, olm[0], HSloc);
}
else // k point algorithm
{
Expand Down Expand Up @@ -642,7 +642,7 @@ void LCAO_gen_fixedH::build_Nonlocal_mu_new(double* NLloc, const bool &calc_deri
// mohan add 2010-12-20
if( nlm_tmp!=0.0 )
{
this->LM->set_HSgamma(iw1_all,iw2_all,nlm_tmp,'N', NLloc);//N stands for nonlocal.
this->LM->set_HSgamma(iw1_all, iw2_all, nlm_tmp, NLloc);//N stands for nonlocal.
}
}
else
Expand Down
3 changes: 1 addition & 2 deletions source/module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ void LCAO_Matrix::allocate_HS_R(const int &nnR)
void LCAO_Matrix::set_HSgamma(
const int &iw1_all, // index i for atomic orbital (row)
const int &iw2_all, // index j for atomic orbital (column)
const double &v, // value for matrix element (i,j)
const char &dtype, // type of the matrix
const double& v, // value for matrix element (i,j)
double* HSloc) //input pointer for store the matrix
{
// use iw1_all and iw2_all to set Hloc
Expand Down
2 changes: 1 addition & 1 deletion source/module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class LCAO_Matrix
double* DHloc_fixed_33;


void set_HSgamma(const int &iw1_all, const int &iw2_all, const double &v, const char &dtype, double* HSloc);
void set_HSgamma(const int& iw1_all, const int& iw2_all, const double& v, double* HSloc);
void set_HSk(const int &iw1_all, const int &iw2_all, const std::complex<double> &v, const char &dtype, const int spin = 0);

void set_force (const int& iw1_all, const int& iw2_all, const double& vx, const double& vy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ void Veff<OperatorLCAO<double>>::contributeHk(int ik)

if(XC_Functional::get_func_type()==3 || XC_Functional::get_func_type()==5)
{
Gint_inout inout(vr_eff1, vofk_eff1, this->LM, Gint_Tools::job_type::vlocal_meta);
this->GG->cal_vlocal(&inout, new_e_iteration);
Gint_inout inout(vr_eff1, vofk_eff1, Gint_Tools::job_type::vlocal_meta);
this->GG->cal_vlocal(&inout, this->LM, new_e_iteration);
}
else
{
Gint_inout inout(vr_eff1, this->LM, Gint_Tools::job_type::vlocal);
this->GG->cal_vlocal(&inout, new_e_iteration);
Gint_inout inout(vr_eff1, Gint_Tools::job_type::vlocal);
this->GG->cal_vlocal(&inout, this->LM, new_e_iteration);
}

this->new_e_iteration = false;
Expand Down
20 changes: 13 additions & 7 deletions source/module_hamilt_lcao/module_gint/gint_gamma.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Gint_Gamma : public Gint
// there is an additional step in calculating vlocal for gamma point
// namely the redistribution of Hamiltonian from grid to 2D block format
// hence we have an additional layer outside the unified interface
void cal_vlocal(Gint_inout *inout, const bool new_e_iteration);
void cal_vlocal(Gint_inout* inout, LCAO_Matrix* lm, const bool new_e_iteration);

//------------------------------------------------------
// in gint_gamma_env.cpp
Expand All @@ -45,12 +45,18 @@ class Gint_Gamma : public Gint

double*** DM; //pointer to LOC.DM

//------------------------------------------------------
// in gint_gamma_vl.cpp
//------------------------------------------------------
// method for redistributing the Hamiltonian
// from grid to 2D format
void vl_grid_to_2D(const int lgd, LCAO_Matrix& lm, const bool new_e_iteration);
///------------------------------------------------------
/// in gint_gamma_vl.cpp
///------------------------------------------------------
/// method for redistributing the Hamiltonian
/// from grid to 2D format
/// pass a setter function to customize row/col major and outputs
void vl_grid_to_2D(const double* vl_grid,
const Parallel_2D& p2d,
const int loc_grid_dim,
const bool new_e_iteration,
double* vl_2d,
std::function<void(const int&, const int&, const double&, double*)> setfunc);

///===============================
/// Use MPI_Alltoallv to convert a grid distributed matrix
Expand Down
25 changes: 13 additions & 12 deletions source/module_hamilt_lcao/module_gint/gint_gamma_vl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern "C"
void Cblacs_pcoord(int icontxt, int pnum, int *prow, int *pcol);
}

void Gint_Gamma::cal_vlocal(Gint_inout *inout, const bool new_e_iteration)
void Gint_Gamma::cal_vlocal(Gint_inout* inout, LCAO_Matrix* lm, bool new_e_iteration)
{
const int max_size = this->gridt->max_atom;
const int lgd = this->gridt->lgd;
Expand All @@ -40,10 +40,10 @@ void Gint_Gamma::cal_vlocal(Gint_inout *inout, const bool new_e_iteration)
}

this->cal_gint(inout);
this->vl_grid_to_2D(pvpR_grid, *lm->ParaV, lgd, new_e_iteration, lm->Hloc.data(),
std::bind(&LCAO_Matrix::set_HSgamma, lm, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));

this->vl_grid_to_2D(lgd,inout->lm[0], new_e_iteration);

if (max_size >0 && lgd > 0) delete[] pvpR_grid;
if (max_size > 0 && lgd > 0) delete[] pvpR_grid;
}
}

Expand Down Expand Up @@ -192,7 +192,8 @@ inline int setBufferParameter(
}
#endif

void Gint_Gamma::vl_grid_to_2D(const int lgd_now, LCAO_Matrix &lm, const bool new_e_iteration)
void Gint_Gamma::vl_grid_to_2D(const double* vl_grid, const Parallel_2D& p2d, const int loc_grid_dim, const bool new_e_iteration, double* vl_2d,
std::function<void(const int&, const int&, const double&, double*)> setfunc)
{
ModuleBase::timer::tick("Gint_Gamma","distri_vl");
// setup send buffer and receive buffer size
Expand All @@ -201,7 +202,7 @@ void Gint_Gamma::vl_grid_to_2D(const int lgd_now, LCAO_Matrix &lm, const bool ne
{
ModuleBase::timer::tick("Gint_Gamma","distri_vl_index");
#ifdef __MPI
setBufferParameter(*this->gridt, lm.ParaV->comm_2D, lm.ParaV->blacs_ctxt, lm.ParaV->nb,
setBufferParameter(*this->gridt, p2d.comm_2D, p2d.blacs_ctxt, p2d.nb,
this->sender_index_size, this->sender_local_index,
this->sender_size_process, this->sender_displacement_process,
this->sender_size, this->sender_buffer,
Expand All @@ -226,11 +227,11 @@ void Gint_Gamma::vl_grid_to_2D(const int lgd_now, LCAO_Matrix &lm, const bool ne
const int icol=this->sender_local_index[i+1];
if(irow<=icol)
{
this->sender_buffer[i/2]=pvpR_grid[irow*lgd_now+icol];
this->sender_buffer[i / 2] = vl_grid[irow * loc_grid_dim + icol];
}
else
{
this->sender_buffer[i/2]=pvpR_grid[icol*lgd_now+irow];
this->sender_buffer[i / 2] = vl_grid[icol * loc_grid_dim + irow];
}
}

Expand All @@ -242,7 +243,7 @@ void Gint_Gamma::vl_grid_to_2D(const int lgd_now, LCAO_Matrix &lm, const bool ne
#ifdef __MPI
MPI_Alltoallv(this->sender_buffer, this->sender_size_process, this->sender_displacement_process, MPI_DOUBLE,
this->receiver_buffer, this->receiver_size_process,
this->receiver_displacement_process, MPI_DOUBLE, lm.ParaV->comm_2D);
this->receiver_displacement_process, MPI_DOUBLE, p2d.comm_2D);
#endif

#ifdef __DEBUG
Expand All @@ -252,9 +253,9 @@ void Gint_Gamma::vl_grid_to_2D(const int lgd_now, LCAO_Matrix &lm, const bool ne
// put local data to H matrix
for(int i=0; i<this->receiver_index_size; i+=2)
{
const int g_row=this->receiver_global_index[i];
const int g_col=this->receiver_global_index[i+1];
lm.set_HSgamma(g_row,g_col,this->receiver_buffer[i/2],'L', lm.Hloc.data());
const int g_row = this->receiver_global_index[i];
const int g_col = this->receiver_global_index[i + 1];
setfunc(g_row, g_col, this->receiver_buffer[i / 2], vl_2d);
}

ModuleBase::timer::tick("Gint_Gamma","distri_vl_value");
Expand Down
10 changes: 3 additions & 7 deletions source/module_hamilt_lcao/module_gint/gint_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "grid_technique.h"
#include <cstdlib>
#include "module_elecstate/module_charge/charge.h"
#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.h"

namespace Gint_Tools
{
Expand All @@ -28,7 +27,6 @@ class Gint_inout
bool isforce;
bool isstress;
int ispin;
LCAO_Matrix *lm;

//output
double** rho;
Expand Down Expand Up @@ -129,19 +127,17 @@ class Gint_inout
}

// vlocal, gamma point
Gint_inout(const double* vl_in, LCAO_Matrix *lm_in, Gint_Tools::job_type job_in)
Gint_inout(const double* vl_in, Gint_Tools::job_type job_in)
{
vl = vl_in;
lm = lm_in;
job = job_in;
}

// mGGA vlocal, gamma point
Gint_inout(const double* vl_in, const double* vofk_in, LCAO_Matrix *lm_in, Gint_Tools::job_type job_in)
Gint_inout(const double* vl_in, const double* vofk_in, Gint_Tools::job_type job_in)
{
vl = vl_in;
vofk = vofk_in;
lm = lm_in;
vofk = vofk_in;
job = job_in;
}
};
Expand Down
2 changes: 1 addition & 1 deletion source/module_ri/RI_2D_Comm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void RI_2D_Comm::add_Hexx(
if(GlobalV::GAMMA_ONLY_LOCAL)
lm.set_HSgamma(iwt0, iwt1,
RI::Global_Func::convert<double>(H(iw0_b, iw1_b)) * RI::Global_Func::convert<double>(frac),
'L', lm.Hloc.data());
lm.Hloc.data());
else
lm.set_HSk(iwt0, iwt1,
RI::Global_Func::convert<std::complex<double>>(H(iw0_b, iw1_b)) * frac,
Expand Down