Skip to content

Commit 3ed543d

Browse files
authored
Update LCAO_matrix and related functions and delete LCAO_gen_fixedH (deepmodeling#4400)
* add set_force and set_stress in LCAO_domain.h * remove set_force and set_stress in LCAO_matrix * add new files LCAO_nl_beta and LCAO_nl_mu * move build_ST_new to LCAO_set_st.cpp * delete LCAO_gen_fixedH * delete useless print_Hk and print_Hgamma functions in LCAO_matrix.h and .cpp * refactor the forces in LCAO * remove GlobalC in fedm * update force-related files * fix a small bug in Makefile
1 parent f16c4a7 commit 3ed543d

43 files changed

Lines changed: 2213 additions & 2029 deletions

Some content is hidden

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

‎source/Makefile.Objects‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -499,23 +499,27 @@ OBJS_LCAO=DM_gamma.o\
499499
td_velocity.o\
500500
upsi.o\
501501
FORCE_STRESS.o\
502-
FORCE_gamma.o\
503-
FORCE_gamma_edm.o\
504-
FORCE_gamma_tvnl.o\
505-
FORCE_gamma_vl.o\
506-
FORCE_k.o\
507-
foverlap_k.o\
508-
ftvnl_dphi_k.o\
509-
fvl_dphi_k.o\
510-
fvnl_dbeta_k.o\
511-
LCAO_gen_fixedH.o\
512-
grid_init.o\
502+
FORCE_gamma.o\
503+
FORCE_k.o\
504+
fvl_dphi_gamma.o\
505+
fvl_dphi_k.o\
506+
fedm_gamma.o\
507+
fedm_k.o\
508+
ftvnl_dphi_gamma.o\
509+
ftvnl_dphi_k.o\
510+
fvnl_dbeta_gamma.o\
511+
fvnl_dbeta_k.o\
512+
grid_init.o\
513513
spar_dh.o\
514514
spar_exx.o\
515515
spar_hsr.o\
516516
spar_st.o\
517517
spar_u.o\
518518
LCAO_matrix.o\
519+
LCAO_set_fs.o\
520+
LCAO_set_st.o\
521+
LCAO_nl_mu.o\
522+
LCAO_nl_beta.o\
519523
LCAO_nnr.o\
520524
center2_orb-orb11.o\
521525
center2_orb-orb21.o\

‎source/module_esolver/esolver_ks_lcao.cpp‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(Input& inp, UnitCell& ucell)
163163
this->init_basis_lcao(this->orb_con, inp, ucell);
164164
//------------------init Basis_lcao----------------------
165165

166-
// 4) redundant ParaV and LM pointers
167-
this->gen_h.LM = &this->LM;
168-
169166
//! pass basis-pointer to EState and Psi
170167
/*
171168
Inform: on getting rid of ORB_control and Parallel_Orbitals
@@ -381,7 +378,6 @@ void ESolver_KS_LCAO<TK, TR>::cal_force(ModuleBase::matrix& force)
381378
this->pelec,
382379
this->psi,
383380
this->LM,
384-
this->gen_h, // mohan add 2024-04-02
385381
this->GG, // mohan add 2024-04-01
386382
this->GK, // mohan add 2024-04-01
387383
uot_,
@@ -1433,7 +1429,6 @@ ModuleIO::Output_Mat_Sparse<TK> ESolver_KS_LCAO<TK, TR>::create_Output_Mat_Spars
14331429
istep,
14341430
this->pelec->pot->get_effective_v(),
14351431
this->orb_con.ParaV,
1436-
this->gen_h, // mohan add 2024-04-06
14371432
this->GK, // mohan add 2024-04-01
14381433
uot_,
14391434
this->LM,

‎source/module_esolver/esolver_ks_lcao.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ namespace ModuleESolver
7575
// we will get rid of this class soon, don't use it, mohan 2024-03-28
7676
Local_Orbital_Charge LOC;
7777

78-
LCAO_gen_fixedH gen_h; // mohan add 2024-04-02
79-
8078
// used for k-dependent grid integration.
8179
Gint_k GK;
8280

‎source/module_esolver/esolver_ks_lcao_elec.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ void ESolver_KS_LCAO<TK, TR>::beforesolver(const int istep)
145145
this->p_hamilt = new hamilt::HamiltLCAO<TK, TR>(
146146
GlobalV::GAMMA_ONLY_LOCAL ? &(this->GG) : nullptr,
147147
GlobalV::GAMMA_ONLY_LOCAL ? nullptr : &(this->GK),
148-
&(this->gen_h),
149148
&(this->LM),
150149
&(this->LOC),
151150
this->pelec->pot,

‎source/module_esolver/esolver_ks_lcao_tddft.cpp‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ void ESolver_KS_LCAO_TDDFT::before_all_runners(Input& inp, UnitCell& ucell)
9191

9292
// this part will be updated soon
9393
// pass Hamilt-pointer to Operator
94-
this->gen_h.LM = &this->LM;
9594
this->LOC.ParaV = this->LM.ParaV;;
9695
this->LOWF.ParaV = this->LM.ParaV;
9796

@@ -435,8 +434,7 @@ void ESolver_KS_LCAO_TDDFT::after_scf(const int istep)
435434
uot_,
436435
tmp_DM->get_paraV_pointer(),
437436
this->RA,
438-
this->LM, // mohan add 2024-04-02
439-
this->gen_h); // mohan add 2024-02
437+
this->LM); // mohan add 2024-04-02
440438
}
441439
ESolver_KS_LCAO<std::complex<double>, double>::after_scf(istep);
442440
}

‎source/module_esolver/io_npz.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void ESolver_KS_LCAO<TK, TR>::read_mat_npz(std::string& zipname, hamilt::HContai
117117
assert(orbital_info[iw*3] == GlobalC::ucell.atoms[it].iw2n[iw]);
118118
assert(orbital_info[iw*3+1] == GlobalC::ucell.atoms[it].iw2l[iw]);
119119
const int im = GlobalC::ucell.atoms[it].iw2m[iw];
120-
const int m = (im % 2 == 0) ? -im/2 : (im+1)/2; // copied from LCAO_gen_fixedH.cpp
120+
const int m = (im % 2 == 0) ? -im/2 : (im+1)/2;
121121
assert(orbital_info[iw*3+2] == m);
122122
}
123123
}
@@ -413,7 +413,7 @@ void ESolver_KS_LCAO<TK, TR>::output_mat_npz(std::string& zipname, const hamilt:
413413
orbital_info[iw*3] = GlobalC::ucell.atoms[it].iw2n[iw];
414414
orbital_info[iw*3+1] = GlobalC::ucell.atoms[it].iw2l[iw];
415415
const int im = GlobalC::ucell.atoms[it].iw2m[iw];
416-
const int m = (im % 2 == 0) ? -im/2 : (im+1)/2; // copied from LCAO_gen_fixedH.cpp
416+
const int m = (im % 2 == 0) ? -im/2 : (im+1)/2;
417417
orbital_info[iw*3+2] = m;
418418
}
419419
shape={(size_t)GlobalC::ucell.atoms[it].nw,3};

‎source/module_hamilt_lcao/hamilt_lcaodft/CMakeLists.txt‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ if(ENABLE_LCAO)
1717
operator_lcao/dftu_lcao.cpp
1818
FORCE_STRESS.cpp
1919
FORCE_gamma.cpp
20-
FORCE_gamma_edm.cpp
21-
FORCE_gamma_tvnl.cpp
22-
FORCE_gamma_vl.cpp
2320
FORCE_k.cpp
24-
foverlap_k.cpp
25-
ftvnl_dphi_k.cpp
21+
fvl_dphi_gamma.cpp
2622
fvl_dphi_k.cpp
23+
fedm_gamma.cpp
24+
fedm_k.cpp
25+
ftvnl_dphi_gamma.cpp
26+
ftvnl_dphi_k.cpp
27+
fvnl_dbeta_gamma.cpp
2728
fvnl_dbeta_k.cpp
28-
LCAO_gen_fixedH.cpp
2929
grid_init.cpp
3030
spar_dh.cpp
3131
spar_exx.cpp
@@ -34,7 +34,11 @@ if(ENABLE_LCAO)
3434
spar_u.cpp
3535
LCAO_matrix.cpp
3636
LCAO_nnr.cpp
37-
record_adj.cpp
37+
LCAO_set_fs.cpp
38+
LCAO_set_st.cpp
39+
LCAO_nl_mu.cpp
40+
LCAO_nl_beta.cpp
41+
record_adj.cpp
3842
center2_orb-orb11.cpp
3943
center2_orb-orb21.cpp
4044
center2_orb-orb22.cpp

‎source/module_hamilt_lcao/hamilt_lcaodft/FORCE.h‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "module_base/matrix.h"
77
#include "module_elecstate/module_dm/density_matrix.h"
88
#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.h"
9-
#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_gen_fixedH.h"
109
#include "module_hamilt_lcao/hamilt_lcaodft/local_orbital_charge.h"
1110
#include "module_psi/psi.h"
1211
#include "module_hamilt_lcao/module_gint/gint_gamma.h"
@@ -44,8 +43,10 @@ class Force_LCAO
4443
elecstate::Potential* pot;
4544

4645
// orthonormal force + contribution from T and VNL
47-
void ftable(const bool isforce,
46+
void ftable(
47+
const bool isforce,
4848
const bool isstress,
49+
const UnitCell& ucell,
4950
const psi::Psi<T>* psi,
5051
const elecstate::ElecState* pelec,
5152
ModuleBase::matrix& foverlap,
@@ -59,7 +60,6 @@ class Force_LCAO
5960
#ifdef __DEEPKS
6061
ModuleBase::matrix& svnl_dalpha,
6162
#endif
62-
LCAO_gen_fixedH& gen_h, // mohan add 2024-04-02
6363
typename TGint<T>::type& gint,
6464
const ORB_gen_tables* uot,
6565
const Parallel_Orbitals& pv,
@@ -71,7 +71,6 @@ class Force_LCAO
7171
// get the ds, dt, dvnl.
7272
void allocate(const Parallel_Orbitals& pv,
7373
LCAO_Matrix& lm,
74-
LCAO_gen_fixedH& gen_h,
7574
const ORB_gen_tables* uot,
7675
const int& nks = 0,
7776
const std::vector<ModuleBase::Vector3<double>>& kvec_d = {});
@@ -88,22 +87,24 @@ class Force_LCAO
8887
// forces related to energy density matrix
8988
//-------------------------------------------------------------
9089

91-
void cal_foverlap(const bool isforce,
90+
void cal_fedm(
91+
const bool isforce,
9292
const bool isstress,
93+
const UnitCell& ucell,
94+
const elecstate::DensityMatrix<T, double>* dm,
9395
const psi::Psi<T>* psi,
9496
const Parallel_Orbitals& pv,
9597
const elecstate::ElecState* pelec,
9698
LCAO_Matrix& lm,
9799
ModuleBase::matrix& foverlap,
98100
ModuleBase::matrix& soverlap,
99101
const K_Vectors* kv = nullptr,
100-
Record_adj* ra = nullptr,
101-
const elecstate::DensityMatrix<T, double>* DM = nullptr);
102+
Record_adj* ra = nullptr);
102103

103104
//-------------------------------------------------------------
104105
// forces related to kinetic and non-local pseudopotentials
105106
//--------------------------------------------------------------
106-
void cal_ftvnl_dphi(const elecstate::DensityMatrix<T, double>* DM,
107+
void cal_ftvnl_dphi(const elecstate::DensityMatrix<T, double>* dm,
107108
const Parallel_Orbitals& pv,
108109
const UnitCell& ucell,
109110
LCAO_Matrix& lm,
@@ -113,7 +114,7 @@ class Force_LCAO
113114
ModuleBase::matrix& stvnl_dphi,
114115
Record_adj* ra = nullptr);
115116

116-
void cal_fvnl_dbeta(const elecstate::DensityMatrix<T, double>* DM,
117+
void cal_fvnl_dbeta(const elecstate::DensityMatrix<T, double>* dm,
117118
const Parallel_Orbitals& pv,
118119
const UnitCell& ucell,
119120
const LCAO_Orbitals& orb,

‎source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ void Force_Stress_LCAO<T>::getForceStress(const bool isforce,
3333
const elecstate::ElecState* pelec,
3434
const psi::Psi<T>* psi,
3535
LCAO_Matrix& lm,
36-
LCAO_gen_fixedH &gen_h, // mohan add 2024-04-02
3736
Gint_Gamma &gint_gamma, // mohan add 2024-04-01
3837
Gint_k &gint_k, // mohan add 2024-04-01
3938
const ORB_gen_tables* uot,
@@ -156,7 +155,6 @@ void Force_Stress_LCAO<T>::getForceStress(const bool isforce,
156155
#ifdef __DEEPKS
157156
svnl_dalpha,
158157
#endif
159-
gen_h, // mohan add 2024-04-02
160158
gint_gamma,
161159
gint_k,
162160
uot,
@@ -744,7 +742,6 @@ void Force_Stress_LCAO<double>::integral_part(
744742
#if __DEEPKS
745743
ModuleBase::matrix& svnl_dalpha,
746744
#endif
747-
LCAO_gen_fixedH &gen_h, // mohan add 2024-04-02
748745
Gint_Gamma &gint_gamma, // mohan add 2024-04-01
749746
Gint_k &gint_k, // mohan add 2024-04-01
750747
const ORB_gen_tables* uot,
@@ -755,6 +752,7 @@ void Force_Stress_LCAO<double>::integral_part(
755752

756753
flk.ftable(isforce,
757754
isstress,
755+
GlobalC::ucell,
758756
psi,
759757
pelec,
760758
foverlap,
@@ -768,7 +766,6 @@ void Force_Stress_LCAO<double>::integral_part(
768766
#if __DEEPKS
769767
svnl_dalpha,
770768
#endif
771-
gen_h,
772769
gint_gamma,
773770
uot,
774771
pv,
@@ -795,7 +792,6 @@ void Force_Stress_LCAO<std::complex<double>>::integral_part(
795792
#if __DEEPKS
796793
ModuleBase::matrix& svnl_dalpha,
797794
#endif
798-
LCAO_gen_fixedH &gen_h, // mohan add 2024-04-02
799795
Gint_Gamma &gint_gamma,
800796
Gint_k &gint_k,
801797
const ORB_gen_tables* uot,
@@ -805,6 +801,7 @@ void Force_Stress_LCAO<std::complex<double>>::integral_part(
805801
{
806802
flk.ftable(isforce,
807803
isstress,
804+
GlobalC::ucell,
808805
psi,
809806
pelec,
810807
foverlap,
@@ -818,7 +815,6 @@ void Force_Stress_LCAO<std::complex<double>>::integral_part(
818815
#if __DEEPKS
819816
svnl_dalpha,
820817
#endif
821-
gen_h,
822818
gint_k,
823819
uot,
824820
pv,

‎source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class Force_Stress_LCAO
3636
const elecstate::ElecState* pelec,
3737
const psi::Psi<T>* psi,
3838
LCAO_Matrix &lm,
39-
LCAO_gen_fixedH &gen_h, // mohan add 2024-04-02
4039
Gint_Gamma &gint_gamma, // mohan add 2024-04-01
4140
Gint_k &gint_k, // mohan add 2024-04-01
4241
const ORB_gen_tables* uot,
@@ -88,7 +87,6 @@ class Force_Stress_LCAO
8887
#if __DEEPKS
8988
ModuleBase::matrix& svnl_dalpha,
9089
#endif
91-
LCAO_gen_fixedH &gen_h, // mohan add 2024-04-02
9290
Gint_Gamma &gint_gamma,
9391
Gint_k &gint_k,
9492
const ORB_gen_tables* uot,

0 commit comments

Comments
 (0)