Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions source/module_cell/read_atoms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
#endif
#include <cstring> // Peize Lin fix bug about strcmp 2016-08-02

#ifdef __LCAO
void UnitCell_pseudo::read_atom_species(std::ifstream &ifa, std::ofstream &ofs_running, LCAO_Orbitals &orb )
#else
void UnitCell_pseudo::read_atom_species(std::ifstream &ifa, std::ofstream &ofs_running)
#endif
{
ModuleBase::TITLE("UnitCell_pseudo","read_atom_species");

Expand Down Expand Up @@ -53,7 +57,7 @@ void UnitCell_pseudo::read_atom_species(std::ifstream &ifa, std::ofstream &ofs_r
{
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "NUMERICAL_ORBITAL") )
{
GlobalC::ORB.read_in_flag = true;
orb.read_in_flag = true;
for(int i=0; i<ntype; i++)
{
std::string ofile;
Expand All @@ -73,13 +77,13 @@ void UnitCell_pseudo::read_atom_species(std::ifstream &ifa, std::ofstream &ofs_r
//-----------------------------------
//ModuleBase::GlobalFunc::READ_VALUE(ifa, nfile);

GlobalC::ORB.orbital_file.push_back(ofile);
orb.orbital_file.push_back(ofile);

//-----------------------------------
// Turn off the read in NONLOCAL file
// function since 2013-08-02 by mohan
//-----------------------------------
//GlobalC::ORB.nonlocal_file.push_back(nfile);
//orb.nonlocal_file.push_back(nfile);

// GlobalV::ofs_running << " For atom type " << i + 1 << std::endl;
// GlobalV::ofs_running << " Read in numerical orbitals from file " << ofile << std::endl;
Expand All @@ -89,11 +93,12 @@ void UnitCell_pseudo::read_atom_species(std::ifstream &ifa, std::ofstream &ofs_r
}
// caoyu add 2021-03-16
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "NUMERICAL_DESCRIPTOR")) {
ifa >> GlobalC::ORB.descriptor_file;
ifa >> orb.descriptor_file;
}
}

// Peize Lin add 2016-09-23
#ifndef __CELL
if( Exx_Global::Hybrid_Type::HF == GlobalC::exx_lcao.info.hybrid_type ||
Exx_Global::Hybrid_Type::PBE0 == GlobalC::exx_lcao.info.hybrid_type ||
Exx_Global::Hybrid_Type::HSE == GlobalC::exx_lcao.info.hybrid_type )
Expand All @@ -108,6 +113,7 @@ void UnitCell_pseudo::read_atom_species(std::ifstream &ifa, std::ofstream &ofs_r
}
}
}
#endif
#endif
//==========================
// read in lattice constant
Expand Down Expand Up @@ -338,7 +344,11 @@ void UnitCell_pseudo::read_atom_species(std::ifstream &ifa, std::ofstream &ofs_r
// Read atomic positions
// return 1: no problem.
// return 0: some problems.
#ifdef __LCAO
bool UnitCell_pseudo::read_atom_positions(std::ifstream &ifpos, std::ofstream &ofs_running, std::ofstream &ofs_warning, LCAO_Orbitals &orb)
#else
bool UnitCell_pseudo::read_atom_positions(std::ifstream &ifpos, std::ofstream &ofs_running, std::ofstream &ofs_warning)
#endif
{
ModuleBase::TITLE("UnitCell_pseudo","read_atom_positions");

Expand Down Expand Up @@ -452,13 +462,13 @@ bool UnitCell_pseudo::read_atom_positions(std::ifstream &ifpos, std::ofstream &o
#ifdef __LCAO
if (GlobalV::BASIS_TYPE == "lcao" || GlobalV::BASIS_TYPE == "lcao_in_pw")
{
std::ifstream ifs(GlobalC::ORB.orbital_file[it].c_str(), ios::in); // pengfei 2014-10-13
std::ifstream ifs(orb.orbital_file[it].c_str(), ios::in); // pengfei 2014-10-13

// mohan add return 2021-04-26
if (!ifs)
{
std::cout << " Element index " << it+1 << std::endl;
std::cout << " orbital file: " << GlobalC::ORB.orbital_file[it] << std::endl;
std::cout << " orbital file: " << orb.orbital_file[it] << std::endl;
ModuleBase::WARNING("read_atom_positions","ABACUS Cannot find the ORBITAL file (basis sets)");
return 0; // means something wrong
}
Expand Down Expand Up @@ -820,7 +830,11 @@ bool UnitCell_pseudo::check_tau(void)const
return 1;
}

#ifdef __LCAO
void UnitCell_pseudo::print_stru_file(const std::string &fn, const LCAO_Orbitals &orb, const int &type)const
#else
void UnitCell_pseudo::print_stru_file(const std::string &fn, const int &type)const
#endif
{
ModuleBase::TITLE("UnitCell_pseudo","print_stru_file");

Expand All @@ -847,9 +861,9 @@ void UnitCell_pseudo::print_stru_file(const std::string &fn, const int &type)con
// Turn off the read in NONLOCAL file
// function since 2013-08-02 by mohan
//-----------------------------------
// ofs << GlobalC::ORB.orbital_file[it] << " " << GlobalC::ORB.nonlocal_file[it] << " #local_orbital; non-local projector" << std::endl;
// ofs << orb.orbital_file[it] << " " << orb.nonlocal_file[it] << " #local_orbital; non-local projector" << std::endl;
//modified by zhengdy 2015-07-24
ofs << GlobalC::ORB.orbital_file[it] << std::endl;
ofs << orb.orbital_file[it] << std::endl;
}
}
#endif
Expand Down
126 changes: 74 additions & 52 deletions source/module_cell/unitcell_pseudo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ UnitCell_pseudo::~UnitCell_pseudo()
//Calculate various lattice related quantities for given latvec
//==============================================================
void UnitCell_pseudo::setup_cell(
#ifdef __LCAO
LCAO_Orbitals &orb,
#endif
const std::string &s_pseudopot_dir,
output &outp,
const std::string &fn,
Expand Down Expand Up @@ -62,32 +65,40 @@ void UnitCell_pseudo::setup_cell(
if(ok)
{

GlobalV::ofs_running << "\n\n\n\n";
GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
GlobalV::ofs_running << " | |" << std::endl;
GlobalV::ofs_running << " | Reading atom information in unitcell: |" << std::endl;
GlobalV::ofs_running << " | From the input file and the structure file we know the number of |" << std::endl;
GlobalV::ofs_running << " | different elments in this unitcell, then we list the detail |" << std::endl;
GlobalV::ofs_running << " | information for each element, especially the zeta and polar atomic |" << std::endl;
GlobalV::ofs_running << " | orbital number for each element. The total atom number is counted. |" << std::endl;
GlobalV::ofs_running << " | We calculate the nearest atom distance for each atom and show the |" << std::endl;
GlobalV::ofs_running << " | Cartesian and Direct coordinates for each atom. We list the file |" << std::endl;
GlobalV::ofs_running << " | address for atomic orbitals. The volume and the lattice vectors |" << std::endl;
GlobalV::ofs_running << " | in real and reciprocal space is also shown. |" << std::endl;
GlobalV::ofs_running << " | |" << std::endl;
GlobalV::ofs_running << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
GlobalV::ofs_running << "\n\n\n\n";

GlobalV::ofs_running << " READING UNITCELL INFORMATION" << std::endl;
log << "\n\n\n\n";
log << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
log << " | |" << std::endl;
log << " | Reading atom information in unitcell: |" << std::endl;
log << " | From the input file and the structure file we know the number of |" << std::endl;
log << " | different elments in this unitcell, then we list the detail |" << std::endl;
log << " | information for each element, especially the zeta and polar atomic |" << std::endl;
log << " | orbital number for each element. The total atom number is counted. |" << std::endl;
log << " | We calculate the nearest atom distance for each atom and show the |" << std::endl;
log << " | Cartesian and Direct coordinates for each atom. We list the file |" << std::endl;
log << " | address for atomic orbitals. The volume and the lattice vectors |" << std::endl;
log << " | in real and reciprocal space is also shown. |" << std::endl;
log << " | |" << std::endl;
log << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
log << "\n\n\n\n";

log << " READING UNITCELL INFORMATION" << std::endl;
//========================
// call read_atom_species
//========================
this->read_atom_species(ifa, GlobalV::ofs_running);
#ifdef __LCAO
this->read_atom_species(ifa, log, orb);
#else
this->read_atom_species(ifa, log);
#endif

//==========================
// call read_atom_positions
//==========================
ok2 = this->read_atom_positions(ifa, GlobalV::ofs_running, GlobalV::ofs_warning);
#ifdef __LCAO
ok2 = this->read_atom_positions(ifa, log, GlobalV::ofs_warning, orb);
#else
ok2 = this->read_atom_positions(ifa, log, GlobalV::ofs_warning);
#endif

if(ok2)
{
Expand Down Expand Up @@ -121,7 +132,7 @@ void UnitCell_pseudo::setup_cell(

// mohan add 2010-09-29
#ifdef __LCAO
GlobalC::ORB.bcast_files(ntype, GlobalV::MY_RANK);
orb.bcast_files(ntype, GlobalV::MY_RANK);
#endif
#endif

Expand All @@ -138,9 +149,9 @@ void UnitCell_pseudo::setup_cell(
}
else
{
GlobalV::ofs_running << std::endl;
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Volume (Bohr^3)", this->omega);
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Volume (A^3)", this->omega * pow(ModuleBase::BOHR_TO_A, 3));
log << std::endl;
ModuleBase::GlobalFunc::OUT(log,"Volume (Bohr^3)", this->omega);
ModuleBase::GlobalFunc::OUT(log,"Volume (A^3)", this->omega * pow(ModuleBase::BOHR_TO_A, 3));
}

//==========================================================
Expand All @@ -158,31 +169,31 @@ void UnitCell_pseudo::setup_cell(
this->GGT0 = G * GT;
this->invGGT0 = GGT.Inverse();

GlobalV::ofs_running << std::endl;
outp.printM3(GlobalV::ofs_running,"Lattice vectors: (Cartesian coordinate: in unit of a_0)",latvec);
outp.printM3(GlobalV::ofs_running,"Reciprocal vectors: (Cartesian coordinate: in unit of 2 pi/a_0)",G);
// OUT(GlobalV::ofs_running,"lattice center x",latcenter.x);
// OUT(GlobalV::ofs_running,"lattice center y",latcenter.y);
// OUT(GlobalV::ofs_running,"lattice center z",latcenter.z);
log << std::endl;
outp.printM3(log,"Lattice vectors: (Cartesian coordinate: in unit of a_0)",latvec);
outp.printM3(log,"Reciprocal vectors: (Cartesian coordinate: in unit of 2 pi/a_0)",G);
// OUT(log,"lattice center x",latcenter.x);
// OUT(log,"lattice center y",latcenter.y);
// OUT(log,"lattice center z",latcenter.z);

// read in non-local pseudopotential and ouput the projectors.

GlobalV::ofs_running << "\n\n\n\n";
GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
GlobalV::ofs_running << " | |" << std::endl;
GlobalV::ofs_running << " | Reading pseudopotentials files: |" << std::endl;
GlobalV::ofs_running << " | The pseudopotential file is in UPF format. The 'NC' indicates that |" << std::endl;
GlobalV::ofs_running << " | the type of pseudopotential is 'norm conserving'. Functional of |" << std::endl;
GlobalV::ofs_running << " | exchange and correlation is decided by 4 given parameters in UPF |" << std::endl;
GlobalV::ofs_running << " | file. We also read in the 'core correction' if there exists. |" << std::endl;
GlobalV::ofs_running << " | Also we can read the valence electrons number and the maximal |" << std::endl;
GlobalV::ofs_running << " | angular momentum used in this pseudopotential. We also read in the |" << std::endl;
GlobalV::ofs_running << " | trail wave function, trail atomic density and local-pseudopotential|" << std::endl;
GlobalV::ofs_running << " | on logrithmic grid. The non-local pseudopotential projector is also|" << std::endl;
GlobalV::ofs_running << " | read in if there is any. |" << std::endl;
GlobalV::ofs_running << " | |" << std::endl;
GlobalV::ofs_running << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
GlobalV::ofs_running << "\n\n\n\n";
log << "\n\n\n\n";
log << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
log << " | |" << std::endl;
log << " | Reading pseudopotentials files: |" << std::endl;
log << " | The pseudopotential file is in UPF format. The 'NC' indicates that |" << std::endl;
log << " | the type of pseudopotential is 'norm conserving'. Functional of |" << std::endl;
log << " | exchange and correlation is decided by 4 given parameters in UPF |" << std::endl;
log << " | file. We also read in the 'core correction' if there exists. |" << std::endl;
log << " | Also we can read the valence electrons number and the maximal |" << std::endl;
log << " | angular momentum used in this pseudopotential. We also read in the |" << std::endl;
log << " | trail wave function, trail atomic density and local-pseudopotential|" << std::endl;
log << " | on logrithmic grid. The non-local pseudopotential projector is also|" << std::endl;
log << " | read in if there is any. |" << std::endl;
log << " | |" << std::endl;
log << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
log << "\n\n\n\n";


this->read_cell_pseudopots(s_pseudopot_dir);
Expand Down Expand Up @@ -306,6 +317,9 @@ void UnitCell_pseudo::setup_cell(
}

void UnitCell_pseudo::setup_cell_classic(
#ifdef __LCAO
LCAO_Orbitals &orb,
#endif
const std::string &fn,
std::ofstream &ofs_running,
std::ofstream &ofs_warning)
Expand Down Expand Up @@ -352,11 +366,19 @@ void UnitCell_pseudo::setup_cell_classic(
//========================
// call read_atom_species
//========================
#ifdef __LCAO
this->read_atom_species(ifa, ofs_running, orb);
#else
this->read_atom_species(ifa, ofs_running);
#endif
//==========================
// call read_atom_positions
//==========================
#ifdef __LCAO
ok2 = this->read_atom_positions(ifa, ofs_running, ofs_warning, orb);
#else
ok2 = this->read_atom_positions(ifa, ofs_running, ofs_warning);
#endif
if(ok2)
{
for(int i=0;i<this->ntype;i++)
Expand Down Expand Up @@ -658,9 +680,9 @@ void UnitCell_pseudo::setup_cell_after_vc(
}
else
{
GlobalV::ofs_running << std::endl;
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Volume (Bohr^3)", this->omega);
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Volume (A^3))", this->omega * pow(ModuleBase::BOHR_TO_A, 3));
log << std::endl;
ModuleBase::GlobalFunc::OUT(log, "Volume (Bohr^3)", this->omega);
ModuleBase::GlobalFunc::OUT(log, "Volume (A^3))", this->omega * pow(ModuleBase::BOHR_TO_A, 3));
}

//==========================================================
Expand Down Expand Up @@ -698,9 +720,9 @@ Parallel_Common::bcast_double( atom->taud[ia].z );
}
#endif

GlobalV::ofs_running << std::endl;
outp.printM3(GlobalV::ofs_running,"Lattice vectors: (Cartesian coordinate: in unit of a_0)",latvec);
outp.printM3(GlobalV::ofs_running,"Reciprocal vectors: (Cartesian coordinate: in unit of 2 pi/a_0)",G);
log << std::endl;
outp.printM3(log,"Lattice vectors: (Cartesian coordinate: in unit of a_0)",latvec);
outp.printM3(log,"Reciprocal vectors: (Cartesian coordinate: in unit of 2 pi/a_0)",G);

return;
}
Expand Down Expand Up @@ -728,4 +750,4 @@ bool UnitCell_pseudo::if_cell_can_change()const
return 1;
}
return 0;
}
}
16 changes: 16 additions & 0 deletions source/module_cell/unitcell_pseudo.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "../src_pw/tools.h"
#include "../src_io/output.h"
#include "unitcell.h"
#include "../module_orbital/ORB_read.h"

class UnitCell_pseudo : public UnitCell
{
Expand Down Expand Up @@ -32,19 +33,34 @@ class UnitCell_pseudo : public UnitCell
UnitCell_pseudo();
~UnitCell_pseudo();
void setup_cell(
#ifdef __LCAO
LCAO_Orbitals &orb,
#endif
const std::string &s_pseudopot_dir,
output &outp,
const std::string &fn,
std::ofstream &log);
void setup_cell_classic(
#ifdef __LCAO
LCAO_Orbitals &orb,
#endif
const std::string &fn,
std::ofstream &ofs_running,
std::ofstream &ofs_warning); // liuyu 2021-07-13, RX changed ofs_running and ofs_warning from globalV to inputs. 2021-07-24
#ifdef __LCAO
void read_atom_species(std::ifstream &ifa, std::ofstream &ofs_running, LCAO_Orbitals &orb);
bool read_atom_positions(std::ifstream &ifpos, std::ofstream &ofs_running, std::ofstream &ofs_warning, LCAO_Orbitals &orb); // read in atomic positions
#else
void read_atom_species(std::ifstream &ifa, std::ofstream &ofs_running); // read in the atom information for each type of atom
bool read_atom_positions(std::ifstream &ifpos, std::ofstream &ofs_running, std::ofstream &ofs_warning); // read in atomic positions
#endif
int find_type(const std::string &label);
void print_tau(void)const;
#ifdef __LCAO
void print_stru_file(const std::string &fn, const LCAO_Orbitals &orb, const int &type=1)const; // mohan add 2011-03-22
#else
void print_stru_file(const std::string &fn, const int &type=1)const; // mohan add 2011-03-22
#endif
void check_dtau(void);
void setup_cell_after_vc(const std::string &s_pseudopot_dir, output &outp, const std::string &fn, std::ofstream &log); //LiuXh add 20180515

Expand Down
4 changes: 4 additions & 0 deletions source/module_md/MD_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,11 @@ void MD_func::printpos(const std::string& file, const int& iter, const int& reco
ss << GlobalV::global_out_dir << "STRU_MD";

//zhengdy modify 2015-05-06, outputfile "STRU_Restart"
#ifdef __LCAO
unit_in.print_stru_file(ss.str(),GlobalC::ORB,2);
#else
unit_in.print_stru_file(ss.str(),2);
#endif

return;
}
Expand Down
6 changes: 5 additions & 1 deletion source/module_md/run_md_classic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ void Run_MD_CLASSIC::classic_md_line(void)
ModuleBase::timer::tick("Run_MD_CLASSIC", "classic_md_line");

// Setup the unitcell.
#ifdef __LCAO
ucell_c.setup_cell_classic(GlobalC::ORB, GlobalV::global_atom_card, GlobalV::ofs_running, GlobalV::ofs_warning);
#else
ucell_c.setup_cell_classic(GlobalV::global_atom_card, GlobalV::ofs_running, GlobalV::ofs_warning);
#endif
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "SETUP UNITCELL");

this->md_allocate_ions();
Expand Down Expand Up @@ -192,4 +196,4 @@ void Run_MD_CLASSIC::update_pos_classic(void)
}
this->ucell_c.save_cartesian_position(this->pos_now);
return;
}
}
Loading