Commit 195e499f authored by Alvarez, Gonzalo's avatar Alvarez, Gonzalo
Browse files

ChemicalH: SuperPlaquette geometry

parent d54a155a
......@@ -18,12 +18,10 @@ public:
SizeType smax,
SizeType emin,
const VectorSizeType& block)
: block_(block),
data_(superGeometry.overSize(block.size()))
: block_(block)
{
VectorSizeType v(2, 0);
SizeType n = block.size();
SizeType counter = 0;
for (SizeType i = 0; i < n; ++i) {
for (SizeType j = i + 1; j < n; ++j) {
v[0] = block[i];
......@@ -35,14 +33,11 @@ public:
if (type == ProgramGlobals::ConnectionEnum::SYSTEM_SYSTEM ||
type == ProgramGlobals::ConnectionEnum::ENVIRON_ENVIRON) continue;
assert(counter < data_.size());
data_[counter++] = v;
data_.push_back(v);
}
}
//counter = superGeometry.addSuperConnections(data_, smax, emin, block, counter);
data_.resize(counter);
superGeometry.addSuperConnections(data_, smax, emin);
}
SizeType items() const { return data_.size(); }
......
......@@ -271,6 +271,9 @@ private:
SizeType cacheConnections(SizeType x)
{
const VectorSizeType& hItems = hamAbstract_.item(x);
if (hItems.size() == 0) return 0;
assert(superGeometry_.connected(smax_, emin_, hItems));
ProgramGlobals::ConnectionEnum type = superGeometry_.connectionKind(smax_, hItems);
......
......@@ -14,11 +14,81 @@ class SuperGeometry {
typedef typename GeometryType::VectorSizeType VectorSizeType;
typedef typename PsimagLite::Vector<VectorSizeType>::Type VectorVectorSizeType;
class SuperPlaquette {
public:
SuperPlaquette(InputType_& io) : value_(0)
{
io.readline(value_, "SuperPlaquetteValue=");
}
bool connected(SizeType emax, SizeType emin, const VectorSizeType& hItems) const
{
assert(hItems.size() == 4);
return (hItems[1] == hItems[0] + 1 &&
hItems[2] == hItems[1] + 1 &&
hItems[3] == hItems[2] + 1);
}
void addSuperConnections(VectorVectorSizeType& data,
SizeType smax,
SizeType emin,
SizeType linSize) const
{
return (smax + 1 == emin) ? addSuperConnectionsFinite_(data, smax, emin, linSize)
: addSuperConnectionsInfinite_(data, smax, emin, linSize);
}
SizeType holloutRadius() const { return 4; }
ComplexOrRealType operator()(SizeType smax,
SizeType emin,
const VectorSizeType& hItems,
const VectorSizeType& edofs) const
{
return value_;
}
private:
void addSuperConnectionsInfinite_(VectorVectorSizeType& data,
SizeType smax,
SizeType emin,
SizeType linSize) const
{
// FIXME: Add here site substitutions for when the lattice is not fully built
return;
}
void addSuperConnectionsFinite_(VectorVectorSizeType& data,
SizeType smax,
SizeType emin,
SizeType linSize) const
{
// smax - 1, smax, emin, emin + 1
if (smax > 0 && emin + 1 < linSize)
data.push_back(VectorSizeType{smax - 1, smax, emin, emin + 1});
// smax, emin, emin + 1, emin + 2
if (emin + 2 < linSize)
data.push_back(VectorSizeType{smax, emin, emin + 1, emin + 2});
// smax - 2, smax -1, smax, emin
if (smax > 1)
data.push_back(VectorSizeType{smax - 2, smax - 1, smax, emin});
}
typename GeometryType::RealType value_;
};
public:
typedef typename GeometryType::RealType RealType;
typedef PsimagLite::GeometryDca<RealType,GeometryType> GeometryDcaType;
typedef PsimagLite::Vector<PsimagLite::String>::Type VectorStringType;
typedef typename PsimagLite::Vector<SuperPlaquette*>::Type VectorSuperPlaquetteType;
SuperGeometry(InputType_& io)
: geometry_(io), dcaPtr_(0), hollowOutRadius_(0)
......@@ -30,12 +100,11 @@ public:
// super term found
// it's gotta be "SuperPlaquette" for now, (only one option, sorry!)
if (geometry_.options(i) == "SuperPlaquette") {
if (std::find(superStrings_.begin(),
superStrings_.end(),
"SuperPlaquette") != superStrings_.end())
continue;
superStrings_.push_back("SuperPlaquette");
hollowOutRadius_ = 4;
auto ptr = new SuperPlaquette(io);
superStrings_.push_back(ptr);
hollowOutRadius_ = std::max(hollowOutRadius_, ptr->holloutRadius());
} else {
err("SuperGeometry " + geometry_.options(i) + " unsupported\n");
}
}
}
......@@ -43,7 +112,12 @@ public:
~SuperGeometry()
{
delete dcaPtr_;
dcaPtr_ = 0;
dcaPtr_ = nullptr;
const SizeType n = superStrings_.size();
for (SizeType i = 0; i < n; ++i) {
delete superStrings_[i];
superStrings_[i] = nullptr;
}
}
void split(SizeType sitesPerBlock,
......@@ -91,24 +165,44 @@ public:
const VectorSizeType& edofs,
SizeType term) const
{
checkVectorHasTwoEntries(hItems);
checkVectorHasTwoEntries(edofs);
return geometry_(smax, emin, hItems[0], edofs[0], hItems[1], edofs[1], term);
const SizeType n = hItems.size();
assert(n == edofs.size());
if (n == 2)
return geometry_(smax, emin, hItems[0], edofs[0], hItems[1], edofs[1], term);
assert(superStrings_.size() == 1);
return superStrings_[0]->operator()(smax, emin, hItems, edofs);
}
bool connected(SizeType smax,SizeType emin, const VectorSizeType& hItems) const
{
checkVectorHasTwoEntries(hItems);
if (hItems.size() == 2)
return geometry_.connected(smax, emin, hItems[0], hItems[1]);
const SizeType n = superStrings_.size();
for (SizeType i = 0; i < n; ++i)
if (superStrings_[i]->connected(smax, emin, hItems))
return true;
return geometry_.connected(smax, emin, hItems[0], hItems[1]);
return false;
}
typename ProgramGlobals::ConnectionEnum connectionKind(SizeType smax,
const VectorSizeType& hItems) const
{
checkVectorHasTwoEntries(hItems);
if (hItems.size() == 2)
return geometry_.connectionKind(smax, hItems[0], hItems[1]);
return geometry_.connectionKind(smax, hItems[0], hItems[1]);
const SizeType n = hItems.size();
SizeType flag = 0;
for (SizeType i = 0; i < n; ++i) {
if (hItems[i] <= smax) flag |= 1;
else flag |= 2;
}
return (flag == 3) ? ProgramGlobals::ConnectionEnum::SYSTEM_ENVIRON
: ProgramGlobals::ConnectionEnum::SYSTEM_SYSTEM;
}
const GeometryDcaType& createDcaObject(SizeType orbitals) const
......@@ -118,19 +212,13 @@ public:
return *dcaPtr_;
}
SizeType overSize(SizeType blockSize) const
{
return blockSize*(blockSize/2 + 1); // + superc_.size();
}
SizeType addSuperConnections(VectorVectorSizeType& data,
SizeType smax,
SizeType emin,
const VectorSizeType& block,
SizeType counter) const
void addSuperConnections(VectorVectorSizeType& data,
SizeType smax,
SizeType emin) const
{
SizeType c = addSuperConnections_(data, smax, emin, block);
return c + counter;
const SizeType n = superStrings_.size();
for (SizeType i = 0; i < n; ++i)
superStrings_[i]->addSuperConnections(data, smax, emin, geometry_.numberOfSites());
}
friend std::ostream& operator<<(std::ostream& os, const SuperGeometry& supergeometry)
......@@ -141,52 +229,10 @@ public:
private:
SizeType addSuperConnections_(VectorVectorSizeType& data,
SizeType smax,
SizeType emin,
const VectorSizeType& block)
{
return (smax + 1 == emin) ? addSuperConnectionsFinite_(data, smax, emin, block) : 0;
// : addSuperConnectionsInfinite_(data, smax, emin, block);
}
SizeType addSuperConnectionsInfinite_(VectorVectorSizeType& data,
SizeType smax,
SizeType emin,
const VectorSizeType& block)
{
if (superStrings_.size() == 0) return 0;
assert(superStrings_.size() == 1);
assert(superStrings_[0] == "SuperPlaquette");
const SizeType linSize = geometry_.numberOfSites();
// smax - 1, smax, emin, emin + 1
if (smax > 0 && emin + 1 < linSize)
data.push_back(VectorSizeType{smax - 1, smax, emin, emin + 1});
// smax, emin, emin + 1, emin + 2
if (emin + 2 < linSize)
data.push_back(VectorSizeType{smax, emin, emin + 1, emin + 2});
// smax - 2, smax -1, smax, emin
if (smax > 1)
data.push_back(VectorSizeType{smax - 2, smax - 1, smax, emin});
}
static void checkVectorHasTwoEntries(const VectorSizeType& hItems)
{
if (hItems.size() != 2)
err("SuperGeometry unimplemented\n");
}
const GeometryType geometry_;
mutable GeometryDcaType* dcaPtr_;
SizeType hollowOutRadius_;
VectorStringType superStrings_;
VectorSuperPlaquetteType superStrings_;
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment