Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e79c1d0
update some timers
mohanchen Mar 25, 2025
3a8b520
update timer
mohanchen Mar 25, 2025
aabb29a
update output formats
mohanchen Mar 25, 2025
931f4ac
update print_cell
mohanchen Mar 26, 2025
71e5556
add ofs in print_tau
mohanchen Mar 26, 2025
4353a55
update print_tau
mohanchen Mar 26, 2025
959fe8b
update output formats
mohanchen Mar 26, 2025
9a8552d
update md outputs
mohanchen Mar 26, 2025
cc35adf
Merge branch 'deepmodeling:develop' into develop
mohanchen Mar 26, 2025
357d43e
Merge branch 'develop' of https://github.com/mohanchen/abacus-mc into…
mohanchen Mar 26, 2025
eb0a302
beging modifying the autotests
mohanchen Mar 27, 2025
258245d
update previous commits
mohanchen Mar 27, 2025
2fc86bb
update integrate tests
mohanchen Mar 27, 2025
5840f50
update some timers
mohanchen Mar 27, 2025
0189b6c
fix total force and total stress
mohanchen Mar 27, 2025
34bcd1a
update integrate tests
mohanchen Mar 27, 2025
9deffae
update print_band
mohanchen Mar 27, 2025
8718960
fix print_band
mohanchen Mar 27, 2025
05e9cc7
update md print out information
mohanchen Mar 27, 2025
abc61a0
update print_stress
mohanchen Mar 27, 2025
bda0769
update print_stress in dp, but still has problems in lj
mohanchen Mar 27, 2025
c4b4b19
fix dp_test.cpp
mohanchen Mar 27, 2025
1060d4a
update esolver_lj
mohanchen Mar 28, 2025
3f77545
Merge branch 'develop' of https://github.com/mohanchen/abacus-mc into…
mohanchen Mar 28, 2025
34c8748
merge new codes
mohanchen Mar 28, 2025
b0d2d0a
set mulliken charge accuracy from 4 to 3
mohanchen Mar 29, 2025
3956c6f
update print force and print stress
mohanchen Mar 30, 2025
b27ddc2
Merge branch 'develop' of https://github.com/mohanchen/abacus-mc into…
mohanchen Mar 31, 2025
ae6552c
delete kv variable in hamilt_lcao
mohanchen Mar 31, 2025
37c253e
update some operators
mohanchen Mar 31, 2025
5fccb05
update hamiltonian and operator
mohanchen Mar 31, 2025
821a947
Merge branch 'develop' of https://github.com/mohanchen/abacus-mc into…
mohanchen Mar 31, 2025
d9eac9e
Merge branch 'lishui' into develop
mohanchen Mar 31, 2025
119872f
update updateHk funciton parameters
mohanchen Apr 1, 2025
975c2cc
fix bug
mohanchen Apr 1, 2025
02eb1de
fix bug in updateHk
mohanchen Apr 1, 2025
8c26095
update updateSk
mohanchen Apr 1, 2025
3354cbc
Merge branch 'develop' into develop
mohanchen Apr 2, 2025
b66725a
update read atoms
mohanchen Apr 2, 2025
65e4630
update SCAN_BEGIN, now the function ignore lines starting with #
mohanchen Apr 2, 2025
73a9881
update
mohanchen Apr 2, 2025
a13470f
Merge branch 'develop' of https://github.com/mohanchen/abacus-mc into…
mohanchen Apr 2, 2025
d5b6acd
add SCAN_LINE_BEGIN
mohanchen Apr 2, 2025
4f499a6
fix bug
mohanchen Apr 2, 2025
c8afa94
fix issue
mohanchen Apr 2, 2025
f4996ed
Merge branch 'deepmodeling:develop' into develop
mohanchen Apr 2, 2025
9cf4ba2
Merge branch 'tea4' into develop
mohanchen Apr 2, 2025
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
51 changes: 50 additions & 1 deletion source/module_base/global_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ void DONE(std::ofstream &ofs, const std::string &description, const bool only_ra
return;
}

bool SCAN_BEGIN(std::ifstream &ifs, const std::string &TargetName, const bool restart, const bool ifwarn)

