implemented a frist try to include symmetry into interactionAssessment routine
[cluster_expansion.git] / Lattice.cpp
blobca8d21c167ddedef7811d3bfa2e33475abf2431d
1 #include <stdexcept>
3 #include "Lattice.h"
4 #include "SimpleIni.h"
6 // FIXME: LatticeType should derive operator= from Array<Occupation, 2>
7 LatticeLayer& LatticeLayer::operator=(Occupation const& o) {
8 for (LatticeLayer::iterator i = this->begin(); i != this->end(); ++i)
9 this->operator()(i.position()) = o;
10 return *this;
13 ostream& operator<<(ostream& output, const LatticeLayer& layer)
15 for (int y = 0; y < layer.extent(secondDim); ++y) {
16 for (int x = 0; x < layer.extent(firstDim); ++x) {
17 switch (layer(x,y)) {
18 case empty: cout << "."; break;
19 case CO: cout << "C"; break;
20 case Pd: cout << "P"; break;
21 default: throw out_of_range("Invalid occupation");
24 output << endl;
27 return output;
30 void
31 Lattice::extendUnitCell(void)
33 extendUnitCell(adsorbates, UnitCellSizeX, UnitCellSizeY);
34 extendUnitCell(surface, UnitCellSizeX, UnitCellSizeY);
37 void
38 Lattice::extendUnitCell(LatticeLayer latticeLayer, int dimX, int dimY)
40 for (LatticeLayer::iterator i = latticeLayer.begin();
41 i != latticeLayer.end(); i++) {
42 int x = i.position()[0];
43 int y = i.position()[1];
44 latticeLayer(x, y) = latticeLayer(x % dimX, y % dimY);
49 void
50 Lattice::assessInteractions(Interactions &interactions)
52 for (LatticeLayer::iterator i = adsorbates.begin(); i != adsorbates.end(); i++) {
53 if (adsorbates(i.position()) == empty)
54 continue;
55 cout << "POS" << i.position() << endl;
56 for (Interactions::iterator interaction = interactions.begin();
57 interaction != interactions.end(); interaction++) {
58 cout << "checking " << interaction->name << ": ";
59 for (Directions::iterator direction = interaction->directions.begin();
60 direction != interaction->directions.end(); direction++) {
61 // FIXME: what about symmetry operations??
62 for (Directions::iterator symmetry_operation = lattice.symmetry.begin();
63 symmetry_operation != lattice.symmetry.end()) {
65 int x = (i.position()[firstDim] + (int)((direction->x / UnitCellSizeX)*
66 symmetry_operation->direction.x) %
67 (UnitCellSizeX * Longitude);
68 int y = (i.position()[secondDim] + (int)((direction->y / UnitCellSizeY)*
69 symmetry_operation->direction.y)) %
70 (UnitCellSizeY * Latitude);
71 cout << "(" << x << "/" << y << ") ";
72 if (adsorbates(x, y) != empty) {
73 interaction->multiplicity++;
74 cout << "HIT ";
78 cout << endl;
83 double
84 Lattice::getEnergy()
86 // FIXME: IMPLEMENTATION HERE
87 return 0.0;
90 ostream& operator<<(ostream& output, const Lattice& lattice)
92 output << "lattice: UnitCellSizeX = " << lattice.UnitCellSizeX
93 << ", UnitCellSizeY = " << lattice.UnitCellSizeY
94 << ", Latitude = " << lattice.Latitude
95 << ", Longitude = " << lattice.Longitude << endl
96 << "surface: " << endl << lattice.surface
97 << "adsorbates: " << endl << lattice.adsorbates;
99 return output;