| 1 | /** \file periodentafel.cpp
|
|---|
| 2 | *
|
|---|
| 3 | * Function implementations for the class periodentafel.
|
|---|
| 4 | *
|
|---|
| 5 | */
|
|---|
| 6 |
|
|---|
| 7 | using namespace std;
|
|---|
| 8 |
|
|---|
| 9 | #include <iomanip>
|
|---|
| 10 | #include <iostream>
|
|---|
| 11 | #include <fstream>
|
|---|
| 12 | #include <cstring>
|
|---|
| 13 |
|
|---|
| 14 | #include "Helpers/Assert.hpp"
|
|---|
| 15 | #include "element.hpp"
|
|---|
| 16 | #include "elements_db.hpp"
|
|---|
| 17 | #include "helpers.hpp"
|
|---|
| 18 | #include "lists.hpp"
|
|---|
| 19 | #include "log.hpp"
|
|---|
| 20 | #include "periodentafel.hpp"
|
|---|
| 21 | #include "verbose.hpp"
|
|---|
| 22 |
|
|---|
| 23 | using namespace std;
|
|---|
| 24 |
|
|---|
| 25 | /************************************* Functions for class periodentafel ***************************/
|
|---|
| 26 |
|
|---|
| 27 | /** constructor for class periodentafel
|
|---|
| 28 | * Initialises start and end of list and resets periodentafel::checkliste to false.
|
|---|
| 29 | */
|
|---|
| 30 | periodentafel::periodentafel()
|
|---|
| 31 | {
|
|---|
| 32 | bool status = true;
|
|---|
| 33 | status = LoadElementsDatabase(new stringstream(elementsDB,ios_base::in));
|
|---|
| 34 | ASSERT(status, "General element initialization failed");
|
|---|
| 35 | status = LoadValenceDatabase(new stringstream(valenceDB,ios_base::in));
|
|---|
| 36 | ASSERT(status, "Valence entry of element initialization failed");
|
|---|
| 37 | status = LoadOrbitalsDatabase(new stringstream(orbitalsDB,ios_base::in));
|
|---|
| 38 | ASSERT(status, "Orbitals entry of element initialization failed");
|
|---|
| 39 | status = LoadHBondAngleDatabase(new stringstream(HbondangleDB,ios_base::in));
|
|---|
| 40 | ASSERT(status, "HBond angle entry of element initialization failed");
|
|---|
| 41 | status = LoadHBondLengthsDatabase(new stringstream(HbonddistanceDB,ios_base::in));
|
|---|
| 42 | ASSERT(status, "HBond distance entry of element initialization failed");
|
|---|
| 43 | };
|
|---|
| 44 |
|
|---|
| 45 | /** destructor for class periodentafel
|
|---|
| 46 | * Removes every element and afterwards deletes start and end of list.
|
|---|
| 47 | * TODO: Handle when elements have changed and store databases then
|
|---|
| 48 | */
|
|---|
| 49 | periodentafel::~periodentafel()
|
|---|
| 50 | {
|
|---|
| 51 | CleanupPeriodtable();
|
|---|
| 52 | };
|
|---|
| 53 |
|
|---|
| 54 | /** Adds element to period table list
|
|---|
| 55 | * \param *pointer element to be added
|
|---|
| 56 | * \return iterator to added element
|
|---|
| 57 | */
|
|---|
| 58 | periodentafel::iterator periodentafel::AddElement(element * const pointer)
|
|---|
| 59 | {
|
|---|
| 60 | atomicNumber_t Z = pointer->getNumber();
|
|---|
| 61 | ASSERT(!elements.count(Z), "Element is already present.");
|
|---|
| 62 | pointer->sort = &pointer->Z;
|
|---|
| 63 | if (pointer->getNumber() < 1 && pointer->getNumber() >= MAX_ELEMENTS)
|
|---|
| 64 | DoeLog(0) && (eLog() << Verbose(0) << "Invalid Z number!\n");
|
|---|
| 65 | pair<iterator,bool> res = elements.insert(pair<atomicNumber_t,element*>(Z,pointer));
|
|---|
| 66 | return res.first;
|
|---|
| 67 | };
|
|---|
| 68 |
|
|---|
| 69 | /** Removes element from list.
|
|---|
| 70 | * \param *pointer element to be removed
|
|---|
| 71 | */
|
|---|
| 72 | void periodentafel::RemoveElement(element * const pointer)
|
|---|
| 73 | {
|
|---|
| 74 | RemoveElement(pointer->getNumber());
|
|---|
| 75 | };
|
|---|
| 76 |
|
|---|
| 77 | /** Removes element from list.
|
|---|
| 78 | * \param Z element to be removed
|
|---|
| 79 | */
|
|---|
| 80 | void periodentafel::RemoveElement(atomicNumber_t Z)
|
|---|
| 81 | {
|
|---|
| 82 | elements.erase(Z);
|
|---|
| 83 | };
|
|---|
| 84 |
|
|---|
| 85 | /** Removes every element from the period table.
|
|---|
| 86 | */
|
|---|
| 87 | void periodentafel::CleanupPeriodtable()
|
|---|
| 88 | {
|
|---|
| 89 | for(iterator iter=elements.begin();iter!=elements.end();++iter){
|
|---|
| 90 | delete(*iter).second;
|
|---|
| 91 | }
|
|---|
| 92 | elements.clear();
|
|---|
| 93 | };
|
|---|
| 94 |
|
|---|
| 95 | /** Finds an element by its atomic number.
|
|---|
| 96 | * If element is not yet in list, returns NULL.
|
|---|
| 97 | * \param Z atomic number
|
|---|
| 98 | * \return pointer to element or NULL if not found
|
|---|
| 99 | */
|
|---|
| 100 | element * const periodentafel::FindElement(atomicNumber_t Z) const
|
|---|
| 101 | {
|
|---|
| 102 | const_iterator res = elements.find(Z);
|
|---|
| 103 | return res!=elements.end()?((*res).second):0;
|
|---|
| 104 | };
|
|---|
| 105 |
|
|---|
| 106 | /** Finds an element by its atomic number.
|
|---|
| 107 | * If element is not yet in list, datas are asked and stored in database.
|
|---|
| 108 | * \param shorthand chemical symbol of the element, e.g. H for hydrogene
|
|---|
| 109 | * \return pointer to element
|
|---|
| 110 | */
|
|---|
| 111 | element * const periodentafel::FindElement(const char * const shorthand) const
|
|---|
| 112 | {
|
|---|
| 113 | element *res = 0;
|
|---|
| 114 | for(const_iterator iter=elements.begin();iter!=elements.end();++iter) {
|
|---|
| 115 | if((*iter).second->getSymbol() == shorthand){
|
|---|
| 116 | res = (*iter).second;
|
|---|
| 117 | break;
|
|---|
| 118 | }
|
|---|
| 119 | }
|
|---|
| 120 | return res;
|
|---|
| 121 | };
|
|---|
| 122 |
|
|---|
| 123 | /** Asks for element number and returns pointer to element
|
|---|
| 124 | * \return desired element or NULL
|
|---|
| 125 | */
|
|---|
| 126 | element * const periodentafel::AskElement() const
|
|---|
| 127 | {
|
|---|
| 128 | element * walker = NULL;
|
|---|
| 129 | int Z;
|
|---|
| 130 | do {
|
|---|
| 131 | DoLog(0) && (Log() << Verbose(0) << "Atomic number Z: ");
|
|---|
| 132 | cin >> Z;
|
|---|
| 133 | walker = this->FindElement(Z); // give type
|
|---|
| 134 | } while (walker == NULL);
|
|---|
| 135 | return walker;
|
|---|
| 136 | };
|
|---|
| 137 |
|
|---|
| 138 | /** Asks for element and if not found, presents mask to enter info.
|
|---|
| 139 | * \return pointer to either present or newly created element
|
|---|
| 140 | */
|
|---|
| 141 | element * const periodentafel::EnterElement()
|
|---|
| 142 | {
|
|---|
| 143 | atomicNumber_t Z = 0;
|
|---|
| 144 | DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl);
|
|---|
| 145 | cin >> Z;
|
|---|
| 146 | element * const res = FindElement(Z);
|
|---|
| 147 | if (!res) {
|
|---|
| 148 | // TODO: make this using the constructor
|
|---|
| 149 | DoLog(0) && (Log() << Verbose(0) << "Element not found in database, please enter." << endl);
|
|---|
| 150 | element *tmp = new element;
|
|---|
| 151 | tmp->Z = Z;
|
|---|
| 152 | DoLog(0) && (Log() << Verbose(0) << "Mass: " << endl);
|
|---|
| 153 | cin >> tmp->mass;
|
|---|
| 154 | DoLog(0) && (Log() << Verbose(0) << "Name [max 64 chars]: " << endl);
|
|---|
| 155 | cin >> tmp->name;
|
|---|
| 156 | DoLog(0) && (Log() << Verbose(0) << "Short form [max 3 chars]: " << endl);
|
|---|
| 157 | cin >> tmp->symbol;
|
|---|
| 158 | AddElement(tmp);
|
|---|
| 159 | return tmp;
|
|---|
| 160 | }
|
|---|
| 161 | return res;
|
|---|
| 162 | };
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 | /******************** Access to iterators ****************************/
|
|---|
| 166 | periodentafel::const_iterator periodentafel::begin(){
|
|---|
| 167 | return elements.begin();
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | periodentafel::const_iterator periodentafel::end(){
|
|---|
| 171 | return elements.end();
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | periodentafel::reverse_iterator periodentafel::rbegin(){
|
|---|
| 175 | return reverse_iterator(elements.end());
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 | periodentafel::reverse_iterator periodentafel::rend(){
|
|---|
| 179 | return reverse_iterator(elements.begin());
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | /** Prints period table to given stream.
|
|---|
| 183 | * \param output stream
|
|---|
| 184 | */
|
|---|
| 185 | bool periodentafel::Output(ostream * const output) const
|
|---|
| 186 | {
|
|---|
| 187 | bool result = true;
|
|---|
| 188 | if (output != NULL) {
|
|---|
| 189 | for(const_iterator iter=elements.begin(); iter !=elements.end();++iter){
|
|---|
| 190 | result = result && (*iter).second->Output(output);
|
|---|
| 191 | }
|
|---|
| 192 | return result;
|
|---|
| 193 | } else
|
|---|
| 194 | return false;
|
|---|
| 195 | };
|
|---|
| 196 |
|
|---|
| 197 | /** Prints period table to given stream.
|
|---|
| 198 | * \param *output output stream
|
|---|
| 199 | * \param *checkliste elements table for this molecule
|
|---|
| 200 | */
|
|---|
| 201 | bool periodentafel::Checkout(ostream * const output, const int * const checkliste) const
|
|---|
| 202 | {
|
|---|
| 203 | bool result = true;
|
|---|
| 204 | int No = 1;
|
|---|
| 205 |
|
|---|
| 206 | if (output != NULL) {
|
|---|
| 207 | *output << "# Ion type data (PP = PseudoPotential, Z = atomic number)" << endl;
|
|---|
| 208 | *output << "#Ion_TypeNr.\tAmount\tZ\tRGauss\tL_Max(PP)L_Loc(PP)IonMass\t# chemical name, symbol" << endl;
|
|---|
| 209 | for(const_iterator iter=elements.begin(); iter!=elements.end();++iter){
|
|---|
| 210 | if (((*iter).first < MAX_ELEMENTS) && (checkliste[(*iter).first])) {
|
|---|
| 211 | (*iter).second->No = No;
|
|---|
| 212 | result = result && (*iter).second->Checkout(output, No++, checkliste[(*iter).first]);
|
|---|
| 213 | }
|
|---|
| 214 | }
|
|---|
| 215 | return result;
|
|---|
| 216 | } else
|
|---|
| 217 | return false;
|
|---|
| 218 | };
|
|---|
| 219 |
|
|---|
| 220 | /** Loads element list from file.
|
|---|
| 221 | * \param *path to to standard file names
|
|---|
| 222 | */
|
|---|
| 223 | bool periodentafel::LoadPeriodentafel(const char *path)
|
|---|
| 224 | {
|
|---|
| 225 | ifstream input;
|
|---|
| 226 | bool status = true;
|
|---|
| 227 | bool otherstatus = true;
|
|---|
| 228 | char filename[255];
|
|---|
| 229 |
|
|---|
| 230 | // fill elements DB
|
|---|
| 231 | strncpy(filename, path, MAXSTRINGSIZE);
|
|---|
| 232 | strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
|
|---|
| 233 | strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename));
|
|---|
| 234 | input.open(filename);
|
|---|
| 235 | status = status && LoadElementsDatabase(&input);
|
|---|
| 236 |
|
|---|
| 237 | // fill valence DB per element
|
|---|
| 238 | strncpy(filename, path, MAXSTRINGSIZE);
|
|---|
| 239 | strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
|
|---|
| 240 | strncat(filename, STANDARDVALENCEDB, MAXSTRINGSIZE-strlen(filename));
|
|---|
| 241 | input.open(filename);
|
|---|
| 242 | otherstatus = otherstatus && LoadValenceDatabase(&input);
|
|---|
| 243 |
|
|---|
| 244 | // fill orbitals DB per element
|
|---|
| 245 | strncpy(filename, path, MAXSTRINGSIZE);
|
|---|
| 246 | strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
|
|---|
| 247 | strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename));
|
|---|
| 248 | input.open(filename);
|
|---|
| 249 | otherstatus = otherstatus && LoadOrbitalsDatabase(&input);
|
|---|
| 250 |
|
|---|
| 251 | // fill H-BondAngle DB per element
|
|---|
| 252 | strncpy(filename, path, MAXSTRINGSIZE);
|
|---|
| 253 | strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
|
|---|
| 254 | strncat(filename, STANDARDHBONDANGLEDB, MAXSTRINGSIZE-strlen(filename));
|
|---|
| 255 | input.open(filename);
|
|---|
| 256 | otherstatus = otherstatus && LoadHBondAngleDatabase(&input);
|
|---|
| 257 |
|
|---|
| 258 | // fill H-BondDistance DB per element
|
|---|
| 259 | strncpy(filename, path, MAXSTRINGSIZE);
|
|---|
| 260 | strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
|
|---|
| 261 | strncat(filename, STANDARDHBONDDISTANCEDB, MAXSTRINGSIZE-strlen(filename));
|
|---|
| 262 | input.open(filename);
|
|---|
| 263 | otherstatus = otherstatus && LoadHBondLengthsDatabase(&input);
|
|---|
| 264 |
|
|---|
| 265 | if (!otherstatus){
|
|---|
| 266 | DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl);
|
|---|
| 267 | }
|
|---|
| 268 |
|
|---|
| 269 | return status;
|
|---|
| 270 | };
|
|---|
| 271 |
|
|---|
| 272 | /** load the element info.
|
|---|
| 273 | * \param *input stream to parse from
|
|---|
| 274 | * \return true - parsing successful, false - something went wrong
|
|---|
| 275 | */
|
|---|
| 276 | bool periodentafel::LoadElementsDatabase(istream *input)
|
|---|
| 277 | {
|
|---|
| 278 | bool status = true;
|
|---|
| 279 | int counter = 0;
|
|---|
| 280 | if (!(*input).fail()) {
|
|---|
| 281 | (*input).getline(header1, MAXSTRINGSIZE);
|
|---|
| 282 | (*input).getline(header2, MAXSTRINGSIZE); // skip first two header lines
|
|---|
| 283 | DoLog(0) && (Log() << Verbose(0) << "Parsed elements:");
|
|---|
| 284 | while (!(*input).eof()) {
|
|---|
| 285 | element *neues = new element;
|
|---|
| 286 | (*input) >> neues->name;
|
|---|
| 287 | //(*input) >> ws;
|
|---|
| 288 | (*input) >> neues->symbol;
|
|---|
| 289 | //(*input) >> ws;
|
|---|
| 290 | (*input) >> neues->period;
|
|---|
| 291 | //(*input) >> ws;
|
|---|
| 292 | (*input) >> neues->group;
|
|---|
| 293 | //(*input) >> ws;
|
|---|
| 294 | (*input) >> neues->block;
|
|---|
| 295 | //(*input) >> ws;
|
|---|
| 296 | (*input) >> neues->Z;
|
|---|
| 297 | //(*input) >> ws;
|
|---|
| 298 | (*input) >> neues->mass;
|
|---|
| 299 | //(*input) >> ws;
|
|---|
| 300 | (*input) >> neues->CovalentRadius;
|
|---|
| 301 | //(*input) >> ws;
|
|---|
| 302 | (*input) >> neues->VanDerWaalsRadius;
|
|---|
| 303 | //(*input) >> ws;
|
|---|
| 304 | (*input) >> ws;
|
|---|
| 305 | if (elements.count(neues->Z)) {// if element already present, remove and delete it
|
|---|
| 306 | element * const Elemental = FindElement(neues->Z);
|
|---|
| 307 | ASSERT(Elemental != NULL, "element should be present but is not??");
|
|---|
| 308 | RemoveElement(Elemental);
|
|---|
| 309 | delete(Elemental);
|
|---|
| 310 | }
|
|---|
| 311 | //neues->Output((ofstream *)&cout);
|
|---|
| 312 | if ((neues->Z > 0) && (neues->Z < MAX_ELEMENTS)) {
|
|---|
| 313 | DoLog(0) && (Log() << Verbose(0) << " " << neues->symbol);
|
|---|
| 314 | elements[neues->getNumber()] = neues;
|
|---|
| 315 | counter++;
|
|---|
| 316 | } else {
|
|---|
| 317 | DoeLog(2) && (eLog() << Verbose(2) << "Detected empty line or invalid element in elements db, discarding." << endl);
|
|---|
| 318 | DoLog(0) && (Log() << Verbose(0) << " <?>");
|
|---|
| 319 | delete(neues);
|
|---|
| 320 | }
|
|---|
| 321 | }
|
|---|
| 322 | DoLog(0) && (Log() << Verbose(0) << endl);
|
|---|
| 323 | } else
|
|---|
| 324 | status = false;
|
|---|
| 325 |
|
|---|
| 326 | if (counter == 0)
|
|---|
| 327 | status = false;
|
|---|
| 328 |
|
|---|
| 329 | return status;
|
|---|
| 330 | }
|
|---|
| 331 |
|
|---|
| 332 | /** load the valence info.
|
|---|
| 333 | * \param *input stream to parse from
|
|---|
| 334 | * \return true - parsing successful, false - something went wrong
|
|---|
| 335 | */
|
|---|
| 336 | bool periodentafel::LoadValenceDatabase(istream *input)
|
|---|
| 337 | {
|
|---|
| 338 | char dummy[MAXSTRINGSIZE];
|
|---|
| 339 | if (!(*input).fail()) {
|
|---|
| 340 | (*input).getline(dummy, MAXSTRINGSIZE);
|
|---|
| 341 | while (!(*input).eof()) {
|
|---|
| 342 | atomicNumber_t Z;
|
|---|
| 343 | (*input) >> Z;
|
|---|
| 344 | ASSERT(elements.count(Z), "Element not present");
|
|---|
| 345 | (*input) >> ws;
|
|---|
| 346 | (*input) >> elements[Z]->Valence;
|
|---|
| 347 | (*input) >> ws;
|
|---|
| 348 | //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->Valence << " valence electrons." << endl;
|
|---|
| 349 | }
|
|---|
| 350 | return true;
|
|---|
| 351 | } else
|
|---|
| 352 | return false;
|
|---|
| 353 | }
|
|---|
| 354 |
|
|---|
| 355 | /** load the orbitals info.
|
|---|
| 356 | * \param *input stream to parse from
|
|---|
| 357 | * \return true - parsing successful, false - something went wrong
|
|---|
| 358 | */
|
|---|
| 359 | bool periodentafel::LoadOrbitalsDatabase(istream *input)
|
|---|
| 360 | {
|
|---|
| 361 | char dummy[MAXSTRINGSIZE];
|
|---|
| 362 | if (!(*input).fail()) {
|
|---|
| 363 | (*input).getline(dummy, MAXSTRINGSIZE);
|
|---|
| 364 | while (!(*input).eof()) {
|
|---|
| 365 | atomicNumber_t Z;
|
|---|
| 366 | (*input) >> Z;
|
|---|
| 367 | ASSERT(elements.count(Z), "Element not present");
|
|---|
| 368 | (*input) >> ws;
|
|---|
| 369 | (*input) >> elements[Z]->NoValenceOrbitals;
|
|---|
| 370 | (*input) >> ws;
|
|---|
| 371 | //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
|
|---|
| 372 | }
|
|---|
| 373 | return true;
|
|---|
| 374 | } else
|
|---|
| 375 | return false;
|
|---|
| 376 | }
|
|---|
| 377 |
|
|---|
| 378 | /** load the hbond angles info.
|
|---|
| 379 | * \param *input stream to parse from
|
|---|
| 380 | * \return true - parsing successful, false - something went wrong
|
|---|
| 381 | */
|
|---|
| 382 | bool periodentafel::LoadHBondAngleDatabase(istream *input)
|
|---|
| 383 | {
|
|---|
| 384 | char dummy[MAXSTRINGSIZE];
|
|---|
| 385 | if (!(*input).fail()) {
|
|---|
| 386 | (*input).getline(dummy, MAXSTRINGSIZE);
|
|---|
| 387 | while (!(*input).eof()) {
|
|---|
| 388 | atomicNumber_t Z;
|
|---|
| 389 | (*input) >> Z;
|
|---|
| 390 | ASSERT(elements.count(Z), "Element not present");
|
|---|
| 391 | (*input) >> ws;
|
|---|
| 392 | (*input) >> elements[Z]->HBondAngle[0];
|
|---|
| 393 | (*input) >> elements[Z]->HBondAngle[1];
|
|---|
| 394 | (*input) >> elements[Z]->HBondAngle[2];
|
|---|
| 395 | (*input) >> ws;
|
|---|
| 396 | //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondAngle[0] << ", " << FindElement((int)tmp)->HBondAngle[1] << ", " << FindElement((int)tmp)->HBondAngle[2] << " degrees bond angle for one, two, three connected hydrogens." << endl;
|
|---|
| 397 | }
|
|---|
| 398 | return true;
|
|---|
| 399 | } else
|
|---|
| 400 | return false;
|
|---|
| 401 | }
|
|---|
| 402 |
|
|---|
| 403 | /** load the hbond lengths info.
|
|---|
| 404 | * \param *input stream to parse from
|
|---|
| 405 | * \return true - parsing successful, false - something went wrong
|
|---|
| 406 | */
|
|---|
| 407 | bool periodentafel::LoadHBondLengthsDatabase(istream *input)
|
|---|
| 408 | {
|
|---|
| 409 | char dummy[MAXSTRINGSIZE];
|
|---|
| 410 | if (!(*input).fail()) {
|
|---|
| 411 | (*input).getline(dummy, MAXSTRINGSIZE);
|
|---|
| 412 | while (!(*input).eof()) {
|
|---|
| 413 | atomicNumber_t Z;
|
|---|
| 414 | (*input) >> Z;
|
|---|
| 415 | ASSERT(elements.count(Z), "Element not present");
|
|---|
| 416 | (*input) >> ws;
|
|---|
| 417 | (*input) >> elements[Z]->HBondDistance[0];
|
|---|
| 418 | (*input) >> elements[Z]->HBondDistance[1];
|
|---|
| 419 | (*input) >> elements[Z]->HBondDistance[2];
|
|---|
| 420 | (*input) >> ws;
|
|---|
| 421 | //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl;
|
|---|
| 422 | }
|
|---|
| 423 | return true;
|
|---|
| 424 | } else
|
|---|
| 425 | return false;
|
|---|
| 426 | }
|
|---|
| 427 |
|
|---|
| 428 | /** Stores element list to file.
|
|---|
| 429 | */
|
|---|
| 430 | bool periodentafel::StorePeriodentafel(const char *path) const
|
|---|
| 431 | {
|
|---|
| 432 | bool result = true;
|
|---|
| 433 | ofstream f;
|
|---|
| 434 | char filename[MAXSTRINGSIZE];
|
|---|
| 435 |
|
|---|
| 436 | strncpy(filename, path, MAXSTRINGSIZE);
|
|---|
| 437 | strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
|
|---|
| 438 | strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename));
|
|---|
| 439 | f.open(filename);
|
|---|
| 440 | if (f != NULL) {
|
|---|
| 441 | f << header1 << endl;
|
|---|
| 442 | f << header2 << endl;
|
|---|
| 443 | for(const_iterator iter=elements.begin();iter!=elements.end();++iter){
|
|---|
| 444 | result = result && (*iter).second->Output(&f);
|
|---|
| 445 | }
|
|---|
| 446 | f.close();
|
|---|
| 447 | return true;
|
|---|
| 448 | } else
|
|---|
| 449 | return result;
|
|---|
| 450 | };
|
|---|