bool SCAN_BEGIN(std::ifstream &ifs,
const std::string &TargetName,
const bool restart,
const bool ifwarn)
{
std::string SearchName;
bool find = false;
Expand All @@ -130,6 +134,51 @@ bool SCAN_BEGIN(std::ifstream &ifs, const std::string &TargetName, const bool re
return find;
}


bool SCAN_LINE_BEGIN(std::ifstream &ifs,
const std::string &TargetName,
const bool restart,
const bool ifwarn)
{
bool find = false;
if (restart)
{
ifs.clear();
ifs.seekg(0);
}
ifs.rdstate();

std::string line;
while (std::getline(ifs,line))
{
//! obtain the first character, should not be #
size_t first_char_pos = line.find_first_not_of(" \t");
if (first_char_pos != std::string::npos && line[first_char_pos] == '#')
{
continue;
}

//! search in each line
std::istringstream iss(line);
std::string SearchName;
while (iss >> SearchName)
{
if (SearchName == TargetName)
{
find = true;
//std::cout << " search name = " << SearchName << std::endl;
return find;
}
}
}

if (!find && ifwarn)
{
GlobalV::ofs_warning << " In SCAN_LINE_BEGIN, can't find: " << TargetName << " block." << std::endl;
}
return find;
}

void SCAN_END(std::ifstream &ifs, const std::string &TargetName, const bool ifwarn)
{
std::string SearchName;
Expand Down
27 changes: 20 additions & 7 deletions source/module_base/global_function.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef W_ABACUS_DEVELOP_ABACUS_DEVELOP_SOURCE_MODULE_BASE_GLOBAL_FUNCTION_H
#define W_ABACUS_DEVELOP_ABACUS_DEVELOP_SOURCE_MODULE_BASE_GLOBAL_FUNCTION_H
#ifndef GLOBAL_FUNCTION_H
#define GLOBAL_FUNCTION_H

#include "blas_connector.h"
#include "global_function-func_each_2.h" // Peize Lin add 2016-09-07
Expand Down Expand Up @@ -145,13 +145,26 @@ static void READ_VALUE(std::ifstream& ifs, T& v)
return;
}

bool SCAN_BEGIN(std::ifstream& ifs, const std::string& TargetName, const bool restart = true, const bool ifwarn = true);
// ifwarn: whether to call GlobalV::ofs_warning when the TargetName is not found, used to avoid invalid warning.
// Mohan warning : the last term can't be written as const bool &restart,
// I don't know why.
//-------------------------------------------------------------
//! The `SCAN_BEGIN` function efficiently searches
//! text files for specified keywords
//-------------------------------------------------------------
bool SCAN_BEGIN(std::ifstream& ifs,
const std::string& TargetName,
const bool restart = true,
const bool ifwarn = true);

//-------------------------------------------------------------
// The `SCAN_LINE_BEGIN` function efficiently searches
// text files for specified keywords while ignoring comment
// lines and whitespace. It skips any line starting with '#'
//-------------------------------------------------------------
bool SCAN_LINE_BEGIN(std::ifstream& ifs,
const std::string& TargetName,
const bool restart = true,
const bool ifwarn = true);

void SCAN_END(std::ifstream& ifs, const std::string& TargetName, const bool ifwarn = true);
// ifwarn: whether to call GlobalV::ofs_warning when the TargetName is not found, used to avoid invalid warning.

template <class T>
static inline void DCOPY(const T& a, T& b, const int& dim)
Expand Down
66 changes: 37 additions & 29 deletions source/module_cell/read_atom_species.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ bool read_atom_species(std::ifstream& ifa,
UnitCell& ucell)
{
ModuleBase::TITLE("UnitCell","read_atom_species");

const int ntype = ucell.ntype;
std::string word;

//==========================================
// read in information of each type of atom
//==========================================
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "ATOMIC_SPECIES") )
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "ATOMIC_SPECIES") )
{
ifa.ignore(300, '\n');
ModuleBase::GlobalFunc::OUT(ofs_running,"ntype",ntype);
for (int i = 0;i < ntype;i++)
{
Expand Down Expand Up @@ -51,7 +51,8 @@ bool read_atom_species(std::ifstream& ifa,

if (!end && ss >> one_string && one_string[0] != '#')
{
if (one_string == "auto" || one_string == "upf" || one_string == "vwr" || one_string == "upf201" || one_string == "blps")
if (one_string == "auto" || one_string == "upf"
|| one_string == "vwr" || one_string == "upf201" || one_string == "blps")
{
ucell.pseudo_type[i] = one_string;
}
Expand All @@ -61,15 +62,17 @@ bool read_atom_species(std::ifstream& ifa,
}
else
{
GlobalV::ofs_warning << "unrecongnized pseudopotential type: " << one_string << ", check your STRU file." << std::endl;
GlobalV::ofs_warning << "unrecongnized pseudopotential type: "
<< one_string << ", check your STRU file." << std::endl;
ModuleBase::WARNING_QUIT("read_atom_species", "unrecongnized pseudo type.");
}
}

// Peize Lin test for bsse 2021.04.07
const std::string bsse_label = "empty";
ucell.atoms[i].flag_empty_element =
(search( ucell.atom_label[i].begin(), ucell.atom_label[i].end(), bsse_label.begin(), bsse_label.end() ) != ucell.atom_label[i].end())
(search( ucell.atom_label[i].begin(), ucell.atom_label[i].end(),
bsse_label.begin(), bsse_label.end() ) != ucell.atom_label[i].end())
? true : false;
}
}
Expand All @@ -80,7 +83,7 @@ bool read_atom_species(std::ifstream& ifa,
||((PARAM.inp.basis_type == "pw")&&(PARAM.inp.init_wfc.substr(0, 3) == "nao"))
|| PARAM.inp.onsite_radius > 0.0)
{
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "NUMERICAL_ORBITAL") )
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "NUMERICAL_ORBITAL") )
{
for(int i=0; i<ntype; i++)
{
Expand All @@ -90,7 +93,7 @@ bool read_atom_species(std::ifstream& ifa,
// caoyu add 2021-03-16
if(PARAM.globalv.deepks_setorb)
{
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "NUMERICAL_DESCRIPTOR")) {
if (ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "NUMERICAL_DESCRIPTOR")) {
ifa >> ucell.descriptor_file;
}
}
Expand All @@ -105,7 +108,7 @@ bool read_atom_species(std::ifstream& ifa,
#ifdef __EXX
if( GlobalC::exx_info.info_global.cal_exx || PARAM.inp.rpa )
{
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "ABFS_ORBITAL") )
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "ABFS_ORBITAL") )
{
for(int i=0; i<ntype; i++)
{
Expand Down Expand Up @@ -133,7 +136,7 @@ bool read_lattice_constant(std::ifstream& ifa,
double& lat0_angstrom =lat.lat0_angstrom;
std::string& latName = lat.latName;
ModuleBase::Matrix3& latvec = lat.latvec;
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_CONSTANT") )
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_CONSTANT") )
{
ModuleBase::GlobalFunc::READ_VALUE(ifa, lat0);
if(lat0<=0.0)
Expand All @@ -153,18 +156,23 @@ bool read_lattice_constant(std::ifstream& ifa,

if(latName=="none")
{
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifa,
// check the existence of keyword "LATTICE_PARAMETERS"
if (ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa,
"LATTICE_PARAMETERS",
true,
false))
{
ModuleBase::WARNING_QUIT("unitcell::read_lattice_constant","do not use LATTICE_PARAMETERS without explicit specification of lattice type");
ModuleBase::WARNING_QUIT("unitcell::read_lattice_constant",
"do not use LATTICE_PARAMETERS without explicit specification of lattice type");
}
if( !ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_VECTORS") )

// check the existence of keyword "LATTICE_VECTORS"
if( !ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_VECTORS") )
{
ModuleBase::WARNING_QUIT("unitcell::read_lattice_constant","Please set LATTICE_VECTORS in STRU file");
ModuleBase::WARNING_QUIT("unitcell::read_lattice_constant",
"Please set LATTICE_VECTORS in STRU file");
}
else if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_VECTORS") )
else if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_VECTORS") )
{
// Reading lattice vectors. notice
// here that only one cpu read these
Expand All @@ -179,12 +187,13 @@ bool read_lattice_constant(std::ifstream& ifa,
}//supply lattice vectors
else
{
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifa,
if (ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa,
"LATTICE_VECTORS",
true,
false))
{
ModuleBase::WARNING_QUIT("unitcell::read_lattice_constant","do not use LATTICE_VECTORS along with explicit specification of lattice type");
ModuleBase::WARNING_QUIT("unitcell::read_lattice_constant",
"do not use LATTICE_VECTORS along with explicit specification of lattice type");
}
if(latName=="sc")
{//simple-cubic, ibrav = 1
Expand All @@ -210,7 +219,7 @@ bool read_lattice_constant(std::ifstream& ifa,
latvec.e11 = 1.0; latvec.e12 = 0.0; latvec.e13 = 0.0;
latvec.e21 =-0.5; latvec.e22 = e22; latvec.e23 = 0.0;
latvec.e31 = 0.0; latvec.e32 = 0.0; latvec.e33 = 0.0;
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
{
ModuleBase::GlobalFunc::READ_VALUE(ifa, latvec.e33);
}
Expand All @@ -219,7 +228,7 @@ bool read_lattice_constant(std::ifstream& ifa,
{//trigonal, ibrav = 5
double t1 = 0.0;
double t2 = 0.0;
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
{
double cosab=0.0;
ModuleBase::GlobalFunc::READ_VALUE(ifa, cosab);
Expand All @@ -239,15 +248,15 @@ bool read_lattice_constant(std::ifstream& ifa,
latvec.e11 = 1.0; latvec.e12 = 0.0; latvec.e13 = 0.0;
latvec.e21 = 0.0; latvec.e22 = 1.0; latvec.e23 = 0.0;
latvec.e31 = 0.0; latvec.e32 = 0.0; latvec.e33 = 0.0;
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
{
ModuleBase::GlobalFunc::READ_VALUE(ifa, latvec.e33);
}
}
else if(latName=="bct")
{//body-centered tetragonal, ibrav = 7
double cba = 0.0;
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
{
ModuleBase::GlobalFunc::READ_VALUE(ifa, cba);
cba = cba / 2.0;
Expand All @@ -261,7 +270,7 @@ bool read_lattice_constant(std::ifstream& ifa,
latvec.e11 = 1.0; latvec.e12 = 0.0; latvec.e13 = 0.0;
latvec.e21 = 0.0; latvec.e22 = 0.0; latvec.e23 = 0.0;
latvec.e31 = 0.0; latvec.e32 = 0.0; latvec.e33 = 0.0;
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
{
ifa >> latvec.e22;
ModuleBase::GlobalFunc::READ_VALUE(ifa, latvec.e33);
Expand All @@ -272,7 +281,7 @@ bool read_lattice_constant(std::ifstream& ifa,
latvec.e11 = 0.5; latvec.e12 = 0.0; latvec.e13 = 0.0;
latvec.e21 =-0.5; latvec.e22 = 0.0; latvec.e23 = 0.0;
latvec.e31 = 0.0; latvec.e32 = 0.0; latvec.e33 = 0.0;
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
{
ifa >> latvec.e12;
latvec.e12 = latvec.e12 / 2.0;
Expand All @@ -283,7 +292,7 @@ bool read_lattice_constant(std::ifstream& ifa,
else if(latName=="fco")
{//face-centered orthorhombic, ibrav = 10
double bba = 0.0; double cba = 0.0;
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
{
ifa >> bba;
ModuleBase::GlobalFunc::READ_VALUE(ifa, cba);
Expand All @@ -296,7 +305,7 @@ bool read_lattice_constant(std::ifstream& ifa,
else if(latName=="bco")
{//body-centered orthorhombic, ibrav = 11
double bba = 0.0; double cba = 0.0;
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
{
ifa >> bba;
ModuleBase::GlobalFunc::READ_VALUE(ifa, cba);
Expand All @@ -311,7 +320,7 @@ bool read_lattice_constant(std::ifstream& ifa,
double bba = 0.0; double cba = 0.0;
double cosab = 0.0;
double e21 = 0.0; double e22 = 0.0;
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
{
ifa >> bba >> cba;
ModuleBase::GlobalFunc::READ_VALUE(ifa, cosab);
Expand All @@ -327,7 +336,7 @@ bool read_lattice_constant(std::ifstream& ifa,
double bba = 0.0; double cba = 0.0;
double cosab = 0.0;
double e21 = 0.0; double e22 = 0.0;
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
{
ifa >> bba >> cba;
ModuleBase::GlobalFunc::READ_VALUE(ifa, cosab);
Expand All @@ -348,7 +357,7 @@ bool read_lattice_constant(std::ifstream& ifa,
double cosbc = 0.0;
double sinab = 0.0;
double term = 0.0;
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_PARAMETERS") )
if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "LATTICE_PARAMETERS") )
{
ifa >> bba >> cba >> cosab >> cosac;
ModuleBase::GlobalFunc::READ_VALUE(ifa, cosbc);
Expand All @@ -363,7 +372,6 @@ bool read_lattice_constant(std::ifstream& ifa,
}
else
{
std::cout << "latname is : " << latName << std::endl;
ModuleBase::WARNING_QUIT("unitcell::read_lattice_constant","latname not supported!");
}
}
Expand All @@ -383,4 +391,4 @@ bool read_lattice_constant(std::ifstream& ifa,
return true;
}

}
}
Loading
Loading