Skip to content

Commit 55d3c09

Browse files
authored
Merge pull request #794 from maki49/develop
add output of realspace pw-wavefunction in ienvelope after lcao calculation
2 parents fded737 + 12be8a8 commit 55d3c09

File tree

8 files changed

+237
-223
lines changed

8 files changed

+237
-223
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ on:
1111
- planewave
1212
- pw_refactor
1313
- TDDFT
14-
jobs:
1514

1615
jobs:
1716
test:

doc/input-main.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,13 @@ This part of variables are used to control the output of properties.
783783
[back to top](#input-file)
784784
- out_wf<a id="out-wf"></a>
785785
- *Type*: Integer
786-
- *Description*: Only used in **planewave basis** set. When set this variable to 1, it outputs the coefficients of wave functions into text files. The file names are WAVEFUNC$K.txt, where $K is the index of k point. When set this variable to 2, results are stored in binary files. The file names are WAVEFUNC$K.dat.
786+
- *Description*: Only used in **planewave basis** and **ienvelope calculation in localized orbitals** set. When set this variable to 1, it outputs the coefficients of wave functions into text files. The file names are WAVEFUNC$K.txt, where $K is the index of k point. When set this variable to 2, results are stored in binary files. The file names are WAVEFUNC$K.dat.
787+
- *Default*: 0
788+
789+
[back to top](#input-file)
790+
- out_wf_r<a id="out-wf-r"></a>
791+
- *Type*: Integer
792+
- *Description*: Only used in **planewave basis** and **ienvelope calculation in localized orbitals** set. When set this variable to 1, it outputs real-space wave functions into `OUT.suffix/wfc_realspace/`. The file names are wfc_realspace$K$B, where $K is the index of k point, $B is the index of band.
787793
- *Default*: 0
788794
789795
[back to top](#input-file)

source/src_io/istate_envelope.cpp

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "../module_base/global_function.h"
44
#include "../module_base/global_variable.h"
55
#include "src_io/wf_io.h"
6+
#include "src_io/write_wfc_realspace.h"
67

78
IState_Envelope::IState_Envelope()
89
{}
@@ -11,7 +12,7 @@ IState_Envelope::~IState_Envelope()
1112
{}
1213

1314

14-
void IState_Envelope::begin(Local_Orbital_wfc &lowf, Gint_Gamma &gg, int& out_wf)
15+
void IState_Envelope::begin(Local_Orbital_wfc &lowf, Gint_Gamma &gg, int& out_wf, int& out_wf_r)
1516
{
1617
ModuleBase::TITLE("IState_Envelope","begin");
1718

@@ -77,7 +78,7 @@ void IState_Envelope::begin(Local_Orbital_wfc &lowf, Gint_Gamma &gg, int& out_wf
7778
//for pw-wfc in G space
7879
ModuleBase::ComplexMatrix* pw_wfc_g;
7980

80-
if (out_wf)
81+
if (out_wf || out_wf_r)
8182
{
8283
pw_wfc_g = new ModuleBase::ComplexMatrix[GlobalC::kv.nks];
8384
for (int ik = 0;ik < GlobalC::kv.nks;++ik)
@@ -118,23 +119,27 @@ void IState_Envelope::begin(Local_Orbital_wfc &lowf, Gint_Gamma &gg, int& out_wf
118119
bool for_plot = true;
119120
GlobalC::CHR.write_rho(GlobalC::CHR.rho_save[is], is, 0, ss.str(), 3, for_plot);
120121

121-
if (out_wf) //only for gamma_only now
122+
if (out_wf || out_wf_r) //only for gamma_only now
122123
this->set_pw_wfc(GlobalC::pw, 0, ib, GlobalV::NSPIN, GlobalC::kv.ngk[0],
123124
GlobalC::CHR.rho_save, pw_wfc_g[0]);
124125
}
125126
}
126127
}
127128

128-
if (out_wf)
129+
if (out_wf || out_wf_r)
129130
{
130-
std::stringstream ssw;
131-
ssw << GlobalV::global_out_dir << "WAVEFUNC";
132-
std::cout << " write pw wavefunction into \"" <<
133-
GlobalV::global_out_dir << "/" << ssw.str() << "\" files." << std::endl;
134-
WF_io::write_wfc2(ssw.str(), pw_wfc_g, GlobalC::pw.gcar);
131+
if (out_wf)
132+
{
133+
std::stringstream ssw;
134+
ssw << GlobalV::global_out_dir << "WAVEFUNC";
135+
std::cout << " write G-space wavefunction into \"" <<
136+
GlobalV::global_out_dir << "/" << ssw.str() << "\" files." << std::endl;
137+
WF_io::write_wfc2(ssw.str(), pw_wfc_g, GlobalC::pw.gcar);
138+
}
139+
if(out_wf_r)
140+
Write_Wfc_Realspace::write_wfc_realspace_1(pw_wfc_g, "wfc_realspace", false);
135141
delete[] pw_wfc_g;
136-
}
137-
142+
}
138143

139144
delete[] bands_picked;
140145
for(int is=0; is<GlobalV::NSPIN; ++is)
@@ -163,10 +168,10 @@ void IState_Envelope::set_pw_wfc(PW_Basis& pwb,
163168
Porter[ir] += std::complex<double>(rho[is][ir], 0.0);
164169

165170
//call FFT
166-
pwb.FFT_chg.FFT3D(Porter.data(), -1);
171+
pwb.FFT_wfc.FFT3D(Porter.data(), -1);
167172

168173
// set pw_wfc_g
169174
// ig2fftw: the index map from i_ngk(local) to i_ngmw(local)
170175
for (int ig = 0;ig < ngk;++ig) // is it right (check local index)???
171-
wfc_g(ib,ig) += Porter[pwb.ig2fftw[GlobalC::wf.igk(ik, ig)]]; //any factor??
176+
wfc_g(ib,ig) = Porter[pwb.ig2fftw[GlobalC::wf.igk(ik, ig)]];
172177
}

source/src_io/istate_envelope.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class IState_Envelope
1010
IState_Envelope();
1111
~IState_Envelope();
1212

13-
void begin(Local_Orbital_wfc& lowf, Gint_Gamma& gg, int & out_wf);
14-
13+
void begin(Local_Orbital_wfc& lowf, Gint_Gamma& gg, int& out_wf, int& out_wf_r);
14+
1515
private:
1616
bool *bands_picked;
1717

0 commit comments

Comments
 (0)