Fixed interim version of checkInteractions, further renamed it to assessInteractions
[cluster_expansion.git] / Lattice.cpp
blobd00c792bee97ce7bc80a32d4c769556f777e3b03
1 #include <stdexcept>
3 #include "Lattice.h"
4 #include "SimpleIni.h"
6 Lattice::Lattice()
8 Lattice(1,1,1,1);
11 Lattice::Lattice(int Longitude, int Latitude,
12 int UnitCellSizeX, int UnitCellSizeY) :
13 Latitude(Latitude), Longitude(Longitude),
14 UnitCellSizeX(UnitCellSizeX), UnitCellSizeY(UnitCellSizeY)
16 // FIXME: add error handling
17 this->adsorbates.resize(Longitude * UnitCellSizeX + 1,
18 Latitude * UnitCellSizeY + 1);
19 this->adsorbates = empty;
20 this->surface.resize(this->adsorbates.shape());
21 this->surface = empty;
24 void
25 Lattice::extendUnitCell(void)
27 extendUnitCell(adsorbates, UnitCellSizeX, UnitCellSizeY);
28 extendUnitCell(surface, UnitCellSizeX, UnitCellSizeY);
31 void
32 Lattice::extendUnitCell(LatticeType lattice, int dimX, int dimY)
34 for (LatticeType::iterator i = lattice.begin(); i != lattice.end(); i++) {
35 int x = i.position()[0];
36 int y = i.position()[1];
37 lattice(x, y) = lattice(x % dimX, y % dimY);
43 void
44 Lattice::assessInteractions(Interactions interactions)
46 for (LatticeType::iterator i = adsorbates.begin(); i != adsorbates.end(); i++) {
47 if (adsorbates(i.position()) == empty)
48 continue;
50 for (Interactions::iterator interaction = interactions.begin();
51 interaction != interactions.end(); interaction++) {
52 for (Directions::iterator direction = interaction->directions.begin();
53 direction != interaction->directions.end(); direction++) {
54 // FIXME: what about symmetry operations??
55 int x = (i.position()[firstDim] + (int)(direction->x * UnitCellSizeX)) %
56 (UnitCellSizeX * Longitude);
57 int y = (i.position()[secondDim] + (int)(direction->y * UnitCellSizeY)) %
58 (UnitCellSizeY * Latitude);
59 if (adsorbates(x, y) != empty)
60 interaction->multiplicity++;
66 double
67 Lattice::getEnergy()
69 // FIXME: IMPLEMENTATION HERE
70 return 0.0;