Skip to content

Commit cbcfb7b

Browse files
committed
delete some production code and modify some variable/function names
1 parent 00fc015 commit cbcfb7b

File tree

8 files changed

+33
-173
lines changed

8 files changed

+33
-173
lines changed

abaInstall_HZWpara.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ rm -rf build
22

33
cmake -B build -DCMAKE_INSTALL_PREFIX=/public1/home/t6s000394/jghan/software/abacus-develop/rdmft-abacus/ -DCMAKE_CXX_COMPILER=icpx -DMPI_CXX_COMPILER=mpiicpc -DELPA_DIR=/public1/home/t6s000394/jghan/software/elpa-2021.11/ -DLibxc_DIR=/public1/home/t6s000394/jghan/software/libxc/ -DLIBRI_DIR=/public1/home/t6s000394/jghan/software/LibRI -DLIBCOMM_DIR=/public1/home/t6s000394/jghan/software/LibComm -DCEREAL_INCLUDE_DIR=/public1/home/t6s000394/jghan/software/cereal/cereal-1.3.2/include
44

5-
cmake --build build -j 16 2>job.err
5+
cmake --build build -j 8 2>job.err
66

77
cmake --install build

job.err

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@
3838
/public1/home/t6s000394/jghan/software/abacus-develop/rdmft-abacus/source/module_ri/Exx_LRI.h:83:7: note: declared private here
3939
83 | void cal_exx_ions(const bool write_cv = false);
4040
| ^
41-
/public1/home/t6s000394/jghan/software/abacus-develop/rdmft-abacus/source/module_rdmft/rdmft.cpp:676:27: warning: 'cal_exx_elec' is a private member of 'Exx_LRI<double>' [-Wintel-compat]
42-
676 | Vxc_fromRI_d->cal_exx_elec(Ds_XC_d, *ParaV);
41+
/public1/home/t6s000394/jghan/software/abacus-develop/rdmft-abacus/source/module_rdmft/rdmft.cpp:675:27: warning: 'cal_exx_elec' is a private member of 'Exx_LRI<double>' [-Wintel-compat]
42+
675 | Vxc_fromRI_d->cal_exx_elec(Ds_XC_d, *ParaV);
4343
| ^
4444
/public1/home/t6s000394/jghan/software/abacus-develop/rdmft-abacus/source/module_ri/Exx_LRI.h:84:10: note: declared private here
4545
84 | void cal_exx_elec(const std::vector<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>>& Ds,
4646
| ^
47-
/public1/home/t6s000394/jghan/software/abacus-develop/rdmft-abacus/source/module_rdmft/rdmft.cpp:704:27: warning: 'cal_exx_elec' is a private member of 'Exx_LRI<std::complex<double>>' [-Wintel-compat]
48-
704 | Vxc_fromRI_c->cal_exx_elec(Ds_XC_c, *ParaV);
47+
/public1/home/t6s000394/jghan/software/abacus-develop/rdmft-abacus/source/module_rdmft/rdmft.cpp:703:27: warning: 'cal_exx_elec' is a private member of 'Exx_LRI<std::complex<double>>' [-Wintel-compat]
48+
703 | Vxc_fromRI_c->cal_exx_elec(Ds_XC_c, *ParaV);
4949
| ^
5050
/public1/home/t6s000394/jghan/software/abacus-develop/rdmft-abacus/source/module_ri/Exx_LRI.h:84:10: note: declared private here
5151
84 | void cal_exx_elec(const std::vector<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>>& Ds,
@@ -80,14 +80,14 @@ In file included from /public1/home/t6s000394/jghan/software/abacus-develop/rdmf
8080
/public1/home/t6s000394/jghan/software/abacus-develop/rdmft-abacus/source/module_ri/Exx_LRI.h:83:7: note: declared private here
8181
83 | void cal_exx_ions(const bool write_cv = false);
8282
| ^
83-
/public1/home/t6s000394/jghan/software/abacus-develop/rdmft-abacus/source/module_rdmft/rdmft.cpp:676:27: warning: 'cal_exx_elec' is a private member of 'Exx_LRI<double>' [-Wintel-compat]
84-
676 | Vxc_fromRI_d->cal_exx_elec(Ds_XC_d, *ParaV);
83+
/public1/home/t6s000394/jghan/software/abacus-develop/rdmft-abacus/source/module_rdmft/rdmft.cpp:675:27: warning: 'cal_exx_elec' is a private member of 'Exx_LRI<double>' [-Wintel-compat]
84+
675 | Vxc_fromRI_d->cal_exx_elec(Ds_XC_d, *ParaV);
8585
| ^
8686
/public1/home/t6s000394/jghan/software/abacus-develop/rdmft-abacus/source/module_ri/Exx_LRI.h:84:10: note: declared private here
8787
84 | void cal_exx_elec(const std::vector<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>>& Ds,
8888
| ^
89-
/public1/home/t6s000394/jghan/software/abacus-develop/rdmft-abacus/source/module_rdmft/rdmft.cpp:704:27: warning: 'cal_exx_elec' is a private member of 'Exx_LRI<std::complex<double>>' [-Wintel-compat]
90-
704 | Vxc_fromRI_c->cal_exx_elec(Ds_XC_c, *ParaV);
89+
/public1/home/t6s000394/jghan/software/abacus-develop/rdmft-abacus/source/module_rdmft/rdmft.cpp:703:27: warning: 'cal_exx_elec' is a private member of 'Exx_LRI<std::complex<double>>' [-Wintel-compat]
90+
703 | Vxc_fromRI_c->cal_exx_elec(Ds_XC_c, *ParaV);
9191
| ^
9292
/public1/home/t6s000394/jghan/software/abacus-develop/rdmft-abacus/source/module_ri/Exx_LRI.h:84:10: note: declared private here
9393
84 | void cal_exx_elec(const std::vector<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>>& Ds,
@@ -97,6 +97,6 @@ In file included from /public1/home/t6s000394/jghan/software/abacus-develop/rdmf
9797
/public1/home/t6s000394/jghan/software/abacus-develop/rdmft-abacus/source/module_ri/Matrix_Orbs22.hpp:221:21: warning: 24 enumeration values not handled in switch: 'A1A2B1B2', 'A1A2B2B1', 'A1B1A2B2'... [-Wswitch]
9898
221 | switch(matrix_order)
9999
| ^~~~~~~~~~~~
100-
6 warnings generated.
101100
1 warning generated.
102101
6 warnings generated.
102+
6 warnings generated.

source/module_esolver/esolver_ks.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,9 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
633633
// 12.5) rdmft, add by jghan 2024-04-08/2024-10-09
634634
if ( PARAM.inp.ab_initio_type == "rdmft" )
635635
{
636+
ModuleBase::TITLE("RDMFT", "E & Egradient");
637+
ModuleBase::timer::tick("RDMFT", "E & Egradient");
638+
636639
// if ( (!GlobalC::exx_info.info_global.cal_exx && iter == 1) || one_step_exx )
637640
if ( !GlobalC::exx_info.info_global.cal_exx || (GlobalC::exx_info.info_global.cal_exx && one_step_exx) )
638641
{
@@ -644,12 +647,14 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
644647

645648
this->update_elec_rdmft(occ_number_ks, *(this->psi));
646649

647-
//initialize the gradients of Etotal on wg and wfc, and set all elements to 0.
648-
ModuleBase::matrix E_gradient_occNum(this->pelec->wg.nr, this->pelec->wg.nc, true);
649-
psi::Psi<T> E_gradient_wfc(this->psi->get_nk(), this->psi->get_nbands(), this->psi->get_nbasis());
650-
E_gradient_wfc.zero_out();
650+
//initialize the gradients of Etotal on occupation numbers and wfc, and set all elements to 0.
651+
ModuleBase::matrix dE_dOccNum(this->pelec->wg.nr, this->pelec->wg.nc, true);
652+
psi::Psi<T> dE_dWfc(this->psi->get_nk(), this->psi->get_nbands(), this->psi->get_nbasis());
653+
dE_dWfc.zero_out();
654+
655+
double Etotal_RDMFT = this->run_rdmft(dE_dOccNum, dE_dWfc);
651656

652-
double Etotal_RDMFT = this->Run_rdmft(E_gradient_occNum, E_gradient_wfc);
657+
ModuleBase::timer::tick("RDMFT", "E & Egradient");
653658

654659
// break;
655660
}

source/module_esolver/esolver_ks.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
#include "module_hsolver/hsolver.h"
1010
#include "module_io/cal_test.h"
1111
#include "module_psi/psi.h"
12-
13-
// // add by jghan for rdmft calculation
14-
// #include "module_rdmft/rdmft.h"
15-
1612
#include <fstream>
1713
#include <cstring>
1814
namespace ModuleESolver
@@ -75,7 +71,7 @@ class ESolver_KS : public ESolver_FP
7571
//! <Temporary> It should be replaced by a function in Hamilt Class
7672
virtual void update_pot(const int istep, const int iter) {};
7773

78-
virtual double Run_rdmft(ModuleBase::matrix& E_gradient_occNum, psi::Psi<T>& E_gradient_wfc) { return 0.0; }; // add by jghan, 2024-03-16
74+
virtual double run_rdmft(ModuleBase::matrix& E_gradient_occNum, psi::Psi<T>& E_gradient_wfc) { return 0.0; }; // add by jghan, 2024-03-16
7975

8076
virtual void update_elec_rdmft(const ModuleBase::matrix& occ_number_in, const psi::Psi<T>& wfc_in) {}; // add by jghan, 2024-03-16
8177

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 9 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,148 +1196,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(const int istep)
11961196
ModuleBase::timer::tick("ESolver_KS_LCAO", "out_deepks_labels");
11971197
#endif
11981198

1199-
1200-
// /******** test RDMFT *********/
1201-
1202-
// // esolver_ks_lcao.h(LCAO_Matrix LM), LCAO_matrix.h(Parallel_Orbitals* ParaV)
1203-
// // esolver_fp.h(elecstate::ElecState* pelec), elecstate.h(ModuleBase::matrix wg), this->pelec->wg
1204-
// // esolver_fp.h(elecstate::ElecState* pelec), elecstate.h(Charge* charge), this->pelec->wg
1205-
// // esolver_ks.h(psi::Psi<T>* psi)
1206-
// // esolver_fp.h(K_Vectors kv), kv.kvec_d
1207-
// // esolver_ks_lcao.h(Local_Orbital_Charge LOC)
1208-
// // esolver_ks_lcao.h(LCAO_Hamilt UHM), LCAO_hamilt.h(Gint_Gamma GG, Gint_k GK), this->UHM.GK
1209-
// // used for gamma only algorithms, Gint_Gamma GG. for k-dependent grid integration, Gint_k GK;
1210-
// // esolver_fp.h(ModulePW::PW_Basis* pw_rho, ModulePW::PW_Basis* pw_rhod), this->pw_rho
1211-
// // GlobalC::ppcell.vloc(ModuleBase::matrix vloc),
1212-
// // esolver_fp.h(Structure_Factor sf), structure_factor.h(ModuleBase::ComplexMatrix strucFac), this->sf.strucFac
1213-
// // elecstate::DensityMatrix<TK, double>& *( dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM() )
1214-
// // elecstate.h (Potential* pot, this->pelec->pot)
1215-
1216-
// //initialize the gradients of Etotal on wg and wfc, and set all elements to 0.
1217-
// ModuleBase::matrix E_gradient_occNum(this->pelec->wg.nr, this->pelec->wg.nc, true);
1218-
// psi::Psi<TK> E_gradient_wfc(this->psi->get_nk(), this->psi->get_nbands(), this->psi->get_nbasis());
1219-
// E_gradient_wfc.zero_out();
1220-
// double Etotal_RDMFT = 0.0;
1221-
1222-
// // get natural occupation numbers from wg which considers k point weights and spin, this just proper for nspin=1 !!! or 2 ? in Soild Si, it's correct
1223-
// // wk consider both weight of k-point and spin. When nspin=1, wk[ik] = W_k * 2 . When nspin=2, wk[ik] = W_k
1224-
// ModuleBase::matrix occ_number(this->pelec->wg);
1225-
// for(int ik=0; ik < occ_number.nr; ++ik)
1226-
// {
1227-
// for(int inb=0; inb < this->pelec->wg.nc; ++inb) occ_number(ik, inb) /= this->kv.wk[ik];
1228-
// }
1229-
1230-
// // gamma only calculation
1231-
// if( GlobalV::GAMMA_ONLY_LOCAL )
1232-
// {
1233-
// // when gamma_only, this->psi->get_nbands() = nbasis_local, so we use ParaV get the true nbands_local for wfc
1234-
// const int nbands_local = LM.ParaV->ncol_bands;
1235-
// const int nk_total = this->psi->get_nk();
1236-
// const int nbasis_local = this->psi->get_nbasis();
1237-
1238-
// std::cout << "\n\n\nnk_total= " << nk_total << "\n\n\n";
1239-
1240-
// psi::Psi<TK> wfc_rdmft(nk_total, nbands_local, nbasis_local);
1241-
// for(int ik=0; ik<nk_total; ++ik)
1242-
// {
1243-
// for(int inbn=0; inbn<nbands_local; ++inbn)
1244-
// {
1245-
// for(int inbs=0; inbs<nbasis_local; ++inbs) wfc_rdmft(ik, inbn, inbs) = (*(this->psi))(ik, inbn, inbs);
1246-
// }
1247-
// }
1248-
1249-
// Etotal_RDMFT = rdmftTest::rdmft_cal<TK,TR,Gint_Gamma>(
1250-
// &LM,
1251-
// LM.ParaV,
1252-
// occ_number,
1253-
// this->pelec->wg,
1254-
// wfc_rdmft,
1255-
// E_gradient_occNum,
1256-
// E_gradient_wfc,
1257-
// this->kv,
1258-
// this->UHM.GG,
1259-
// this->LOC,
1260-
// *(this->pelec->charge),
1261-
// *(this->pw_rho),
1262-
// GlobalC::ppcell.vloc,
1263-
// this->sf.strucFac,
1264-
// "HF",
1265-
// 1.0
1266-
// );
1267-
// }
1268-
// // multi-k calculation
1269-
// else
1270-
// {
1271-
// Etotal_RDMFT = rdmftTest::rdmft_cal<TK,TR,Gint_k>(
1272-
// &LM,
1273-
// LM.ParaV,
1274-
// occ_number,
1275-
// this->pelec->wg,
1276-
// *(this->psi),
1277-
// E_gradient_occNum,
1278-
// E_gradient_wfc,
1279-
// this->kv,
1280-
// this->UHM.GK,
1281-
// this->LOC,
1282-
// *(this->pelec->charge),
1283-
// *(this->pw_rho),
1284-
// GlobalC::ppcell.vloc,
1285-
// this->sf.strucFac,
1286-
// "HF",
1287-
// 1.0
1288-
// );
1289-
// }
1290-
1291-
// // GlobalV::ofs_running << "E_one_elec "
1292-
// // << std::setw(10) << pelec->f_en.deband + pelec->f_en.eband << std::endl;
1293-
// // GlobalV::ofs_running << "E_Hartree "
1294-
// // << std::setw(10) << pelec->f_en.hartree_energy << std::endl;
1295-
// // GlobalV::ofs_running << "E_xc "
1296-
// // << std::setw(10) << pelec->f_en.etxc - pelec->f_en.etxcc<< std::endl;
1297-
1298-
// double E_xc_KS = this->pelec->f_en.etxc - this->pelec->f_en.etxcc;
1299-
1300-
// double E_TV_Hartree_EXX = this->pelec->f_en.deband + this->pelec->f_en.eband
1301-
// + this->pelec->f_en.hartree_energy + this->pelec->f_en.exx;
1302-
// double E_TV_Hartree_XC = this->pelec->f_en.deband + this->pelec->f_en.eband
1303-
// + this->pelec->f_en.hartree_energy + this->pelec->f_en.etxc - this->pelec->f_en.etxcc;
1304-
// std::cout << std::fixed << std::setprecision(10) << "\n\n******\nE(one_elec + Hartree + EXX) by KS-DFT: " << E_TV_Hartree_EXX
1305-
// << "\n\nE(one_elec + Hartree + XC) by KS-DFT: " << E_TV_Hartree_XC << "\nExc_KS: " << E_xc_KS << "\n******\n\n" << std::endl;
1306-
1307-
// ModuleBase::TITLE("RDMFT", "E & Egradient");
1308-
// ModuleBase::timer::tick("RDMFT", "E & Egradient");
1309-
1310-
// // // test class rdmft
1311-
// // rdmft_solver.update_elec(occ_number, *(this->psi));
1312-
// // this->Run_rdmft(E_gradient_occNum, E_gradient_wfc);
1313-
// // std::cout << "\nrdmft_solver: " << "0.0000" << std::endl;
1314-
1315-
// // double minus = 0.0;
1316-
1317-
// // // delete in the future
1318-
// // std::cout << "\n\n occ_number(ik, inband): " << std::endl;
1319-
// // for(int ik=0; ik < occ_number.nr; ++ik)
1320-
// // {
1321-
// // for(int inb=0; inb < occ_number.nc; ++inb) std::cout << occ_number(ik, inb) << " ";
1322-
// // std::cout << "\n" << std::endl;
1323-
// // }
1324-
1325-
// // std::cout << "\n\n wg(ik, inband): " << std::endl;
1326-
// // for(int ik=0; ik < occ_number.nr; ++ik)
1327-
// // {
1328-
// // for(int inb=0; inb < occ_number.nc; ++inb)
1329-
// // {
1330-
// // std::cout << this->pelec->wg(ik, inb) << " ";
1331-
// // minus += this->pelec->wg(ik, inb) - occ_number(ik, inb)*this->kv.wk[ik];
1332-
// // }
1333-
// // std::cout << "\n" << std::endl;
1334-
// // }
1335-
1336-
// // if( std::abs(minus) < 1e-12 ) std::cout << "\n\nminus<1e-12, minus: " << minus << std::endl;
1337-
// // else if( std::abs(minus) < 1e-16 ) std::cout << "\n\nminus<1e-16, minus: " << minus << std::endl;
1338-
// // else {std::cout << "\n\nminus is big, minus: " << minus << std::endl;}
1339-
1340-
// ModuleBase::timer::tick("RDMFT", "E & Egradient");
1199+
/******** test RDMFT *********/
13411200

13421201
// rdmft, added by jghan, 2024-10-17
13431202
if ( PARAM.inp.ab_initio_type == "rdmft" )
@@ -1349,15 +1208,15 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(const int istep)
13491208
}
13501209
this->update_elec_rdmft(occ_number_ks, *(this->psi));
13511210

1352-
//initialize the gradients of Etotal on wg and wfc, and set all elements to 0.
1353-
ModuleBase::matrix E_gradient_occNum(this->pelec->wg.nr, this->pelec->wg.nc, true);
1354-
psi::Psi<TK> E_gradient_wfc(this->psi->get_nk(), this->psi->get_nbands(), this->psi->get_nbasis());
1355-
E_gradient_wfc.zero_out();
1211+
//initialize the gradients of Etotal on occupation numbers and wfc, and set all elements to 0.
1212+
ModuleBase::matrix dE_dOccNum(this->pelec->wg.nr, this->pelec->wg.nc, true);
1213+
psi::Psi<T> dE_dWfc(this->psi->get_nk(), this->psi->get_nbands(), this->psi->get_nbasis());
1214+
dE_dWfc.zero_out();
13561215

1357-
double Etotal_RDMFT = this->Run_rdmft(E_gradient_occNum, E_gradient_wfc);
1216+
double Etotal_RDMFT = this->run_rdmft(dE_dOccNum, dE_dWfc);
13581217
}
13591218

1360-
// /******** test RDMFT *********/
1219+
/******** test RDMFT *********/
13611220

13621221

13631222
#ifdef __EXX
@@ -1487,9 +1346,9 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(const int istep)
14871346

14881347

14891348
template <typename TK, typename TR>
1490-
double ESolver_KS_LCAO<TK, TR>::Run_rdmft(ModuleBase::matrix& E_gradient_occNum, psi::Psi<TK>& E_gradient_wfc)
1349+
double ESolver_KS_LCAO<TK, TR>::run_rdmft(ModuleBase::matrix& E_gradient_occNum, psi::Psi<TK>& E_gradient_wfc)
14911350
{
1492-
return rdmft_solver.Run(E_gradient_occNum, E_gradient_wfc);
1351+
return rdmft_solver.run(E_gradient_occNum, E_gradient_wfc);
14931352
}
14941353

14951354
template <typename TK, typename TR>

source/module_esolver/esolver_ks_lcao.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ESolver_KS_LCAO : public ESolver_KS<TK> {
4848

4949
void cal_mag(const int istep, const bool print = false);
5050

51-
virtual double Run_rdmft(ModuleBase::matrix& E_gradient_occNum, psi::Psi<TK>& E_gradient_wfc) override; // add by jghan for rdmft calculation, 2024-03-16
51+
virtual double run_rdmft(ModuleBase::matrix& E_gradient_occNum, psi::Psi<TK>& E_gradient_wfc) override; // add by jghan for rdmft calculation, 2024-03-16
5252

5353
virtual void update_elec_rdmft(const ModuleBase::matrix& occ_number_in, const psi::Psi<TK>& wfc_in) override; // add by jghan for rdmft calculation, 2024-03-16
5454

source/module_rdmft/rdmft.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ void RDMFT<TK, TR>::cal_Energy(const int cal_type)
944944

945945

946946
template <typename TK, typename TR>
947-
double RDMFT<TK, TR>::Run(ModuleBase::matrix& E_gradient_occNum, psi::Psi<TK>& E_gradient_wfc)
947+
double RDMFT<TK, TR>::run(ModuleBase::matrix& E_gradient_occNum, psi::Psi<TK>& E_gradient_wfc)
948948
{
949949
// this->cal_V_hartree();
950950
// this->cal_V_XC();

source/module_rdmft/rdmft.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class RDMFT
206206
void cal_Hk_Hpsi();
207207

208208
// do all calculation after update occNum&wfc, get Etotal and the gradient of energy with respect to the occNum&wfc
209-
double Run(ModuleBase::matrix& E_gradient_occNum, psi::Psi<TK>&E_gradient_wfc);
209+
double run(ModuleBase::matrix& E_gradient_occNum, psi::Psi<TK>&E_gradient_wfc);
210210

211211

212212

0 commit comments

Comments
 (0)