Skip to content

Commit 5941818

Browse files
committed
Fix: Warning Quit when the lattice vector is left-handed.
1 parent 806de4a commit 5941818

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

source/module_cell/unitcell.cpp

+12-9
Original file line numberDiff line numberDiff line change
@@ -325,17 +325,20 @@ void UnitCell::setup_cell(const std::string& fn, std::ofstream& log) {
325325
// Firstly, latvec must be read in.
326326
//========================================================
327327
assert(lat0 > 0.0);
328-
this->omega = std::abs(latvec.Det()) * this->lat0 * lat0 * lat0;
329-
if (this->omega <= 0) {
330-
std::cout << "The volume is negative: " << this->omega << std::endl;
331-
ModuleBase::WARNING_QUIT("setup_cell", "omega <= 0 .");
332-
} else {
328+
this->omega = latvec.Det() * this->lat0 * lat0 * lat0;
329+
if (this->omega < 0)
330+
{
331+
ModuleBase::WARNING_QUIT("setup_cell", "The lattice vector is left-handed, please change it to right-handed.");
332+
}
333+
else if (this->omega == 0)
334+
{
335+
ModuleBase::WARNING_QUIT("setup_cell", "The volume is zero.");
336+
}
337+
else
338+
{
333339
log << std::endl;
334340
ModuleBase::GlobalFunc::OUT(log, "Volume (Bohr^3)", this->omega);
335-
ModuleBase::GlobalFunc::OUT(log,
336-
"Volume (A^3)",
337-
this->omega
338-
* pow(ModuleBase::BOHR_TO_A, 3));
341+
ModuleBase::GlobalFunc::OUT(log, "Volume (A^3)", this->omega * pow(ModuleBase::BOHR_TO_A, 3));
339342
}
340343

341344
//==========================================================

0 commit comments

Comments
 (0)