Commit 6536ef92 authored by Alvarez, Gonzalo's avatar Alvarez, Gonzalo
Browse files

ladder geometry; long range geometry

Ladder geometry now supports odd legs.

Ladder geometry now honors IsPeriodicX=1 even for DMRG++,
but note that GeometryMaxConnections is then set to number of sites.

LongRange geometry now makes GeometryMaxConnections= mandatory.
Say 0 if in doubt.
parent 0bf39d8f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ use warnings;
use strict;

use Getopt::Long qw(:config no_ignore_case);
use lib "../../PsimagLite/scripts";
use lib "../scripts";
use NewMake;
use PsiTag;

+17 −17
Original line number Diff line number Diff line
@@ -118,9 +118,6 @@ public:
			if (leg_>2) throw RuntimeError("LadderLeg>2 must have IsPeriodicY= line\n");
		}

		if (leg_ & 1)
			throw RuntimeError("Ladder: leg must be even\n");

		if (leg_ == 2)
			isPeriodicY_ = false;

@@ -161,7 +158,7 @@ public:
		return sizeof(*this);
	}

	virtual SizeType maxConnections() const { return leg_ + 1; }
	virtual SizeType maxConnections() const { return (isPeriodicX_) ? linSize_ : leg_ + 1; }

	virtual SizeType dirs() const { return 2; }

@@ -192,8 +189,7 @@ public:
	SizeType calcDir(SizeType i1,SizeType i2) const
	{
		assert(connected(i1,i2));
		if (sameColumn(i1,i2)) return DIRECTION_Y;
		return DIRECTION_X;
		return (sameColumn(i1,i2)) ? DIRECTION_Y : DIRECTION_X;
	}

	bool fringe(SizeType i,SizeType smax,SizeType emin) const
@@ -223,18 +219,20 @@ public:

	SizeType handle(SizeType i1,SizeType i2) const
	{
		SizeType dir = calcDir(i1,i2);
		SizeType imin = (i1<i2) ? i1 : i2;
		SizeType y = imin/leg_;
		const SizeType dir = calcDir(i1,i2);
		const SizeType imin = (i1 < i2) ? i1 : i2;
		const SizeType imax = (i1 < i2) ? i2 : i1;
		const SizeType y = imin/leg_;
		switch(dir) {
		case DIRECTION_X:
			return imin;
			if (!isPeriodicX_) return imin;
			return (imin < leg_ && imax == imin + linSize_ - leg_) ? imax : imin;
		case DIRECTION_Y:
			if (!isPeriodicY_) return imin-imin/leg_;
			if (imin ==0 || imin % leg_ == 0) imin = (i1>i2) ? i1 : i2;
			return imin-imin/leg_ + y;
			if (!isPeriodicY_) return imin - y;
			return (imin % leg_ == 0 && imax == imin + leg_ -1) ? imax : imin;
		}
		throw RuntimeError("hanlde: Unknown direction\n");

		throw RuntimeError("handle: Unknown direction\n");
	}

	bool sameColumn(SizeType i1,SizeType i2) const
@@ -294,6 +292,8 @@ public:

	bool isPeriodicY() const { return isPeriodicY_; }

	bool isPeriodicX() const { return isPeriodicX_; }

private:

	SizeType translateInternal(SizeType c,SizeType l,SizeType amount) const
+4 −1
Original line number Diff line number Diff line
@@ -98,7 +98,10 @@ public:
		orbitals_ = static_cast<SizeType>(matrix_.rows()/linSize);
		try {
			io.readline(maxConnections_,"GeometryMaxConnections=");
		} catch (std::exception&) {}
		} catch (std::exception& e) {
			std::cerr<<"Please add GeometryMaxConnections=0 or some other number\n";
			throw e.what();
		}
	}

	virtual void set(MatrixType& m, SizeType orbitals) const