Skip to content

Commit f158182

Browse files
authored
Update the output and readin of electronic wave functions in plane wave basis set (#6223)
* update the readin wave function information * remove the extra write_wfc_pw in esolver_ks_pw * let GPU OW test passes * update the output formats of pw wave functions * update pw readin wf, found 2 places that read in wave functions, need to be refactored in near future * update 055 example * update doc * update input files and fix compilation error * update input-main.md * update 090 example * update 090 example * update some tests in 01 * update CASES * update file names in 08_EXX example * I found read_wfc_lcao code and the corresponding tests are useless * update test.yml * update read_wf2rho_pw function and tests * rewrite the input variables for write_wfc_pw * update read_wfc_pw * remove ofs_running info * fix read_wf2rho_pw_test.cpp * fix bug * update read_input_ptest.cpp test * add back wfs1k1_pw.dat * update 055_PW_OW result.ref
1 parent dcbeb06 commit f158182

File tree

239 files changed

+1098
-880
lines changed

Some content is hidden

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

239 files changed

+1098
-880
lines changed

.github/workflows/test.yml

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,41 @@ jobs:
4949
cmake --build build -j8
5050
cmake --install build
5151
52-
- name: Integrated Test
52+
- name: Integrated Tests Preparation
5353
env:
5454
GTEST_COLOR: 'yes'
5555
OMP_NUM_THREADS: '2'
5656
run: |
5757
cmake --build build --target test ARGS="-V --timeout 1700 -R integrated_test"
5858
59+
- name: Module_Base Unittests
60+
env:
61+
GTEST_COLOR: 'yes'
62+
OMP_NUM_THREADS: '2'
63+
run: |
64+
cmake --build build --target test ARGS="-V --timeout 1700 -R MODULE_BASE"
65+
66+
- name: Module_IO Unittests
67+
env:
68+
GTEST_COLOR: 'yes'
69+
OMP_NUM_THREADS: '2'
70+
run: |
71+
cmake --build build --target test ARGS="-V --timeout 1700 -R MODULE_IO"
72+
73+
- name: Module_HSolver Unittests
74+
env:
75+
GTEST_COLOR: 'yes'
76+
OMP_NUM_THREADS: '2'
77+
run: |
78+
cmake --build build --target test ARGS="-V --timeout 1700 -R MODULE_HSOLVER"
79+
80+
- name: Module_Cell Unittests
81+
env:
82+
GTEST_COLOR: 'yes'
83+
OMP_NUM_THREADS: '2'
84+
run: |
85+
cmake --build build --target test ARGS="-V --timeout 1700 -R MODULE_CELL"
86+
5987
- name: 01_PW Test
6088
env:
6189
GTEST_COLOR: 'yes'
@@ -126,35 +154,7 @@ jobs:
126154
run: |
127155
cmake --build build --target test ARGS="-V --timeout 1700 -R 10_others"
128156
129-
- name: Module Base Unit Test
130-
env:
131-
GTEST_COLOR: 'yes'
132-
OMP_NUM_THREADS: '2'
133-
run: |
134-
cmake --build build --target test ARGS="-V --timeout 1700 -R MODULE_BASE"
135-
136-
- name: Module IO Unit Test
137-
env:
138-
GTEST_COLOR: 'yes'
139-
OMP_NUM_THREADS: '2'
140-
run: |
141-
cmake --build build --target test ARGS="-V --timeout 1700 -R MODULE_IO"
142-
143-
- name: Module HSolver Unit Test
144-
env:
145-
GTEST_COLOR: 'yes'
146-
OMP_NUM_THREADS: '2'
147-
run: |
148-
cmake --build build --target test ARGS="-V --timeout 1700 -R MODULE_HSOLVER"
149-
150-
- name: Module Cell Unit Test
151-
env:
152-
GTEST_COLOR: 'yes'
153-
OMP_NUM_THREADS: '2'
154-
run: |
155-
cmake --build build --target test ARGS="-V --timeout 1700 -R MODULE_CELL"
156-
157-
- name: Other Unit Tests
157+
- name: Other Unittests
158158
env:
159159
GTEST_COLOR: 'yes'
160160
OMP_NUM_THREADS: '2'

docs/advanced/input_files/input-main.md

Lines changed: 59 additions & 56 deletions
Large diffs are not rendered by default.

source/Makefile.Objects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ OBJS_IO=input_conv.o\
561561
read_set_globalv.o\
562562
orb_io.o\
563563
cal_pLpR.o\
564+
filename.o\
564565

565566
OBJS_IO_LCAO=cal_r_overlap_R.o\
566567
write_orb_info.o\

source/module_elecstate/module_charge/charge_init.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,16 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
243243
{
244244
ModuleBase::WARNING_QUIT("Charge::init_rho", "wfc is only supported for PW-KSDFT.");
245245
}
246+
246247
const ModulePW::PW_Basis_K* pw_wfc = reinterpret_cast<ModulePW::PW_Basis_K*>(const_cast<void*>(wfcpw));
247248
const K_Vectors* kv = reinterpret_cast<const K_Vectors*>(klist);
248-
const int nkstot = kv->get_nkstot();
249-
const std::vector<int>& isk = kv->isk;
250-
ModuleIO::read_wf2rho_pw(pw_wfc, symm, kv->ik2iktot.data(), nkstot, isk, *this);
249+
250+
ModuleIO::read_wf2rho_pw(pw_wfc, symm, *this,
251+
PARAM.globalv.global_readin_dir,
252+
GlobalV::KPAR, GlobalV::MY_POOL, GlobalV::MY_RANK,
253+
GlobalV::NPROC_IN_POOL, GlobalV::RANK_IN_POOL,
254+
PARAM.inp.nbands, PARAM.inp.nspin, PARAM.globalv.npol,
255+
kv->get_nkstot(),kv->ik2iktot,kv->isk,GlobalV::ofs_running);
251256
}
252257
}
253258

