Skip to content

Commit f9cc2b9

Browse files
committed
modify the reszie of the atom_mass
1 parent 6b611ef commit f9cc2b9

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

source/module_cell/read_atom_species.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ bool read_atom_species(std::ifstream& ifa,
1818
delete[] ucell.orbital_fn;
1919
ucell.orbital_fn = new std::string[ntype]; // filename of orbitals
2020
std::string word;
21+
std::string one_line;
22+
std::string one_string;
23+
std::stringstream ss;
2124

2225
//==========================================
2326
// read in information of each type of atom
@@ -28,12 +31,10 @@ bool read_atom_species(std::ifstream& ifa,
2831
ModuleBase::GlobalFunc::OUT(ofs_running,"ntype",ntype);
2932
for (int i = 0;i < ntype;i++)
3033
{
31-
std::string one_line;
32-
std::string one_string;
3334
std::getline(ifa, one_line);
34-
std::stringstream ss;
3535
ss << one_line;
36-
ss >> ucell.atom_label[i] >> ucell.atom_mass[i];
36+
ss >> ucell.atom_label[i]
37+
ss >> ucell.atom_mass[i];
3738
ucell.pseudo_fn[i] = "auto";
3839
ucell.pseudo_type[i] = "auto";
3940

@@ -102,10 +103,8 @@ bool read_atom_species(std::ifstream& ifa,
102103
ucell.descriptor_file = PARAM.inp.orbital_dir + ucell.orbital_fn[0];
103104
}
104105
}
105-
#ifdef __LCAO
106+
#ifdef (__LCAO) && (__MPI) && (__EXX)
106107
// Peize Lin add 2016-09-23
107-
#ifdef __MPI
108-
#ifdef __EXX
109108
if( GlobalC::exx_info.info_global.cal_exx || PARAM.inp.rpa )
110109
{
111110
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "ABFS_ORBITAL") )
@@ -118,9 +117,6 @@ bool read_atom_species(std::ifstream& ifa,
118117
}
119118
}
120119
}
121-
122-
#endif // __EXX
123-
#endif // __MPI
124120
#endif // __LCAO
125121
return true;
126122
}
@@ -141,27 +137,28 @@ bool read_lattice_constant(std::ifstream& ifa,
141137
ModuleBase::GlobalFunc::READ_VALUE(ifa, lat0);
142138
if(lat0<=0.0)
143139
{
144-
ModuleBase::WARNING_QUIT("read_atom_species","lat0<=0.0");
140+
ModuleBase::WARNING_QUIT("read_lattice_constant","lat0<=0.0");
145141
}
146142
lat0_angstrom = lat0 * 0.529177;
147-
ModuleBase::GlobalFunc::OUT(ofs_running,"lattice constant (Bohr)",lat0);
148-
ModuleBase::GlobalFunc::OUT(ofs_running,"lattice constant (Angstrom)",lat0_angstrom);
149143
lat.tpiba = ModuleBase::TWO_PI / lat0;
150144
lat.tpiba2 = lat.tpiba * lat.tpiba;
145+
ModuleBase::GlobalFunc::OUT(ofs_running,"lattice constant (Bohr)",lat0);
146+
ModuleBase::GlobalFunc::OUT(ofs_running,"lattice constant (Angstrom)",lat0_angstrom);
147+
151148
}
152149

153150
//===========================
154151
// Read in latticies vector
155152
//===========================
156-
157153
if(latName=="none")
158154
{
159155
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifa,
160156
"LATTICE_PARAMETERS",
161157
true,
162158
false))
163159
{
164-
ModuleBase::WARNING_QUIT("unitcell::read_lattice_constant","do not use LATTICE_PARAMETERS without explicit specification of lattice type");
160+
ModuleBase::WARNING_QUIT("unitcell::read_lattice_constant",
161+
"do not use LATTICE_PARAMETERS without explicit specification of lattice type");
165162
}
166163
if( !ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "LATTICE_VECTORS") )
167164
{
@@ -187,7 +184,8 @@ bool read_lattice_constant(std::ifstream& ifa,
187184
true,
188185
false))
189186
{
190-
ModuleBase::WARNING_QUIT("unitcell::read_lattice_constant","do not use LATTICE_VECTORS along with explicit specification of lattice type");
187+
ModuleBase::WARNING_QUIT("unitcell::read_lattice_constant",
188+
"do not use LATTICE_VECTORS along with explicit specification of lattice type");
191189
}
192190
if(latName=="sc")
193191
{//simple-cubic, ibrav = 1

source/module_cell/unitcell.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ void UnitCell::setup_cell(const std::string& fn, std::ofstream& log) {
331331
bool ok2 = true;
332332

333333
// (3) read in atom information
334+
this->atom_mass.resize(ntype);
335+
this->atom_label.resize(ntype);
336+
this->pseudo_fn.resize(ntype);
337+
this->pseudo_type.resize(ntype);
334338
if (GlobalV::MY_RANK == 0) {
335339
// open "atom_unitcell" file.
336340
std::ifstream ifa(fn.c_str(), std::ios::in);

0 commit comments

Comments
 (0)