source: src/periodentafel.cpp@ febef3

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since febef3 was febef3, checked in by Frederik Heber <heber@…>, 14 years ago

Removed verbosity of LoadElectronegativityDb.

  • Property mode set to 100755
File size: 16.8 KB
RevLine 
[bcf653]1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
[6ac7ee]8/** \file periodentafel.cpp
9 *
10 * Function implementations for the class periodentafel.
11 *
12 */
13
[bf3817]14// include config.h
15#ifdef HAVE_CONFIG_H
16#include <config.h>
17#endif
[112b09]18
[ad011c]19#include "CodePatterns/MemDebug.hpp"
[6ac7ee]20
[cd4ccc]21#include <iomanip>
[4eb4fe]22#include <iostream>
[cd4ccc]23#include <fstream>
[49e1ae]24#include <cstring>
[cd4ccc]25
[ad011c]26#include "CodePatterns/Assert.hpp"
[f66195]27#include "element.hpp"
[4eb4fe]28#include "elements_db.hpp"
[952f38]29#include "Helpers/helpers.hpp"
[ad011c]30#include "CodePatterns/Log.hpp"
[67c92b]31//#include "lists.hpp"
[6ac7ee]32#include "periodentafel.hpp"
[ad011c]33#include "CodePatterns/Verbose.hpp"
[6ac7ee]34
[ead4e6]35using namespace std;
36
[6ac7ee]37/************************************* Functions for class periodentafel ***************************/
38
39/** constructor for class periodentafel
40 * Initialises start and end of list and resets periodentafel::checkliste to false.
41 */
[ead4e6]42periodentafel::periodentafel()
[4eb4fe]43{
[f34c23]44 {
45 stringstream input(elementsDB,ios_base::in);
[b2ae3b]46#ifndef NDEBUG
47 bool status =
48#endif
49 LoadElementsDatabase(input);
[f34c23]50 ASSERT(status, "General element initialization failed");
51 }
[67c92b]52 {
53 stringstream input(ElectronegativitiesDB,ios_base::in);
54#ifndef NDEBUG
55 bool status =
56#endif
57 LoadElectronegativityDatabase(input);
58 ASSERT(status, "Electronegativities entry of element initialization failed");
59 }
[f34c23]60 {
61 stringstream input(valenceDB,ios_base::in);
[b2ae3b]62#ifndef NDEBUG
63 bool status =
64#endif
[67c92b]65 LoadValenceDatabase(input);
[f34c23]66 ASSERT(status, "Valence entry of element initialization failed");
67 }
68 {
69 stringstream input(orbitalsDB,ios_base::in);
[b2ae3b]70#ifndef NDEBUG
71 bool status =
72#endif
[67c92b]73 LoadOrbitalsDatabase(input);
[f34c23]74 ASSERT(status, "Orbitals entry of element initialization failed");
75 }
76 {
77 stringstream input(HbondangleDB,ios_base::in);
[b2ae3b]78#ifndef NDEBUG
79 bool status =
80#endif
[67c92b]81 LoadHBondAngleDatabase(input);
[f34c23]82 ASSERT(status, "HBond angle entry of element initialization failed");
83 }
84 {
85 stringstream input(HbonddistanceDB,ios_base::in);
[b2ae3b]86#ifndef NDEBUG
87 bool status =
88#endif
[67c92b]89 LoadHBondLengthsDatabase(input);
[f34c23]90 ASSERT(status, "HBond distance entry of element initialization failed");
91 }
[4eb4fe]92};
[6ac7ee]93
94/** destructor for class periodentafel
95 * Removes every element and afterwards deletes start and end of list.
[42af9e]96 * TODO: Handle when elements have changed and store databases then
[6ac7ee]97 */
98periodentafel::~periodentafel()
99{
[042f82]100 CleanupPeriodtable();
[6ac7ee]101};
102
103/** Adds element to period table list
104 * \param *pointer element to be added
[4eb4fe]105 * \return iterator to added element
[6ac7ee]106 */
[e5c0a1]107periodentafel::iterator periodentafel::AddElement(element * pointer)
[6ac7ee]108{
[ead4e6]109 atomicNumber_t Z = pointer->getNumber();
[4eb4fe]110 ASSERT(!elements.count(Z), "Element is already present.");
[ead4e6]111 if (pointer->getNumber() < 1 && pointer->getNumber() >= MAX_ELEMENTS)
[5f612ee]112 DoeLog(0) && (eLog() << Verbose(0) << "Invalid Z number!\n");
[ead4e6]113 pair<iterator,bool> res = elements.insert(pair<atomicNumber_t,element*>(Z,pointer));
114 return res.first;
[6ac7ee]115};
116
117/** Removes element from list.
118 * \param *pointer element to be removed
119 */
[e5c0a1]120size_t periodentafel::RemoveElement(const element * pointer)
[6ac7ee]121{
[61745cc]122 return RemoveElement(pointer->getNumber());
[4eb4fe]123};
124
125/** Removes element from list.
126 * \param Z element to be removed
127 */
[61745cc]128size_t periodentafel::RemoveElement(atomicNumber_t Z)
[4eb4fe]129{
[61745cc]130 return elements.erase(Z);
[6ac7ee]131};
132
133/** Removes every element from the period table.
134 */
[ead4e6]135void periodentafel::CleanupPeriodtable()
[6ac7ee]136{
[745a85]137 for(iterator iter=elements.begin();iter!=elements.end();++iter){
138 delete(*iter).second;
139 }
[ead4e6]140 elements.clear();
[6ac7ee]141};
142
143/** Finds an element by its atomic number.
[fb73b8]144 * If element is not yet in list, returns NULL.
[6ac7ee]145 * \param Z atomic number
[fb73b8]146 * \return pointer to element or NULL if not found
[6ac7ee]147 */
[e5c0a1]148const element * periodentafel::FindElement(atomicNumber_t Z) const
[6ac7ee]149{
[ead4e6]150 const_iterator res = elements.find(Z);
151 return res!=elements.end()?((*res).second):0;
[6ac7ee]152};
153
154/** Finds an element by its atomic number.
155 * If element is not yet in list, datas are asked and stored in database.
156 * \param shorthand chemical symbol of the element, e.g. H for hydrogene
157 * \return pointer to element
158 */
[e5c0a1]159const element * periodentafel::FindElement(const string &shorthand) const
[6ac7ee]160{
[ead4e6]161 element *res = 0;
162 for(const_iterator iter=elements.begin();iter!=elements.end();++iter) {
163 if((*iter).second->getSymbol() == shorthand){
164 res = (*iter).second;
165 break;
166 }
[042f82]167 }
[ead4e6]168 return res;
[6ac7ee]169};
170
171/** Asks for element number and returns pointer to element
[4eb4fe]172 * \return desired element or NULL
[6ac7ee]173 */
[e5c0a1]174const element * periodentafel::AskElement() const
[6ac7ee]175{
[e5c0a1]176 const element * walker = NULL;
[042f82]177 int Z;
178 do {
[a67d19]179 DoLog(0) && (Log() << Verbose(0) << "Atomic number Z: ");
[042f82]180 cin >> Z;
181 walker = this->FindElement(Z); // give type
182 } while (walker == NULL);
183 return walker;
[6ac7ee]184};
185
[fb73b8]186/** Asks for element and if not found, presents mask to enter info.
187 * \return pointer to either present or newly created element
188 */
[e5c0a1]189const element * periodentafel::EnterElement()
[fb73b8]190{
[ead4e6]191 atomicNumber_t Z = 0;
[a67d19]192 DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl);
[fb73b8]193 cin >> Z;
[e5c0a1]194 const element *res = FindElement(Z);
[ead4e6]195 if (!res) {
196 // TODO: make this using the constructor
[a67d19]197 DoLog(0) && (Log() << Verbose(0) << "Element not found in database, please enter." << endl);
[4eb4fe]198 element *tmp = new element;
[ead4e6]199 tmp->Z = Z;
[a67d19]200 DoLog(0) && (Log() << Verbose(0) << "Mass: " << endl);
[ead4e6]201 cin >> tmp->mass;
[a67d19]202 DoLog(0) && (Log() << Verbose(0) << "Name [max 64 chars]: " << endl);
[7e3fc94]203 cin >> tmp->getName();
[a67d19]204 DoLog(0) && (Log() << Verbose(0) << "Short form [max 3 chars]: " << endl);
[7e3fc94]205 cin >> tmp->getSymbol();
[ead4e6]206 AddElement(tmp);
[4eb4fe]207 return tmp;
[fb73b8]208 }
[ead4e6]209 return res;
[fb73b8]210};
211
[ead4e6]212
213/******************** Access to iterators ****************************/
[e5c0a1]214periodentafel::const_iterator periodentafel::begin() const{
[ead4e6]215 return elements.begin();
216}
217
[e5c0a1]218periodentafel::const_iterator periodentafel::end() const{
[ead4e6]219 return elements.end();
220}
221
[e5c0a1]222periodentafel::reverse_iterator periodentafel::rbegin() const{
[ead4e6]223 return reverse_iterator(elements.end());
224}
225
[e5c0a1]226periodentafel::reverse_iterator periodentafel::rend() const{
[ead4e6]227 return reverse_iterator(elements.begin());
228}
229
[6ac7ee]230/** Prints period table to given stream.
231 * \param output stream
232 */
[ead4e6]233bool periodentafel::Output(ostream * const output) const
[6ac7ee]234{
[042f82]235 bool result = true;
236 if (output != NULL) {
[ead4e6]237 for(const_iterator iter=elements.begin(); iter !=elements.end();++iter){
238 result = result && (*iter).second->Output(output);
[042f82]239 }
240 return result;
241 } else
242 return false;
[6ac7ee]243};
244
245/** Loads element list from file.
246 * \param *path to to standard file names
247 */
[989bf6]248bool periodentafel::LoadPeriodentafel(const char *path)
[6ac7ee]249{
[4eb4fe]250 ifstream input;
[042f82]251 bool status = true;
252 bool otherstatus = true;
253 char filename[255];
[6ac7ee]254
[042f82]255 // fill elements DB
256 strncpy(filename, path, MAXSTRINGSIZE);
257 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
258 strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename));
[4eb4fe]259 input.open(filename);
[61745cc]260 if (!input.fail())
261 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as elements database." << endl);
[e5c0a1]262 status = status && LoadElementsDatabase(input);
[61745cc]263 input.close();
264 input.clear();
[4eb4fe]265
[67c92b]266 // fill valence DB per element
267 strncpy(filename, path, MAXSTRINGSIZE);
268 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
269 strncat(filename, STANDARDELECTRONEGATIVITYDB, MAXSTRINGSIZE-strlen(filename));
270 input.open(filename);
271 if (!input.fail())
272 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as electronegativity database." << endl);
273 otherstatus = otherstatus && LoadElectronegativityDatabase(input);
274 input.close();
275 input.clear();
276
[4eb4fe]277 // fill valence DB per element
278 strncpy(filename, path, MAXSTRINGSIZE);
279 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
280 strncat(filename, STANDARDVALENCEDB, MAXSTRINGSIZE-strlen(filename));
281 input.open(filename);
[61745cc]282 if (!input.fail())
283 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as valence database." << endl);
[67c92b]284 otherstatus = otherstatus && LoadValenceDatabase(input);
[61745cc]285 input.close();
286 input.clear();
[4eb4fe]287
288 // fill orbitals DB per element
289 strncpy(filename, path, MAXSTRINGSIZE);
290 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
291 strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename));
292 input.open(filename);
[61745cc]293 if (!input.fail())
294 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as orbitals database." << endl);
[67c92b]295 otherstatus = otherstatus && LoadOrbitalsDatabase(input);
[61745cc]296 input.close();
297 input.clear();
[4eb4fe]298
299 // fill H-BondAngle DB per element
300 strncpy(filename, path, MAXSTRINGSIZE);
301 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
302 strncat(filename, STANDARDHBONDANGLEDB, MAXSTRINGSIZE-strlen(filename));
303 input.open(filename);
[61745cc]304 if (!input.fail())
305 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as H bond angle database." << endl);
[67c92b]306 otherstatus = otherstatus && LoadHBondAngleDatabase(input);
[61745cc]307 input.close();
308 input.clear();
[4eb4fe]309
310 // fill H-BondDistance DB per element
311 strncpy(filename, path, MAXSTRINGSIZE);
312 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
313 strncat(filename, STANDARDHBONDDISTANCEDB, MAXSTRINGSIZE-strlen(filename));
314 input.open(filename);
[61745cc]315 if (!input.fail())
316 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as H bond length database." << endl);
[67c92b]317 otherstatus = otherstatus && LoadHBondLengthsDatabase(input);
[61745cc]318 input.close();
319 input.clear();
[4eb4fe]320
321 if (!otherstatus){
322 DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl);
323 }
324
325 return status;
326};
327
328/** load the element info.
329 * \param *input stream to parse from
330 * \return true - parsing successful, false - something went wrong
331 */
[e5c0a1]332bool periodentafel::LoadElementsDatabase(istream &input)
[4eb4fe]333{
[ff73a2]334 bool status = true;
[e5c0a1]335 string header1tmp,header2tmp;
336 // first parse into a map, so we can revert to old status in case something goes wront
337 map<atomicNumber_t,element*> parsedElements;
338 if (!input.fail()) {
339 getline(input,header1tmp);
340 getline(input,header2tmp); // skip first two header lines
[4e6d74]341 //cout << "First header: " << header1tmp << endl;
342 //cout << "Second header: " << header2tmp << endl;
[ad7270]343// DoLog(0) && (Log() << Verbose(0) << "Parsed elements:");
[e5c0a1]344 while (!input.eof()) {
[042f82]345 element *neues = new element;
[83f176]346 input >> neues->name;
[67c92b]347 //input >> ws;
[83f176]348 input >> neues->symbol;
[67c92b]349 //input >> ws;
[e5c0a1]350 input >> neues->period;
[67c92b]351 //input >> ws;
[e5c0a1]352 input >> neues->group;
[67c92b]353 //input >> ws;
[e5c0a1]354 input >> neues->block;
[67c92b]355 //input >> ws;
[e5c0a1]356 input >> neues->Z;
[67c92b]357 //input >> ws;
[e5c0a1]358 input >> neues->mass;
[67c92b]359 //input >> ws;
[e5c0a1]360 input >> neues->CovalentRadius;
[67c92b]361 //input >> ws;
[e5c0a1]362 input >> neues->VanDerWaalsRadius;
[67c92b]363 //input >> ws;
[e5c0a1]364 input >> ws;
[042f82]365 //neues->Output((ofstream *)&cout);
[61745cc]366 if ((neues->getNumber() > 0) && (neues->getNumber() < MAX_ELEMENTS)) {
[e5c0a1]367 parsedElements[neues->Z] = neues;
[ad7270]368// DoLog(0) && (Log() << Verbose(0) << " " << *neues);
[ff73a2]369 } else {
370 DoeLog(2) && (eLog() << Verbose(2) << "Detected empty line or invalid element in elements db, discarding." << endl);
371 DoLog(0) && (Log() << Verbose(0) << " <?>");
[db6bf74]372 delete(neues);
[042f82]373 }
[e5c0a1]374 // when the input is in failed state, we most likely just read garbage
375 if(input.fail()) {
376 DoeLog(2) && (eLog() << Verbose(2) << "Error parsing elements db." << endl);
377 status = false;
378 break;
379 }
[042f82]380 }
[ad7270]381// DoLog(0) && (Log() << Verbose(0) << endl);
[61745cc]382 } else {
383 DoeLog(1) && (eLog() << Verbose(1) << "Could not open the database." << endl);
[ff73a2]384 status = false;
[61745cc]385 }
[ff73a2]386
[e5c0a1]387 if (!parsedElements.size())
[ff73a2]388 status = false;
389
[e5c0a1]390 if(status){
391 for(map<atomicNumber_t,element*>::iterator iter=parsedElements.begin();
392 iter!=parsedElements.end();
393 ++iter){
394 if (elements.count(iter->first)) {
395 // if element already present, replace the old one
396 // pointer to old element might still be in use, so we have to replace into the old element
397 *(elements[iter->first])=*iter->second;
[9f99b3]398 delete(iter->second);
[e5c0a1]399 }
400 else {
401 // no such element in periodentafel... we can just insert
402 elements[iter->first] = iter->second;
403 }
404 }
405 // all went well.. we now copy the header
406 strncpy(header1,header1tmp.c_str(),MAXSTRINGSIZE);
407 header1[MAXSTRINGSIZE-1]=0;
408 strncpy(header2,header2tmp.c_str(),MAXSTRINGSIZE);
409 header2[MAXSTRINGSIZE-1]=0;
410 }
411
[ff73a2]412 return status;
[4eb4fe]413}
[6ac7ee]414
[67c92b]415/** load the electronegativity info.
416 * \param *input stream to parse from
417 * \return true - parsing successful, false - something went wrong
418 */
419bool periodentafel::LoadElectronegativityDatabase(std::istream &input)
420{
421 char dummy[MAXSTRINGSIZE];
422 if (!input.fail()) {
423 input.getline(dummy, MAXSTRINGSIZE);
424 while (!input.eof()) {
425 atomicNumber_t Z;
426 input >> Z;
427 ASSERT(elements.count(Z), "Element not present");
428 input >> ws;
429 input >> elements[Z]->Electronegativity;
430 input >> ws;
[febef3]431 //DoLog(1) && (Log() << Verbose(1)
432 // << "Element " << Z << " has " << FindElement(Z)->Electronegativity << " valence electrons." << endl);
[67c92b]433 }
434 return true;
435 } else
436 return false;
437}
438
[4eb4fe]439/** load the valence info.
440 * \param *input stream to parse from
441 * \return true - parsing successful, false - something went wrong
442 */
[67c92b]443bool periodentafel::LoadValenceDatabase(istream &input)
[4eb4fe]444{
445 char dummy[MAXSTRINGSIZE];
[67c92b]446 if (!input.fail()) {
447 input.getline(dummy, MAXSTRINGSIZE);
448 while (!input.eof()) {
[ead4e6]449 atomicNumber_t Z;
[67c92b]450 input >> Z;
[4eb4fe]451 ASSERT(elements.count(Z), "Element not present");
[67c92b]452 input >> ws;
453 input >> elements[Z]->Valence;
454 input >> ws;
[274d45]455 //Log() << Verbose(3) << "Element " << Z << " has " << FindElement(Z)->Valence << " valence electrons." << endl;
[042f82]456 }
[4eb4fe]457 return true;
[042f82]458 } else
[4eb4fe]459 return false;
460}
[6ac7ee]461
[4eb4fe]462/** load the orbitals info.
463 * \param *input stream to parse from
464 * \return true - parsing successful, false - something went wrong
465 */
[67c92b]466bool periodentafel::LoadOrbitalsDatabase(istream &input)
[4eb4fe]467{
468 char dummy[MAXSTRINGSIZE];
[67c92b]469 if (!input.fail()) {
470 input.getline(dummy, MAXSTRINGSIZE);
471 while (!input.eof()) {
[ead4e6]472 atomicNumber_t Z;
[67c92b]473 input >> Z;
[4eb4fe]474 ASSERT(elements.count(Z), "Element not present");
[67c92b]475 input >> ws;
476 input >> elements[Z]->NoValenceOrbitals;
477 input >> ws;
[274d45]478 //Log() << Verbose(3) << "Element " << Z << " has " << FindElement(Z)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
[042f82]479 }
[4eb4fe]480 return true;
[042f82]481 } else
[4eb4fe]482 return false;
483}
[6ac7ee]484
[4eb4fe]485/** load the hbond angles info.
486 * \param *input stream to parse from
487 * \return true - parsing successful, false - something went wrong
488 */
[67c92b]489bool periodentafel::LoadHBondAngleDatabase(istream &input)
[4eb4fe]490{
491 char dummy[MAXSTRINGSIZE];
[67c92b]492 if (!input.fail()) {
493 input.getline(dummy, MAXSTRINGSIZE);
494 while (!input.eof()) {
[ead4e6]495 atomicNumber_t Z;
[67c92b]496 input >> Z;
[4eb4fe]497 ASSERT(elements.count(Z), "Element not present");
[67c92b]498 input >> ws;
499 input >> elements[Z]->HBondAngle[0];
500 input >> elements[Z]->HBondAngle[1];
501 input >> elements[Z]->HBondAngle[2];
502 input >> ws;
[4eb4fe]503 //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;
[042f82]504 }
[4eb4fe]505 return true;
[042f82]506 } else
[4eb4fe]507 return false;
508}
[6ac7ee]509
[4eb4fe]510/** load the hbond lengths info.
511 * \param *input stream to parse from
512 * \return true - parsing successful, false - something went wrong
513 */
[67c92b]514bool periodentafel::LoadHBondLengthsDatabase(istream &input)
[4eb4fe]515{
516 char dummy[MAXSTRINGSIZE];
[67c92b]517 if (!input.fail()) {
518 input.getline(dummy, MAXSTRINGSIZE);
519 while (!input.eof()) {
[ead4e6]520 atomicNumber_t Z;
[67c92b]521 input >> Z;
[4eb4fe]522 ASSERT(elements.count(Z), "Element not present");
[67c92b]523 input >> ws;
524 input >> elements[Z]->HBondDistance[0];
525 input >> elements[Z]->HBondDistance[1];
526 input >> elements[Z]->HBondDistance[2];
527 input >> ws;
[4eb4fe]528 //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl;
[042f82]529 }
[4eb4fe]530 return true;
[042f82]531 } else
[4eb4fe]532 return false;
533}
[6ac7ee]534
535/** Stores element list to file.
536 */
[989bf6]537bool periodentafel::StorePeriodentafel(const char *path) const
[6ac7ee]538{
[042f82]539 bool result = true;
540 ofstream f;
541 char filename[MAXSTRINGSIZE];
[6ac7ee]542
[042f82]543 strncpy(filename, path, MAXSTRINGSIZE);
544 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
545 strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename));
546 f.open(filename);
547 if (f != NULL) {
548 f << header1 << endl;
549 f << header2 << endl;
[ead4e6]550 for(const_iterator iter=elements.begin();iter!=elements.end();++iter){
551 result = result && (*iter).second->Output(&f);
[042f82]552 }
553 f.close();
[4eb4fe]554 return true;
[042f82]555 } else
[4eb4fe]556 return result;
[6ac7ee]557};
Note: See TracBrowser for help on using the repository browser.