Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
697b359
Merge develop branch to TDDFT branch (#2249)
lyb9812 Apr 17, 2023
6ad3493
New propagator for better Convergence (#2253)
ESROAMER Apr 19, 2023
ea9f4fd
Update dipole.py (#2270)
Satinelamp Apr 21, 2023
2199171
Simplify matrix multiplication and add new propagator method (#2272)
lyb9812 Apr 23, 2023
2899d3d
solve conflicts
lyb9812 Apr 29, 2023
2676e97
delete td_htype and update ref of tddft autotests
lyb9812 Apr 29, 2023
952088e
delete td_htype
lyb9812 Apr 29, 2023
8a1adeb
Merge branch 'develop' of https://github.com/deepmodeling/abacus-deve…
lyb9812 May 5, 2023
4ac0f2b
refactor tddft code
lyb9812 May 10, 2023
f1f9204
move read_paramter of electric field to input_conv.cpp for tddft
lyb9812 May 10, 2023
c72bf06
solve conflicts
lyb9812 May 11, 2023
2d4e343
sve conflicts
lyb9812 May 11, 2023
3c9a477
move definition of tag
lyb9812 May 11, 2023
b93d3bc
convert read_parameter
lyb9812 May 11, 2023
345b215
add namespace module_tddft
lyb9812 May 11, 2023
aa8341c
remove tmp file
lyb9812 May 11, 2023
d8c51cf
Merge branch 'develop' of https://github.com/deepmodeling/abacus-deve…
lyb9812 May 11, 2023
344dca6
Merge branch 'develop' into refactor_tddft
Qianruipku May 12, 2023
cb78184
Merge branch 'develop' of https://github.com/deepmodeling/abacus-deve…
lyb9812 May 15, 2023
fca26fa
move read_paramters of electric field in tddft to input_conv.cpp
lyb9812 May 15, 2023
7e2c1f1
add force of tddft efield
lyb9812 May 15, 2023
db18fee
add annotations
lyb9812 May 15, 2023
2a7f5e6
Merge remote-tracking branch 'deepmodeling/develop' into refactor_tddft
lyb9812 May 15, 2023
2125f1e
Merge branch 'develop' into refactor_tddft
lyb9812 May 15, 2023
3d61fe9
move read_parameters from H_TDDFT_pw.cpp to input_conv.cpp
lyb9812 May 15, 2023
5325b49
add ifdef __LCAO
lyb9812 May 15, 2023
090ad00
remove input parameter of read_td_efield
lyb9812 May 15, 2023
328ea91
remove input parameter of read_td_efield
lyb9812 May 15, 2023
729a668
fix bug for input UTs
lyb9812 May 15, 2023
4a26b4f
Merge branch 'develop' of https://github.com/deepmodeling/abacus-deve…
lyb9812 May 15, 2023
1332d40
solve conflicts
lyb9812 May 16, 2023
f9ca299
change name of parameters of compute_force in H_TDDFT_pw.h
lyb9812 May 16, 2023
ee10c65
improve annotation
lyb9812 May 16, 2023
18dfa10
solve conflicts
lyb9812 May 16, 2023
08e8b48
solve conflicts
lyb9812 May 16, 2023
a40e106
add UT for read_td_efield
lyb9812 May 16, 2023
d5104b0
solve conflicts
lyb9812 May 16, 2023
8b3d637
add ifdef __LCAO
lyb9812 May 16, 2023
b2335c8
add ifdef __LCAO
lyb9812 May 16, 2023
d4a48aa
mistake for TEST and TEST_F
lyb9812 May 16, 2023
fa1b3d9
fix ReadTdEfieldTest
lyb9812 May 16, 2023
025f9f7
fix ReadTdEfieldTest
lyb9812 May 16, 2023
1e6563b
add doublenear() for EXPECT_EQ in ReadEfieldTest
lyb9812 May 16, 2023
73dd38e
add nampspace for doublenear
lyb9812 May 16, 2023
443e86f
add nampspace for doublenear
lyb9812 May 16, 2023
49af77d
mistake
lyb9812 May 16, 2023
cf1107b
replace doublenear with EXPECT_NEAR
lyb9812 May 16, 2023
14264e0
TEST_F
lyb9812 May 16, 2023
8098270
Merge branch 'develop' into refactor_tddft
Qianruipku May 17, 2023
b75098f
Merge branch 'develop' into refactor_tddft
Qianruipku May 17, 2023
90e7494
Merge branch 'develop' of https://github.com/deepmodeling/abacus-deve…
lyb9812 May 17, 2023
39a7c11
Merge branch 'develop' of https://github.com/deepmodeling/abacus-deve…
lyb9812 May 17, 2023
4916d43
Merge branch 'refactor_tddft' of https://github.com/lyb9812/abacus-de…
lyb9812 May 17, 2023
ab573e6
delete nband in propagator
lyb9812 May 17, 2023
075f0f7
add UT for module tddft
lyb9812 Jun 1, 2023
0cfa9b0
solve conflicts
lyb9812 Jun 1, 2023
f371f4c
comment add_test
lyb9812 Jun 1, 2023
4c1b31b
fix bug of prepare() in H_TDDFT_pw.cpp
lyb9812 Jun 1, 2023
ca80668
split tddft_test
lyb9812 Jun 2, 2023
ba24351
Merge branch 'develop' of https://github.com/deepmodeling/abacus-deve…
lyb9812 Jun 2, 2023
7847219
fix bug
lyb9812 Jun 2, 2023
0f5fa28
fix bug of UT for tddft
lyb9812 Jun 5, 2023
270c57d
Merge branch 'develop' of https://github.com/deepmodeling/abacus-deve…
lyb9812 Jun 5, 2023
abcbeb7
add tddft prefix
lyb9812 Jun 5, 2023
60eef9e
add UT for cblacs_gridinit
lyb9812 Jun 6, 2023
c84c9da
fix bug of UT for tddft
lyb9812 Jun 6, 2023
a1af752
Merge branch 'develop' of https://github.com/deepmodeling/abacus-deve…
lyb9812 Jun 6, 2023
7d0ca20
Merge branch 'develop' of https://github.com/deepmodeling/abacus-deve…
lyb9812 Jun 6, 2023
e7a11c4
fix bug of UT for tddft
lyb9812 Jun 6, 2023
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
5 changes: 3 additions & 2 deletions source/module_base/blacs_connector.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ extern "C"
void Cblacs_gridmap(int* icontxt, int *usermap, int ldumap, int nprow, int npcol);
// Informational and Miscellaneous
void Cblacs_gridinfo(int icontxt, int* nprow, int *npcol, int *myprow, int *mypcol);
int Cblacs_pnum(int icontxt, int prow, int pcol);
void Cblacs_pcoord(int icontxt, int pnum, int *prow, int *pcol);
void Cblacs_gridinit(int* icontxt, char* layout, int nprow, int npcol);
int Cblacs_pnum(int icontxt, int prow, int pcol);
void Cblacs_pcoord(int icontxt, int pnum, int *prow, int *pcol);
void Cblacs_exit(int icontxt);
}
5 changes: 5 additions & 0 deletions source/module_base/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ AddTest(
LIBS ${math_libs}
SOURCES blas_connector_test.cpp
)
AddTest(
TARGET base_blacs_connector
LIBS ${math_libs}
SOURCES blacs_connector_test.cpp
)
AddTest(
TARGET base_timer
SOURCES timer_test.cpp ../timer.cpp
Expand Down
53 changes: 53 additions & 0 deletions source/module_base/test/blacs_connector_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include "../blacs_connector.h"

#include <mpi.h>

#include "gtest/gtest.h"

/************************************************
* unit test of functions in blacs_connector.h
***********************************************/

/**
* - Tested Function
* - Cblacs_gridinit
* - Initializes a grid of processors with a given number of rows and columns.
* The function creates a cartesian topology of all the processors initialized
* by the BLS library. In this topology, each processor is identified by its
* coordinates (row, col) in the grid.
*/

TEST(blacs_connector, Cblacs_gridinit)
{
int icontxt;
char layout[] = "ROW";
int nprow = 1;
int npcol = 1;

int myid, nprocs;
Cblacs_pinfo(&myid, &nprocs);
Cblacs_get(-1, 0, &icontxt);

// Call the Cblacs_gridinit() function
Cblacs_gridinit(&icontxt, layout, nprow, npcol);

// Check if the grid context handle is created successfully
EXPECT_EQ(icontxt, 0);
}

int main(int argc, char** argv)
{
int myrank;
int mysize;

MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &mysize);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);

testing::InitGoogleTest(&argc, argv);

int result = 0;
result = RUN_ALL_TESTS();
MPI_Finalize();
return 0;
}
6 changes: 3 additions & 3 deletions source/module_elecstate/potentials/H_TDDFT_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,19 @@ double H_TDDFT_pw::cal_v_time_heaviside()

void H_TDDFT_pw::prepare(const UnitCell& cell, int& dir)
{
if (dir == 0)
if (dir == 1)
{
bvec[0] = cell.G.e11;
bvec[1] = cell.G.e12;
bvec[2] = cell.G.e13;
}
else if (dir == 1)
else if (dir == 2)
{
bvec[0] = cell.G.e21;
bvec[1] = cell.G.e22;
bvec[2] = cell.G.e23;
}
else if (dir == 2)
else if (dir == 3)
{
bvec[0] = cell.G.e31;
bvec[1] = cell.G.e32;
Expand Down
122 changes: 63 additions & 59 deletions source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,32 @@
double Force_Stress_LCAO::force_invalid_threshold_ev = 0.00;
double Force_Stress_LCAO::output_acc = 1.0e-8;

Force_Stress_LCAO::Force_Stress_LCAO(Record_adj& ra, const int nat_in) :
RA(&ra), f_pw(nat_in), nat(nat_in){}
Force_Stress_LCAO::~Force_Stress_LCAO() {}

void Force_Stress_LCAO::getForceStress(
const bool isforce,
const bool isstress,
const bool istestf,
const bool istests,
Local_Orbital_Charge& loc,
const elecstate::ElecState* pelec,
const psi::Psi<double>* psid,
const psi::Psi<std::complex<double>>* psi,
LCAO_Hamilt &uhm,
ModuleBase::matrix& fcs,
ModuleBase::matrix & scs,
const Structure_Factor& sf,
const K_Vectors& kv,
ModulePW::PW_Basis* rhopw,
Force_Stress_LCAO::Force_Stress_LCAO(Record_adj& ra, const int nat_in) : RA(&ra), f_pw(nat_in), nat(nat_in)
{
}
Force_Stress_LCAO::~Force_Stress_LCAO()
{
}

void Force_Stress_LCAO::getForceStress(const bool isforce,
const bool isstress,
const bool istestf,
const bool istests,
Local_Orbital_Charge& loc,
const elecstate::ElecState* pelec,
const psi::Psi<double>* psid,
const psi::Psi<std::complex<double>>* psi,
LCAO_Hamilt& uhm,
ModuleBase::matrix& fcs,
ModuleBase::matrix& scs,
const Structure_Factor& sf,
const K_Vectors& kv,
ModulePW::PW_Basis* rhopw,
#ifdef __EXX
Exx_LRI<double>& exx_lri_double,
Exx_LRI<std::complex<double>>& exx_lri_complex,
Exx_LRI<double>& exx_lri_double,
Exx_LRI<std::complex<double>>& exx_lri_complex,
#endif
ModuleSymmetry::Symmetry* symm)
ModuleSymmetry::Symmetry* symm)
{
ModuleBase::TITLE("Force_Stress_LCAO", "getForceStress");
ModuleBase::timer::tick("Force_Stress_LCAO", "getForceStress");
Expand Down Expand Up @@ -154,13 +156,13 @@ void Force_Stress_LCAO::getForceStress(
svl_dphi,
#endif
uhm,
kv);
//implement vdw force or stress here
// Peize Lin add 2014-04-04, update 2021-03-09
// jiyy add 2019-05-18, update 2021-05-02
ModuleBase::matrix force_vdw;
ModuleBase::matrix stress_vdw;
kv);
// implement vdw force or stress here
// Peize Lin add 2014-04-04, update 2021-03-09
// jiyy add 2019-05-18, update 2021-05-02
ModuleBase::matrix force_vdw;
ModuleBase::matrix stress_vdw;

auto vdw_solver = vdw::make_vdw(GlobalC::ucell, INPUT);
if (vdw_solver != nullptr)
{
Expand Down Expand Up @@ -219,13 +221,13 @@ void Force_Stress_LCAO::getForceStress(
if (isforce)
{
force_dftu.create(nat, 3);
}
if(isstress)
{
stress_dftu.create(3, 3);
}
GlobalC::dftu.force_stress(loc.dm_gamma, loc.dm_k, *uhm.LM, force_dftu, stress_dftu, kv);
}
}
if (isstress)
{
stress_dftu.create(3, 3);
}
GlobalC::dftu.force_stress(loc.dm_gamma, loc.dm_k, *uhm.LM, force_dftu, stress_dftu, kv);
}

if (!GlobalV::GAMMA_ONLY_LOCAL)
this->flk.finish_k();
Expand Down Expand Up @@ -366,35 +368,37 @@ void Force_Stress_LCAO::getForceStress(
GlobalC::ld.save_npy_f(fcs, "f_tot.npy", GlobalC::ucell.nat); // Ty/Bohr, F_tot
if (GlobalV::deepks_scf)
{
GlobalC::ld.save_npy_f(fcs - GlobalC::ld.F_delta, "f_base.npy", GlobalC::ucell.nat); //Ry/Bohr, F_base
GlobalC::ld.save_npy_f(fcs - GlobalC::ld.F_delta, "f_base.npy", GlobalC::ucell.nat); // Ry/Bohr, F_base

if(GlobalV::GAMMA_ONLY_LOCAL)
if (GlobalV::GAMMA_ONLY_LOCAL)
{
GlobalC::ld.cal_gdmx(loc.dm_gamma[0],
GlobalC::ucell,
GlobalC::ORB,
GlobalC::GridD,
pv->trace_loc_row,
pv->trace_loc_col,
isstress);
GlobalC::ucell,
GlobalC::ORB,
GlobalC::GridD,
pv->trace_loc_row,
pv->trace_loc_col,
isstress);
}
else
{
GlobalC::ld.cal_gdmx_k(loc.dm_k,
GlobalC::ucell,
GlobalC::ORB,
GlobalC::GridD,
pv->trace_loc_row,
pv->trace_loc_col,
kv.nks,
kv.kvec_d,
isstress);
{
GlobalC::ld.cal_gdmx_k(loc.dm_k,
GlobalC::ucell,
GlobalC::ORB,
GlobalC::GridD,
pv->trace_loc_row,
pv->trace_loc_col,
kv.nks,
kv.kvec_d,
isstress);
}
if(GlobalV::deepks_out_unittest) GlobalC::ld.check_gdmx(GlobalC::ucell.nat);
if (GlobalV::deepks_out_unittest)
GlobalC::ld.check_gdmx(GlobalC::ucell.nat);
GlobalC::ld.cal_gvx(GlobalC::ucell.nat);

if(GlobalV::deepks_out_unittest) GlobalC::ld.check_gvx(GlobalC::ucell.nat);
GlobalC::ld.save_npy_gvx(GlobalC::ucell.nat);// /Bohr, grad_vx
if (GlobalV::deepks_out_unittest)
GlobalC::ld.check_gvx(GlobalC::ucell.nat);
GlobalC::ld.save_npy_gvx(GlobalC::ucell.nat); // /Bohr, grad_vx
}
else
{
Expand Down Expand Up @@ -712,7 +716,7 @@ void Force_Stress_LCAO::calForceStressIntegralPart(const bool isGammaOnly,
#else
ModuleBase::matrix& svl_dphi,
#endif
LCAO_Hamilt &uhm,
LCAO_Hamilt& uhm,
const K_Vectors& kv)
{
if (isGammaOnly)
Expand Down Expand Up @@ -759,7 +763,7 @@ void Force_Stress_LCAO::calForceStressIntegralPart(const bool isGammaOnly,
svl_dphi,
#endif
uhm,
kv);
kv);
}
return;
}
Expand Down
4 changes: 4 additions & 0 deletions source/module_hamilt_lcao/module_tddft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ if(ENABLE_LCAO)
add_coverage(tddft)
endif()

IF (BUILD_TESTING)
add_subdirectory(test)
endif()

endif()
2 changes: 1 addition & 1 deletion source/module_hamilt_lcao/module_tddft/evolve_psi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void evolve_psi(const int nband,
/// @input Stmp, Htmp, print_matrix
/// @output U_operator
Propagator prop(propagator, pv);
prop.compute_propagator(nband, nlocal, Stmp, Htmp, H_laststep, U_operator, print_matrix);
prop.compute_propagator(nlocal, Stmp, Htmp, H_laststep, U_operator, print_matrix);

// (3)->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Expand Down
22 changes: 9 additions & 13 deletions source/module_hamilt_lcao/module_tddft/propagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ inline int globalIndex(int localindex, int nblk, int nprocs, int myproc)
return gIndex;
}

void Propagator::compute_propagator(const int nband,
const int nlocal,
void Propagator::compute_propagator(const int nlocal,
const std::complex<double>* Stmp,
const std::complex<double>* Htmp,
const std::complex<double>* H_laststep,
Expand All @@ -35,16 +34,16 @@ void Propagator::compute_propagator(const int nband,
switch (ptype)
{
case 0:
compute_propagator_cn2(nband, nlocal, Stmp, Htmp, U_operator, print_matrix);
compute_propagator_cn2(nlocal, Stmp, Htmp, U_operator, print_matrix);
break;

case 1:
tag = 1;
compute_propagator_taylor(nband, nlocal, Stmp, Htmp, U_operator, print_matrix, tag);
compute_propagator_taylor(nlocal, Stmp, Htmp, U_operator, print_matrix, tag);
break;

case 2:
compute_propagator_etrs(nband, nlocal, Stmp, Htmp, H_laststep, U_operator, print_matrix);
compute_propagator_etrs(nlocal, Stmp, Htmp, H_laststep, U_operator, print_matrix);

break;

Expand All @@ -54,8 +53,7 @@ void Propagator::compute_propagator(const int nband,
}
}

void Propagator::compute_propagator_cn2(const int nband,
const int nlocal,
void Propagator::compute_propagator_cn2(const int nlocal,
const std::complex<double>* Stmp,
const std::complex<double>* Htmp,
std::complex<double>* U_operator,
Expand Down Expand Up @@ -259,8 +257,7 @@ void Propagator::compute_propagator_cn2(const int nband,
delete[] ipiv;
}

void Propagator::compute_propagator_taylor(const int nband,
const int nlocal,
void Propagator::compute_propagator_taylor(const int nlocal,
const std::complex<double>* Stmp,
const std::complex<double>* Htmp,
std::complex<double>* U_operator,
Expand Down Expand Up @@ -580,8 +577,7 @@ void Propagator::compute_propagator_taylor(const int nband,
delete[] ipiv;
}

void Propagator::compute_propagator_etrs(const int nband,
const int nlocal,
void Propagator::compute_propagator_etrs(const int nlocal,
const std::complex<double>* Stmp,
const std::complex<double>* Htmp,
const std::complex<double>* H_laststep,
Expand All @@ -593,8 +589,8 @@ void Propagator::compute_propagator_etrs(const int nband,
ModuleBase::GlobalFunc::ZEROS(U1, this->ParaV->nloc);
ModuleBase::GlobalFunc::ZEROS(U2, this->ParaV->nloc);
int tag = 2;
compute_propagator_taylor(nband, nlocal, Stmp, Htmp, U1, print_matrix, tag);
compute_propagator_taylor(nband, nlocal, Stmp, H_laststep, U2, print_matrix, tag);
compute_propagator_taylor(nlocal, Stmp, Htmp, U1, print_matrix, tag);
compute_propagator_taylor(nlocal, Stmp, H_laststep, U2, print_matrix, tag);
ScalapackConnector::gemm('N',
'N',
nlocal,
Expand Down
Loading