Skip to content

Commit 2401e82

Browse files
committed
update cal_pdos_gamma
1 parent 16a91f5 commit 2401e82

File tree

3 files changed

+79
-47
lines changed

3 files changed

+79
-47
lines changed

source/module_io/cal_pdos.h

Lines changed: 0 additions & 17 deletions
This file was deleted.

source/module_io/cal_pdos.cpp renamed to source/module_io/cal_pdos_gamma.cpp

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ void ModuleIO::cal_pdos_gamma(
1212
{
1313
ModuleBase::TITLE("ModuleIO", "cal_pdos_gamma");
1414

15+
assert(nspin0>0);
16+
assert(emax>=emin);
17+
assert(dos_edelta_ev>0.0);
18+
1519
const int npoints = static_cast<int>(std::floor((emax - emin) / dos_edelta_ev));
1620
const int nlocal = PARAM.globalv.nlocal;
1721

@@ -36,9 +40,6 @@ void ModuleIO::cal_pdos_gamma(
3640

3741
double* gauss = new double[npoints];
3842

39-
// get the date pointer of Sk
40-
const double* sk = dynamic_cast<const hamilt::HamiltLCAO<double, double>*>(p_ham)->getSk();
41-
4243
for (int is = 0; is < nspin0; ++is)
4344
{
4445
std::vector<ModuleBase::matrix> mulk;
@@ -119,16 +120,21 @@ void ModuleIO::cal_pdos_gamma(
119120

120121
if (GlobalV::MY_RANK == 0)
121122
{
122-
write_tdos_gamma(pdos);
123-
write_pdos_gamma(pdos);
123+
print_tdos_gamma(pdos);
124+
print_pdos_gamma(pdos);
124125
ModuleIO::write_orb_info(&ucell);
125126
}
126127

127128
delete[] pdos;
128129
}
129130

130131

131-
void write_tdos_gamma()
132+
void write_tdos_gamma(
133+
const ModuleBase::matrix& pdos,
134+
const int nlocal,
135+
const int npoints,
136+
const double& emin,
137+
const double& dos_edelta_ev)
132138
{
133139
ModuleBase::TITLE("ModuleIO", "write_tdos_gamma");
134140

@@ -139,40 +145,47 @@ void write_tdos_gamma()
139145

140146
if (PARAM.inp.nspin == 1 || PARAM.inp.nspin == 4)
141147
{
142-
for (int n = 0; n < npoints; ++n)
148+
for (int in = 0; in < npoints; ++in)
143149
{
144-
double y = 0.0;
145-
double en = emin + n * dos_edelta_ev;
146-
for (int i = 0; i < PARAM.globalv.nlocal; i++)
150+
double dos1 = 0.0;
151+
double en = emin + in * dos_edelta_ev;
152+
for (int iw = 0; iw < nlocal; iw++)
147153
{
148-
y += pdos[0](i, n);
154+
dos1 += pdos[0](iw, in);
149155
}
150156

151-
ofs << std::setw(20) << en << std::setw(30) << y << std::endl;
157+
ofs << std::setw(20) << en
158+
<< std::setw(20) << dos1 << std::endl;
152159
}
153160
}
154161
else if (PARAM.inp.nspin == 2)
155162
{
156-
for (int n = 0; n < npoints; ++n)
163+
for (int in = 0; in < npoints; ++in)
157164
{
158-
double y = 0.0;
159-
double z = 0.0;
160-
double en = emin + n * dos_edelta_ev;
161-
for (int i = 0; i < PARAM.globalv.nlocal; i++)
165+
double dos1 = 0.0;
166+
double dos2 = 0.0;
167+
double en = emin + in * dos_edelta_ev;
168+
for (int iw = 0; iw < nlocal; iw++)
162169
{
163-
y += pdos[0](i, n);
164-
z += pdos[1](i, n);
170+
dos1 += pdos[0](iw, in);
171+
dos2 += pdos[1](iw, in);
165172
}
166173

167174
ofs << std::setw(20) << en
168-
<< std::setw(30) << y
169-
<< std::setw(30) << z << std::endl;
175+
<< std::setw(20) << dos1
176+
<< std::setw(20) << dos2 << std::endl;
170177
}
171178
}
172179
ofs.close();
173180
}
174181

175-
void write_pdos_gamma()
182+
void write_pdos_gamma(
183+
const UnitCell& ucell,
184+
const ModuleBase::matrix& pdos,
185+
const int nlocal,
186+
const int npoints,
187+
const double& emin,
188+
const double& dos_edelta_ev)
176189
{
177190
ModuleBase::TITLE("ModuleIO", "write_pdos_gamma");
178191

@@ -185,11 +198,11 @@ void write_pdos_gamma()
185198

186199
if (PARAM.inp.nspin == 4)
187200
{
188-
ofs << "<norbitals>" << std::setw(2) << PARAM.globalv.nlocal / 2 << "</norbitals>" << std::endl;
201+
ofs << "<norbitals>" << std::setw(2) << nlocal / 2 << "</norbitals>" << std::endl;
189202
}
190203
else
191204
{
192-
ofs << "<norbitals>" << std::setw(2) << PARAM.globalv.nlocal << "</norbitals>" << std::endl;
205+
ofs << "<norbitals>" << std::setw(2) << nlocal << "</norbitals>" << std::endl;
193206
}
194207
ofs << "<energy_values units=\"eV\">" << std::endl;
195208

@@ -199,6 +212,7 @@ void write_pdos_gamma()
199212
double en = emin + n * dos_edelta_ev;
200213
ofs << std::setw(20) << en << std::endl;
201214
}
215+
202216
ofs << "</energy_values>" << std::endl;
203217
for (int i = 0; i < ucell.nat; i++)
204218
{
@@ -213,7 +227,6 @@ void write_pdos_gamma()
213227
const int m1 = atom1->iw2m[j];
214228
const int w = ucell.itiaiw2iwt(t, a, j);
215229

216-
// ofs << "</energy_values>" <<std::endl;
217230
ofs << "<orbital" << std::endl;
218231
ofs << std::setw(6) << "index=\"" << std::setw(40) << w + 1 << "\"" << std::endl;
219232
ofs << std::setw(5) << "atom_index=\"" << std::setw(40) << i + 1 << "\"" << std::endl;
@@ -229,28 +242,28 @@ void write_pdos_gamma()
229242
{
230243

231244
ofs << std::setw(13) << pdos[0](w, n) << std::endl;
232-
} // n
245+
}
233246
}
234247
else if (PARAM.inp.nspin == 2)
235248
{
236249
for (int n = 0; n < npoints; ++n)
237250
{
238251
ofs << std::setw(20) << pdos[0](w, n) << std::setw(30) << pdos[1](w, n) << std::endl;
239-
} // n
252+
}
240253
}
241254
else if (PARAM.inp.nspin == 4)
242255
{
243256
int w0 = w - s0;
244257
for (int n = 0; n < npoints; ++n)
245258
{
246259
ofs << std::setw(20) << pdos[0](s0 + 2 * w0, n) + pdos[0](s0 + 2 * w0 + 1, n) << std::endl;
247-
} // n
260+
}
248261
}
249262

250263
ofs << "</data>" << std::endl;
251264
ofs << "</orbital>" << std::endl;
252-
} // j
253-
} // i
265+
}
266+
}
254267

255268
ofs << "</pdos>" << std::endl;
256269
ofs.close();

source/module_io/cal_pdos_gamma.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#ifndef PDOS_H
2+
#define PDOS_H
3+
4+
#include "module_base/matrix.h"
5+
6+
namespace ModuleIO
7+
{
8+
9+
void cal_pdos_gamma(
10+
const int nspin0,
11+
const double& emax,
12+
const double& emin,
13+
const double& dos_edelta_ev,
14+
const double& bcoeff,
15+
const double* sk,
16+
const psi::Psi<double>* psi,
17+
const Parallel_Orbitals& pv);
18+
19+
void print_tdos_gamma(
20+
const ModuleBase::matrix& pdos,
21+
const int nlocal,
22+
const int npoints,
23+
const double& emin,
24+
const double& dos_edelta_ev);
25+
26+
void print_pdos_gamma(
27+
const UnitCell& ucell,
28+
const ModuleBase::matrix& pdos,
29+
const int nlocal,
30+
const int npoints,
31+
const double& emin,
32+
const double& dos_edelta_ev);
33+
34+
}
35+
36+
#endif

0 commit comments

Comments
 (0)