Skip to content

Uploading hybrid gague tddft #6341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 83 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
2046103
Add files via upload
ESROAMER Jun 27, 2025
2f07ba2
Update global_file.cpp
ESROAMER Jun 27, 2025
1dc6abc
Update global_file.h
ESROAMER Jun 27, 2025
94c45bd
Update ORB_nonlocal_lm.h
ESROAMER Jun 27, 2025
6bd0ee5
Update H_TDDFT_pw.cpp
ESROAMER Jun 27, 2025
0a0f953
Update H_TDDFT_pw.h
ESROAMER Jun 27, 2025
851a9a7
Update esolver_ks_lcao_tddft.cpp
ESROAMER Jun 27, 2025
a40adcd
Update esolver_ks_lcao_tddft.h
ESROAMER Jun 27, 2025
ff8bbaa
Update esolver_ks_lcao.cpp
ESROAMER Jun 27, 2025
9753627
Update esolver_ks.cpp
ESROAMER Jun 27, 2025
d9edeed
Update esolver.cpp
ESROAMER Jun 27, 2025
138811f
Update operator.h
ESROAMER Jun 27, 2025
d143d8e
Update CMakeLists.txt
ESROAMER Jun 27, 2025
f25b3a2
Update CMakeLists.txt
ESROAMER Jun 27, 2025
63101bd
Update operator_lcao.cpp
ESROAMER Jun 27, 2025
0583ba4
Update overlap_new.cpp
ESROAMER Jun 27, 2025
0a3bd92
Update td_ekinetic_lcao.cpp
ESROAMER Jun 27, 2025
b378c10
Update td_ekinetic_lcao.h
ESROAMER Jun 27, 2025
dad7c0d
Update td_nonlocal_lcao.cpp
ESROAMER Jun 27, 2025
3aefc9f
Update td_nonlocal_lcao.h
ESROAMER Jun 27, 2025
741c4e1
Add files via upload
ESROAMER Jun 27, 2025
aa0859b
Update hamilt_lcao.cpp
ESROAMER Jun 27, 2025
7ea87e2
Update spar_hsr.cpp
ESROAMER Jun 27, 2025
d0353dc
Update spar_hsr.cpp
ESROAMER Jun 27, 2025
8ba4c69
Update CMakeLists.txt
ESROAMER Jun 27, 2025
ca5e692
Update evolve_elec.h
ESROAMER Jun 27, 2025
5642fef
Update evolve_psi.cpp
ESROAMER Jun 27, 2025
de01481
Update solve_propagation.cpp
ESROAMER Jun 27, 2025
812904e
Add files via upload
ESROAMER Jun 27, 2025
dcfcd05
Delete source/module_hamilt_lcao/module_tddft/td_velocity.cpp
ESROAMER Jun 27, 2025
2f4147f
Delete source/module_hamilt_lcao/module_tddft/td_velocity.h
ESROAMER Jun 27, 2025
a19518b
Delete source/module_hamilt_lcao/module_tddft/td_current.cpp
ESROAMER Jun 27, 2025
822c3bb
Delete source/module_hamilt_lcao/module_tddft/td_current.h
ESROAMER Jun 27, 2025
6a75c76
Update cal_r_overlap_R.cpp
ESROAMER Jun 27, 2025
4efbb25
Update cal_r_overlap_R.h
ESROAMER Jun 27, 2025
cc85159
Update cal_r_overlap_R.h
ESROAMER Jun 27, 2025
ff163c7
Update input_conv.cpp
ESROAMER Jun 27, 2025
473b094
Update output_log.cpp
ESROAMER Jun 27, 2025
f8239de
Update output_log.h
ESROAMER Jun 27, 2025
c9c49f4
Update read_input_item_md.cpp
ESROAMER Jun 27, 2025
1f927dd
Update read_input_item_system.cpp
ESROAMER Jun 27, 2025
f1d8f06
Update read_input_item_tddft.cpp
ESROAMER Jun 27, 2025
a9cca5c
Update read_input.cpp
ESROAMER Jun 27, 2025
87c9889
Update read_set_globalv.cpp
ESROAMER Jun 27, 2025
3934384
Update read_set_globalv.cpp
ESROAMER Jun 27, 2025
2a14ab7
Update read_wfc_nao.cpp
ESROAMER Jun 27, 2025
e0336ce
Update read_wfc_nao.h
ESROAMER Jun 27, 2025
a5ba582
Update td_current_io.cpp
ESROAMER Jun 27, 2025
466dfe9
Update td_current_io.h
ESROAMER Jun 27, 2025
cd4cb69
Update write_HS_sparse.cpp
ESROAMER Jun 27, 2025
af9f5e7
Update write_wfc_nao.cpp
ESROAMER Jun 27, 2025
defb3a4
Update lr_spectrum.h
ESROAMER Jun 27, 2025
16132ef
Update lr_spectrum_velocity.cpp
ESROAMER Jun 27, 2025
14fa609
Update input_parameter.h
ESROAMER Jun 27, 2025
637b11d
Update system_parameter.h
ESROAMER Jun 27, 2025
d0fdc61
Update Makefile.Objects
ESROAMER Jun 27, 2025
a793f90
Delete source/source_estate/density_matrix.cpp
ESROAMER Jun 27, 2025
ae02387
Delete source/source_estate/density_matrix.h
ESROAMER Jun 27, 2025
9301ecb
Add files via upload
ESROAMER Jun 27, 2025
7e7e396
Add files via upload
ESROAMER Jun 27, 2025
662888f
Add files via upload
ESROAMER Jun 27, 2025
763b0f9
Update operator_lcao.cpp
ESROAMER Jun 27, 2025
fbdd3ba
Update write_HS_sparse.cpp
ESROAMER Jun 27, 2025
43587e1
Merge pull request #9 from ESROAMER/upload
ESROAMER Jun 27, 2025
ad6cbf8
Delete source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/td_curr…
ESROAMER Jun 27, 2025
6153408
Update velocity_op.cpp
ESROAMER Jun 27, 2025
153211f
Update velocity_op.h
ESROAMER Jun 27, 2025
322c85a
Update Makefile.Objects
ESROAMER Jun 27, 2025
8864868
Update read_input_test.cpp
ESROAMER Jun 27, 2025
4b8f2d0
Add files via upload
ESROAMER Jun 27, 2025
2e16732
Delete source/module_hamilt_lcao/hamilt_lcaodft/CMakeLists.txt
ESROAMER Jun 28, 2025
4fb2038
Delete source/module_hamilt_lcao directory
ESROAMER Jun 28, 2025
f884805
Delete source/module_io directory
ESROAMER Jun 28, 2025
cce302d
Update esolver_ks_lcao_tddft.cpp
ESROAMER Jun 28, 2025
a403d76
Delete source/module_lr/lr_spectrum.h
ESROAMER Jun 28, 2025
f4bac2c
Delete source/source_esolver/esolver_ks_lcao_tddft.cpp
ESROAMER Jun 28, 2025
b277fcb
Add files via upload
ESROAMER Jun 28, 2025
88fc3ec
Add files via upload
ESROAMER Jun 28, 2025
500db74
Merge pull request #10 from deepmodeling/develop
ESROAMER Jun 28, 2025
115d5e8
Add files via upload
ESROAMER Jun 28, 2025
b326fe8
Delete source/source_hamilt_lcao directory
ESROAMER Jun 28, 2025
fc061bb
Add files via upload
ESROAMER Jun 28, 2025
74e14fa
rename
ESROAMER Jun 28, 2025
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
6 changes: 4 additions & 2 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ OBJS_HAMILT_LCAO=hamilt_lcao.o\
overlap_new.o\
td_ekinetic_lcao.o\
td_nonlocal_lcao.o\
td_pot_hybrid.o\
veff_lcao.o\
meta_lcao.o\
op_dftu_lcao.o\
Expand Down Expand Up @@ -623,8 +624,9 @@ OBJS_LCAO=evolve_elec.o\
propagator_cn2.o\
propagator_taylor.o\
propagator_etrs.o\
td_velocity.o\
td_current.o\
td_folding.o\
td_info.o\
velocity_op.o\
snap_psibeta_half_tddft.o\
solve_propagation.o\
upsi.o\
Expand Down
6 changes: 3 additions & 3 deletions source/module_lr/lr_spectrum.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "source_estate/module_dm/density_matrix.h"
#include "module_lr/utils/lr_util.h"
#include "source_basis/module_nao/two_center_bundle.h"
#include "source_lcao/module_tddft/td_current.h"
#include "source_lcao/module_tddft/velocity_op.h"
namespace LR
{
template<typename T>
Expand Down Expand Up @@ -52,8 +52,8 @@ namespace LR
/// calculate the transition dipole of all states in length gauge
void cal_transition_dipoles_length();
/// calculate the transition dipole of state S in velocity gauge: $i(\sum_{iak}X^S_{iak}<ik|v|ak>)/\Omega_S$
ModuleBase::Vector3<T> cal_transition_dipole_istate_velocity_R(const int istate, const TD_current& vR);
ModuleBase::Vector3<T> cal_transition_dipole_istate_velocity_k(const int istate, const TD_current& vR);
ModuleBase::Vector3<T> cal_transition_dipole_istate_velocity_R(const int istate, const Velocity_op<std::complex<double>>& vR);
ModuleBase::Vector3<T> cal_transition_dipole_istate_velocity_k(const int istate, const Velocity_op<std::complex<double>>& vR);
/// calculate the transition dipole of all states in velocity gauge
void cal_transition_dipoles_velocity();
double cal_mean_squared_dipole(ModuleBase::Vector3<T> dipole);
Expand Down
16 changes: 8 additions & 8 deletions source/module_lr/lr_spectrum_velocity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
namespace LR
{
/// get the velocity matrix v(R)
inline TD_current get_velocity_matrix_R(const UnitCell& ucell,
inline Velocity_op<std::complex<double>> get_velocity_matrix_R(const UnitCell& ucell,
const Grid_Driver& gd,
const Parallel_Orbitals& pmat,
const TwoCenterBundle& two_center_bundle)
{
// convert the orbital object to the old class for TD_current
// convert the orbital object to the old class for Velocity_op
LCAO_Orbitals orb;
const auto& inp = PARAM.inp;
two_center_bundle.to_LCAO_Orbitals(orb, inp.lcao_ecut, inp.lcao_dk, inp.lcao_dr, inp.lcao_rmax);
// actually this class calculates the velocity matrix v(R) at A=0
TD_current vR(&ucell, &gd, &pmat, orb, two_center_bundle.overlap_orb.get());
Velocity_op<std::complex<double>> vR(&ucell, &gd, &pmat, orb, two_center_bundle.overlap_orb.get());
vR.calculate_vcomm_r(); // $<\mu, 0|[Vnl, r]|\nu, R>$
vR.calculate_grad_term(); // $<\mu, 0|\nabla|\nu, R>$
return vR;
Expand Down Expand Up @@ -47,7 +47,7 @@ namespace LR

/// this algorithm has bug in multi-k cases, just for test
template<typename T>
ModuleBase::Vector3<T> LR::LR_Spectrum<T>::cal_transition_dipole_istate_velocity_R(const int istate, const TD_current& vR)
ModuleBase::Vector3<T> LR::LR_Spectrum<T>::cal_transition_dipole_istate_velocity_R(const int istate, const Velocity_op<std::complex<double>>& vR)
{
// transition density matrix D(R)
const elecstate::DensityMatrix<T, T>& DM_trans = this->cal_transition_density_matrix(istate);
Expand All @@ -69,7 +69,7 @@ namespace LR

// this algorithm is actually in use
template<typename T>
ModuleBase::Vector3<T> LR::LR_Spectrum<T>::cal_transition_dipole_istate_velocity_k(const int istate, const TD_current& vR)
ModuleBase::Vector3<T> LR::LR_Spectrum<T>::cal_transition_dipole_istate_velocity_k(const int istate, const Velocity_op<std::complex<double>>& vR)
{
// transition density matrix D(R)
const elecstate::DensityMatrix<T, T>& DM_trans = this->cal_transition_density_matrix(istate, this->X, false);
Expand Down Expand Up @@ -97,7 +97,7 @@ namespace LR
template<typename T>
void LR::LR_Spectrum<T>::cal_transition_dipoles_velocity()
{
const TD_current& vR = get_velocity_matrix_R(ucell, gd_, pmat, two_center_bundle_); // velocity matrix v(R)
const Velocity_op<std::complex<double>>& vR = get_velocity_matrix_R(ucell, gd_, pmat, two_center_bundle_); // velocity matrix v(R)
transition_dipole_.resize(nstate);
this->mean_squared_transition_dipole_.resize(nstate);
for (int istate = 0;istate < nstate;++istate)
Expand Down Expand Up @@ -148,7 +148,7 @@ namespace LR
void LR::LR_Spectrum<T>::test_transition_dipoles_velocity_ks(const double* const ks_eig)
{
// velocity matrix v(R)
const TD_current& vR = get_velocity_matrix_R(ucell, gd_, pmat, two_center_bundle_);
const Velocity_op<std::complex<double>>& vR = get_velocity_matrix_R(ucell, gd_, pmat, two_center_bundle_);
// (e_c-e_v) of KS eigenvalues
std::vector<double> eig_ks_diff(this->ldim);
for (int is = 0;is < this->nspin_x;++is)
Expand Down Expand Up @@ -183,4 +183,4 @@ namespace LR
}
}
template class LR::LR_Spectrum<double>;
template class LR::LR_Spectrum<std::complex<double>>;
template class LR::LR_Spectrum<std::complex<double>>;
3 changes: 2 additions & 1 deletion source/module_parameter/input_parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ struct Input_para
double bessel_descriptor_sigma = 0.1; ///< spherical bessel smearing_sigma

// ============== #Parameters (9.rt-tddft) ===========================
double td_force_dt = 0.02; ///<"fs"
double td_dt = -1.0; ///< time step for propagation
int estep_per_md = 1; ///< number of electronic steps per MD step
bool td_vext = false; ///< add extern potential or not
// std::string td_vext_dire = "1"; ///< vext direction
std::vector<int> td_vext_dire = {1}; ///< vector of vext direction
Expand Down
3 changes: 2 additions & 1 deletion source/module_parameter/system_parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct System_para
std::string global_readin_dir = ""; ///< global readin directory
std::string global_stru_dir = ""; ///< global structure directory
std::string global_matrix_dir = ""; ///< global matrix directory
std::string global_wfc_dir = ""; ///< global wavefunction directory
std::string global_mlkedf_descriptor_dir = ""; ///< global ML KEDF descriptor directory
std::string global_deepks_label_elec_dir = ""; ///< global directory for DeePKS labels during electronic steps
std::string log_file = "log"; ///< log file name
Expand All @@ -65,4 +66,4 @@ struct System_para

bool search_pbc = true; ///< whether to search for periodic boundary conditions, force set to true
};
#endif
#endif
41 changes: 41 additions & 0 deletions source/source_base/global_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ void ModuleBase::Global_File::make_dir_out(
const std::string &suffix,
const std::string &calculation,
const bool &out_dir,
const bool &out_wfc_dir,
const int rank,
const bool &restart,
const bool out_alllog)
Expand Down Expand Up @@ -153,6 +154,46 @@ void ModuleBase::Global_File::make_dir_out(
#endif
}

if(out_wfc_dir)
{
int make_dir_wfc = 0;
std::string command1 = "test -d " + PARAM.globalv.global_wfc_dir + " || mkdir " + PARAM.globalv.global_wfc_dir;

times = 0;
while(times<GlobalV::NPROC)
{
if(rank==times)
{
if ( system( command1.c_str() ) == 0 )
{
std::cout << " MAKE THE WFC DIR : " << PARAM.globalv.global_wfc_dir << std::endl;
make_dir_wfc = 1;
}
else
{
std::cout << " PROC " << rank << " CAN NOT MAKE THE WFC DIR !!! " << std::endl;
make_dir_wfc = 0;
}
}
#ifdef __MPI
Parallel_Reduce::reduce_all(make_dir_wfc);
#endif
if(make_dir_wfc>0) { break;
}
++times;
}

#ifdef __MPI
if(make_dir_wfc==0)
{
std::cout << " CAN NOT MAKE THE WFC DIR......." << std::endl;
ModuleBase::QUIT();
}
MPI_Barrier(MPI_COMM_WORLD);
#endif
}


if(PARAM.inp.of_ml_gene_data == 1)
{
int make_dir_descrip = 0;
Expand Down
1 change: 1 addition & 0 deletions source/source_base/global_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace Global_File
void make_dir_out(const std::string &suffix,
const std::string &calculation,
const bool &out_dir,
const bool &out_wfc_dir,
const int rank,
const bool &restart,
const bool out_alllog = false);
Expand Down
6 changes: 3 additions & 3 deletions source/source_base/test/global_file_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ TEST_F(GlobalFile,mkdirout)
{
std::string output;
testing::internal::CaptureStdout();
ModuleBase::Global_File::make_dir_out("Si","m",false,0,true,true);
ModuleBase::Global_File::make_dir_out("Si","m",false,false,0,true,true);
output = testing::internal::GetCapturedStdout();
EXPECT_THAT(output,testing::HasSubstr("MAKE THE DIR"));
GlobalV::ofs_warning.close();
Expand All @@ -43,7 +43,7 @@ TEST_F(GlobalFile,mkdirout)
remove(dd.c_str());

testing::internal::CaptureStdout();
ModuleBase::Global_File::make_dir_out("Si","md",false,0,true,false);
ModuleBase::Global_File::make_dir_out("Si","md",false,false,0,true,false);
output = testing::internal::GetCapturedStdout();
EXPECT_THAT(output,testing::HasSubstr("MAKE THE STRU DIR"));
EXPECT_TRUE(GlobalV::ofs_running.is_open());
Expand All @@ -53,7 +53,7 @@ TEST_F(GlobalFile,mkdirout)
remove(bb.c_str());

testing::internal::CaptureStdout();
ModuleBase::Global_File::make_dir_out("Si","md",true,0,true,true);
ModuleBase::Global_File::make_dir_out("Si","md",true,false,0,true,true);
output = testing::internal::GetCapturedStdout();
EXPECT_THAT(output,testing::HasSubstr("MAKE THE MATRIX DIR"));
EXPECT_TRUE(GlobalV::ofs_running.is_open());
Expand Down
3 changes: 3 additions & 0 deletions source/source_basis/module_ao/ORB_nonlocal_lm.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class Numerical_Nonlocal_Lm
const double& getKpoint(const int &ik) const { return this->k_radial[ik]; }
const double* getBeta_k() const { return this->beta_k; }
const double& getBeta_k(const int &ik) const { return this->beta_k[ik]; }

const int& getNk() const { return nk; }
const double& getDruniform() const { return dr_uniform; }

// enables deep copy
Numerical_Nonlocal_Lm& operator= (const Numerical_Nonlocal_Lm& nol );
Expand Down
21 changes: 17 additions & 4 deletions source/source_esolver/esolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,26 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell)
}
else if (esolver_type == "ksdft_lcao_tddft")
{
#if ((defined __CUDA) /* || (defined __ROCM) */)
if (PARAM.inp.device == "gpu")
if (PARAM.inp.nspin < 4)
{
return new ESolver_KS_LCAO_TDDFT<base_device::DEVICE_GPU>();
#if ((defined __CUDA) /* || (defined __ROCM) */)
if (PARAM.inp.device == "gpu")
{
return new ESolver_KS_LCAO_TDDFT<double, base_device::DEVICE_GPU>();
}
#endif
return new ESolver_KS_LCAO_TDDFT<double, base_device::DEVICE_CPU>();
}
else
{
#if ((defined __CUDA) /* || (defined __ROCM) */)
if (PARAM.inp.device == "gpu")
{
return new ESolver_KS_LCAO_TDDFT<std::complex<double>, base_device::DEVICE_GPU>();
}
#endif
return new ESolver_KS_LCAO_TDDFT<base_device::DEVICE_CPU>();
return new ESolver_KS_LCAO_TDDFT<std::complex<double>, base_device::DEVICE_CPU>();
}
}
else if (esolver_type == "lr_lcao")
{
Expand Down
5 changes: 4 additions & 1 deletion source/source_esolver/esolver_ks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,10 @@ void ESolver_KS<T, Device>::before_scf(UnitCell& ucell, const int istep)
template <typename T, typename Device>
void ESolver_KS<T, Device>::iter_init(UnitCell& ucell, const int istep, const int iter)
{
ModuleIO::write_head(GlobalV::ofs_running, istep, iter, this->basisname);
if(PARAM.inp.esolver_type != "tddft")
{
ModuleIO::write_head(GlobalV::ofs_running, istep, iter, this->basisname);
}

#ifdef __MPI
iter_time = MPI_Wtime();
Expand Down
2 changes: 1 addition & 1 deletion source/source_esolver/esolver_ks_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
}

// 5) read psi from file
if (PARAM.inp.init_wfc == "file")
if (PARAM.inp.init_wfc == "file" && PARAM.inp.esolver_type != "tddft")
{
if (!ModuleIO::read_wfc_nao(PARAM.globalv.global_readin_dir,
this->pv,
Expand Down
Loading
Loading