Changeset 4eb4fe


Ignore:
Timestamp:
May 18, 2010, 3:20:52 PM (15 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:
673c7f, b0e9c9
Parents:
5079a0
Message:

"-e <db path>" not necessary anymore.

Removed necessity of specifying path to databases (this was one check of molecuilder/test/testsuite.at which cannot be fulfilled anymore with boost::program_options)
For this to work a great number of small changes have been necessary:

class periodentafel:

  • all .db files merged into const char * arrays in elements_db.cpp
  • periodentafel rewritten:
  • FindElement(), AskElement() and EnterElement return element * const instead of const element * (i.e. the contents of the pointer is const (the element) not the pointer itself which is very vexatious (i.e. FindElement() yields const element * which can subsequently not be used for RemoveElement(), ...)
  • parsedElems is not needed anymore. Instead we operate on map elements directly
  • new unittest periodentafelTest which is made friend of periodentafel to be able to access private loading functions directly

A number of unit tests had to be changed (all that create elements during setUp() which is now unnecessary)

Some of the analysis_bonds function's signatures were changed in the process:

Finally, the respective tests are removed from molecuilder/tests/testsuite.at.

Files:
4 added
25 edited

Legend:

Unmodified
Added
Removed
  • src/analysis_bonds.cpp

    r5079a0 r4eb4fe  
    5151 * \param &Max maximum distance on return, 0 if no bond between the two elements
    5252 */
    53 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, element *type1, element *type2, double &Min, double &Mean, double &Max)
     53void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, const element *type1, const element *type2, double &Min, double &Mean, double &Max)
    5454{
    5555  Min = 2e+6;
     
    124124 * \param *InterfaceElement or NULL
    125125 */
    126 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, element * InterfaceElement = NULL)
     126int CountHydrogenBridgeBonds(MoleculeListClass *molecules, const element * InterfaceElement = NULL)
    127127{
    128128  atom *Walker = NULL;
  • src/analysis_bonds.hpp

    r5079a0 r4eb4fe  
    3131
    3232void GetMaxMinMeanBondCount(const molecule * const mol, double &Min, double &Mean, double &Max);
    33 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, element *type1, element *type2, double &Min, double &Mean, double &Max);
     33void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, const element *type1, const element *type2, double &Min, double &Mean, double &Max);
    3434
    35 int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, element * InterfaceElement);
     35int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, const element * InterfaceElement);
    3636int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second);
    3737int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third);
  • src/builder.cpp

    r5079a0 r4eb4fe  
    25012501    bool ArgumentsCopied = false;
    25022502
     2503    // print version check whether arguments are present at all
    25032504    cout << ESPACKVersion << endl;
     2505    if (argc < 2) {
     2506      cout << "Obtain help with " << argv[0] << " -h." << endl;
     2507      return(1);
     2508    }
     2509
    25042510
    25052511    setVerbosity(0);
  • src/elements.db

    • Property mode changed from 100755 to 100644
    r5079a0 r4eb4fe  
    22#Element        Name    Symbol  Period  Group   Block   Atomic  Number  AtomicWeight    Covalent        Radius  vdW     Radius
    33Hydrogen        H       1       1       s       1       1.008   0.23    1.09
    4 Helium  He      1       18      p       2       4.003   1.50    1.40
     4Helium  He      1       18      p       2       4.003   1.5     1.4
    55Lithium Li      2       1       s       3       6.941   0.68    1.82
    6 Beryllium       Be      2       2       s       4       9.012   0.35    2.00
    7 Boron   B       2       13      p       5       10.811  0.83    2.00
    8 Carbon  C       2       14      p       6       12.011  0.68    1.70
     6Beryllium       Be      2       2       s       4       9.012   0.35    2
     7Boron   B       2       13      p       5       10.811  0.83    2
     8Carbon  C       2       14      p       6       12.011  0.68    1.7
    99Nitrogen        N       2       15      p       7       14.007  0.68    1.55
    1010Oxygen  O       2       16      p       8       15.999  0.68    1.52
    1111Fluorine        F       2       17      p       9       18.998  0.64    1.47
    12 Neon    Ne      2       18      p       10      20.180  1.50    1.54
     12Neon    Ne      2       18      p       10      20.18   1.5     1.54
    1313Sodium  Na      3       1       s       11      22.991  0.97    2.27
    14 Magnesium       Mg      3       2       s       12      24.305  1.10    1.73
    15 Aluminium       Al      3       13      p       13      26.982  1.35    2.00
    16 Silicon Si      3       14      p       14      28.086  1.20    2.10
    17 Phosphorus      P       3       15      p       15      30.974  1.05    1.80
    18 Sulphur S       3       16      p       16      32.066  1.02    1.80
     14Magnesium       Mg      3       2       s       12      24.305  1.1     1.73
     15Aluminium       Al      3       13      p       13      26.982  1.35    2
     16Silicon Si      3       14      p       14      28.086  1.2     2.1
     17Phosphorus      P       3       15      p       15      30.974  1.05    1.8
     18Sulphur S       3       16      p       16      32.066  1.02    1.8
    1919Chlorine        Cl      3       17      p       17      35.453  0.99    1.75
    2020Argon   Ar      3       18      p       18      39.948  1.51    1.88
    2121Potassium       K       4       1       s       19      39.098  1.33    2.75
    22 Calcium Ca      4       2       s       20      40.078  0.99    2.00
    23 Scandium        Sc      4       3       d       21      44.956  1.44    2.00
    24 Titanium        Ti      4       4       d       22      47.867  1.47    2.00
    25 Vanadium        V       4       5       d       23      50.942  1.33    2.00
    26 Chromium        Cr      4       6       d       24      51.996  1.35    2.00
    27 Manganese       Mn      4       7       d       25      54.938  1.35    2.00
    28 Iron    Fe      4       8       d       26      55.845  1.34    2.00
    29 Cobalt  Co      4       9       d       27      58.933  1.33    2.00
    30 Nickel  Ni      4       10      d       28      58.693  1.50    1.63
    31 Copper  Cu      4       11      d       29      63.546  1.52    1.40
    32 Zinc    Zn      4       12      d       30      65.390  1.45    1.39
     22Calcium Ca      4       2       s       20      40.078  0.99    2
     23Scandium        Sc      4       3       d       21      44.956  1.44    2
     24Titanium        Ti      4       4       d       22      47.867  1.47    2
     25Vanadium        V       4       5       d       23      50.942  1.33    2
     26Chromium        Cr      4       6       d       24      51.996  1.35    2
     27Manganese       Mn      4       7       d       25      54.938  1.35    2
     28Iron    Fe      4       8       d       26      55.845  1.34    2
     29Cobalt  Co      4       9       d       27      58.933  1.33    2
     30Nickel  Ni      4       10      d       28      58.693  1.5     1.63
     31Copper  Cu      4       11      d       29      63.546  1.52    1.4
     32Zinc    Zn      4       12      d       30      65.39   1.45    1.39
    3333Gallium Ga      4       13      p       31      69.723  1.22    1.87
    34 Germanium       Ge      4       14      p       32      72.610  1.17    2.00
     34Germanium       Ge      4       14      p       32      72.61   1.17    2
    3535Arsenic As      4       15      p       33      74.922  1.21    1.85
    36 Selenium        Se      4       16      p       34      78.960  1.22    1.90
     36Selenium        Se      4       16      p       34      78.96   1.22    1.9
    3737Bromine Br      4       17      p       35      79.904  1.21    1.85
    38 Krypton Kr      4       18      p       36      83.800  1.50    2.02
    39 Rubidium        Rb      5       1       s       37      85.468  1.47    2.00
    40 Strontium       Sr      5       2       s       38      87.620  1.12    2.00
    41 Yttrium Y       5       3       d       39      88.906  1.78    2.00
    42 Zirconium       Zr      5       4       d       40      91.224  1.56    2.00
    43 Niobium Nb      5       5       d       41      92.906  1.48    2.00
    44 Molybdenum      Mo      5       6       d       42      95.940  1.47    2.00
    45 Technetium      Tc      5       7       d       43      98      1.35    2.00
    46 Ruthenium       Ru      5       8       d       44      101.070 1.40    2.00
    47 Rhodium Rh      5       9       d       45      102.906 1.45    2.00
    48 Palladium       Pd      5       10      d       46      106.420 1.50    1.63
     38Krypton Kr      4       18      p       36      83.8    1.5     2.02
     39Rubidium        Rb      5       1       s       37      85.468  1.47    2
     40Strontium       Sr      5       2       s       38      87.62   1.12    2
     41Yttrium Y       5       3       d       39      88.906  1.78    2
     42Zirconium       Zr      5       4       d       40      91.224  1.56    2
     43Niobium Nb      5       5       d       41      92.906  1.48    2
     44Molybdenum      Mo      5       6       d       42      95.94   1.47    2
     45Technetium      Tc      5       7       d       43      98      1.35    2
     46Ruthenium       Ru      5       8       d       44      101.07  1.4     2
     47Rhodium Rh      5       9       d       45      102.906 1.45    2
     48Palladium       Pd      5       10      d       46      106.42  1.5     1.63
    4949Silver  Ag      5       11      d       47      107.868 1.59    1.72
    5050Cadmium Cd      5       12      d       48      112.411 1.69    1.58
    5151Indium  In      5       13      p       49      114.818 1.63    1.93
    5252Tin     Sn      5       14      p       50      118.71  1.46    2.17
    53 Antimony        Sb      5       15      p       51      121.760 1.46    2.00
    54 Tellurium       Te      5       16      p       52      127.600 1.47    2.06
    55 Iodine  I       5       17      p       53      126.904 1.40    1.98
    56 Xenon   Xe      5       18      p       54      131.290 1.50    2.16
    57 Caesium Cs      6       1       s       55      132.905 1.67    2.00
    58 Barium  Ba      6       2       s       56      137.327 1.34    2.00
    59 Lutetium        Lu      6       3       d       71      174.967 1.72    2.00
    60 Hafnium Hf      6       4       d       72      178.490 1.57    2.00
    61 Tantalum        Ta      6       5       d       73      180.948 1.43    2.00
    62 Tungsten        W       6       6       d       74      183.840 1.37    2.00
    63 Rhenium Re      6       7       d       75      186.207 1.35    2.00
    64 Osmium  Os      6       8       d       76      190.230 1.37    2.00
    65 Iridium Ir      6       9       d       77      192.217 1.32    2.00
    66 Platinum        Pt      6       10      d       78      195.078 1.50    1.72
    67 Gold    Au      6       11      d       79      196.967 1.50    1.66
    68 Mercury Hg      6       12      d       80      200.590 1.70    1.55
     53Antimony        Sb      5       15      p       51      121.76  1.46    2
     54Tellurium       Te      5       16      p       52      127.6   1.47    2.06
     55Iodine  I       5       17      p       53      126.904 1.4     1.98
     56Xenon   Xe      5       18      p       54      131.29  1.5     2.16
     57Caesium Cs      6       1       s       55      132.905 1.67    2
     58Barium  Ba      6       2       s       56      137.327 1.34    2
     59Lanthanum       La      6Lan    19      f       57      138.906 1.87    2
     60Cerium  Ce      6Lan    19      f       58      140.116 1.83    2
     61Praseodymium    Pr      6Lan    19      f       59      140.908 1.82    2
     62Neodymium       Nd      6Lan    19      f       60      144.24  1.81    2
     63Promethium      Pm      6Lan    19      f       61      145     1.8     2
     64Samarium        Sm      6Lan    19      f       62      150.36  1.8     2
     65Europium        Eu      6Lan    19      f       63      151.964 1.99    2
     66Gadolinium      Gd      6Lan    19      f       64      157.25  1.79    2
     67Terbium Tb      6Lan    19      f       65      158.925 1.76    2
     68Dysprosium      Dy      6Lan    19      f       66      162.5   1.75    2
     69Holmium Ho      6Lan    19      f       67      164.93  1.74    2
     70Erbium  Er      6Lan    19      f       68      167.26  1.73    2
     71Thulium Tm      6Lan    19      f       69      168.934 1.72    2
     72Ytterbium       Yb      6Lan    19      f       70      173.04  1.94    2
     73Lutetium        Lu      6       3       d       71      174.967 1.72    2
     74Hafnium Hf      6       4       d       72      178.49  1.57    2
     75Tantalum        Ta      6       5       d       73      180.948 1.43    2
     76Tungsten        W       6       6       d       74      183.84  1.37    2
     77Rhenium Re      6       7       d       75      186.207 1.35    2
     78Osmium  Os      6       8       d       76      190.23  1.37    2
     79Iridium Ir      6       9       d       77      192.217 1.32    2
     80Platinum        Pt      6       10      d       78      195.078 1.5     1.72
     81Gold    Au      6       11      d       79      196.967 1.5     1.66
     82Mercury Hg      6       12      d       80      200.59  1.7     1.55
    6983Thallium        Tl      6       13      p       81      204.383 1.55    1.96
    70 Lead    Pb      6       14      p       82      207.200 1.54    2.02
    71 Bismuth Bi      6       15      p       83      208.980 1.54    2.00
    72 Polonium        Po      6       16      p       84      210     1.68    2.00
    73 Astatine        At      6       17      p       85      210     1.21    2.00
    74 Radon   Rn      6       18      p       86      222     1.50    2.00
    75 Cerium  Ce      6Lan    19      f       58      140.116 1.83    2.00
    76 Dysprosium      Dy      6Lan    19      f       66      162.500 1.75    2.00
    77 Erbium  Er      6Lan    19      f       68      167.260 1.73    2.00
    78 Europium        Eu      6Lan    19      f       63      151.964 1.99    2.00
    79 Gadolinium      Gd      6Lan    19      f       64      157.250 1.79    2.00
    80 Holmium Ho      6Lan    19      f       67      164.930 1.74    2.00
    81 Lanthanum       La      6Lan    19      f       57      138.906 1.87    2.00
    82 Neodymium       Nd      6Lan    19      f       60      144.240 1.81    2.00
    83 Promethium      Pm      6Lan    19      f       61      145     1.80    2.00
    84 Praseodymium    Pr      6Lan    19      f       59      140.908 1.82    2.00
    85 Samarium        Sm      6Lan    19      f       62      150.360 1.80    2.00
    86 Terbium Tb      6Lan    19      f       65      158.925 1.76    2.00
    87 Thulium Tm      6Lan    19      f       69      168.934 1.72    2.00
    88 Ytterbium       Yb      6Lan    19      f       70      173.040 1.94    2.00
    89 Francium        Fr      7       1       s       87      223     1.50    2.00
    90 Radium  Ra      7       2       s       88      226     1.90    2.00
    91 Lawrencium      Lr      7       3       d       103     262     1.50    2.00
    92 Rutherfordium   Rf      7       4       d       104     261     1.50    2.00
    93 Dubnium Db      7       5       d       105     262     1.50    2.00
    94 Seaborgium      Sg      7       6       d       106     266     1.50    2.00
    95 Bohrium Bh      7       7       d       107     264     1.50    2.00
    96 Hassium Hs      7       8       d       108     269     1.50    2.00
    97 Meitnerium      Mt      7       9       d       109     268     1.50    2.00
    98 Darmstadtium    Ds      7       10      d       110     271     1.50    2.00
    99 Actinium        Ac      7Act    20      f       89      227     1.88    2.00
    100 Americium       Am      7Act    20      f       95      243     1.51    2.00
    101 Berkelium       Bk      7Act    20      f       97      247     1.54    2.00
    102 Californium     Cf      7Act    20      f       98      251     1.83    2.00
    103 Curium  Cm      7Act    20      f       96      247     0.99    2.00
    104 Einsteinium     Es      7Act    20      f       99      252     1.50    2.00
    105 Fermium Fm      7Act    20      f       100     257     1.50    2.00
    106 Mendelevium     Md      7Act    20      f       101     258     1.50    2.00
    107 Nobelium        No      7Act    20      f       102     259     1.50    2.00
    108 Neptunium       Np      7Act    20      f       93      237     1.55    2.00
    109 Protactinium    Pa      7Act    20      f       91      231.036 1.61    2.00
    110 Plutonium       Pu      7Act    20      f       94      244     1.53    2.00
    111 Thorium Th      7Act    20      f       90      232.038 1.79    2.00
     84Lead    Pb      6       14      p       82      207.2   1.54    2.02
     85Bismuth Bi      6       15      p       83      208.98  1.54    2
     86Polonium        Po      6       16      p       84      210     1.68    2
     87Astatine        At      6       17      p       85      210     1.21    2
     88Radon   Rn      6       18      p       86      222     1.5     2
     89Francium        Fr      7       1       s       87      223     1.5     2
     90Radium  Ra      7       2       s       88      226     1.9     2
     91Actinium        Ac      7Act    20      f       89      227     1.88    2
     92Thorium Th      7Act    20      f       90      232.038 1.79    2
     93Protactinium    Pa      7Act    20      f       91      231.036 1.61    2
    11294Uranium U       7Act    20      f       92      238.029 1.58    1.86
     95Neptunium       Np      7Act    20      f       93      237     1.55    2
     96Plutonium       Pu      7Act    20      f       94      244     1.53    2
     97Americium       Am      7Act    20      f       95      243     1.51    2
     98Curium  Cm      7Act    20      f       96      247     0.99    2
     99Berkelium       Bk      7Act    20      f       97      247     1.54    2
     100Californium     Cf      7Act    20      f       98      251     1.83    2
     101Einsteinium     Es      7Act    20      f       99      252     1.5     2
     102Fermium Fm      7Act    20      f       100     257     1.5     2
     103Mendelevium     Md      7Act    20      f       101     258     1.5     2
     104Nobelium        No      7Act    20      f       102     259     1.5     2
     105Lawrencium      Lr      7       3       d       103     262     1.5     2
     106Rutherfordium   Rf      7       4       d       104     261     1.5     2
     107Dubnium Db      7       5       d       105     262     1.5     2
     108Seaborgium      Sg      7       6       d       106     266     1.5     2
     109Bohrium Bh      7       7       d       107     264     1.5     2
     110Hassium Hs      7       8       d       108     269     1.5     2
     111Meitnerium      Mt      7       9       d       109     268     1.5     2
     112Darmstadtium    Ds      7       10      d       110     271     1.5     2
  • src/periodentafel.cpp

    r5079a0 r4eb4fe  
    88
    99#include <iomanip>
     10#include <iostream>
    1011#include <fstream>
    1112#include <cstring>
    12 #include <cassert>
    13 
     13
     14#include "Helpers/Assert.hpp"
    1415#include "element.hpp"
     16#include "elements_db.hpp"
    1517#include "helpers.hpp"
    1618#include "lists.hpp"
     
    2729 */
    2830periodentafel::periodentafel()
    29 {};
     31{
     32  ASSERT(LoadElementsDatabase(new stringstream(elementsDB,ios_base::in)), "General element initialization failed");
     33  ASSERT(LoadValenceDatabase(new stringstream(valenceDB,ios_base::in)), "Valence entry of element initialization failed");
     34  ASSERT(LoadOrbitalsDatabase(new stringstream(orbitalsDB,ios_base::in)), "Orbitals entry of element initialization failed");
     35  ASSERT(LoadHBondAngleDatabase(new stringstream(HbondangleDB,ios_base::in)), "HBond angle entry of element initialization failed");
     36  ASSERT(LoadHBondLengthsDatabase(new stringstream(HbonddistanceDB,ios_base::in)), "HBond distance entry of element initialization failed");
     37};
    3038
    3139/** destructor for class periodentafel
     
    3947/** Adds element to period table list
    4048 * \param *pointer element to be added
    41  * \return true - succeeded, false - does not occur
     49 * \return iterator to added element
    4250 */
    4351periodentafel::iterator periodentafel::AddElement(element * const pointer)
    4452{
    4553  atomicNumber_t Z = pointer->getNumber();
    46   assert(!elements.count(Z));
     54  ASSERT(!elements.count(Z), "Element is already present.");
    4755  pointer->sort = &pointer->Z;
    4856  if (pointer->getNumber() < 1 && pointer->getNumber() >= MAX_ELEMENTS)
     
    5462/** Removes element from list.
    5563 * \param *pointer element to be removed
    56  * \return true - succeeded, false - element not found
    5764 */
    5865void periodentafel::RemoveElement(element * const pointer)
    5966{
    60   atomicNumber_t Z = pointer->getNumber();
     67  RemoveElement(pointer->getNumber());
     68};
     69
     70/** Removes element from list.
     71 * \param Z element to be removed
     72 */
     73void periodentafel::RemoveElement(atomicNumber_t Z)
     74{
    6175  elements.erase(Z);
    6276};
    6377
    6478/** Removes every element from the period table.
    65  * \return true - succeeded, false - does not occur
    6679 */
    6780void periodentafel::CleanupPeriodtable()
     
    7891 * \return pointer to element or NULL if not found
    7992 */
    80 const element * periodentafel::FindElement(atomicNumber_t Z) const
     93element * const periodentafel::FindElement(atomicNumber_t Z) const
    8194{
    8295  const_iterator res = elements.find(Z);
     
    89102 * \return pointer to element
    90103 */
    91 const element * periodentafel::FindElement(const char * const shorthand) const
     104element * const periodentafel::FindElement(const char * const shorthand) const
    92105{
    93106  element *res = 0;
     
    102115
    103116/** Asks for element number and returns pointer to element
    104  */
    105 const element * periodentafel::AskElement() const
    106 {
    107   const element *walker = NULL;
     117 * \return desired element or NULL
     118 */
     119element * const periodentafel::AskElement() const
     120{
     121  element * walker = NULL;
    108122  int Z;
    109123  do {
     
    118132 * \return pointer to either present or newly created element
    119133 */
    120 const element * periodentafel::EnterElement()
    121 {
    122   const element *res = NULL;
     134element * const periodentafel::EnterElement()
     135{
    123136  atomicNumber_t Z = 0;
    124137  DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl);
    125138  cin >> Z;
    126   res = FindElement(Z);
     139  element * const res = FindElement(Z);
    127140  if (!res) {
    128141    // TODO: make this using the constructor
    129     element *tmp;
    130142    DoLog(0) && (Log() << Verbose(0) << "Element not found in database, please enter." << endl);
    131     tmp = new element;
     143    element *tmp = new element;
    132144    tmp->Z = Z;
    133145    DoLog(0) && (Log() << Verbose(0) << "Mass: " << endl);
     
    138150    cin >> tmp->symbol;
    139151    AddElement(tmp);
    140     res = tmp;
     152    return tmp;
    141153  }
    142154  return res;
     
    204216bool periodentafel::LoadPeriodentafel(const char *path)
    205217{
    206   ifstream infile;
    207   element *ptr;
    208   map<atomicNumber_t,element*> parsedElems;
     218  ifstream input;
    209219  bool status = true;
    210220  bool otherstatus = true;
     
    215225  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
    216226  strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename));
    217   infile.open(filename);
    218   if (infile != NULL) {
    219     infile.getline(header1, MAXSTRINGSIZE);
    220     infile.getline(header2, MAXSTRINGSIZE); // skip first two header lines
     227  input.open(filename);
     228  status = status && LoadElementsDatabase(&input);
     229
     230  // fill valence DB per element
     231  strncpy(filename, path, MAXSTRINGSIZE);
     232  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     233  strncat(filename, STANDARDVALENCEDB, MAXSTRINGSIZE-strlen(filename));
     234  input.open(filename);
     235  otherstatus = otherstatus && LoadValenceDatabase(&input);
     236
     237  // fill orbitals DB per element
     238  strncpy(filename, path, MAXSTRINGSIZE);
     239  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     240  strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename));
     241  input.open(filename);
     242  otherstatus = otherstatus && LoadOrbitalsDatabase(&input);
     243
     244  // fill H-BondAngle DB per element
     245  strncpy(filename, path, MAXSTRINGSIZE);
     246  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     247  strncat(filename, STANDARDHBONDANGLEDB, MAXSTRINGSIZE-strlen(filename));
     248  input.open(filename);
     249  otherstatus = otherstatus && LoadHBondAngleDatabase(&input);
     250
     251  // fill H-BondDistance DB per element
     252  strncpy(filename, path, MAXSTRINGSIZE);
     253  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     254  strncat(filename, STANDARDHBONDDISTANCEDB, MAXSTRINGSIZE-strlen(filename));
     255  input.open(filename);
     256  otherstatus = otherstatus && LoadHBondLengthsDatabase(&input);
     257
     258  if (!otherstatus){
     259    DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl);
     260  }
     261
     262  return status;
     263};
     264
     265/** load the element info.
     266 * \param *input stream to parse from
     267 * \return true - parsing successful, false - something went wrong
     268 */
     269bool periodentafel::LoadElementsDatabase(istream *input)
     270{
     271  if ((*input) != NULL) {
     272    (*input).getline(header1, MAXSTRINGSIZE);
     273    (*input).getline(header2, MAXSTRINGSIZE); // skip first two header lines
    221274    DoLog(0) && (Log() << Verbose(0) <<  "Parsed elements:");
    222     while (!infile.eof()) {
     275    while (!(*input).eof()) {
    223276      element *neues = new element;
    224       infile >> neues->name;
    225       //infile >> ws;
    226       infile >> neues->symbol;
    227       //infile >> ws;
    228       infile >> neues->period;
    229       //infile >> ws;
    230       infile >> neues->group;
    231       //infile >> ws;
    232       infile >> neues->block;
    233       //infile >> ws;
    234       infile >> neues->Z;
    235       //infile >> ws;
    236       infile >> neues->mass;
    237       //infile >> ws;
    238       infile >> neues->CovalentRadius;
    239       //infile >> ws;
    240       infile >> neues->VanDerWaalsRadius;
    241       //infile >> ws;
    242       infile >> ws;
     277      (*input) >> neues->name;
     278      //(*input) >> ws;
     279      (*input) >> neues->symbol;
     280      //(*input) >> ws;
     281      (*input) >> neues->period;
     282      //(*input) >> ws;
     283      (*input) >> neues->group;
     284      //(*input) >> ws;
     285      (*input) >> neues->block;
     286      //(*input) >> ws;
     287      (*input) >> neues->Z;
     288      //(*input) >> ws;
     289      (*input) >> neues->mass;
     290      //(*input) >> ws;
     291      (*input) >> neues->CovalentRadius;
     292      //(*input) >> ws;
     293      (*input) >> neues->VanDerWaalsRadius;
     294      //(*input) >> ws;
     295      (*input) >> ws;
    243296      DoLog(0) && (Log() << Verbose(0) << " " << neues->symbol);
     297      if (elements.count(neues->Z)) {// if element already present, remove and delete it
     298        element * const Elemental = FindElement(neues->Z);
     299        ASSERT(Elemental != NULL, "element should be present but is not??");
     300        RemoveElement(Elemental);
     301        delete(Elemental);
     302      }
    244303      //neues->Output((ofstream *)&cout);
    245304      if ((neues->Z > 0) && (neues->Z < MAX_ELEMENTS))
    246         parsedElems[neues->getNumber()] = neues;
     305        elements[neues->getNumber()] = neues;
    247306      else {
    248307        DoLog(0) && (Log() << Verbose(0) << "Could not parse element: ");
     
    252311    }
    253312    DoLog(0) && (Log() << Verbose(0) << endl);
    254     infile.close();
    255     infile.clear();
    256   } else
    257     status = false;
    258 
    259   // fill valence DB per element
    260   strncpy(filename, path, MAXSTRINGSIZE);
    261   strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
    262   strncat(filename, STANDARDVALENCEDB, MAXSTRINGSIZE-strlen(filename));
    263   infile.open(filename);
    264   if (infile != NULL) {
    265     while (!infile.eof()) {
     313    return true;
     314  } else
     315    return false;
     316}
     317
     318/** load the valence info.
     319 * \param *input stream to parse from
     320 * \return true - parsing successful, false - something went wrong
     321 */
     322bool periodentafel::LoadValenceDatabase(istream *input)
     323{
     324  char dummy[MAXSTRINGSIZE];
     325  if ((*input) != NULL) {
     326    (*input).getline(dummy, MAXSTRINGSIZE);
     327    while (!(*input).eof()) {
    266328      atomicNumber_t Z;
    267       infile >> Z;
    268       infile >> ws;
    269       infile >> parsedElems[Z]->Valence;
    270       infile >> ws;
     329      (*input) >> Z;
     330      ASSERT(elements.count(Z), "Element not present");
     331      (*input) >> ws;
     332      (*input) >> elements[Z]->Valence;
     333      (*input) >> ws;
    271334      //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->Valence << " valence electrons." << endl;
    272335    }
    273     infile.close();
    274     infile.clear();
    275   } else
    276     otherstatus = false;
    277 
    278   // fill valence DB per element
    279   strncpy(filename, path, MAXSTRINGSIZE);
    280   strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
    281   strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename));
    282   infile.open(filename);
    283   if (infile != NULL) {
    284     while (!infile.eof()) {
     336    return true;
     337  } else
     338                return false;
     339}
     340
     341/** load the orbitals info.
     342 * \param *input stream to parse from
     343 * \return true - parsing successful, false - something went wrong
     344 */
     345bool periodentafel::LoadOrbitalsDatabase(istream *input)
     346{
     347  char dummy[MAXSTRINGSIZE];
     348  if ((*input) != NULL) {
     349    (*input).getline(dummy, MAXSTRINGSIZE);
     350    while (!(*input).eof()) {
    285351      atomicNumber_t Z;
    286       infile >> Z;
    287       infile >> ws;
    288       infile >> parsedElems[Z]->NoValenceOrbitals;
    289       infile >> ws;
     352      (*input) >> Z;
     353      ASSERT(elements.count(Z), "Element not present");
     354      (*input) >> ws;
     355      (*input) >> elements[Z]->NoValenceOrbitals;
     356      (*input) >> ws;
    290357      //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
    291358    }
    292     infile.close();
    293     infile.clear();
    294   } else
    295     otherstatus = false;
    296 
    297   // fill H-BondDistance DB per element
    298   strncpy(filename, path, MAXSTRINGSIZE);
    299   strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
    300   strncat(filename, STANDARDHBONDDISTANCEDB, MAXSTRINGSIZE-strlen(filename));
    301   infile.open(filename);
    302   if (infile != NULL) {
    303     while (!infile.eof()) {
     359    return true;
     360  } else
     361    return false;
     362}
     363
     364/** load the hbond angles info.
     365 * \param *input stream to parse from
     366 * \return true - parsing successful, false - something went wrong
     367 */
     368bool periodentafel::LoadHBondAngleDatabase(istream *input)
     369{
     370  char dummy[MAXSTRINGSIZE];
     371  if ((*input) != NULL) {
     372    (*input).getline(dummy, MAXSTRINGSIZE);
     373    while (!(*input).eof()) {
    304374      atomicNumber_t Z;
    305       infile >> Z;
    306       ptr = parsedElems[Z];
    307       infile >> ws;
    308       infile >> ptr->HBondDistance[0];
    309       infile >> ptr->HBondDistance[1];
    310       infile >> ptr->HBondDistance[2];
    311       infile >> ws;
     375      (*input) >> Z;
     376      ASSERT(elements.count(Z), "Element not present");
     377      (*input) >> ws;
     378      (*input) >> elements[Z]->HBondAngle[0];
     379      (*input) >> elements[Z]->HBondAngle[1];
     380      (*input) >> elements[Z]->HBondAngle[2];
     381      (*input) >> ws;
     382      //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;
     383    }
     384    return true;
     385  } else
     386                return false;
     387}
     388
     389/** load the hbond lengths info.
     390 * \param *input stream to parse from
     391 * \return true - parsing successful, false - something went wrong
     392 */
     393bool periodentafel::LoadHBondLengthsDatabase(istream *input)
     394{
     395  char dummy[MAXSTRINGSIZE];
     396  if ((*input) != NULL) {
     397    (*input).getline(dummy, MAXSTRINGSIZE);
     398    while (!(*input).eof()) {
     399      atomicNumber_t Z;
     400      (*input) >> Z;
     401      ASSERT(elements.count(Z), "Element not present");
     402      (*input) >> ws;
     403      (*input) >> elements[Z]->HBondDistance[0];
     404      (*input) >> elements[Z]->HBondDistance[1];
     405      (*input) >> elements[Z]->HBondDistance[2];
     406      (*input) >> ws;
    312407      //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl;
    313408    }
    314     infile.close();
    315     infile.clear();
    316   } else
    317     otherstatus = false;
    318 
    319   // fill H-BondAngle DB per element
    320   strncpy(filename, path, MAXSTRINGSIZE);
    321   strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
    322   strncat(filename, STANDARDHBONDANGLEDB, MAXSTRINGSIZE-strlen(filename));
    323   infile.open(filename);
    324   if (infile != NULL) {
    325     while (!infile.eof()) {
    326       atomicNumber_t Z;
    327       infile >> Z;
    328       ptr = parsedElems[Z];
    329       infile >> ws;
    330       infile >> ptr->HBondAngle[0];
    331       infile >> ptr->HBondAngle[1];
    332       infile >> ptr->HBondAngle[2];
    333       infile >> ws;
    334       //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;
    335     }
    336     infile.close();
    337   } else
    338     otherstatus = false;
    339 
    340   if (otherstatus){
    341     map<atomicNumber_t,element*>::iterator iter;
    342     for(iter=parsedElems.begin();iter!=parsedElems.end();++iter){
    343       AddElement((*iter).second);
    344     }
    345   }
    346   else{
    347     DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl);
    348     map<atomicNumber_t,element*>::iterator iter;
    349     for(iter=parsedElems.begin();iter!=parsedElems.end();++iter){
    350       AddElement((*iter).second);
    351     }
    352   }
    353 
    354   return status;
    355 };
     409    return true;
     410  } else
     411                return false;
     412}
    356413
    357414/** Stores element list to file.
     
    374431    }
    375432    f.close();
    376   } else
    377     result = false;
    378   return result;
    379 };
     433    return true;
     434  } else
     435    return result;
     436};
  • src/periodentafel.hpp

    r5079a0 r4eb4fe  
    1313#include <iterator>
    1414
     15#include "unittests/periodentafelTest.hpp"
    1516#include "defs.hpp"
    1617#include "types.hpp"
     
    2728class periodentafel {
    2829  /******* Types *********/
     30  friend class periodentafelTest;
    2931  private:
    3032    typedef std::map<atomicNumber_t,element*> elementSet;
     
    4345  iterator AddElement(element * const pointer);
    4446  void RemoveElement(element * const pointer);
     47  void RemoveElement(atomicNumber_t);
    4548  void CleanupPeriodtable();
    46   const element *FindElement(atomicNumber_t) const;
    47   const element *FindElement(const char * const shorthand) const;
    48   const element *AskElement() const;
    49   const element *EnterElement();
     49  element * const FindElement(atomicNumber_t) const;
     50  element * const FindElement(const char * const shorthand) const;
     51  element * const AskElement() const;
     52  element * const EnterElement();
    5053
    5154  const_iterator begin();
     
    5962
    6063  private:
     64
     65  bool LoadElementsDatabase(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);
     70
    6171    elementSet elements;
    6272};
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    r5079a0 r4eb4fe  
    1717#include "AnalysisCorrelationToPointUnitTest.hpp"
    1818
    19 #include "World.hpp"
    2019#include "atom.hpp"
    21 #include "boundary.hpp"
    2220#include "element.hpp"
    2321#include "molecule.hpp"
    2422#include "linkedcell.hpp"
    2523#include "periodentafel.hpp"
    26 #include "tesselation.hpp"
    2724#include "World.hpp"
    2825
     
    4340  TestList = NULL;
    4441  TestMolecule = NULL;
    45   hydrogen = NULL;
    46   tafel = NULL;
    4742  pointmap = NULL;
    4843  binmap = NULL;
    4944  point = NULL;
    5045
    51   // construct element
    52   hydrogen = new element;
    53   hydrogen->Z = 1;
    54   strcpy(hydrogen->name, "hydrogen");
    55   strcpy(hydrogen->symbol, "H");
    56 
    57 
    58   // construct periodentafel
    59   tafel = World::getInstance().getPeriode();
    60   tafel->AddElement(hydrogen);
    61 
    6246  // construct molecule (tetraeder of hydrogens)
     47  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     48  CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
    6349  TestMolecule = World::getInstance().createMolecule();
    6450  Walker = World::getInstance().createAtom();
  • src/unittests/AnalysisCorrelationToPointUnitTest.hpp

    r5079a0 r4eb4fe  
    1212
    1313class element;
    14 class LinkedCell;
    1514class molecule;
    1615class MoleculeListClass;
    17 class periodentafel;
    18 class Tesselation;
    1916class Vector;
    2017
     
    4037      MoleculeListClass *TestList;
    4138      molecule *TestMolecule;
    42       element *hydrogen;
    43       periodentafel *tafel;
     39      const element *hydrogen;
    4440
    4541      CorrelationToPointMap *pointmap;
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    r5079a0 r4eb4fe  
    1717#include "AnalysisCorrelationToSurfaceUnitTest.hpp"
    1818
    19 #include "World.hpp"
    2019#include "atom.hpp"
    2120#include "boundary.hpp"
     
    4746  TestList = NULL;
    4847  TestSurfaceMolecule = NULL;
    49   hydrogen = NULL;
    50   tafel = NULL;
    5148  surfacemap = NULL;
    5249  binmap = NULL;
     
    5451  LC = NULL;
    5552
    56   // construct element
    57   hydrogen = new element;
    58   hydrogen->Z = 1;
    59   strcpy(hydrogen->name, "hydrogen");
    60   strcpy(hydrogen->symbol, "H");
    61   carbon = new element;
    62   carbon->Z = 6;
    63   strcpy(carbon->name, "carbon");
    64   strcpy(carbon->symbol, "C");
    65 
    66   // construct periodentafel
    67   tafel = World::getInstance().getPeriode();
    68   tafel->AddElement(hydrogen);
    69   tafel->AddElement(carbon);
    70 
    7153  // construct molecule (tetraeder of hydrogens) base
     54  hydrogen = World::getInstance().getPeriode()->FindElement(1);
    7255  TestSurfaceMolecule = World::getInstance().createMolecule();
    7356  Walker = World::getInstance().createAtom();
     
    10285
    10386  // add outer atoms
     87  carbon = World::getInstance().getPeriode()->FindElement(6);
    10488  TestSurfaceMolecule = World::getInstance().createMolecule();
    10589  Walker = World::getInstance().createAtom();
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp

    r5079a0 r4eb4fe  
    4545      MoleculeListClass *TestList;
    4646      molecule *TestSurfaceMolecule;
    47       element *hydrogen;
    48       element *carbon;
    49       periodentafel *tafel;
     47      const element *hydrogen;
     48      const element *carbon;
    5049
    5150      CorrelationToSurfaceMap *surfacemap;
  • src/unittests/AnalysisPairCorrelationUnitTest.cpp

    r5079a0 r4eb4fe  
    4444  TestList = NULL;
    4545  TestMolecule = NULL;
    46   hydrogen = NULL;
    47   tafel = NULL;
    4846  correlationmap = NULL;
    4947  binmap = NULL;
    5048
    51   // construct element
    52   hydrogen = new element;
    53   hydrogen->Z = 1;
    54   strcpy(hydrogen->name, "hydrogen");
    55   strcpy(hydrogen->symbol, "H");
    56 
    57   // construct periodentafel
    58   tafel = World::getInstance().getPeriode();
    59   tafel->AddElement(hydrogen);
    60 
    6149  // construct molecule (tetraeder of hydrogens)
     50  hydrogen = World::getInstance().getPeriode()->FindElement(1);
    6251  TestMolecule = World::getInstance().createMolecule();
    6352  Walker = World::getInstance().createAtom();
  • src/unittests/AnalysisPairCorrelationUnitTest.hpp

    r5079a0 r4eb4fe  
    1212
    1313class element;
    14 class LinkedCell;
    1514class molecule;
    1615class MoleculeListClass;
    17 class periodentafel;
    18 class Tesselation;
    1916class Vector;
    2017
     
    4037      MoleculeListClass *TestList;
    4138      molecule *TestMolecule;
    42       element *hydrogen;
    43       periodentafel *tafel;
     39      const element *hydrogen;
    4440
    4541      PairCorrelationMap *correlationmap;
  • src/unittests/CountBondsUnitTest.cpp

    r5079a0 r4eb4fe  
    1616#include <stdio.h>
    1717#include <cstring>
     18
     19#include "Helpers/Assert.hpp"
    1820
    1921#include "analysis_bonds.hpp"
     
    4042{
    4143  atom *Walker = NULL;
    42   BG = NULL;
    43   filename = NULL;
    44 
    45   // init private all pointers to zero
    46   molecules = NULL;
    47   TestMolecule1 = NULL;
    48   TestMolecule2 = NULL;
    49   hydrogen = NULL;
    50   oxygen = NULL;
    51   tafel = NULL;
    5244
    5345  // construct element
    54   hydrogen = new element;
    55   hydrogen->Z = 1;
    56   hydrogen->CovalentRadius = 0.23;
    57   strcpy(hydrogen->name, "hydrogen");
    58   strcpy(hydrogen->symbol, "H");
    59   oxygen = new element;
    60   oxygen->Z = 8;
    61   oxygen->CovalentRadius = 0.68;
    62   strcpy(oxygen->name, "oxygen");
    63   strcpy(oxygen->symbol, "O");
    64 
    65   // construct periodentafel
    66   tafel = World::getInstance().getPeriode();
    67   tafel->AddElement(hydrogen);
    68   tafel->AddElement(oxygen);
     46  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     47  oxygen = World::getInstance().getPeriode()->FindElement(8);
     48  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
     49  CPPUNIT_ASSERT(oxygen != NULL && "could not find element oxygen");
    6950
    7051  // construct molecule (water molecule)
    7152  TestMolecule1 = World::getInstance().createMolecule();
    72   Walker = World::getInstance().createAtom();
     53  CPPUNIT_ASSERT(TestMolecule1 != NULL && "could not create first molecule");
     54  Walker = World::getInstance().createAtom();
     55  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7356  Walker->type = hydrogen;
    7457  *Walker->node = Vector(-0.2418, 0.9350, 0. );
    7558  TestMolecule1->AddAtom(Walker);
    7659  Walker = World::getInstance().createAtom();
     60  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7761  Walker->type = hydrogen;
    7862  *Walker->node = Vector(0.9658, 0., 0. );
    7963  TestMolecule1->AddAtom(Walker);
    8064  Walker = World::getInstance().createAtom();
     65  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8166  Walker->type = oxygen;
    8267  *Walker->node = Vector(0., 0., 0. );
     
    8469
    8570  TestMolecule2 = World::getInstance().createMolecule();
    86   Walker = World::getInstance().createAtom();
     71  CPPUNIT_ASSERT(TestMolecule2 != NULL && "could not create second molecule");
     72  Walker = World::getInstance().createAtom();
     73  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8774  Walker->type = hydrogen;
    8875  *Walker->node = Vector(-0.2418, 0.9350, 0. );
    8976  TestMolecule2->AddAtom(Walker);
    9077  Walker = World::getInstance().createAtom();
     78  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    9179  Walker->type = hydrogen;
    9280  *Walker->node = Vector(0.9658, 0., 0. );
    9381  TestMolecule2->AddAtom(Walker);
    9482  Walker = World::getInstance().createAtom();
     83  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    9584  Walker->type = oxygen;
    9685  *Walker->node = Vector(0., 0., 0. );
     
    9887
    9988  molecules = World::getInstance().getMolecules();
     89  CPPUNIT_ASSERT(molecules != NULL && "could not obtain list of molecules");
    10090  molecules->insert(TestMolecule1);
    10191  molecules->insert(TestMolecule2);
     
    111101  // create a small file with table
    112102  BG = new BondGraph(true);
     103  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
    113104
    114105  // construct bond graphs
     
    158149{
    159150  double *mirror = new double[3];
     151  CPPUNIT_ASSERT(mirror != NULL && "could not create array of doubles");
    160152  for (int i=0;i<3;i++)
    161153    mirror[i] = -1.;
  • src/unittests/CountBondsUnitTest.hpp

    r5079a0 r4eb4fe  
    3939      molecule *TestMolecule1;
    4040      molecule *TestMolecule2;
    41       element *hydrogen;
    42       element *oxygen;
    43       periodentafel *tafel;
     41      const element *hydrogen;
     42      const element *oxygen;
    4443
    4544      BondGraph *BG;
  • src/unittests/LinkedCellUnitTest.cpp

    r5079a0 r4eb4fe  
    3838  atom *Walker = NULL;
    3939
    40   // init private all pointers to zero
    41   TestMolecule = NULL;
    42   hydrogen = NULL;
    43   tafel = NULL;
    44 
    4540  // construct element
    46   hydrogen = new element;
    47   hydrogen->Z = 1;
    48   hydrogen->CovalentRadius = 0.23;
    49   strcpy(hydrogen->name, "hydrogen");
    50   strcpy(hydrogen->symbol, "H");
    51 
    52   // construct periodentafel
    53   tafel = World::getInstance().getPeriode();
    54   tafel->AddElement(hydrogen);
     41  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     42  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
    5543
    5644  // construct molecule (water molecule)
    5745  TestMolecule = World::getInstance().createMolecule();
     46  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
    5847  for (double x=0.5;x<3;x+=1.)
    5948    for (double y=0.5;y<3;y+=1.)
    6049      for (double z=0.5;z<3;z+=1.) {
    6150        Walker = World::getInstance().createAtom();
     51        CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    6252        Walker->type = hydrogen;
    6353        *Walker->node = Vector(x, y, z );
     
    6757  // construct linked cell
    6858  LC = new LinkedCell (TestMolecule, 1.);
     59  CPPUNIT_ASSERT(LC != NULL && "could not create LinkedCell");
    6960
    7061  // check that TestMolecule was correctly constructed
  • src/unittests/LinkedCellUnitTest.hpp

    r5079a0 r4eb4fe  
    4848
    4949      molecule *TestMolecule;
    50       element *hydrogen;
    51       periodentafel *tafel;
     50      const element *hydrogen;
    5251      LinkedCell *LC;
    5352};
  • src/unittests/Makefile.am

    r5079a0 r4eb4fe  
    3333  MemoryAllocatorUnitTest \
    3434  MoleculeDescriptorTest \
    35   PlaneUnittest \
    3635  ObserverTest \
    3736  ParserUnitTest \
     37  periodentafelTest \
     38  PlaneUnittest \
    3839  SingletonTest \
    3940  StackClassUnitTest \
     
    7576  memoryusageobserverunittest.cpp \
    7677  MoleculeDescriptorTest.cpp \
    77   PlaneUnittest.cpp \
    7878  ObserverTest.cpp \
    7979  ParserUnitTest.cpp \
     80  periodentafelTest.cpp \
     81  PlaneUnittest.cpp \
    8082  SingletonTest.cpp \
    8183  stackclassunittest.cpp \
     
    109111  memoryusageobserverunittest.hpp \
    110112  MoleculeDescriptorTest.hpp \
     113  periodentafelTest.hpp \
    111114  PlaneUnittest.hpp \
    112115  ObserverTest.hpp \
     
    194197ParserUnitTest_LDADD = ${ALLLIBS}
    195198
     199periodentafelTest_SOURCES = UnitTestMain.cpp periodentafelTest.cpp periodentafelTest.hpp
     200periodentafelTest_LDADD = ${ALLLIBS}
     201
    196202PlaneUnittest_SOURCES = UnitTestMain.cpp PlaneUnittest.cpp PlaneUnittest.hpp
    197203PlaneUnittest_LDADD = ${ALLLIBS}
  • src/unittests/ParserUnitTest.cpp

    r5079a0 r4eb4fe  
    3131
    3232void ParserUnitTest::setUp() {
    33   element* oxygen = new element();
    34   oxygen->symbol[0] = 'O';
    35   oxygen->Z = 8;
    36   World::getInstance().getPeriode()->AddElement(oxygen);
    37 
    38   element* hydrogen = new element();
    39   hydrogen->symbol[0] = 'H';
    40   hydrogen->Z = 1;
    41   World::getInstance().getPeriode()->AddElement(hydrogen);
     33  World::getInstance();
    4234}
    4335
  • src/unittests/analysisbondsunittest.cpp

    r5079a0 r4eb4fe  
    4040  atom *Walker = NULL;
    4141
    42   // init private all pointers to zero
    43   TestMolecule = NULL;
    44   hydrogen = NULL;
    45   tafel = NULL;
    46 
    47   // construct element
    48   hydrogen = new element;
    49   hydrogen->Z = 1;
    50   hydrogen->Valence = 1;
    51   hydrogen->NoValenceOrbitals = 1;
    52   strcpy(hydrogen->name, "hydrogen");
    53   strcpy(hydrogen->symbol, "H");
    54   carbon = new element;
    55   carbon->Z = 2;
    56   carbon->Valence = 4;
    57   carbon->NoValenceOrbitals = 4;
    58   strcpy(carbon->name, "carbon");
    59   strcpy(carbon->symbol, "C");
    60 
    61 
    62   // construct periodentafel
    63   tafel = World::getInstance().getPeriode();
    64   tafel->AddElement(hydrogen);
    65   tafel->AddElement(carbon);
     42  // get elements
     43  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     44  carbon = World::getInstance().getPeriode()->FindElement(6);
     45  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
     46  CPPUNIT_ASSERT(carbon != NULL && "could not find element carbon");
    6647
    6748  // construct molecule (tetraeder of hydrogens)
    6849  TestMolecule = World::getInstance().createMolecule();
     50  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
    6951  Walker = World::getInstance().createAtom();
     52  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7053  Walker->type = hydrogen;
    7154  *Walker->node = Vector(1.5, 0., 1.5 );
    7255  TestMolecule->AddAtom(Walker);
    7356  Walker = World::getInstance().createAtom();
     57  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7458  Walker->type = hydrogen;
    7559  *Walker->node = Vector(0., 1.5, 1.5 );
    7660  TestMolecule->AddAtom(Walker);
    7761  Walker = World::getInstance().createAtom();
     62  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7863  Walker->type = hydrogen;
    7964  *Walker->node = Vector(1.5, 1.5, 0. );
    8065  TestMolecule->AddAtom(Walker);
    8166  Walker = World::getInstance().createAtom();
     67  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8268  Walker->type = hydrogen;
    8369  *Walker->node = Vector(0., 0., 0. );
    8470  TestMolecule->AddAtom(Walker);
    8571  Walker = World::getInstance().createAtom();
     72  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8673  Walker->type = carbon;
    8774  *Walker->node = Vector(0.5, 0.5, 0.5 );
     
    9380  // create a small file with table
    9481  filename = new string("test.dat");
     82  CPPUNIT_ASSERT(filename != NULL && "could not create string");
    9583  ofstream test(filename->c_str());
    96   test << ".\tH\tC\n";
    97   test << "H\t1.\t1.2\n";
    98   test << "C\t1.2\t1.5\n";
     84  test << ".\tH\tHe\tLi\tBe\tB\tC\n";
     85  test << "H\t1.\t1.\t1.\t1.\t1.\t1.2\n";
     86  test << "He\t1.\t1.\t1.\t1.\t1.\t1.\n";
     87  test << "Li\t1.\t1.\t1.\t1.\t1.\t1.\n";
     88  test << "Be\t1.\t1.\t1.\t1.\t1.\t1.\n";
     89  test << "B\t1.\t1.\t1.\t1.\t1.\t1.\n";
     90  test << "C\t1.2\t1.\t1.\t1.\t1.\t1.5\n";
    9991  test.close();
    10092  BG = new BondGraph(true);
     93  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
    10194
    10295  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
    10396  CPPUNIT_ASSERT_EQUAL( 1., BG->GetBondLength(0,0) );
    104   CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,1) );
    105   CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(1,1) );
     97  CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,5) );
     98  CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(5,5) );
    10699
    107100  BG->ConstructBondGraph(TestMolecule);
  • src/unittests/analysisbondsunittest.hpp

    r5079a0 r4eb4fe  
    3434
    3535      molecule *TestMolecule;
    36       element *hydrogen;
    37       element *carbon;
    38       periodentafel *tafel;
     36      const element *hydrogen;
     37      const element *carbon;
    3938
    4039      BondGraph *BG;
  • src/unittests/bondgraphunittest.cpp

    r5079a0 r4eb4fe  
    1515#include <stdio.h>
    1616#include <cstring>
     17
     18#include "Helpers/Assert.hpp"
    1719
    1820#include "World.hpp"
     
    4143  atom *Walker = NULL;
    4244
    43   // init private all pointers to zero
    44   TestMolecule = NULL;
    45   hydrogen = NULL;
    46   tafel = NULL;
    47 
    4845  // construct element
    49   hydrogen = new element;
    50   hydrogen->Z = 1;
    51   hydrogen->CovalentRadius = 0.23;
    52   hydrogen->VanDerWaalsRadius = 1.09;
    53   strcpy(hydrogen->name, "hydrogen");
    54   strcpy(hydrogen->symbol, "H");
    55   carbon = new element;
    56   carbon->Z = 2;
    57   carbon->CovalentRadius = 0.68;
    58   carbon->VanDerWaalsRadius = 1.7;
    59   strcpy(carbon->name, "carbon");
    60   strcpy(carbon->symbol, "C");
    61 
    62 
    63   // construct periodentafel
    64   tafel = World::getInstance().getPeriode();
    65   tafel->AddElement(hydrogen);
    66   tafel->AddElement(carbon);
     46  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     47  carbon = World::getInstance().getPeriode()->FindElement(6);
     48  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
     49  CPPUNIT_ASSERT(carbon != NULL && "could not find element carbon");
    6750
    6851  // construct molecule (tetraeder of hydrogens)
    6952  TestMolecule = World::getInstance().createMolecule();
     53  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
    7054  Walker = World::getInstance().createAtom();
     55  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7156  Walker->type = carbon;
    7257  *Walker->node = Vector(1., 0., 1. );
     
    7459
    7560  Walker = World::getInstance().createAtom();
     61  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7662  Walker->type = carbon;
    7763  *Walker->node = Vector(0., 1., 1. );
     
    7965
    8066  Walker = World::getInstance().createAtom();
     67  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8168  Walker->type = carbon;
    8269  *Walker->node = Vector(1., 1., 0. );
     
    8471
    8572  Walker = World::getInstance().createAtom();
     73  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8674  Walker->type = carbon;
    8775  *Walker->node = Vector(0., 0., 0. );
     
    9381  // create a small file with table
    9482  dummyname = new string("dummy.dat");
     83  CPPUNIT_ASSERT(dummyname != NULL && "could not create string");
    9584  filename = new string("test.dat");
     85  CPPUNIT_ASSERT(filename != NULL && "could not create string");
    9686  ofstream test(filename->c_str());
    97   test << ".\tH\tC\n";
    98   test << "H\t1.\t1.2\n";
    99   test << "C\t1.2\t1.5\n";
     87  test << ".\tH\tHe\tLi\tBe\tB\tC\n";
     88  test << "H\t1.\t1.\t1.\t1.\t1.\t1.2\n";
     89  test << "He\t1.\t1.\t1.\t1.\t1.\t1.\n";
     90  test << "Li\t1.\t1.\t1.\t1.\t1.\t1.\n";
     91  test << "Be\t1.\t1.\t1.\t1.\t1.\t1.\n";
     92  test << "B\t1.\t1.\t1.\t1.\t1.\t1.\n";
     93  test << "C\t1.2\t1.\t1.\t1.\t1.\t1.5\n";
    10094  test.close();
    10195  BG = new BondGraph(true);
     96  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
    10297};
    10398
     
    126121  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
    127122  CPPUNIT_ASSERT_EQUAL( 1., BG->GetBondLength(0,0) );
    128   CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,1) );
    129   CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(1,1) );
     123  CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,5) );
     124  CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(5,5) );
    130125};
    131126
  • src/unittests/bondgraphunittest.hpp

    r5079a0 r4eb4fe  
    3737
    3838      molecule *TestMolecule;
    39       element *hydrogen;
    40       element *carbon;
    41       periodentafel *tafel;
     39      const element *hydrogen;
     40      const element *carbon;
    4241
    4342      BondGraph *BG;
  • src/unittests/listofbondsunittest.cpp

    r5079a0 r4eb4fe  
    3838  atom *Walker = NULL;
    3939
    40   // init private all pointers to zero
    41   TestMolecule = NULL;
    42   hydrogen = NULL;
    43   tafel = NULL;
    44 
    4540  // construct element
    46   hydrogen = new element;
    47   hydrogen->Z = 1;
    48   strcpy(hydrogen->name, "hydrogen");
    49   strcpy(hydrogen->symbol, "H");
    50 
    51 
    52   // construct periodentafel
    53   tafel = World::getInstance().getPeriode();
    54   tafel->AddElement(hydrogen);
     41  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     42  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
    5543
    5644  // construct molecule (tetraeder of hydrogens)
    5745  TestMolecule = World::getInstance().createMolecule();
    58   Walker = World::getInstance().createAtom();
     46  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
     47  Walker = World::getInstance().createAtom();
     48  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    5949  Walker->type = hydrogen;
    6050  *Walker->node = Vector(1., 0., 1. );
    6151  TestMolecule->AddAtom(Walker);
    6252  Walker = World::getInstance().createAtom();
     53  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    6354  Walker->type = hydrogen;
    6455  *Walker->node = Vector(0., 1., 1. );
    6556  TestMolecule->AddAtom(Walker);
    6657  Walker = World::getInstance().createAtom();
     58  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    6759  Walker->type = hydrogen;
    6860  *Walker->node = Vector(1., 1., 0. );
    6961  TestMolecule->AddAtom(Walker);
    7062  Walker = World::getInstance().createAtom();
     63  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7164  Walker->type = hydrogen;
    7265  *Walker->node = Vector(0., 0., 0. );
     
    7568  // check that TestMolecule was correctly constructed
    7669  CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    77 
    7870};
    7971
  • src/unittests/listofbondsunittest.hpp

    r5079a0 r4eb4fe  
    4141
    4242      molecule *TestMolecule;
    43       element *hydrogen;
    44       periodentafel *tafel;
     43      const element *hydrogen;
    4544};
    4645
  • tests/testsuite.at

    r5079a0 r4eb4fe  
    1717AT_CHECK([../../molecuilder -e], 134, [ignore], [stderr])
    1818AT_CHECK([fgrep "Not enough or invalid arguments" stderr], 0, [ignore], [ignore])
    19 AT_CHECK([../../molecuilder test.conf], 0, [stdout], [stderr])
    20 AT_CHECK([fgrep "Element list loading failed" stdout], 0, [ignore], [ignore])
    2119AT_CLEANUP
    2220
Note: See TracChangeset for help on using the changeset viewer.