source/module_esolver/esolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ std::string determine_type()
9696
ModuleBase::WARNING_QUIT("ESolver", "No such esolver_type combined with basis_type");
9797
}
9898

99-
GlobalV::ofs_running << "\n The esolver type: " << esolver_type << std::endl;
99+
GlobalV::ofs_running << "\n Energy Solver:" << esolver_type << std::endl;
100100

101101
auto device_info = PARAM.inp.device;
102102

source/module_esolver/esolver_ks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void ESolver_KS<T, Device>::before_all_runners(UnitCell& ucell, const Input_para
5858
ESolver_FP::before_all_runners(ucell, inp);
5959

6060
classname = "ESolver_KS";
61-
basisname = "PLEASE ADD BASISNAME FOR CURRENT ESOLVER.";
61+
basisname = "";
6262

6363
scf_thr = PARAM.inp.scf_thr;
6464
scf_ene_thr = PARAM.inp.scf_ene_thr;

source/module_esolver/esolver_ks_lcaopw.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "module_io/nscf_band.h"
66
#include "module_io/output_log.h"
77
#include "module_io/write_istate_info.h"
8-
#include "module_io/write_wfc_pw.h"
98

109
#include <iostream>
1110

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -647,15 +647,14 @@ void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int
647647
//----------------------------------------------------------
648648
// 3) Print out electronic wavefunctions in pw basis
649649
//----------------------------------------------------------
650-
if (PARAM.inp.out_wfc_pw == 1 || PARAM.inp.out_wfc_pw == 2)
651-
{
652-
if (iter % PARAM.inp.out_freq_elec == 0 || iter == PARAM.inp.scf_nmax || conv_esolver)
653-
{
654-
std::stringstream ssw;
655-
ssw << PARAM.globalv.global_out_dir << "WAVEFUNC";
656-
ModuleIO::write_wfc_pw(ssw.str(), this->psi[0], this->kv, this->pw_wfc);
657-
}
658-
}
650+
if (iter % PARAM.inp.out_freq_elec == 0 || iter == PARAM.inp.scf_nmax || conv_esolver)
651+
{
652+
ModuleIO::write_wfc_pw(GlobalV::KPAR, GlobalV::MY_POOL, GlobalV::MY_RANK,
653+
PARAM.inp.nbands, PARAM.inp.nspin, PARAM.globalv.npol,
654+
GlobalV::RANK_IN_POOL, GlobalV::NPROC_IN_POOL,
655+
PARAM.inp.out_wfc_pw, PARAM.inp.ecutwfc, PARAM.globalv.global_out_dir,
656+
this->psi[0], this->kv, this->pw_wfc, GlobalV::ofs_running);
657+
}
659658

660659
//----------------------------------------------------------
661660
// 4) check if oscillate for delta_spin method
@@ -709,17 +708,7 @@ void ESolver_KS_PW<T, Device>::after_scf(UnitCell& ucell, const int istep, const
709708
}
710709

711710
//------------------------------------------------------------------
712-
// 4) output wavefunctions in pw basis
713-
//------------------------------------------------------------------
714-
if (PARAM.inp.out_wfc_pw == 1 || PARAM.inp.out_wfc_pw == 2)
715-
{
716-
std::stringstream ssw;
717-
ssw << PARAM.globalv.global_out_dir << "WAVEFUNC";
718-
ModuleIO::write_wfc_pw(ssw.str(), this->psi[0], this->kv, this->pw_wfc);
719-
}
720-
721-
//------------------------------------------------------------------
722-
// 5) calculate band-decomposed (partial) charge density in pw basis
711+
// 4) calculate band-decomposed (partial) charge density in pw basis
723712
//------------------------------------------------------------------
724713
const std::vector<int> out_pchg = PARAM.inp.out_pchg;
725714
if (out_pchg.size() > 0)
@@ -747,8 +736,16 @@ void ESolver_KS_PW<T, Device>::after_scf(UnitCell& ucell, const int istep, const
747736
PARAM.inp.if_separate_k);
748737
}
749738

