Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Output a warning when the lattice vector is left-handed. #5855

Merged
merged 9 commits into from
Jan 18, 2025
4 changes: 2 additions & 2 deletions examples/band/lcao_Si2/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.2 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Cartesian //Cartesian or Direct coordinate.
Expand Down
4 changes: 2 additions & 2 deletions examples/charge_density/lcao_nspin1_Si2/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.2 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Cartesian //Cartesian or Direct coordinate.
Expand Down
4 changes: 2 additions & 2 deletions examples/density_matrix/lcao_nspin1_Si2/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.2 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Cartesian //Cartesian or Direct coordinate.
Expand Down
4 changes: 2 additions & 2 deletions examples/dos/lcao_Si2/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.2 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Cartesian //Cartesian or Direct coordinate.
Expand Down
4 changes: 2 additions & 2 deletions examples/lr-tddft/lcao_Si2/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ LATTICE_CONSTANT
10.2 #Lattice constant

LATTICE_VECTORS
0.5 0.5 0.0 #Lattice vector 1
0.0 0.5 0.5 #Lattice vector 1
0.5 0.0 0.5 #Lattice vector 2
0.0 0.5 0.5 #Lattice vector 3
0.5 0.5 0.0 #Lattice vector 3

ATOMIC_POSITIONS
Cartesian #Cartesian(Unit is LATTICE_CONSTANT)
Expand Down
4 changes: 2 additions & 2 deletions examples/matrix_hs/out_hs2_multik/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.2 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Direct
Expand Down
4 changes: 2 additions & 2 deletions examples/matrix_hs/out_hs_gammaonly/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
20 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Direct
Expand Down
4 changes: 2 additions & 2 deletions examples/matrix_hs/out_hs_multik/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.2 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Direct
Expand Down
4 changes: 2 additions & 2 deletions examples/matrix_hs/out_s_multik/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.2 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Direct
Expand Down
4 changes: 2 additions & 2 deletions examples/mulliken/lcao_Si2/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ LATTICE_CONSTANT
10.2 #Lattice constant

LATTICE_VECTORS
0.5 0.5 0.0 #Lattice vector 1
0.0 0.5 0.5 #Lattice vector 1
0.5 0.0 0.5 #Lattice vector 2
0.0 0.5 0.5 #Lattice vector 3
0.5 0.5 0.0 #Lattice vector 3

ATOMIC_POSITIONS
Cartesian #Cartesian(Unit is LATTICE_CONSTANT)
Expand Down
4 changes: 2 additions & 2 deletions examples/scf/lcao_Si2/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ LATTICE_CONSTANT
10.2 #Lattice constant

LATTICE_VECTORS
0.5 0.5 0.0 #Lattice vector 1
0.0 0.5 0.5 #Lattice vector 1
0.5 0.0 0.5 #Lattice vector 2
0.0 0.5 0.5 #Lattice vector 3
0.5 0.5 0.0 #Lattice vector 3

ATOMIC_POSITIONS
Cartesian #Cartesian(Unit is LATTICE_CONSTANT)
Expand Down
4 changes: 2 additions & 2 deletions examples/scf/pw_Si2/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.2 #Lattice constant

LATTICE_VECTORS
0.5 0.5 0.0 #Lattice vector 1
0.0 0.5 0.5 #Lattice vector 1
0.5 0.0 0.5 #Lattice vector 2
0.0 0.5 0.5 #Lattice vector 3
0.5 0.5 0.0 #Lattice vector 3

ATOMIC_POSITIONS
Cartesian #Cartesian(Unit is LATTICE_CONSTANT)
Expand Down
4 changes: 2 additions & 2 deletions examples/stochastic/pw_Si2/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.2 #Lattice constant

LATTICE_VECTORS
0.5 0.5 0.0 #Lattice vector 1
0.0 0.5 0.5 #Lattice vector 1
0.5 0.0 0.5 #Lattice vector 2
0.0 0.5 0.5 #Lattice vector 3
0.5 0.5 0.0 #Lattice vector 3

ATOMIC_POSITIONS
Cartesian #Cartesian(Unit is LATTICE_CONSTANT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
5.11 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Direct //Cartesian or Direct coordinate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.21 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Direct //Cartesian or Direct coordinate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.00 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Direct //Cartesian or Direct coordinate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.40 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Direct //Cartesian or Direct coordinate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.21 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Direct //Cartesian or Direct coordinate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
5.11 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Direct //Cartesian or Direct coordinate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.21 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Direct //Cartesian or Direct coordinate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.00 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Direct //Cartesian or Direct coordinate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.40 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Direct //Cartesian or Direct coordinate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.21 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Direct //Cartesian or Direct coordinate.
Expand Down
4 changes: 2 additions & 2 deletions examples/vdw/si2-vdwd2/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ LATTICE_CONSTANT
10.2 #Lattice constant

