Changeset 67c92b


Ignore:
Timestamp:
Feb 3, 2011, 9:51:18 AM (14 years ago)
Author:
Frederik Heber <heber@…>
Branches:
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
Children:
be945c
Parents:
ea430a
git-author:
Frederik Heber <heber@…> (12/17/10 18:51:30)
git-committer:
Frederik Heber <heber@…> (02/03/11 09:51:18)
Message:

Added Electronegativity database and member value to class element.

  • periodentafel contains new loading functions.
  • also all periodentafel::load...() now accept reference of istream, not pointer. This causes changes in PeriodentafelUnitTest.
Location:
src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/Helpers/defs.cpp

    rea430a r67c92b  
    5454const char *STANDARDCONFIG = "unknown.conf";    //!< default filename of standard config file
    5555const char *STANDARDELEMENTSDB = "elements.db";    //!< default filename of elements data base with masses, Z, VanDerWaals radii, ...
     56const char *STANDARDELECTRONEGATIVITYDB = "electronegativity.db";    //!< default filename of electronegativity per element number data base
    5657const char *STANDARDVALENCEDB = "valence.db";    //!< default filename of valence number per element database
    5758const char *STANDARDORBITALDB = "orbitals.db";    //!< default filename of orbitals per element database
  • src/Helpers/defs.hpp

    rea430a r67c92b  
    7272extern "C" const char *FRAGMENTPREFIX;    //!< default filename prefix of BOSSANOVA fragment config and directories
    7373extern "C" const char *STANDARDCONFIG;    //!< default filename of standard config file
     74extern "C" const char *STANDARDELECTRONEGATIVITYDB;    //!< default filename of electronegativity per element data base
    7475extern "C" const char *STANDARDELEMENTSDB;    //!< default filename of elements data base with masses, Z, VanDerWaals radii, ...
    7576extern "C" const char *STANDARDVALENCEDB;    //!< default filename of valence number per element database
  • src/element.cpp

    rea430a r67c92b  
    118118}
    119119
     120double element::getElectronegativity() const
     121{
     122  return Electronegativity;
     123}
     124
    120125double element::getVanDerWaalsRadius() const
    121126{
  • src/element.hpp

    rea430a r67c92b  
    4242    double getMass() const;
    4343    double getCovalentRadius() const;
     44    double getElectronegativity() const;
    4445    double getVanDerWaalsRadius() const;
    4546    int getAtomicNumber() const;
     
    6465    double mass;    //!< mass in g/mol
    6566    double CovalentRadius;  //!< covalent radius
     67    double Electronegativity; //!< electronegativity in Pauling units
    6668    double VanDerWaalsRadius;  //!< can-der-Waals radius
    6769    int Z;          //!< atomic number
  • src/elements_db.cpp

    rea430a r67c92b  
    135135";
    136136
     137const char *ElectronegativitiesDB =\
     138"#atomic number\tEN [Pauling units], taken from http://en.wikipedia.org/wiki/Electronegativities_of_the_elements_%28data_page%29\n\
     1391 2.2\n\
     1402 -1\n\
     1413 0.98\n\
     1424 1.57\n\
     1435 2.04\n\
     1446 2.55\n\
     1457 3.04\n\
     1468 3.44\n\
     1479  3.98\n\
     14810  -1\n\
     14911  0.93\n\
     15012  1.31\n\
     15113  1.61\n\
     15214  1.90\n\
     15315  2.19\n\
     15416  2.58\n\
     15517  3.16\n\
     15618  -1\n\
     15719  0.82\n\
     15820  1.00\n\
     15921  1.36\n\
     16022  1.54\n\
     16123  1.63\n\
     16224  1.66\n\
     16325  1.55\n\
     16426  1.83\n\
     16527  1.88\n\
     16628  1.91\n\
     16729  1.90\n\
     16830  1.65\n\
     16931  1.81\n\
     17032  2.01\n\
     17133  2.18\n\
     17234  2.55\n\
     17335  2.96\n\
     17436  3.00\n\
     17537  0.82\n\
     17638  0.95\n\
     17739  1.22\n\
     17840  1.33\n\
     17941  1.6\n\
     18042  2.16\n\
     18143  1.9\n\
     18244  2.2\n\
     18345  2.28\n\
     18446  2.20\n\
     18547  1.93\n\
     18648  1.69\n\
     18749  1.78\n\
     18850  1.96\n\
     18951  2.05\n\
     19052  2.1\n\
     19153  2.66\n\
     19254  2.6\n\
     19355  0.79\n\
     19456  0.89\n\
     19557  1.10\n\
     19658  1.12\n\
     19759  1.13\n\
     19860  1.14\n\
     19961  -1\n\
     20062  1.17\n\
     20163  -1\n\
     20264  1.20\n\
     20365  -1\n\
     20466  1.22\n\
     20567  1.23\n\
     20668  1.24\n\
     20769  1.25\n\
     20870  -1\n\
     20971  1.27\n\
     21072  1.3\n\
     21173  1.5\n\
     21274  2.36\n\
     21375  1.9\n\
     21476  2.2\n\
     21577  2.20\n\
     21678  2.28\n\
     21779  2.54\n\
     21880  2.00\n\
     21981  1.62\n\
     22082  2.33\n\
     22183  2.02\n\
     22284  2.0\n\
     22385  2.2\n\
     22486  -1\n\
     22587  0.7\n\
     22688  0.9\n\
     22789  1.1\n\
     22890  1.3\n\
     22991  1.5\n\
     23092  1.38\n\
     23193  1.36\n\
     23294  1.28\n\
     23395  1.3\n\
     23496  1.3\n\
     23597  1.3\n\
     23698  1.3\n\
     23799  1.3\n\
     238100 1.3\n\
     239101 1.3\n\
     240102 1.3\n\
     241";
     242
    137243const char *HbonddistanceDB =\
    138244"#atomic number bond distances for single, double and triple bond (-1 no bond)\n\
  • src/elements_db.hpp

    rea430a r67c92b  
    1616
    1717extern const char *elementsDB;
     18extern const char *ElectronegativitiesDB;
    1819extern const char *HbonddistanceDB;
    1920extern const char *HbondangleDB;
  • src/periodentafel.cpp

    rea430a r67c92b  
    2828#include "elements_db.hpp"
    2929#include "Helpers/helpers.hpp"
    30 #include "lists.hpp"
    3130#include "CodePatterns/Log.hpp"
     31//#include "lists.hpp"
    3232#include "periodentafel.hpp"
    3333#include "CodePatterns/Verbose.hpp"
     
    5151  }
    5252  {
     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  }
     60  {
    5361    stringstream input(valenceDB,ios_base::in);
    5462#ifndef NDEBUG
    5563    bool status =
    5664#endif
    57         LoadValenceDatabase(&input);
     65        LoadValenceDatabase(input);
    5866    ASSERT(status, "Valence entry of element initialization failed");
    5967  }
     
    6371    bool status =
    6472#endif
    65         LoadOrbitalsDatabase(&input);
     73        LoadOrbitalsDatabase(input);
    6674    ASSERT(status, "Orbitals entry of element initialization failed");
    6775  }
     
    7179    bool status =
    7280#endif
    73         LoadHBondAngleDatabase(&input);
     81        LoadHBondAngleDatabase(input);
    7482    ASSERT(status, "HBond angle entry of element initialization failed");
    7583  }
     
    7987    bool status =
    8088#endif
    81         LoadHBondLengthsDatabase(&input);
     89        LoadHBondLengthsDatabase(input);
    8290    ASSERT(status, "HBond distance entry of element initialization failed");
    8391  }
     
    259267  strncpy(filename, path, MAXSTRINGSIZE);
    260268  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
     277  // fill valence DB per element
     278  strncpy(filename, path, MAXSTRINGSIZE);
     279  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
    261280  strncat(filename, STANDARDVALENCEDB, MAXSTRINGSIZE-strlen(filename));
    262281  input.open(filename);
    263282  if (!input.fail())
    264283    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as valence database." << endl);
    265   otherstatus = otherstatus && LoadValenceDatabase(&input);
     284  otherstatus = otherstatus && LoadValenceDatabase(input);
    266285  input.close();
    267286  input.clear();
     
    274293  if (!input.fail())
    275294    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as orbitals database." << endl);
    276   otherstatus = otherstatus && LoadOrbitalsDatabase(&input);
     295  otherstatus = otherstatus && LoadOrbitalsDatabase(input);
    277296  input.close();
    278297  input.clear();
     
    285304  if (!input.fail())
    286305    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as H bond angle database." << endl);
    287   otherstatus = otherstatus && LoadHBondAngleDatabase(&input);
     306  otherstatus = otherstatus && LoadHBondAngleDatabase(input);
    288307  input.close();
    289308  input.clear();
     
    296315  if (!input.fail())
    297316    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as H bond length database." << endl);
    298   otherstatus = otherstatus && LoadHBondLengthsDatabase(&input);
     317  otherstatus = otherstatus && LoadHBondLengthsDatabase(input);
    299318  input.close();
    300319  input.clear();
     
    326345      element *neues = new element;
    327346      input >> neues->name;
    328       //(*input) >> ws;
     347      //input >> ws;
    329348      input >> neues->symbol;
    330       //(*input) >> ws;
     349      //input >> ws;
    331350      input >> neues->period;
    332       //(*input) >> ws;
     351      //input >> ws;
    333352      input >> neues->group;
    334       //(*input) >> ws;
     353      //input >> ws;
    335354      input >> neues->block;
    336       //(*input) >> ws;
     355      //input >> ws;
    337356      input >> neues->Z;
    338       //(*input) >> ws;
     357      //input >> ws;
    339358      input >> neues->mass;
    340       //(*input) >> ws;
     359      //input >> ws;
    341360      input >> neues->CovalentRadius;
    342       //(*input) >> ws;
     361      //input >> ws;
    343362      input >> neues->VanDerWaalsRadius;
    344       //(*input) >> ws;
     363      //input >> ws;
    345364      input >> ws;
    346365      //neues->Output((ofstream *)&cout);
     
    394413}
    395414
     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;
     431      DoLog(1) && (Log() << Verbose(1)
     432          << "Element " << Z << " has " << FindElement(Z)->Electronegativity << " valence electrons." << endl);
     433    }
     434    return true;
     435  } else
     436    return false;
     437}
     438
    396439/** load the valence info.
    397440 * \param *input stream to parse from
    398441 * \return true - parsing successful, false - something went wrong
    399442 */
    400 bool periodentafel::LoadValenceDatabase(istream *input)
     443bool periodentafel::LoadValenceDatabase(istream &input)
    401444{
    402445  char dummy[MAXSTRINGSIZE];
    403   if (!(*input).fail()) {
    404     (*input).getline(dummy, MAXSTRINGSIZE);
    405     while (!(*input).eof()) {
     446  if (!input.fail()) {
     447    input.getline(dummy, MAXSTRINGSIZE);
     448    while (!input.eof()) {
    406449      atomicNumber_t Z;
    407       (*input) >> Z;
     450      input >> Z;
    408451      ASSERT(elements.count(Z), "Element not present");
    409       (*input) >> ws;
    410       (*input) >> elements[Z]->Valence;
    411       (*input) >> ws;
     452      input >> ws;
     453      input >> elements[Z]->Valence;
     454      input >> ws;
    412455      //Log() << Verbose(3) << "Element " << Z << " has " << FindElement(Z)->Valence << " valence electrons." << endl;
    413456    }
     
    421464 * \return true - parsing successful, false - something went wrong
    422465 */
    423 bool periodentafel::LoadOrbitalsDatabase(istream *input)
     466bool periodentafel::LoadOrbitalsDatabase(istream &input)
    424467{
    425468  char dummy[MAXSTRINGSIZE];
    426   if (!(*input).fail()) {
    427     (*input).getline(dummy, MAXSTRINGSIZE);
    428     while (!(*input).eof()) {
     469  if (!input.fail()) {
     470    input.getline(dummy, MAXSTRINGSIZE);
     471    while (!input.eof()) {
    429472      atomicNumber_t Z;
    430       (*input) >> Z;
     473      input >> Z;
    431474      ASSERT(elements.count(Z), "Element not present");
    432       (*input) >> ws;
    433       (*input) >> elements[Z]->NoValenceOrbitals;
    434       (*input) >> ws;
     475      input >> ws;
     476      input >> elements[Z]->NoValenceOrbitals;
     477      input >> ws;
    435478      //Log() << Verbose(3) << "Element " << Z << " has " << FindElement(Z)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
    436479    }
     
    444487 * \return true - parsing successful, false - something went wrong
    445488 */
    446 bool periodentafel::LoadHBondAngleDatabase(istream *input)
     489bool periodentafel::LoadHBondAngleDatabase(istream &input)
    447490{
    448491  char dummy[MAXSTRINGSIZE];
    449   if (!(*input).fail()) {
    450     (*input).getline(dummy, MAXSTRINGSIZE);
    451     while (!(*input).eof()) {
     492  if (!input.fail()) {
     493    input.getline(dummy, MAXSTRINGSIZE);
     494    while (!input.eof()) {
    452495      atomicNumber_t Z;
    453       (*input) >> Z;
     496      input >> Z;
    454497      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;
     498      input >> ws;
     499      input >> elements[Z]->HBondAngle[0];
     500      input >> elements[Z]->HBondAngle[1];
     501      input >> elements[Z]->HBondAngle[2];
     502      input >> ws;
    460503      //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;
    461504    }
     
    469512 * \return true - parsing successful, false - something went wrong
    470513 */
    471 bool periodentafel::LoadHBondLengthsDatabase(istream *input)
     514bool periodentafel::LoadHBondLengthsDatabase(istream &input)
    472515{
    473516  char dummy[MAXSTRINGSIZE];
    474   if (!(*input).fail()) {
    475     (*input).getline(dummy, MAXSTRINGSIZE);
    476     while (!(*input).eof()) {
     517  if (!input.fail()) {
     518    input.getline(dummy, MAXSTRINGSIZE);
     519    while (!input.eof()) {
    477520      atomicNumber_t Z;
    478       (*input) >> Z;
     521      input >> Z;
    479522      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;
     523      input >> ws;
     524      input >> elements[Z]->HBondDistance[0];
     525      input >> elements[Z]->HBondDistance[1];
     526      input >> elements[Z]->HBondDistance[2];
     527      input >> ws;
    485528      //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl;
    486529    }
  • src/periodentafel.hpp

    rea430a r67c92b  
    6363
    6464  bool LoadElementsDatabase(std::istream &input);
    65   bool LoadValenceDatabase(std::istream *input);
    66   bool LoadOrbitalsDatabase(std::istream *input);
    67   bool LoadHBondAngleDatabase(std::istream *input);
    68   bool LoadHBondLengthsDatabase(std::istream *input);
     65  bool LoadElectronegativityDatabase(std::istream &input);
     66  bool LoadValenceDatabase(std::istream &input);
     67  bool LoadOrbitalsDatabase(std::istream &input);
     68  bool LoadHBondAngleDatabase(std::istream &input);
     69  bool LoadHBondLengthsDatabase(std::istream &input);
    6970
    7071    elementSet elements;
  • src/unittests/PeriodentafelUnitTest.cpp

    rea430a r67c92b  
    8484  // reload all databases
    8585  stringstream elementsDBstream(elementsDB,ios_base::in);
     86  stringstream ElectronegativityDBstream(ElectronegativitiesDB,ios_base::in);
     87  stringstream valenceDBstream(valenceDB,ios_base::in);
     88  stringstream orbitalsDBstream(orbitalsDB,ios_base::in);
     89  stringstream HbondangleDBstream(HbondangleDB,ios_base::in);
     90  stringstream HbonddistanceDBstream(HbonddistanceDB,ios_base::in);
    8691  CPPUNIT_ASSERT(tafel->LoadElementsDatabase(elementsDBstream) && "General element initialization failed");
    87   CPPUNIT_ASSERT(tafel->LoadValenceDatabase(new stringstream(valenceDB,ios_base::in)) && "Valence entry of element initialization failed");
    88   CPPUNIT_ASSERT(tafel->LoadOrbitalsDatabase(new stringstream(orbitalsDB,ios_base::in)) && "Orbitals entry of element initialization failed");
    89   CPPUNIT_ASSERT(tafel->LoadHBondAngleDatabase(new stringstream(HbondangleDB,ios_base::in)) && "HBond angle entry of element initialization failed");
    90   CPPUNIT_ASSERT(tafel->LoadHBondLengthsDatabase(new stringstream(HbonddistanceDB,ios_base::in)) && "HBond distance entry of element initialization failed");
     92  CPPUNIT_ASSERT(tafel->LoadElectronegativityDatabase(ElectronegativityDBstream) && "Electronegativity entry of element initialization failed");
     93  CPPUNIT_ASSERT(tafel->LoadValenceDatabase(valenceDBstream) && "Valence entry of element initialization failed");
     94  CPPUNIT_ASSERT(tafel->LoadOrbitalsDatabase(orbitalsDBstream) && "Orbitals entry of element initialization failed");
     95  CPPUNIT_ASSERT(tafel->LoadHBondAngleDatabase(HbondangleDBstream) && "HBond angle entry of element initialization failed");
     96  CPPUNIT_ASSERT(tafel->LoadHBondLengthsDatabase(HbonddistanceDBstream) && "HBond distance entry of element initialization failed");
    9197  // check presence of elements
    9298  atomicNumber_t Z = 1;
Note: See TracChangeset for help on using the changeset viewer.