From 92a1952b0674e33cde1379690cb5a96412fd8f64 Mon Sep 17 00:00:00 2001 From: Miles Stoudenmire Date: Tue, 28 Apr 2020 22:48:56 -0400 Subject: [PATCH] Fix totalQN function to always succeed if lims set --- itensor/mps/mpsalgs.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/itensor/mps/mpsalgs.cc b/itensor/mps/mpsalgs.cc index cf98ff9bd..9648ecb0b 100644 --- a/itensor/mps/mpsalgs.cc +++ b/itensor/mps/mpsalgs.cc @@ -241,10 +241,14 @@ checkQNs(MPS const& psi) QN totalQN(MPS const& psi) { - const int center = findCenter(psi); - if(center == -1) - Error("Could not find ortho. center"); - return div(psi(center)); + auto tq = QN(); + auto sj = psi.leftLim()+1; + auto ej = psi.rightLim()-1; + for(int j = sj; j <= ej; ++j) + { + tq += flux(psi(j)); + } + return tq; } } //namespace itensor