LATTICE_VECTORS
0.5 0.5 0.0 #Lattice vector 1
0.0 0.5 0.5 #Lattice vector 1
0.5 0.0 0.5 #Lattice vector 2
0.0 0.5 0.5 #Lattice vector 3
0.5 0.5 0.0 #Lattice vector 3

ATOMIC_POSITIONS
Cartesian #Cartesian(Unit is LATTICE_CONSTANT)
Expand Down
4 changes: 2 additions & 2 deletions examples/vdw/si2-vdwd3/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ LATTICE_CONSTANT
10.2 #Lattice constant

LATTICE_VECTORS
0.5 0.5 0.0 #Lattice vector 1
0.0 0.5 0.5 #Lattice vector 1
0.5 0.0 0.5 #Lattice vector 2
0.0 0.5 0.5 #Lattice vector 3
0.5 0.5 0.0 #Lattice vector 3

ATOMIC_POSITIONS
Cartesian #Cartesian(Unit is LATTICE_CONSTANT)
Expand Down
4 changes: 2 additions & 2 deletions examples/wfc/lcao_ienvelope_Si2/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.2 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Cartesian //Cartesian or Direct coordinate.
Expand Down
4 changes: 2 additions & 2 deletions examples/wfc/lcao_scf_Si2/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.2 // add lattice constant

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Cartesian //Cartesian or Direct coordinate.
Expand Down
27 changes: 18 additions & 9 deletions source/module_cell/unitcell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,17 +325,26 @@ void UnitCell::setup_cell(const std::string& fn, std::ofstream& log) {
// Firstly, latvec must be read in.
//========================================================
assert(lat0 > 0.0);
this->omega = std::abs(latvec.Det()) * this->lat0 * lat0 * lat0;
if (this->omega <= 0) {
std::cout << "The volume is negative: " << this->omega << std::endl;
ModuleBase::WARNING_QUIT("setup_cell", "omega <= 0 .");
} else {
this->omega = latvec.Det() * this->lat0 * lat0 * lat0;
if (this->omega < 0)
{
std::cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << std::endl;
std::cout << " Warning: The lattice vector is left-handed; a right-handed vector is prefered." << std::endl;
std::cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << std::endl;
GlobalV::ofs_warning << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << std::endl;
GlobalV::ofs_warning << " Warning: The lattice vector is left-handed; a right-handed vector is prefered." << std::endl;
GlobalV::ofs_warning << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << std::endl;
this->omega = std::abs(this->omega);
}
else if (this->omega == 0)
{
ModuleBase::WARNING_QUIT("setup_cell", "The volume is zero.");
}
else
{
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));
ModuleBase::GlobalFunc::OUT(log, "Volume (A^3)", this->omega * pow(ModuleBase::BOHR_TO_A, 3));
}

//==========================================================
Expand Down
4 changes: 2 additions & 2 deletions source/module_io/test/support/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
8.92

LATTICE_VECTORS
0.5 0.5 0.0
0.5 0.0 0.5
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0

ATOMIC_POSITIONS
Direct
Expand Down
4 changes: 2 additions & 2 deletions source/module_psi/test/support/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ LATTICE_CONSTANT
10.2 #Lattice constant

LATTICE_VECTORS
0.5 0.5 0.0 #Lattice vector 1
0.0 0.5 0.5 #Lattice vector 1
0.5 0.0 0.5 #Lattice vector 2
0.0 0.5 0.5 #Lattice vector 3
0.5 0.5 0.0 #Lattice vector 3

ATOMIC_POSITIONS
Cartesian #Cartesian(Unit is LATTICE_CONSTANT)
Expand Down
4 changes: 2 additions & 2 deletions tests/integrate/1001_NO_Si2_dzp_rdmft/STRU
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ LATTICE_CONSTANT
10.2

LATTICE_VECTORS
0.5 0.5 0.0 #Lattice vector 1
0.0 0.5 0.5 #Lattice vector 1
0.5 0.0 0.5 #Lattice vector 2
0.0 0.5 0.5 #Lattice vector 3
0.5 0.5 0.0 #Lattice vector 3

ATOMIC_POSITIONS
Cartesian #Cartesian(Unit is LATTICE_CONSTANT)
Expand Down
Loading
Loading