Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into after_scf
  • Loading branch information
YuLiu98 committed Jul 30, 2024
2 parents e22e3a0 + 130562f commit 6468d6a
Show file tree
Hide file tree
Showing 28 changed files with 611 additions and 220 deletions.
9 changes: 9 additions & 0 deletions docs/advanced/opt.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,12 @@ Sometimes we want to do variable-cell relaxation with some of the cell degrees o
- ISIF = 5 : calculation = "cell-relax", fixed_axes = "volume", fixed_atoms = True
- ISIF = 6 : calculation = "cell-relax", fixed_atoms = True
- ISIF = 7 : calculation = "cell-realx", fixed_axes = "shape", fixed_atoms = True

### Stop Geometry Optimization Manually

It is usually difficult to converge when calculating large systems, but people do not want to give up this calculation result.
Providing a file named `EXIT`:
```
stop_ion true
```
ABACUS will end normally and produce a complete file.
2 changes: 2 additions & 0 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ OBJS_CELL=atom_pseudo.o\
atom_spec.o\
pseudo.o\
read_pp.o\
read_pp_complete.o\
read_pp_upf100.o\
read_pp_upf201.o\
read_pp_blps.o\
Expand Down Expand Up @@ -476,6 +477,7 @@ OBJS_IO=input_conv.o\
read_cube.o\
read_rho.o\
read_rhog.o\
read_exit_file.o\
read_wfc_pw.o\
restart.o\
binstream.o\
Expand Down
1 change: 1 addition & 0 deletions source/module_cell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ add_library(
atom_spec.cpp
pseudo.cpp
read_pp.cpp
read_pp_complete.cpp
read_pp_upf100.cpp
read_pp_upf201.cpp
read_pp_blps.cpp
Expand Down
185 changes: 0 additions & 185 deletions source/module_cell/pseudo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,6 @@ pseudo::~pseudo()
delete[] lll;
}

//---------------------------------------------------------------------
void pseudo::set_pseudo()
{
ModuleBase::TITLE("pseudo", "set_pseudo");

// call subroutines
this->set_pseudo_h();
this->set_pseudo_atom();
this->set_pseudo_vl();

if (nbeta == 0) {
return;
}

if (lll == nullptr)
{
lll = new int[nbeta];
assert(lll != nullptr);
}

nh = 0;

for (int nb = 0; nb < nbeta;nb++)
{
nh += 2 * lll [nb] + 1;
}

return;
} // end subroutine set_pseudo_upf

void pseudo::print_pseudo(std::ofstream& ofs)
{
print_pseudo_vl(ofs);
Expand All @@ -63,161 +33,6 @@ void pseudo::print_pseudo(std::ofstream& ofs)
ofs << "\n ----------------------";
}


void pseudo::set_pseudo_h()
{
ModuleBase::TITLE("pseudo","set_pseudo_h");

// mohan update 2021-02-22
// max number of points in the atomic radial mesh
int ndmx = 200000;
if (this->mesh > ndmx)
{
std::cout << "\n set_pseudo_h, too many grid points,";
}

if (this->els == nullptr)
{
this->els = new std::string[nchi];
assert(this->els != nullptr);
}

if (this->lchi == nullptr)
{
this->lchi = new int[this->nchi];
assert(this->lchi != nullptr);
}

if (this->oc == nullptr)
{
this->oc = new double[nchi];
assert(this->oc != nullptr);
}

if (jjj == nullptr) {
this->jjj = new double[nbeta];
assert(this->jjj != nullptr);
assert(!this->has_so);
for (int i=0; i<nbeta; i++)
{
this->jjj[i] = 0;
}
}

if (nn == nullptr) {
this->nn = new int[nchi];
assert(this->nn != nullptr);
assert(!this->has_so);
for (int i=0; i<nchi; i++)
{
this->nn[i] = 0;
}
}

if (jchi == nullptr) {
this->jchi = new double[nchi];
assert(this->jchi != nullptr);
assert(!this->has_so);
for (int i=0; i<nchi; i++)
{
this->jchi[i] = 0;
}
}

return;
} // end subroutine set_pseudo_upf


void pseudo::set_pseudo_atom()
{
ModuleBase::TITLE("pseudo","set_pseudo_atom");

// mohan 2009-12-15
// mohan update again 2011-05-23,
// in order to calculate more accurate Vna.
this->rcut = GlobalV::PSEUDORCUT;//(a.u.);

// remember to update here if you need it.
// rcut = 25.0;

ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"PAO radial cut off (Bohr)",rcut);
if(rcut <= 0.0)
{
ModuleBase::WARNING_QUIT("pseudo_atom::set_pseudo_atom","PAO rcut<=0.0");
}

// chi.create(nchi, mesh);

if (r == nullptr) {
r = new double[mesh];
assert(r != nullptr);
ModuleBase::GlobalFunc::ZEROS(r, mesh);
}

if (rab == nullptr) {
rab = new double[mesh];
assert(rab != nullptr);
ModuleBase::GlobalFunc::ZEROS(rab, mesh);
}

