source: src/periodentafel.cpp@ ea430a

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

Removed smaller warning, mostly due to NDEBUG.

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