739+
740+
// tmp 2025-05-17, mohan note
741+
ModuleIO::write_wfc_pw(GlobalV::KPAR, GlobalV::MY_POOL, GlobalV::MY_RANK,
742+
PARAM.inp.nbands, PARAM.inp.nspin, PARAM.globalv.npol,
743+
GlobalV::RANK_IN_POOL, GlobalV::NPROC_IN_POOL,
744+
PARAM.inp.out_wfc_pw, PARAM.inp.ecutwfc, PARAM.globalv.global_out_dir,
745+
this->psi[0], this->kv, this->pw_wfc, GlobalV::ofs_running);
746+
750747
//------------------------------------------------------------------
751-
//! 6) calculate Wannier functions in pw basis
748+
//! 5) calculate Wannier functions in pw basis
752749
//------------------------------------------------------------------
753750
if (PARAM.inp.calculation == "nscf" && PARAM.inp.towannier90)
754751
{
@@ -766,7 +763,7 @@ void ESolver_KS_PW<T, Device>::after_scf(UnitCell& ucell, const int istep, const
766763
}
767764

768765
//------------------------------------------------------------------
769-
//! 7) calculate Berry phase polarization in pw basis
766+
//! 6) calculate Berry phase polarization in pw basis
770767
//------------------------------------------------------------------
771768
if (PARAM.inp.calculation == "nscf" && berryphase::berry_phase_flag && ModuleSymmetry::Symmetry::symm_flag != 1)
772769
{
@@ -777,7 +774,7 @@ void ESolver_KS_PW<T, Device>::after_scf(UnitCell& ucell, const int istep, const
777774
}
778775

779776
//------------------------------------------------------------------
780-
// 8) write spin constrian results in pw basis
777+
// 7) write spin constrian results in pw basis
781778
// spin constrain calculations, write atomic magnetization and magnetic force.
782779
//------------------------------------------------------------------
783780
if (PARAM.inp.sc_mag_switch)
@@ -789,7 +786,7 @@ void ESolver_KS_PW<T, Device>::after_scf(UnitCell& ucell, const int istep, const
789786
}
790787

791788
//------------------------------------------------------------------
792-
// 9) write onsite occupations for charge and magnetizations
789+
// 8) write onsite occupations for charge and magnetizations
793790
//------------------------------------------------------------------
794791
if (PARAM.inp.onsite_radius > 0)
795792
{ // float type has not been implemented

source/module_esolver/pw_others.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "module_io/nscf_band.h"
77
#include "module_io/output_log.h"
88
#include "module_io/write_istate_info.h"
9-
#include "module_io/write_wfc_pw.h"
109

1110
#include <iostream>
1211

source/module_io/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ list(APPEND objects
3333
para_json.cpp
3434
parse_args.cpp
3535
orb_io.cpp
36+
filename.cpp
3637
)
3738

3839
list(APPEND objects_advanced

0 commit comments

Comments
 (0)