From d4803e8cc3a12cb44bd6cfa2ef81674916c706f4 Mon Sep 17 00:00:00 2001 From: Michael Rieger Date: Wed, 16 Apr 2008 17:58:46 +0200 Subject: [PATCH] final format definition of structure.ini file rewritten reading routine for CObr positions not working completely, some mismatch of type conversion for fractional coordinates in lattice coordinates enumerating CObr atoms is also not working correctly --- input.ini | 56 +++++++++++++++++++++++-------------- main.cpp | 94 +++++++++++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 106 insertions(+), 44 deletions(-) diff --git a/input.ini b/input.ini index c56b969..48a1404 100644 --- a/input.ini +++ b/input.ini @@ -2,30 +2,44 @@ ; at bridge sites ; [cell] -; first: definition of the unit cell in terms of multipliers of x,y of square c(2x2)= (1,1) unit cells -unit_cell_x = 2 -unit_cell_y = 1 +; first: definition of the unit cell in terms of multipliers of A,B of (A*sqrt2 x B*sqrt2) R45 cells +unit_cell_A = 1 +unit_cell_B = 1 ; ; now defining the CO adsorbate positions, for each adsorbed CO an own section ; giving in fractional coordinates of the unit cell +; +; first: general information: total number of adsorbates in unit cell [adsorbates] +nr_of_CObr = 3 +; second: position of each +[CO_1] x = 0.25 -y = 0.33 -;[CO_2] -x = 0.3 -y = 0.7 +y = 0.25 +[CO_2] +x = 0.75 +y = 0.75 ;[CO_3] -x = 0.6 -y = 0.99 - -;[ec-0-0] -;c3 = 1/4, 1/8 -;fe3 = 1/6, 7/8 - -;[ec-1-0] -;c4 = 1/4, 7/8 - -;[ec-0-1] -;fe5 = 1/6, 1/6 - -;[ec-1-1] \ No newline at end of file +x = 0.25 +y = 0.75 +; +; now defining symmetry of adsorption position: C2v for bridge site -> 4 symmetrie operations +; given as x,y value pairs of the mirroring vector +; +; first: general information: total number of symmetrie operations included +[sym] +nr_of_symmetry_operations = 4 +; +; second: vectors for each operation +[sym_1] +x = 1 +y = 1 +[sym_2] +x = -1 +y = 1 +[sym_3] +x = 1 +y = -1 +[sym_4] +x = -1 +y = -1 \ No newline at end of file diff --git a/main.cpp b/main.cpp index 594fd65..b520567 100755 --- a/main.cpp +++ b/main.cpp @@ -9,6 +9,7 @@ #include #include +#include #include // http://www.oonumerics.org/blitz/ #include // blitz Random Number Generator - Mersenne Twister type @@ -20,6 +21,7 @@ using namespace ranlib; Array lattice; Array CObr_pos; +Array symmetry_operation; enum occupation { @@ -35,27 +37,42 @@ enum directions max_directions }; +string itos(int i) // convert int to string + { + stringstream s; + s << i; + return s.str(); + } -int read_ini_structure(const char *input_file_name, int &lattice_size_x, int &lattice_size_y, int &nr_of_CObr) +int read_ini_structure(const char *input_file_name, int &lattice_size_x, int &lattice_size_y, int &nr_of_CObr, int &nr_of_symmetry_operations) { CSimpleIni ini; - int unit_cell_x,unit_cell_y; + int unit_cell_A,unit_cell_B; //loading input file SI_Error rc = ini.LoadFile(input_file_name); if (rc < 0) return false; // getting cell dimensions from [cell] section in input file - unit_cell_x = atoi(ini.GetValue("cell", "unit_cell_x")); - std::cout << unit_cell_x << endl; - unit_cell_y = atoi(ini.GetValue("cell", "unit_cell_y")); - std::cout << unit_cell_y << endl; + unit_cell_A = atoi(ini.GetValue("cell", "unit_cell_A")); + std::cout << unit_cell_A << endl; + unit_cell_B = atoi(ini.GetValue("cell", "unit_cell_B")); + std::cout << unit_cell_B << endl; // creating simulation lattice - lattice_size_x = 4*unit_cell_x; - lattice_size_y = 4*unit_cell_y; + lattice_size_x = 4*unit_cell_A; + lattice_size_y = 4*unit_cell_B; std::cout << lattice_size_x << " " << lattice_size_y << endl; + // get nr of adsorbed CO br molecules as given in the simulation file + + nr_of_CObr = atoi(ini.GetValue("adsorbates", "nr_of_CObr")); + + // get nr of symmetry operations for adsorption site + + nr_of_symmetry_operations = atoi(ini.GetValue("sym", "nr_of_symmetry_operations")); + + /* // output all of the items of the input file CSimpleIniA::TNamesDepend sections; @@ -118,7 +135,7 @@ int read_ini_structure(const char *input_file_name, int &lattice_size_x, int &la printf("end of input file reading"); - + */ return 1; } @@ -139,9 +156,38 @@ int fill_surface_atoms(Array lattice, occupation site_occupation, int la return 1; } -int get_and_fill_adorbates(const char *input_file_name, Array lattice, Array CObr_pos, occupation atom, int lattice_size_x, int lattice_size_y) +int get_and_fill_adorbates(const char *input_file_name, Array lattice, Array CObr_pos, occupation atom, int lattice_size_x, int lattice_size_y, int nr_of_CObr) { CSimpleIni ini; + //loading input file + SI_Error rc = ini.LoadFile(input_file_name); + if (rc < 0) return false; + + string section_name; + section_name = "CO_"; + + // not completely working so far, but we are on the right way. + // some mismatch in type conversion of fractional coordinates of CObr + // some problems with enumerating all CObr + + for (int i = 1; i < nr_of_CObr; i++) + { + string CO_counter = itos(i); + section_name += CO_counter; + cout << section_name << endl; + CObr_pos(i,1) = int ( lattice_size_x * atof(ini.GetValue( section_name.c_str(), "x"))); + CObr_pos(i,2) = int ( lattice_size_y * atof(ini.GetValue( section_name.c_str(), "x"))); + section_name = "CO_"; + }; + + for (int i = 1; i < nr_of_CObr; i++) + { + cout << "x-koordinaten fuer CO " << i << " ist " << CObr_pos(i,1) << endl; + cout << "y-koordinaten fuer CO " << i << " ist " << CObr_pos(i,2) << endl; + }; + + /* + CSimpleIni ini; CSimpleIniA::TNamesDepend sections; CSimpleIniA::TNamesDepend keys; CSimpleIniA::TNamesDepend::const_iterator sections_iterator; @@ -150,25 +196,27 @@ int get_and_fill_adorbates(const char *input_file_name, Array lattice, A SI_Error rc = ini.LoadFile(input_file_name); if (rc < 0) return false; - const char * pszValue = ini.GetValue("adsorbates","x", NULL /*default*/); - bool bHasMultipleValues = true; - pszValue = ini.GetValue("adsorbates", "x", NULL /*default*/, &bHasMultipleValues); + // const char * pszValue = ini.GetValue("adsorbates","x", NULL , &bHasMultipleValues); + // bool bHasMultipleValues = true; + // pszValue = ini.GetValue("adsorbates", "x", NULL , &bHasMultipleValues); // const char *wert; - // *wert = ini.GetValue("adsorbates", "x",NULL /*default*/, &bHasMultipleValues); + // *wert = ini.GetValue("adsorbates", "x",NULL , &bHasMultipleValues); + + // std::cout << pszValue; CSimpleIniA::TNamesDepend values; ini.GetAllValues("adsorbates", "x", values); - values.sort(CSimpleIniA::Entry::LoadOrder()); + // values.sort(CSimpleIniA::Entry::LoadOrder()); CSimpleIniA::TNamesDepend::const_iterator value_iterator; - for (value_iterator = values.begin(); value_iterator != values.end(); ++value_iterator) + for ((value_iterator = values.begin()); value_iterator != values.end(); value_iterator++) { printf("key-name = '%s'\n", value_iterator->pItem); }; - /* + @@ -180,15 +228,14 @@ int get_and_fill_adorbates(const char *input_file_name, Array lattice, A ini.GetAllSections(sections); sections_iterator = sections.end(); - sections_iterator--; + // sections_iterator--; ini.GetAllKeys(sections_iterator->pItem, keys); for (CSimpleIniA::TNamesDepend::const_iterator key_iterator = keys.begin(); key_iterator != keys.end(); ++key_iterator) { std::cout << key_iterator->pItem << endl; }; - */ - + */ return 1; } @@ -196,14 +243,15 @@ int get_and_fill_adorbates(const char *input_file_name, Array lattice, A int main(int argc, char* argv[]) { int lattice_size_x, lattice_size_y; - int nr_of_CObr; + int nr_of_CObr, nr_of_symmetry_operations; // subroutine to read all necessary input files - if (read_ini_structure(argv[1], lattice_size_x, lattice_size_y, nr_of_CObr)) + if (read_ini_structure(argv[1], lattice_size_x, lattice_size_y, nr_of_CObr, nr_of_symmetry_operations)) { std::cout << "\n\n filling surface atoms now\n" << std::endl; Array lattice(lattice_size_x,lattice_size_y); // array constructor Array CObr_pos(nr_of_CObr, max_directions); + Array symmetry_operation(nr_of_symmetry_operations, max_directions); lattice = 0; CObr_pos = 1; @@ -215,7 +263,7 @@ int main(int argc, char* argv[]) // filling surface atoms fill_surface_atoms(lattice, Pd, lattice_size_x, lattice_size_y); - get_and_fill_adorbates(argv[1], lattice, CObr_pos, CO, lattice_size_x, lattice_size_y); + get_and_fill_adorbates(argv[1], lattice, CObr_pos, CO, lattice_size_x, lattice_size_y, nr_of_CObr); } -- 2.11.4.GIT