source: src/periodentafel.cpp@ 255829

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 255829 was 255829, checked in by Frederik Heber <heber@…>, 14 years ago

Removed Helpers.hpp, deleted Helpers.cpp and libMoleCuilderHelpers.la is history.

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