Skip to content

Commit 8e8c30f

Browse files
authored
Uploading hybrid gauge tddft (#6369)
* hybrid gague * update tests * update * update * update * update * update unit test * fix tests * update tests * fix read_wfc * fix catch_properties.sh * fix restart * update gpu test * update tests * fix * fix input_conv
1 parent b554f40 commit 8e8c30f

File tree

147 files changed

+2705
-780
lines changed

Some content is hidden

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

147 files changed

+2705
-780
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@
375375
- [out\_wannier\_unk](#out_wannier_unk)
376376
- [out\_wannier\_wvfn\_formatted](#out_wannier_wvfn_formatted)
377377
- [rt-TDDFT: Real-time time dependent density functional theory](#tddft-time-dependent-density-functional-theory)
378+
- [estep\_per\_md](#estep_per_md)
379+
- [td\_dt](#td_dt)
378380
- [td\_edm](#td_edm)
379381
- [td\_print\_eij](#td_print_eij)
380382
- [td\_propagator](#td_propagator)
@@ -1728,7 +1730,7 @@ These variables are used to control the output of properties.
17281730

17291731
- **Type**: Integer
17301732
- **Availability**: Numerical atomic orbital basis
1731-
- **Description**: Whether to output the electronic wavefunction coefficients into files and store them in the folder `OUT.${suffix}`. The files are named as `wf{s}{spin index}{k(optional)}{k-point index}{g(optional)}{geometry index1}{_nao} + {".txt"/".dat"}`. Here, 's' refers to spin, where s1 means spin up channel while s2 means spin down channel, and 's12' refer to spinor wave functions that contains both spin channels with spin-orbital coupling or noncollinear calculations enabled. In addition, if 'gamma_only' is set to 0, then the optinoal k-point sampling index appears with the k-point index attached to the electronic wave function file names. Finally, if [out_app_flag](#out_app_flag) is set to false, the file name contains the optional 'g' index for each ionic step that may have different geometries, and if [out_app_flag](#out_app_flag) is set to true, the wave functions accumulate during ionic steps.
1733+
- **Description**: Whether to output the electronic wavefunction coefficients into files and store them in the folder `OUT.${suffix}`. The files are named as `wf{s}{spin index}{k(optional)}{k-point index}{g(optional)}{geometry index1}{_nao} + {".txt"/".dat"}`. Here, 's' refers to spin, where s1 means spin up channel while s2 means spin down channel, and 's12' refer to spinor wave functions that contains both spin channels with spin-orbital coupling or noncollinear calculations enabled. In addition, if 'gamma_only' is set to 0, then the optinoal k-point sampling index appears with the k-point index attached to the electronic wave function file names. Finally, if [out_app_flag](#out_app_flag) is set to false, the file name contains the optional 'g' index for each ionic step that may have different geometries, and if [out_app_flag](#out_app_flag) is set to true, the wave functions accumulate during ionic steps. If the out_app_flag is set to false, a new folder named WFC will be created, and the wave function files will be saved into it.
17321734
- 0: no output
17331735
- 1: (txt format)
17341736
- gamma-only: `wfs1_nao.txt` or `wfs2_nao.txt`, ...;
@@ -3687,6 +3689,18 @@ These variables are used to control berry phase and wannier90 interface paramete
36873689

36883690
## TDDFT: time dependent density functional theory
36893691

3692+
### estep_per_md
3693+
3694+
- **Type**: Integer
3695+
- **Description**: The number of electron propagation steps between two ionic steps.
3696+
- **Default**: 1
3697+
3698+
### td_dt
3699+
3700+
- **Type**: Real
3701+
- **Description**: The time step used in electron propagation. Setting td_dt will reset the md_dt value to td_dt * estep_per_md.
3702+
- **Default**: md_dt/estep_per_md
3703+
36903704
### td_edm
36913705

36923706
- **Type**: Integer
@@ -3739,6 +3753,7 @@ These variables are used to control berry phase and wannier90 interface paramete
37393753
Type of electric field in space domain
37403754
- 0: length gauge.
37413755
- 1: velocity gauge.
3756+
- 2: hybrid gauge.
37423757
- **Default**: 0
37433758

37443759
### td_ttype

source/Makefile.Objects

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ OBJS_HAMILT_LCAO=hamilt_lcao.o\
356356
overlap_new.o\
357357
td_ekinetic_lcao.o\
358358
td_nonlocal_lcao.o\
359+
td_pot_hybrid.o\
359360
veff_lcao.o\
360361
meta_lcao.o\
361362
op_dftu_lcao.o\
@@ -624,8 +625,9 @@ OBJS_LCAO=evolve_elec.o\
624625
propagator_cn2.o\
625626
propagator_taylor.o\
626627
propagator_etrs.o\
627-
td_velocity.o\
628-
td_current.o\
628+
td_folding.o\
629+
td_info.o\
630+
velocity_op.o\
629631
snap_psibeta_half_tddft.o\
630632
solve_propagation.o\
631633
upsi.o\

source/module_lr/lr_spectrum.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "source_estate/module_dm/density_matrix.h"
66
#include "module_lr/utils/lr_util.h"
77
#include "source_basis/module_nao/two_center_bundle.h"
8-
#include "source_lcao/module_rt/td_current.h"
8+
#include "source_lcao/module_rt/velocity_op.h"
99
namespace LR
1010
{
1111
template<typename T>
@@ -52,8 +52,8 @@ namespace LR
5252
/// calculate the transition dipole of all states in length gauge
5353
void cal_transition_dipoles_length();
5454
/// calculate the transition dipole of state S in velocity gauge: $i(\sum_{iak}X^S_{iak}<ik|v|ak>)/\Omega_S$
55-
ModuleBase::Vector3<T> cal_transition_dipole_istate_velocity_R(const int istate, const TD_current& vR);
56-
ModuleBase::Vector3<T> cal_transition_dipole_istate_velocity_k(const int istate, const TD_current& vR);
55+
ModuleBase::Vector3<T> cal_transition_dipole_istate_velocity_R(const int istate, const Velocity_op<std::complex<double>>& vR);
56+
ModuleBase::Vector3<T> cal_transition_dipole_istate_velocity_k(const int istate, const Velocity_op<std::complex<double>>& vR);
5757
/// calculate the transition dipole of all states in velocity gauge
5858
void cal_transition_dipoles_velocity();
5959
double cal_mean_squared_dipole(ModuleBase::Vector3<T> dipole);

source/module_lr/lr_spectrum_velocity.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
namespace LR
88
{
99
/// get the velocity matrix v(R)
10-
inline TD_current get_velocity_matrix_R(const UnitCell& ucell,
10+
inline Velocity_op<std::complex<double>> get_velocity_matrix_R(const UnitCell& ucell,
1111
const Grid_Driver& gd,
1212
const Parallel_Orbitals& pmat,
1313
const TwoCenterBundle& two_center_bundle)
1414
{
15-
// convert the orbital object to the old class for TD_current
15+
// convert the orbital object to the old class for Velocity_op
1616
LCAO_Orbitals orb;
1717
const auto& inp = PARAM.inp;
1818
two_center_bundle.to_LCAO_Orbitals(orb, inp.lcao_ecut, inp.lcao_dk, inp.lcao_dr, inp.lcao_rmax);
1919
// actually this class calculates the velocity matrix v(R) at A=0
20-
TD_current vR(&ucell, &gd, &pmat, orb, two_center_bundle.overlap_orb.get());
20+
Velocity_op<std::complex<double>> vR(&ucell, &gd, &pmat, orb, two_center_bundle.overlap_orb.get());
2121
vR.calculate_vcomm_r(); // $<\mu, 0|[Vnl, r]|\nu, R>$
2222
vR.calculate_grad_term(); // $<\mu, 0|\nabla|\nu, R>$
2323
return vR;
@@ -47,7 +47,7 @@ namespace LR
4747

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

7070
// this algorithm is actually in use
7171
template<typename T>
72-
ModuleBase::Vector3<T> LR::LR_Spectrum<T>::cal_transition_dipole_istate_velocity_k(const int istate, const TD_current& vR)
72+
ModuleBase::Vector3<T> LR::LR_Spectrum<T>::cal_transition_dipole_istate_velocity_k(const int istate, const Velocity_op<std::complex<double>>& vR)
7373
{
7474
// transition density matrix D(R)
7575
const elecstate::DensityMatrix<T, T>& DM_trans = this->cal_transition_density_matrix(istate, this->X, false);
@@ -97,7 +97,7 @@ namespace LR
9797
template<typename T>
9898
void LR::LR_Spectrum<T>::cal_transition_dipoles_velocity()
9999
{
100-
const TD_current& vR = get_velocity_matrix_R(ucell, gd_, pmat, two_center_bundle_); // velocity matrix v(R)
100+
const Velocity_op<std::complex<double>>& vR = get_velocity_matrix_R(ucell, gd_, pmat, two_center_bundle_); // velocity matrix v(R)
101101
transition_dipole_.resize(nstate);
102102
this->mean_squared_transition_dipole_.resize(nstate);
103103
for (int istate = 0;istate < nstate;++istate)
@@ -148,7 +148,7 @@ namespace LR
148148
void LR::LR_Spectrum<T>::test_transition_dipoles_velocity_ks(const double* const ks_eig)
149149
{
150150
// velocity matrix v(R)
151-
const TD_current& vR = get_velocity_matrix_R(ucell, gd_, pmat, two_center_bundle_);
151+
const Velocity_op<std::complex<double>>& vR = get_velocity_matrix_R(ucell, gd_, pmat, two_center_bundle_);
152152
// (e_c-e_v) of KS eigenvalues
153153
std::vector<double> eig_ks_diff(this->ldim);
154154
for (int is = 0;is < this->nspin_x;++is)

source/source_base/global_file.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ void ModuleBase::Global_File::make_dir_out(
2525
const std::string &suffix,
2626
const std::string &calculation,
2727
const bool &out_dir,
28+
const bool &out_wfc_dir,
2829
const int rank,
2930
const bool &restart,
3031
const bool out_alllog)
@@ -153,6 +154,45 @@ void ModuleBase::Global_File::make_dir_out(
153154
#endif
154155
}
155156

157+
if(out_wfc_dir)
158+
{
159+
int make_dir_wfc = 0;
160+
std::string command1 = "test -d " + PARAM.globalv.global_wfc_dir + " || mkdir " + PARAM.globalv.global_wfc_dir;
161+
162+
times = 0;
163+
while(times<GlobalV::NPROC)
164+
{
165+
if(rank==times)
166+
{
167+
if ( system( command1.c_str() ) == 0 )
168+
{
169+
std::cout << " MAKE THE WFC DIR : " << PARAM.globalv.global_wfc_dir << std::endl;
170+
make_dir_wfc = 1;
171+
}
172+
else
173+
{
174+
std::cout << " PROC " << rank << " CAN NOT MAKE THE WFC DIR !!! " << std::endl;
175+
make_dir_wfc = 0;
176+
}
177+
}
178+
#ifdef __MPI
179+
Parallel_Reduce::reduce_all(make_dir_wfc);
180+
#endif
181+
if(make_dir_wfc>0) { break;
182+
}
183+
++times;
184+
}
185+
186+
#ifdef __MPI
187+
if(make_dir_wfc==0)
188+
{
189+
std::cout << " CAN NOT MAKE THE WFC DIR......." << std::endl;
190+
ModuleBase::QUIT();
191+
}
192+
MPI_Barrier(MPI_COMM_WORLD);
193+
#endif
194+
}
195+
156196
if(PARAM.inp.of_ml_gene_data == 1)
157197
{
158198
int make_dir_descrip = 0;

source/source_base/global_file.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ namespace Global_File
2323
void make_dir_out(const std::string &suffix,
2424
const std::string &calculation,
2525
const bool &out_dir,
26+
const bool &out_wfc_dir,
2627
const int rank,
2728
const bool &restart,
2829
const bool out_alllog = false);

source/source_base/module_mixing/test/mixing_test.cpp

100755100644
File mode changed.

source/source_base/test/global_file_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ TEST_F(GlobalFile,mkdirout)
3333
{
3434
std::string output;
3535
testing::internal::CaptureStdout();
36-
ModuleBase::Global_File::make_dir_out("Si","m",false,0,true,true);
36+
ModuleBase::Global_File::make_dir_out("Si","m",false,false,0,true,true);
3737
output = testing::internal::GetCapturedStdout();
3838
EXPECT_THAT(output,testing::HasSubstr("MAKE THE DIR"));
3939
GlobalV::ofs_warning.close();
@@ -43,7 +43,7 @@ TEST_F(GlobalFile,mkdirout)
4343
remove(dd.c_str());
4444

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

5555
testing::internal::CaptureStdout();
56-
ModuleBase::Global_File::make_dir_out("Si","md",true,0,true,true);
56+
ModuleBase::Global_File::make_dir_out("Si","md",true,false,0,true,true);
5757
output = testing::internal::GetCapturedStdout();
5858
EXPECT_THAT(output,testing::HasSubstr("MAKE THE MATRIX DIR"));
5959
EXPECT_TRUE(GlobalV::ofs_running.is_open());

source/source_base/test_parallel/parallel_2d_test.sh

100755100644
File mode changed.

source/source_base/test_parallel/parallel_common_test.sh

100755100644
File mode changed.

0 commit comments

Comments
 (0)