changed usage of SizeX, SizeY as unit cell descriptors and Longitude, Lattitude als...
[cluster_expansion.git] / Lattice.cpp
blob2b1ad02d725a06fb854c9f962dbedecebd65f9ed
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 int x = (i.position()[firstDim] + (int)(direction->x * UnitCellSizeX)) %
63 (UnitCellSizeX * Longitude);
64 int y = (i.position()[secondDim] + (int)(direction->y * UnitCellSizeY)) %
65 (UnitCellSizeY * Latitude);
66 cout << "(" << x << "/" << y << ") ";
67 if (adsorbates(x, y) != empty) {
68 interaction->multiplicity++;
69 cout << "HIT ";
72 cout << endl;
77 double
78 Lattice::getEnergy()
80 // FIXME: IMPLEMENTATION HERE
81 return 0.0;
84 ostream& operator<<(ostream& output, const Lattice& lattice)
86 output << "lattice: UnitCellSizeX = " << lattice.UnitCellSizeX
87 << ", UnitCellSizeY = " << lattice.UnitCellSizeY
88 << ", Latitude = " << lattice.Latitude
89 << ", Longitude = " << lattice.Longitude << endl
90 << "surface: " << endl << lattice.surface
91 << "adsorbates: " << endl << lattice.adsorbates;
93 return output;