awietek / xdiag

C++ library for Exact Diagonalization of quantum many-body systems
https://awietek.github.io/xdiag
Apache License 2.0
22 stars 5 forks source link

Use of `generated_group` is unclear #11

Open Spuriosity1 opened 2 months ago

Spuriosity1 commented 2 months ago
#include <xdiag/all.hpp>
#include <xdiag/blocks/spinhalf/spinhalf.hpp>
#include <xdiag/common.hpp>
#include <xdiag/symmetries/generated_group.hpp>
#include <xdiag/symmetries/representation.hpp>
#include <xdiag/utils/logger.hpp>
#include "geometry.hpp"

using namespace xdiag;

const int N_SITES = 7;

/* Set up the spins in opposing pyramids:
 *      1
 *     2 3 
 *
 *      0
 *
 *     6 5
 *      4
 *
 *  Top View:
 *
 *       1
 *  6         5
 *       0
 *  2         3
 *       4
 *
 */
const std::vector<std::pair<int, int>> cluster_bonds = {
  {1,2},
  {2,3},
  {3,1},
  {0,1},
  {0,2},
  {0,3},
  {0,4},
  {0,5},
  {0,6},
  {4,5},
  {5,6},
  {6,4}
};

int main(int argc, char* argv[]) try {

  BondList bonds;

  // Generate all the bonds
  for (auto& [i1, i2] : cluster_bonds) {
    bonds << Bond("HB", "J", {i1, i2});
  }

  bonds["J"] = 1.0; // Sets bond strength of bondspec "J"

  // generate the symmetries
  std::vector<Permutation> perm_generators = {
    //                             {0, 1, 2, 3, 4, 5, 6}
      Permutation(std::vector<int>({0, 2, 3, 1, 5, 6, 4})),
      Permutation(std::vector<int>({0, 1, 3, 2, 4, 6, 5})),
      Permutation(std::vector<int>({0, 4, 5, 6, 1, 2, 3}))
      };

  set_verbosity(3);

  // Create the symmetry group
  auto group = generated_group(perm_generators);
  auto irrep = Representation(static_cast<std::vector<complex>>(symmetry::irreps_D3d[argv[1]]));

  auto block = Spinhalf(N_SITES, group, irrep);
  double e0 = eigval0(bonds, block);
  Log("e0: {}", e0);

} catch (Error e) {
  error_trace(e);
}

Running this code yields the log Error constructing PermutationGroup: group multiplication not closed which is clearly untrue, since $D_{3d}$ is a perfectly well defined group. Where is the mistake here?

For reference, I'm running XDiag Version: 0.2.0 Git hash : 4891db93d76818dd84bd2db434326f30590060da

awietek commented 2 months ago

Thank you for filing the issue. I am amazed you found the function generated_group, but probably it was somewhere in the examples. This function will be deleted soon, as I think it is a bit opaque what it does and doesn't really serve a good purpose. Still, It's weird you got an error here.

What I would suggest is that you explicitly build the whole group. You can actually multiply Permutations with the "*" operator and you can compute inverses, see https://awietek.github.io/xdiag/documentation/symmetries/permutation/

I would suggest that you explicitly build the group with multiplication and using inverses. One also needs to add the identity element. Could you give that a try and let me know if you still have the same issue?