From 350a0ce206350616c4d6c9e5cbd3599cb48a8592 Mon Sep 17 00:00:00 2001 From: rieger Date: Mon, 21 Apr 2008 16:44:22 +0200 Subject: [PATCH] added explanations in .ini file added symmetry section to .ini file added second array to resemble underlying surface structure (for further applications) copied read procedure for surface array added lattice construction and resizing increment of +1 to get right surface setup --- input.ini | 26 +++++++++++++++++++------- main.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 66 insertions(+), 15 deletions(-) diff --git a/input.ini b/input.ini index 5ce534c..bb30d19 100644 --- a/input.ini +++ b/input.ini @@ -1,14 +1,26 @@ ; Input file for the cluster expansion of lateral interaction of CO molecules -; adsorbed at bridge sites +; adsorbed at adsorption sites +; General Parameter section for the Simulation +; [SimulationParameters] +; Definition of Unit Cell (Longitude, Latitide) and lattice mesh to be mapped on cell (SizeX, SizeY) [UnitCell] SizeX = 4 SizeY = 4 -Longitude = 2 +Longitude = 2 Latitude = 1 - +; Definition of surface structure +[Surface] +Pd = 0.0/0.0 +Pd = 0.5/0.5 ; Now defining the CO adsorbate positions in fractional coordinates of unit cell [Adsorbates] -CO = 0.25/0.25 -CO = 0.125/0.5 -CO = 0.25/0.1 - +CO = 0.25/0.125 +;CO = 0.25/0.75 +;CO = 0.75/0.75 +; Site-symmetry of adsorption site described as symmetry operations +; Bridge site (for CO) got C2v symmetry +[bridge] +sym_operation = 1 1 +sym_operation = -1 1 +sym_operation = 1 -1 +sym_operation = -1 -1 diff --git a/main.cpp b/main.cpp index aa5df4b..717600d 100755 --- a/main.cpp +++ b/main.cpp @@ -22,15 +22,21 @@ using namespace blitz; using namespace ranlib; -enum Occupation { +enum Occupation { empty = 0, - PD, CO }; +enum Atom { + no_atom = 0, + Pd = 2 +}; + + class Lattice { public: Array sites; + Array surface; int Latitude, Longitude; int UnitCellSizeX, UnitCellSizeY; }; @@ -95,10 +101,41 @@ void read_ini_structure(const char *input_file_name, Lattice &lattice) lattice.Longitude < 1 || lattice.Latitude < 1) panic("Unit cell has unreasonable size."); - lattice.sites.resize(lattice.Longitude * lattice.UnitCellSizeX, - lattice.Latitude * lattice.UnitCellSizeY); + // Building adsorbate sites array + lattice.sites.resize(lattice.Longitude * lattice.UnitCellSizeX + 1, + lattice.Latitude * lattice.UnitCellSizeY + 1); lattice.sites = empty; + + // Building surface sites array + lattice.surface.resize(lattice.Longitude * lattice.UnitCellSizeX + 1, + lattice.Latitude * lattice.UnitCellSizeY + 1); + lattice.surface = no_atom; + + // Parse Adsorbates + section = ini.GetSection("Surface"); + if (!section) + panic("Ini file is missing 'Surface' section. Maybe meaningful??"); + + CSimpleIniA::TNamesDepend Pd_positions; + ini.GetAllValues("Surface", "Pd", Pd_positions); + for (CSimpleIniA::TNamesDepend::const_iterator i = Pd_positions.begin(); + i != Pd_positions.end(); ++i) { + double x_frac, y_frac; + if (sscanf(i->pItem, "%lf/%lf", &x_frac, &y_frac) != 2 || + x_frac < 0 || x_frac >= 1 || + y_frac < 0 || y_frac >= 1) + panic("Skrewed coordinates in '%s'", i->pItem); + lattice.surface((int)(lattice.UnitCellSizeX * x_frac), + (int)(lattice.UnitCellSizeY * y_frac)) = Pd; + } + // Replicate surface unit cell to full dimension + for (int x = 0; x < lattice.Longitude * lattice.UnitCellSizeX + 1; ++x) + for (int y = 0; y < lattice.Latitude * lattice.UnitCellSizeY + 1; ++y) + lattice.surface(x, y) = + lattice.surface((x % lattice.UnitCellSizeX), + (y % lattice.UnitCellSizeY)); + // Parse Adsorbates section = ini.GetSection("Adsorbates"); if (!section) @@ -116,13 +153,14 @@ void read_ini_structure(const char *input_file_name, Lattice &lattice) lattice.sites((int)(lattice.UnitCellSizeX * x_frac), (int)(lattice.UnitCellSizeY * y_frac)) = CO; } - - // Replicate unit cell to full dimension - for (int x = 0; x < lattice.Longitude * lattice.UnitCellSizeX; ++x) - for (int y = 0; y < lattice.Latitude * lattice.UnitCellSizeY; ++y) + + // Replicate adsorbates unit cell to full dimension + for (int x = 0; x < lattice.Longitude * lattice.UnitCellSizeX + 1; ++x) + for (int y = 0; y < lattice.Latitude * lattice.UnitCellSizeY + 1; ++y) lattice.sites(x, y) = lattice.sites((x % lattice.UnitCellSizeX), (y % lattice.UnitCellSizeY)); + } int main(int argc, char* argv[]) @@ -133,6 +171,7 @@ int main(int argc, char* argv[]) read_ini_structure(argv[1], lattice); cout << "lattice:" << endl << lattice.sites; + cout << "underlying surface:" << endl << lattice.surface; exit(EXIT_SUCCESS); } -- 2.11.4.GIT