if (rho_at == nullptr) {
rho_at = new double[mesh];
assert(rho_at != nullptr);
ModuleBase::GlobalFunc::ZEROS(rho_at, mesh);
}

if (rho_atc == nullptr) {
rho_atc = new double[mesh];
assert(rho_atc != nullptr);
assert(!nlcc);
ModuleBase::GlobalFunc::ZEROS(rho_atc, mesh);
}

bool br = false;

this->msh = 0;

for (int ir = 0;ir < mesh;ir++)
{
if (r [ir] > rcut)
{
msh = ir + 1;
br = true;
break;
}
}

if (br)
{
// force msh to be odd for simpson integration
msh = 2 * (int)((msh + 1) / 2) - 1; // 5
}
else
{
msh = mesh ;
}

return;
} // end subroutine set_pseudo



void pseudo::set_pseudo_vl()
{
ModuleBase::TITLE("pseudo","set_pseudo_vl");

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

if (vloc_at == nullptr) {
vloc_at = new double[mesh];
assert(vloc_at != nullptr);
}


return;
}


void pseudo::print_pseudo_atom(std::ofstream &ofs)
{
print_pseudo_h(ofs);
Expand Down
5 changes: 0 additions & 5 deletions source/module_cell/pseudo.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ class pseudo
ModuleBase::realArray qfuncl; // qfuncl(2*lmax+1,nbeta*(nbeta+1)/2,mesh) Q_{mu,nu}(|r|) function for |r|> r_L
ModuleBase::matrix qqq; // qqq(nbeta,nbeta) q_{mu,nu}

void set_pseudo_h();
void set_pseudo_atom();
void set_pseudo_vl();
void set_pseudo();

void print_pseudo_h(std::ofstream& ofs);
void print_pseudo_atom(std::ofstream& ofs);
void print_pseudo_vl(std::ofstream& ofs);
Expand Down
3 changes: 1 addition & 2 deletions source/module_cell/read_cell_pseudopots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ void UnitCell::read_cell_pseudopots(const std::string& pp_dir, std::ofstream& lo

if (GlobalV::MY_RANK == 0)
{
atoms[i].ncpp.set_pseudo(); // need to refactor, sunliang 20240716

upf.complete_default(this->atoms[i].ncpp);
log << "\n Read in pseudopotential file is " << pseudo_fn[i] << std::endl;
ModuleBase::GlobalFunc::OUT(log, "pseudopotential type", atoms[i].ncpp.pp_type);
ModuleBase::GlobalFunc::OUT(log, "exchange-correlation functional", atoms[i].ncpp.xc_func);
Expand Down
18 changes: 9 additions & 9 deletions source/module_cell/read_pp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,36 @@ int Pseudopot_upf::init_pseudo_reader(const std::string &fn, std::string &type,
{
set_pseudo_type(fn, type);
}

int info = -1;
// read in the .UPF type of pseudopotentials
// if(GlobalV::global_pseudo_type=="upf")
if (type == "upf")
{
int info = read_pseudo_upf(ifs, pp);
return info;
info = read_pseudo_upf(ifs, pp);
}
// read in the .vwr type of pseudopotentials
// else if(GlobalV::global_pseudo_type=="vwr")
else if (type == "vwr")
{
int info = read_pseudo_vwr(ifs, pp);
return info;
info = read_pseudo_vwr(ifs, pp);
}
// else if(GlobalV::global_pseudo_type=="upf201")
else if (type == "upf201")
{
int info = read_pseudo_upf201(ifs, pp);
return info;
info = read_pseudo_upf201(ifs, pp);
}
// else if(GlobalV::global_pseudo_type=="blps") // sunliang added 2021.7
else if (type == "blps")
{
int info = read_pseudo_blps(ifs, pp);
return info;
info = read_pseudo_blps(ifs, pp);
}
else
{
return 4;
}

return info;
}


Expand Down Expand Up @@ -486,4 +486,4 @@ void Pseudopot_upf::setqfnew(const int& nqf,
}
rho[ir] *= pow(r[ir], l + n);
}
}
}
7 changes: 7 additions & 0 deletions source/module_cell/read_pp.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class Pseudopot_upf
int average_p(const double& lambda, Atom_pseudo& pp); // zhengdy add 2020-10-20
void set_empty_element(Atom_pseudo& pp); // Peize Lin add for bsse 2022.04.07
void set_upf_q(Atom_pseudo& pp); // liuyu add 2023-09-21
void complete_default(Atom_pseudo& pp);

private:
int set_pseudo_type(const std::string& fn, std::string& type);
Expand Down Expand Up @@ -118,6 +119,12 @@ class Pseudopot_upf
const double* qfcoef,
const double* r,
double* rho);

// complete default
// void complete_default(Atom_pseudo& pp);
void complete_default_h(Atom_pseudo& pp);
void complete_default_atom(Atom_pseudo& pp);
void complete_default_vl(Atom_pseudo& pp);
};

#endif //pseudopot_upf class
Loading

0 comments on commit 6468d6a

Please sign in to comment.