Skip to content

Commit 6c2f68b

Browse files
authored
Feature: functions needed by uspp (#3026)
* Refactor: rename pseudo_nc to pseudo * Fix: read zv from string with scientific notation * Refactor: rename pseudo_nc to pseudo * Feature: add smooth FFT grid for uspp * Feature: renormalize norm of pseudo-wavefunctions * Test: add unittests for ecutrho/ecutwfc * Test: add unit tests * Test: update unit tests * Fix: mpi bug * Refactor: update NQX * Fix: renormalize norm of wavefunctions
1 parent 398df6d commit 6c2f68b

Some content is hidden

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

55 files changed

+7509
-34653
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
- [wannier\_card](#wannier_card)
3737
- [Plane wave related variables](#plane-wave-related-variables)
3838
- [ecutwfc](#ecutwfc)
39+
- [ecutrho](#ecutrho)
3940
- [nx, ny, nz](#nx-ny-nz)
41+
- [nsx, nsy, nsz](#nsx-nsy-nsz)
4042
- [pw\_seed](#pw_seed)
4143
- [pw\_diag\_thr](#pw_diag_thr)
4244
- [pw\_diag\_nmax](#pw_diag_nmax)
@@ -662,10 +664,22 @@ These variables are used to control the plane wave related parameters.
662664
- **Description**: Energy cutoff for plane wave functions, the unit is **Rydberg**. Note that even for localized orbitals basis, you still need to setup an energy cutoff for this system. Because our local pseudopotential parts and the related force are calculated from plane wave basis set, etc. Also, because our orbitals are generated by matching localized orbitals to a chosen set of wave functions from a certain energy cutoff, this set of localize orbitals is most accurate under this same plane wave energy cutoff.
663665
- **Default**: 50
664666

667+
### ecutrho
668+
669+
- **Type**: Real
670+
- **Description**: Energy cutoff for charge density and potential, the unit is **Rydberg**. For norm-conserving pseudopotential you should stick to the default value, you can reduce it by a little but it will introduce noise especially on forces and stress. For ultrasoft pseudopotential a larger value than the default is often desirable (`ecutrho` = 8 to 12 times `ecutwfc`, typically). The use of gradient-corrected functional, especially in cells with vacuum, or for pseudopotential without non-linear core correction, usually requires an higher values of `ecutrho` to be accurately converged.
671+
- **Default**: 4*ecutwfc
672+
665673
### nx, ny, nz
666674

667675
- **Type**: Integer
668-
- **Description**: If set to a positive number, then the three variables specify the numbers of FFT grid points in x, y, z directions, respectively. If set to 0, the number will be calculated from ecutwfc.
676+
- **Description**: If set to a positive number, then the three variables specify the numbers of FFT grid points in x, y, z directions, respectively. If set to 0, the number will be calculated from ecutrho. Note: you must specify all three dimensions for this setting to be used.
677+
- **Default**: 0
678+
679+
### nsx, nsy, nsz
680+
681+
- **Type**: Integer
682+
- **Description**: If set to a positive number, then the three variables specify the numbers of FFT grid (for the smooth part of charge density in ultrasoft pseudopotential) points in x, y, z directions, respectively. If set to 0, the number will be calculated from ecutwfc. Note: you must specify all three dimensions for this setting to be used.
669683
- **Default**: 0
670684

671685
### pw_seed

source/Makefile.Objects

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ OBJS_BASE=abfs-vector3_order.o\
144144

145145
OBJS_CELL=atom_pseudo.o\
146146
atom_spec.o\
147-
pseudo_nc.o\
147+
pseudo.o\
148148
read_pp.o\
149149
read_pp_upf100.o\
150150
read_pp_upf201.o\

source/module_base/global_variable.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ int md_prec_level = 0;
6161
int SCF_NMAX = 100;
6262

6363
bool use_paw = false;
64+
bool use_uspp = false;
6465

6566
std::string BASIS_TYPE = "pw"; // xiaohui add 2013-09-01
6667
std::string KS_SOLVER = "cg"; // xiaohui add 2013-09-01

source/module_base/global_variable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ extern double relax_scale_force;
5959
extern bool relax_new;
6060

6161
extern bool use_paw;
62+
extern bool use_uspp;
6263

6364
extern bool fixed_atoms;
6465

source/module_cell/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ add_library(
99
OBJECT
1010
atom_pseudo.cpp
1111
atom_spec.cpp
12-
pseudo_nc.cpp
12+
pseudo.cpp
1313
read_pp.cpp
1414
read_pp_upf100.cpp
1515
read_pp_upf201.cpp

source/module_cell/atom_pseudo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void Atom_pseudo::bcast_atom_pseudo(void)
239239
Parallel_Common::bcast_double( vloc_at, mesh);
240240
// == end of pseudo_vl ==
241241

242-
// == pseudo_nc ==
242+
// == pseudo ==
243243
if(GlobalV::MY_RANK != 0)
244244
{
245245
delete[] lll;

source/module_cell/atom_pseudo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
#include "../module_io/output.h"
88
#include "../module_base/complexarray.h"
99
#include "../module_base/complexmatrix.h"
10-
#include "pseudo_nc.h"
10+
#include "pseudo.h"
1111

1212

13-
class Atom_pseudo : public pseudo_nc
13+
class Atom_pseudo : public pseudo
1414
{
1515
public:
1616

source/module_cell/module_symmetry/test/symmetry_test_analysis.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@
2020
***********************************************/
2121
// mock the useless functions
2222
void output::printM3(std::ofstream &ofs, const std::string &description, const ModuleBase::Matrix3 &m){}
23-
pseudo_nc::pseudo_nc(){}
24-
pseudo_nc::~pseudo_nc(){}
23+
pseudo::pseudo()
24+
{
25+
}
26+
pseudo::~pseudo()
27+
{
28+
}
2529
Atom::Atom(){}
2630
Atom::~Atom(){}
2731
Atom_pseudo::Atom_pseudo(){}

source/module_cell/module_symmetry/test/symmetry_test_symtrz.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
***********************************************/
99
// mock the useless functions
1010
void output::printM3(std::ofstream& ofs, const std::string& description, const ModuleBase::Matrix3& m) {}
11-
pseudo_nc::pseudo_nc() {}
12-
pseudo_nc::~pseudo_nc() {}
11+
pseudo::pseudo() {}
12+
pseudo::~pseudo() {}
1313
Atom::Atom() {}
1414
Atom::~Atom() {}
1515
Atom_pseudo::Atom_pseudo() {}

source/module_cell/pseudo_nc.cpp renamed to source/module_cell/pseudo.cpp

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include "pseudo_nc.h"
1+
#include "pseudo.h"
22

3-
pseudo_nc::pseudo_nc()
3+
pseudo::pseudo()
44
{
55
// pseudo_h
66
els = new std::string[1];
@@ -21,11 +21,11 @@ pseudo_nc::pseudo_nc()
2121
rho_at = nullptr;
2222
rho_atc = nullptr;
2323

24-
// pseudo_nc
24+
// pseudo
2525
lll = nullptr;
2626
}
2727

28-
pseudo_nc::~pseudo_nc()
28+
pseudo::~pseudo()
2929
{
3030
// pseudo_h
3131
delete[] els;
@@ -44,19 +44,19 @@ pseudo_nc::~pseudo_nc()
4444
delete[] rho_at;
4545
delete[] rho_atc;
4646

47-
// pseudo_nc
47+
// pseudo
4848
delete[] lll;
4949
}
5050

5151

5252

5353
//---------------------------------------------------------------------
54-
void pseudo_nc::set_pseudo_nc(const Pseudopot_upf &upf)
54+
void pseudo::set_pseudo(const Pseudopot_upf& upf)
5555
{
56-
ModuleBase::TITLE("pseudo_nc","set_pseudo_nc");
56+
ModuleBase::TITLE("pseudo", "set_pseudo");
5757

58-
// call subroutines
59-
this->set_pseudo_h(upf);
58+
// call subroutines
59+
this->set_pseudo_h(upf);
6060
this->set_pseudo_atom(upf);
6161
this->set_pseudo_vl(upf);
6262

@@ -70,14 +70,9 @@ void pseudo_nc::set_pseudo_nc(const Pseudopot_upf &upf)
7070
lll[i] = upf.lll[i];
7171
}
7272

73-
kkbeta = 0;
73+
kkbeta = upf.kkbeta;
7474

75-
for (int nb = 0;nb < nbeta;nb++)
76-
{
77-
kkbeta = (upf.kbeta[nb] > kkbeta) ? upf.kbeta[nb] : kkbeta;
78-
}
79-
80-
betar.create(upf.beta.nr, upf.beta.nc);
75+
betar.create(upf.beta.nr, upf.beta.nc);
8176

8277
// OUT("betar.nr",upf.beta.nr); // nbeta
8378
// OUT("betar.nc",upf.beta.nc); // mesh
@@ -98,11 +93,10 @@ void pseudo_nc::set_pseudo_nc(const Pseudopot_upf &upf)
9893
return;
9994
} // end subroutine set_pseudo_upf
10095

101-
102-
void pseudo_nc::print_pseudo_nc(std::ofstream &ofs)
96+
void pseudo::print_pseudo(std::ofstream& ofs)
10397
{
10498
print_pseudo_vl(ofs);
105-
ofs << "\n pseudo_nc : ";
99+
ofs << "\n pseudo : ";
106100
ofs << "\n kkbeta " << kkbeta;
107101
ofs << "\n nh " << nh;
108102
output::printr1_d(ofs, " lll : ", lll, nbeta);
@@ -112,9 +106,9 @@ void pseudo_nc::print_pseudo_nc(std::ofstream &ofs)
112106
}
113107

114108

115-
void pseudo_nc::set_pseudo_h(const Pseudopot_upf &upf)
109+
void pseudo::set_pseudo_h(const Pseudopot_upf &upf)
116110
{
117-
ModuleBase::TITLE("pseudo_nc","set_pseudo_h");
111+
ModuleBase::TITLE("pseudo","set_pseudo_h");
118112
// set pseudopotential for each atom type
119113
// by using the Unified Pseudopotential Format
120114

@@ -221,9 +215,9 @@ void pseudo_nc::set_pseudo_h(const Pseudopot_upf &upf)
221215
} // end subroutine set_pseudo_upf
222216

223217

224-
void pseudo_nc::set_pseudo_atom(const Pseudopot_upf &upf)
218+
void pseudo::set_pseudo_atom(const Pseudopot_upf &upf)
225219
{
226-
ModuleBase::TITLE("pseudo_nc","set_pseudo_atom");
220+
ModuleBase::TITLE("pseudo","set_pseudo_atom");
227221

228222
// mohan 2009-12-15
229223
// mohan update again 2011-05-23,
@@ -323,9 +317,9 @@ void pseudo_nc::set_pseudo_atom(const Pseudopot_upf &upf)
323317

324318

325319

326-
void pseudo_nc::set_pseudo_vl(const Pseudopot_upf &upf)
320+
void pseudo::set_pseudo_vl(const Pseudopot_upf &upf)
327321
{
328-
ModuleBase::TITLE("pseudo_nc","set_pseudo_vl");
322+
ModuleBase::TITLE("pseudo","set_pseudo_vl");
329323

330324
assert(mesh>0);//mohan add 2021-05-01
331325

@@ -342,7 +336,7 @@ void pseudo_nc::set_pseudo_vl(const Pseudopot_upf &upf)
342336
}
343337

344338

345-
void pseudo_nc::print_pseudo_atom(std::ofstream &ofs)
339+
void pseudo::print_pseudo_atom(std::ofstream &ofs)
346340
{
347341
print_pseudo_h(ofs);
348342
ofs << "\n pseudo_atom : ";
@@ -358,15 +352,15 @@ void pseudo_nc::print_pseudo_atom(std::ofstream &ofs)
358352
}
359353

360354

361-
void pseudo_nc::print_pseudo_vl(std::ofstream &ofs)
355+
void pseudo::print_pseudo_vl(std::ofstream &ofs)
362356
{
363357
ofs << "\n pseudo_vl:";
364358
print_pseudo_atom(ofs);
365359
output::printr1_d(ofs, "vloc_at : ", vloc_at, mesh);
366360
ofs << "\n ----------------------------------- ";
367361
}
368362

369-
void pseudo_nc::print_pseudo_h(std::ofstream &ofs)
363+
void pseudo::print_pseudo_h(std::ofstream &ofs)
370364
{
371365
ofs << "\n pseudo_info :";
372366
ofs << "\n nv " << nv;

0 commit comments

Comments
 (0)