Skip to content

Commit

Permalink
add runtime error for wrong point group
Browse files Browse the repository at this point in the history
  • Loading branch information
hczhai committed Aug 9, 2022
1 parent 57b4ca5 commit 8ae7855
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
3 changes: 3 additions & 0 deletions pyblock2/driver/block2main
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,9 @@ if pre_run or not no_pre_run:
n_sites = n_orbs
if orb_sym is None:
orb_sym = VectorUInt8(map(swap_pg, fcidump.orb_sym))
for x in orb_sym:
if x == 8:
raise RuntimeError("Wrong point group symmetry : ", dic.get("sym", "d2h"))
sym_error = fcidump.symmetrize(orb_sym)
_print("integral sym error = %12.4g" % sym_error)
if "k_symmetry" in dic:
Expand Down
3 changes: 3 additions & 0 deletions pyblock2/driver/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ def read_fcidump(self, filename, pg='d2h', rescale=None, iprint=1):
fcidump.read(filename)
swap_pg = getattr(bw.b.PointGroup, "swap_" + pg)
self.orb_sym = bw.b.VectorUInt8(map(swap_pg, fcidump.orb_sym))
for x in self.orb_sym:
if x == 8:
raise RuntimeError("Wrong point group symmetry : ", pg)
self.n_sites = fcidump.n_sites
self.n_elec = fcidump.n_elec
self.spin = fcidump.twos
Expand Down
14 changes: 7 additions & 7 deletions src/core/point_group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct PointGroup {
// 0 1 2 3 (XOR)
// A1 A2 B1 B2
static int16_t swap_c2v(int16_t isym) {
static int16_t arr_swap[] = {8, 0, 2, 3, 1};
static int16_t arr_swap[] = {8, 0, 2, 3, 1, 8, 8, 8, 8};
return arr_swap[isym];
}
// C2H
Expand All @@ -56,7 +56,7 @@ struct PointGroup {
// 0 1 2 3 (XOR)
// Ag Bg Au Bu
static int16_t swap_c2h(int16_t isym) {
static int16_t arr_swap[] = {8, 0, 2, 3, 1};
static int16_t arr_swap[] = {8, 0, 2, 3, 1, 8, 8, 8, 8};
return arr_swap[isym];
}
// D2
Expand All @@ -65,7 +65,7 @@ struct PointGroup {
// 0 1 2 3 (XOR)
// A1 B1 B2 B3
static int16_t swap_d2(int16_t isym) {
static int16_t arr_swap[] = {8, 0, 3, 2, 1};
static int16_t arr_swap[] = {8, 0, 3, 2, 1, 8, 8, 8, 8};
return arr_swap[isym];
}
// CS
Expand All @@ -74,7 +74,7 @@ struct PointGroup {
// 0 1 (XOR)
// A' A''
static int16_t swap_cs(int16_t isym) {
static int16_t arr_swap[] = {8, 0, 1};
static int16_t arr_swap[] = {8, 0, 1, 8, 8, 8, 8, 8, 8};
return arr_swap[isym];
}
// C2
Expand All @@ -83,7 +83,7 @@ struct PointGroup {
// 0 1 (XOR)
// A B
static int16_t swap_c2(int16_t isym) {
static int16_t arr_swap[] = {8, 0, 1};
static int16_t arr_swap[] = {8, 0, 1, 8, 8, 8, 8, 8, 8};
return arr_swap[isym];
}
// CI
Expand All @@ -92,7 +92,7 @@ struct PointGroup {
// 0 1 (XOR)
// Ag Au
static int16_t swap_ci(int16_t isym) {
static int16_t arr_swap[] = {8, 0, 1};
static int16_t arr_swap[] = {8, 0, 1, 8, 8, 8, 8, 8, 8};
return arr_swap[isym];
}
// C1
Expand All @@ -101,7 +101,7 @@ struct PointGroup {
// 0 (XOR)
// A
static int16_t swap_c1(int16_t isym) {
static int16_t arr_swap[] = {8, 0};
static int16_t arr_swap[] = {8, 0, 8, 8, 8, 8, 8, 8, 8};
return arr_swap[isym];
}
static int16_t swap_nopg(int16_t isym) {
Expand Down
6 changes: 6 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ template <typename S, typename FL> void run(const map<string, string> &params) {
vector<uint8_t> orbsym = fcidump->template orb_sym<uint8_t>();
transform(orbsym.begin(), orbsym.end(), orbsym.begin(),
PointGroup::swap_pg(pg));
for (auto x : orbsym)
if (x == 8) {
cerr << "wrong point group symmetry irrep: pg is "
<< (params.count("pg") != 0 ? params.at("pg") : "c1") << endl;
abort();
}
typename FCIDUMP<FL>::FP integral_error = fcidump->symmetrize(orbsym);
if (integral_error != 0)
cout << "integral error = " << scientific << setprecision(5)
Expand Down

0 comments on commit 8ae7855

Please sign in to comment.