Changes in / [c39cc4:bdb143]


Ignore:
Files:
255 added
51 deleted
167 edited

Legend:

Unmodified
Added
Removed
  • configure.ac

    rc39cc4 rbdb143  
    2727
    2828# Boost libraries
    29 AX_BOOST_BASE([1.33.1])
    30 #AX_BOOST_PROGRAM_OPTIONS
     29AX_BOOST_BASE([1.40])
     30AX_BOOST_PROGRAM_OPTIONS
    3131#AX_BOOST_FOREACH
    3232#AX_BOOST_FILESYSTEM
    3333AX_BOOST_THREAD
    34 #AX_BOOST_PROGRAM_OPTIONS
    3534#AX_BOOST_SERIALIZATION
     35
     36#QT4 libraries
     37gw_CHECK_QT4
     38AX_CHECK_GLU
     39AC_MSG_NOTICE(["GLU_CFLAGS: $GLU_CFLAGS, GLU_CXXFLAGS: $GLU_CXXFLAGS, GLU_LDFLAGS: $GLU_LDFLAGS, GLU_LIBS: $GLU_LIBS"])
     40
    3641
    3742# Checks for header files.
     
    9398
    9499# test suite
    95 AC_CONFIG_TESTDIR(tests)
    96 AC_CONFIG_FILES([tests/atlocal tests/Makefile])
    97 AC_CONFIG_FILES([tests/Tesselations/Makefile tests/Tesselations/defs])
    98 AC_CONFIG_FILES([tests/molecuilder], [chmod +x tests/molecuilder])
    99 AC_CONFIG_FILES([doc/molecuilder.xml])
    100 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile src/unittests/Makefile])
     100AC_CONFIG_TESTDIR(tests/regression)
     101AC_CONFIG_FILES([
     102        tests/Makefile
     103        tests/regression/atlocal
     104        tests/regression/Makefile])
     105AC_CONFIG_FILES([tests/regression/molecuilder], [chmod +x tests/regression/molecuilder])
     106AC_CONFIG_FILES([
     107        tests/Tesselations/Makefile
     108        tests/Tesselations/defs])
     109AC_CONFIG_FILES([
     110        doc/molecuilder.xml])
     111AC_CONFIG_FILES([
     112        Makefile
     113        doc/Makefile
     114        src/Makefile
     115        src/Actions/Makefile
     116        src/UIElements/Makefile
     117        src/unittests/Makefile])
    101118AC_OUTPUT
  • doc/Doxyfile

    rc39cc4 rbdb143  
    258258# Configuration::additions related to the search engine   
    259259#---------------------------------------------------------------------------
    260 SEARCHENGINE           = NO
     260SEARCHENGINE           = YES
  • doc/class structure.uxf

    rc39cc4 rbdb143  
    2121
    2222
    23 // This text will be stored with each diagram;  use it for notes.</help_text><zoom_level>7</zoom_level><element><type>com.umlet.element.base.Class</type><coordinates><x>1855</x><y>294</y><w>147</w><h>70</h></coordinates><panel_attributes>AtomInfo
     23// This text will be stored with each diagram;  use it for notes.</help_text><zoom_level>7</zoom_level><element><type>com.umlet.element.base.Class</type><coordinates><x>1855</x><y>210</y><w>147</w><h>70</h></coordinates><panel_attributes>AtomInfo
    2424--
    2525-x,v,F: Vector
     
    2828#AtomInfo();
    2929#~AtomInfo();
    30 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1645</x><y>315</y><w>223</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>210;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1274</x><y>147</y><w>392</w><h>259</h></coordinates><panel_attributes>Element
     30</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1645</x><y>231</y><w>223</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>210;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1274</x><y>63</y><w>392</w><h>259</h></coordinates><panel_attributes>Element
    3131--
    3232mass: double
     
    4949#~element();
    5050#Output(ofstream * const out) const: bool
    51 #Checkout(ofstream * const out, const int No, const int NoOfAtoms) const: bool</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1960</x><y>532</y><w>280</w><h>161</h></coordinates><panel_attributes>BondedParticle
     51#Checkout(ofstream * const out, const int No, const int NoOfAtoms) const: bool</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1960</x><y>448</y><w>280</w><h>161</h></coordinates><panel_attributes>BondedParticle
    5252--
    5353--
     
    6363#OutputBondOfAtom() const
    6464#OutputAdjacency(ofstream *AdjacencyFile) const
    65 #OutputOrder(ofstream *file) const</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2184</x><y>343</y><w>258</w><h>202</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>245;21;245;154;21;154;21;189</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1925</x><y>343</y><w>293</w><h>202</h></coordinates><panel_attributes>lt=&lt;&lt;-
    66 </panel_attributes><additional_attributes>21;21;21;154;280;154;280;189</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2184</x><y>343</y><w>34</w><h>202</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;189</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2359</x><y>294</y><w>147</w><h>70</h></coordinates><panel_attributes>BondedParticleInfo
     65#OutputOrder(ofstream *file) const</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2184</x><y>259</y><w>258</w><h>202</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>245;21;245;154;21;154;21;189</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1925</x><y>259</y><w>293</w><h>202</h></coordinates><panel_attributes>lt=&lt;&lt;-
     66</panel_attributes><additional_attributes>21;21;21;154;280;154;280;189</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2184</x><y>259</y><w>34</w><h>202</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;189</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2359</x><y>210</y><w>147</w><h>70</h></coordinates><panel_attributes>BondedParticleInfo
    6767--
    6868AdaptiveOrder: unsigned char
     
    7171#BondedParticleInfo()
    7272#~BondedParticleInfo()
    73 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2079</x><y>280</y><w>217</w><h>84</h></coordinates><panel_attributes>ParticleInfo
     73</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2079</x><y>196</y><w>217</w><h>84</h></coordinates><panel_attributes>ParticleInfo
    7474--
    7575nr: int
     
    7979#~ParticleInfo()
    8080#ostream &amp; operator &lt;&lt; (ostream &amp;ost) const
    81 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2485</x><y>315</y><w>174</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;161;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2646</x><y>245</y><w>147</w><h>133</h></coordinates><panel_attributes>BondList
     81</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2485</x><y>231</y><w>174</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;161;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2646</x><y>161</y><w>147</w><h>133</h></coordinates><panel_attributes>BondList
    8282{Some Properties}
    8383--
     
    9090Responsibilities
    9191-- Resp1
    92 *-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1372</x><y>427</y><w>147</w><h>105</h></coordinates><panel_attributes>GraphNodeInfo
     92*-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1372</x><y>343</y><w>147</w><h>105</h></coordinates><panel_attributes>GraphNodeInfo
    9393--
    9494--
     
    102102#GraphNodeInfo()
    103103#~GraphNodeInfo()
    104 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1484</x><y>609</y><w>126</w><h>70</h></coordinates><panel_attributes>GraphNode
     104</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1484</x><y>525</y><w>126</w><h>70</h></coordinates><panel_attributes>GraphNode
    105105--
    106106--
     
    109109#OutputGraphInfo() const
    110110#OutputComponentNumber() const
    111 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1484</x><y>343</y><w>748</w><h>279</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>735;21;735;70;217;70;217;210;21;210;21;266</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1484</x><y>511</y><w>34</w><h>111</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;98</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1288</x><y>756</y><w>588</w><h>245</h></coordinates><panel_attributes>Atom
     111</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1484</x><y>259</y><w>748</w><h>279</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>735;21;735;70;217;70;217;210;21;210;21;266</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1484</x><y>427</y><w>34</w><h>111</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;98</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1288</x><y>672</y><w>588</w><h>245</h></coordinates><panel_attributes>Atom
    112112--
    113113sort: int*
     
    129129#DistanceToVector(const Vector &amp;origin) const: double
    130130#DistanceSquaredToVector(const Vector &amp;origin) const: double
    131 #IsInParallelepiped(const Vector offset, const double *parallelepiped) const: bool</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1379</x><y>511</y><w>83</w><h>258</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;182;70;182;70;245</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2226</x><y>749</y><w>504</w><h>210</h></coordinates><panel_attributes>TrajectoryParticle
     131#IsInParallelepiped(const Vector offset, const double *parallelepiped) const: bool</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1379</x><y>427</y><w>83</w><h>258</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;182;70;182;70;245</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2226</x><y>665</y><w>504</w><h>210</h></coordinates><panel_attributes>TrajectoryParticle
    132132--
    133133--
     
    147147#Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration)
    148148#Thermostat_NoseHoover_init(int Step, double *delta_alpha)
    149 #Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration)</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2149</x><y>343</y><w>209</w><h>419</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;112;196;112;196;406</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1967</x><y>343</y><w>391</w><h>419</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;112;378;112;378;406</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1617</x><y>574</y><w>203</w><h>70</h></coordinates><panel_attributes>TrajectoryParticleInfo
     149#Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration)</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2149</x><y>259</y><w>209</w><h>419</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;112;196;112;196;406</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1967</x><y>259</y><w>391</w><h>419</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;112;378;112;378;406</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1617</x><y>490</y><w>203</w><h>70</h></coordinates><panel_attributes>TrajectoryParticleInfo
    150150--
    151151Trajectory: struct {vector&lt;Vector&gt; R,U,V}
     
    153153--
    154154#TrajectoryParticleInfo()
    155 #~TrajectoryParticleInfo()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1757</x><y>623</y><w>601</w><h>139</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;105;588;105;588;126</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>623</y><w>34</w><h>146</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;133</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1519</x><y>658</y><w>244</w><h>111</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;56;231;56;231;98</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1736</x><y>448</y><w>147</w><h>112</h></coordinates><panel_attributes>TesselPoint
     155#~TrajectoryParticleInfo()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1757</x><y>539</y><w>601</w><h>139</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;105;588;105;588;126</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>539</y><w>34</w><h>146</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;133</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1519</x><y>574</y><w>244</w><h>111</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;56;231;56;231;98</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1736</x><y>364</y><w>147</w><h>112</h></coordinates><panel_attributes>TesselPoint
    156156--
    157157-id: Long
     
    163163Responsibilities
    164164-- Resp1
    165 *-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>539</y><w>146</w><h>230</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>133;21;133;175;21;175;21;217</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>672</y><w>398</w><h>97</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>385;21;385;42;21;42;21;84</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>343</y><w>398</w><h>426</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>385;21;385;168;196;168;196;371;21;371;21;413</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>343</y><w>209</w><h>426</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>196;21;196;371;21;371;21;413</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>833</x><y>854</y><w>357</w><h>224</h></coordinates><panel_attributes>Bond
     165*-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>455</y><w>146</w><h>230</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>133;21;133;175;21;175;21;217</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>588</y><w>398</w><h>97</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>385;21;385;42;21;42;21;84</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>259</y><w>398</w><h>426</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>385;21;385;168;196;168;196;371;21;371;21;413</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>259</y><w>209</w><h>426</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>196;21;196;371;21;371;21;413</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>833</x><y>770</y><w>357</w><h>224</h></coordinates><panel_attributes>Bond
    166166--
    167167HydrogenBond: int
     
    182182#bond()
    183183#bond(atom *left, atom *right, const int degree=1, const int number=0)
    184 #~bond()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1834</x><y>707</y><w>107</w><h>125</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
    185 3</panel_attributes><additional_attributes>42;112;91;112;91;35;21;35;21;49</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1169</x><y>896</y><w>132</w><h>49</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
    186 2</panel_attributes><additional_attributes>21;35;119;35</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>770</x><y>742</y><w>111</w><h>167</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
    187 2</panel_attributes><additional_attributes>63;154;28;154;28;35;98;35;98;112</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1113</x><y>1330</y><w>504</w><h>168</h></coordinates><panel_attributes>BondGraph
     184#~bond()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1834</x><y>623</y><w>107</w><h>125</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
     1853</panel_attributes><additional_attributes>42;112;91;112;91;35;21;35;21;49</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1169</x><y>812</y><w>132</w><h>49</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
     1862</panel_attributes><additional_attributes>21;35;119;35</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>770</x><y>658</y><w>111</w><h>167</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
     1872</panel_attributes><additional_attributes>63;154;28;154;28;35;98;35;98;112</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1113</x><y>1246</y><w>504</w><h>168</h></coordinates><panel_attributes>BondGraph
    188188--
    189189max_distance: double
     
    199199                                                        double &amp;MinDistance, double &amp;MaxDistance, bool IsAngstroem)
    200200#CovalentMinMaxDistance(BondedParticle * const Walker, BondedParticle * const OtherWalker,
    201                                           double &amp;MinDistance, double &amp;MaxDistance, bool IsAngstroem)</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1596</x><y>1407</y><w>167</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;154;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1750</x><y>1365</y><w>147</w><h>133</h></coordinates><panel_attributes>MatrixContainer
     201                                          double &amp;MinDistance, double &amp;MaxDistance, bool IsAngstroem)</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1596</x><y>1323</y><w>167</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;154;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1750</x><y>1281</y><w>147</w><h>133</h></coordinates><panel_attributes>MatrixContainer
    202202--
    203203-id: Long
     
    209209Responsibilities
    210210-- Resp1
    211 *-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>0</x><y>539</y><w>511</w><h>1050</h></coordinates><panel_attributes>config
     211*-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>0</x><y>455</y><w>511</w><h>1050</h></coordinates><panel_attributes>config
    212212--
    213213PsiType: int
     
    297297#SetDefaultPath(const char * const path);
    298298#InitThermostats();
    299 #ParseThermostats(class ConfigFileBuffer * const fb);</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>490</x><y>1428</y><w>636</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;623;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1596</x><y>84</y><w>121</w><h>139</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
    300 2</panel_attributes><additional_attributes>70;126;105;126;105;35;21;35;21;63</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2520</x><y>980</y><w>224</w><h>140</h></coordinates><panel_attributes>&lt;&lt;Singleton&gt;&gt;
     299#ParseThermostats(class ConfigFileBuffer * const fb);</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>490</x><y>1344</y><w>636</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;623;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1596</x><y>0</y><w>121</w><h>139</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
     3002</panel_attributes><additional_attributes>70;126;105;126;105;35;21;35;21;63</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2520</x><y>896</y><w>224</w><h>140</h></coordinates><panel_attributes>&lt;&lt;Singleton&gt;&gt;
    301301errorLogger
    302302--
     
    310310#static setVerbosity(int verbosityLevel);
    311311#protected errorLogger()
    312 #protected ~errorLogger()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2093</x><y>1064</y><w>364</w><h>35</h></coordinates><panel_attributes>KeyCompare
     312#protected ~errorLogger()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2093</x><y>980</y><w>364</w><h>35</h></coordinates><panel_attributes>KeyCompare
    313313--
    314314--
    315315#operator() (const KeySet SubgraphA, const KeySet SubgraphB) const: bool
    316 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1169</x><y>1218</y><w>147</w><h>105</h></coordinates><panel_attributes>UniqueFragments
     316</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1169</x><y>1134</y><w>147</w><h>105</h></coordinates><panel_attributes>UniqueFragments
    317317--
    318318ANOVAOrder: int
     
    322322ShortestPathList: int *
    323323UsedList: bool **
    324 BondsPerSPCount: int *</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>490</x><y>1253</y><w>692</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>679;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1120</x><y>980</y><w>251</w><h>307</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>49;294;21;294;21;224;238;224;238;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>840</x><y>1127</y><w>245</w><h>28</h></coordinates><panel_attributes>Graph
     324BondsPerSPCount: int *</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>490</x><y>1169</y><w>692</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>679;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1120</x><y>896</y><w>251</w><h>307</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>49;294;21;294;21;224;238;224;238;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>840</x><y>1043</y><w>245</w><h>28</h></coordinates><panel_attributes>Graph
    325325{map &lt;KeySet, NumberValuePair, KeyCompare&gt;}
    326 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>861</x><y>1134</y><w>321</w><h>153</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>308;140;21;140;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>945</x><y>1190</y><w>56</w><h>28</h></coordinates><panel_attributes>KeySet
    327 {set&lt;int&gt;}</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>945</x><y>1197</y><w>237</w><h>90</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>224;77;21;77;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1085</x><y>1057</y><w>99</w><h>230</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
    328 0...N X 0...N</panel_attributes><additional_attributes>84;217;56;217;56;112;21;112;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1736</x><y>2282</y><w>147</w><h>42</h></coordinates><panel_attributes>LSQ_params
     326</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>861</x><y>1050</y><w>321</w><h>153</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>308;140;21;140;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>945</x><y>1106</y><w>56</w><h>28</h></coordinates><panel_attributes>KeySet
     327{set&lt;int&gt;}</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>945</x><y>1113</y><w>237</w><h>90</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>224;77;21;77;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1085</x><y>973</y><w>99</w><h>230</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
     3280...N X 0...N</panel_attributes><additional_attributes>84;217;56;217;56;112;21;112;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1736</x><y>2198</y><w>147</w><h>42</h></coordinates><panel_attributes>LSQ_params
    329329--
    330330vectors: const Vector **
    331331num: int
    332 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1043</x><y>266</y><w>147</w><h>35</h></coordinates><panel_attributes>lsq_params
    333 --
    334 x: gsl_vector *</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1169</x><y>266</y><w>118</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;105;21</additional_attributes></element></umlet_diagram>
     332</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1043</x><y>182</y><w>147</w><h>35</h></coordinates><panel_attributes>lsq_params
     333--
     334x: gsl_vector *</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1169</x><y>182</y><w>118</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;105;21</additional_attributes></element></umlet_diagram>
  • src/Actions/Action.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <string>
     
    1517using namespace std;
    1618
     19Action::state_ptr getEmptyState() {
     20  return Action::state_ptr(Memory::ignore(new ActionState()));
     21}
     22
    1723// An empty state to indicate success
    18 Action::state_ptr Action::success = Action::state_ptr(Memory::ignore(new ActionState()));
    19 Action::state_ptr Action::failure = Action::state_ptr(Memory::ignore(new ActionState()));
     24Action::state_ptr Action::success = getEmptyState();
     25Action::state_ptr Action::failure = getEmptyState();
    2026
    2127Action::Action(std::string _name,bool _doRegister) :
  • src/Actions/ActionHistory.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "ActionHistory.hpp"
  • src/Actions/ActionRegistry.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "Actions/ActionRegistry.hpp"
     
    1719using namespace std;
    1820
     21/** Constructor for class ActionRegistry.
     22 */
    1923ActionRegistry::ActionRegistry()
    2024{
    2125}
    2226
     27/** Destructor for class ActionRegistry.
     28 */
    2329ActionRegistry::~ActionRegistry()
    2430{
     
    3036}
    3137
     38/** Returns pointer to an action named by \a name.
     39 * \param name name of action
     40 * \return pointer to Action
     41 */
    3242Action* ActionRegistry::getActionByName(const std::string name){
    3343  map<const string,Action*>::iterator iter;
     
    3747}
    3848
     49/** States whether action is present or not.
     50 * \note This iss needed as ActionRegistry::getActionByName() ASSERT()s that action is in map.
     51 * \param name name of action
     52 * \return true - Action present, false - Action absent
     53 */
     54bool ActionRegistry::isActionByNamePresent(const std::string name){
     55  map<const string,Action*>::iterator iter;
     56  iter = actionMap.find(name);
     57  return iter!=actionMap.end();
     58}
     59
     60/** Registers an Action with the ActionRegistry.
     61 * \param *action pointer to Action.
     62 */
    3963void ActionRegistry::registerAction(Action* action){
    4064  pair<map<const string,Action*>::iterator,bool> ret;
     65  //cout << "Trying to register action with name " << action->getName() << "." << endl;
    4166  ret = actionMap.insert(pair<const string,Action*>(action->getName(),action));
    4267  ASSERT(ret.second,"Two actions with the same name added to registry");
    4368}
    4469
     70/** Unregisters an Action.
     71 * \param *action pointer to Action.
     72 */
     73void ActionRegistry::unregisterAction(Action* action){
     74  //cout << "Unregistering action with name " << action->getName() << "." << endl;
     75  actionMap.erase(action->getName());
     76}
     77
     78/** Returns an iterator pointing to the start of the map of Action's.
     79 * \return begin iterator
     80 */
     81std::map<const std::string,Action*>::iterator ActionRegistry::getBeginIter()
     82{
     83  return actionMap.begin();
     84}
     85
     86/** Returns an iterator pointing to the end of the map of Action's.
     87 * \return end iterator
     88 */
     89std::map<const std::string,Action*>::iterator ActionRegistry::getEndIter()
     90{
     91  return actionMap.end();
     92}
     93
     94/** Returns a const iterator pointing to the start of the map of Action's.
     95 * \return constant begin iterator
     96 */
     97std::map<const std::string,Action*>::const_iterator ActionRegistry::getBeginIter() const
     98{
     99  return actionMap.begin();
     100}
     101
     102/** Returns a const iterator pointing to the end of the map of Action's.
     103 * \return constant end iterator
     104 */
     105std::map<const std::string,Action*>::const_iterator ActionRegistry::getEndIter() const
     106{
     107  return actionMap.end();
     108}
     109
     110/** Prints the contents of the ActionRegistry \a &m to \a &ost.
     111 * \param &ost output stream
     112 * \param &m reference to ActionRegistry
     113 * \return reference to the above out stream for concatenation
     114 */
     115ostream& operator<<(ostream& ost, const ActionRegistry& m)
     116{
     117  ost << "ActionRegistry contains:" << endl;
     118  for (std::map<const std::string,Action*>::const_iterator iter = m.getBeginIter(); iter != m.getEndIter(); ++iter) {
     119    ost << "\t" << iter->first << " with pointer " << iter->second << endl;
     120  }
     121  return ost;
     122};
     123
     124
     125
    45126CONSTRUCT_SINGLETON(ActionRegistry)
  • src/Actions/ActionRegistry.hpp

    rc39cc4 rbdb143  
    99#define ACTIONREGISTRY_HPP_
    1010
     11#include <iostream>
    1112#include <string>
    1213#include <map>
     
    2122public:
    2223  Action* getActionByName(const std::string);
     24  bool isActionByNamePresent(const std::string name);
    2325  void registerAction(Action*);
     26  void unregisterAction(Action*);
     27
     28  std::map<const std::string,Action*>::iterator getBeginIter();
     29  std::map<const std::string,Action*>::const_iterator getBeginIter() const;
     30  std::map<const std::string,Action*>::iterator getEndIter();
     31  std::map<const std::string,Action*>::const_iterator getEndIter() const;
    2432
    2533private:
     
    3139};
    3240
     41std::ostream& operator<<(std::ostream& ost, const ActionRegistry& m);
     42
    3343#endif /* ACTIONREGISTRY_HPP_ */
  • src/Actions/ActionSequence.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "Actions/ActionSequence.hpp"
  • src/Actions/ErrorAction.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <iostream>
  • src/Actions/MakroAction.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <string>
  • src/Actions/ManipulateAtomsProcess.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "ManipulateAtomsProcess.hpp"
  • src/Actions/MethodAction.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <iostream>
  • src/Actions/Process.cpp

    rc39cc4 rbdb143  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include "Process.hpp"
    911
     
    1214Process::Process(int _maxSteps, std::string _name, bool _doRegister) :
    1315  Action(_name,_doRegister),
     16  Observable("Process"),
    1417  maxSteps(_maxSteps),
    1518  active(false),
     
    3841
    3942int Process::getCurrStep(){
    40   OBSERVE;
    4143  return currStep;
    4244}
    4345
    4446void Process::setCurrStep(int _currStep){
     47  OBSERVE;
    4548  currStep = _currStep;
    4649}
     
    5255    return 0;
    5356}
    54 
    5557int Process::getMaxSteps(){
    5658  return maxSteps;
  • src/Descriptors/AtomDescriptor.cpp

    rc39cc4 rbdb143  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include "Descriptors/AtomDescriptor.hpp"
    911#include "Descriptors/AtomDescriptor_impl.hpp"
    1012
    1113#include "World.hpp"
    12 
    1314#include "atom.hpp"
    1415
    1516#include <boost/bind.hpp>
    16 #include <cassert>
     17
    1718#include <iostream>
    1819
  • src/Descriptors/AtomIdDescriptor.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "AtomIdDescriptor.hpp"
  • src/Descriptors/AtomTypeDescriptor.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "Descriptors/AtomTypeDescriptor.hpp"
  • src/Descriptors/MoleculeDescriptor.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "Descriptors/MoleculeDescriptor.hpp"
     
    1416
    1517#include <boost/bind.hpp>
    16 #include <cassert>
    1718#include <iostream>
    1819
  • src/Descriptors/MoleculeIdDescriptor.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "MoleculeIdDescriptor.hpp"
  • src/Exceptions/CustomException.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "CustomException.hpp"
  • src/Exceptions/LinearDependenceException.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "LinearDependenceException.hpp"
  • src/Exceptions/MathException.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "MathException.hpp"
  • src/Exceptions/SkewException.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "SkewException.hpp"
  • src/Exceptions/ZeroVectorException.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "ZeroVectorException.hpp"
  • src/Hbondangle.db

    rc39cc4 rbdb143  
     1# atomicnumber angles for single, double and triple bond (-1 no angle)
    121       180     -1      -1
    235       180     131.0   109.2
  • src/Hbonddistance.db

    rc39cc4 rbdb143  
     1#atomic number bond distances for single, double and triple bond (-1 no bond)
    121       0.74    -1      -1
    232       0.77429209      -1      -1
  • src/Helpers/Assert.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "Helpers/Assert.hpp"
     
    4648using namespace Assert;
    4749
     50#ifndef NDEBUG
     51
    4852Action _my_assert::defaultAction = Ask;
    4953std::vector<Assert::hook_t> _my_assert::hooks;
     
    5256const char* _wrapper::message_ptr = "source pointer did not point to object of desired type";
    5357const char* _wrapper::message_ref = "source reference did not contain object of desired type";
    54 
    5558
    5659
     
    6366{
    6467  if(!res){
    65     cout << "Assertion " << condition << " failed in file " << filename << " at line " << line << endl;
     68    cout << "Assertion \"" << condition << "\" failed in file " << filename << " at line " << line << endl;
    6669    cout << "Assertion Message: " << message << std::endl;
    6770    while(true){
     
    123126  return ActionNames[defaultAction];
    124127}
     128
     129#endif
     130
  • src/Helpers/MemDebug.cpp

    rc39cc4 rbdb143  
    66 */
    77
     8#ifndef NDEBUG
     9#ifndef NO_MEMDEBUG
     10
    811#include <iostream>
    912#include <cstdlib>
     
    1114#include <boost/thread.hpp>
    1215
     16#ifdef __GNUC__
     17#include <execinfo.h>
     18#include <cxxabi.h>
     19#endif
     20
    1321using namespace std;
    1422
    15 #ifndef NDBEGUG
    16 #ifndef NO_MEMDEBUG
     23// we need our own low level mutexex, since we cannot assure the time of construction and destruction
     24// otherwise
     25#if defined(unix) || defined(__unix)
     26
     27#include <pthread.h>
     28#include <cassert>
     29#define mutex_t    pthread_mutex_t
     30#define mutex_init PTHREAD_MUTEX_INITIALIZER
     31#define mutex_lock(mtx) \
     32  do{\
     33    int res = pthread_mutex_lock(&(mtx));\
     34    assert(!res && "Could not lock mutex!");\
     35  }while(0)
     36
     37#define mutex_unlock(mtx) \
     38  do{\
     39    int res = pthread_mutex_unlock(&(mtx));\
     40    assert(!res && "Could not unlock mutex!");\
     41  }while(0)
     42
     43#else
     44# error "No thread structure defined for this plattform..."
     45#endif
    1746
    1847namespace Memory {
     
    3463      char file[length+1];
    3564      int line;
     65#ifdef __GNUC__  // function tracking only works with GCC
     66      // function names can get looooong
     67      enum {length2 = 256};
     68      char function[length2+1];
     69#endif
    3670      size_t nbytes;
    3771      bool isUsed;
     
    4478  };
    4579
    46   boost::mutex memorylock;
     80
     81  mutex_t memorylock = mutex_init;
    4782
    4883  // start and end of the doubly-linked list
     
    96131    for(entry_t *pos=begin;pos;pos=pos->next){
    97132      cout << "\nChunk of " << pos->info.nbytes << " bytes" << " still available" << endl;
     133#ifdef __GNUC__
     134      cout << "Chunk reserved at: " << pos->info.function
     135           << " (" << pos->info.file << ":" << pos->info.line  << ")" << endl;
     136#else
    98137      cout << "Chunk reserved at: " << pos->info.file << ":" << pos->info.line << endl;
    99     }
     138#endif
     139    }
     140  }
     141
     142  // Adds an entry to the linked list
     143  void addEntry(entry_t *entry){
     144    // check if the entry is already in the list
     145    if(!entry->isIgnored)
     146      return;
     147
     148    mutex_lock(Memory::memorylock);
     149
     150    entry->next=0;            // the created block is last in the list
     151    entry->prev=Memory::end;  // the created block is last in the list
     152    if(!Memory::begin){
     153      // the list was empty... start a new one
     154      Memory::begin=entry;
     155    }
     156    else {
     157      // other blocks present... we can add to the last one
     158      Memory::end->next=entry;
     159    }
     160    Memory::end=entry;
     161
     162    // update some global info
     163    Memory::state  += entry->info.nbytes;
     164    if(Memory::state>Memory::max){
     165        Memory::max = Memory::state;
     166    }
     167    ++Memory::allocs;
     168    // done with the list... it is safe to unlock now
     169    mutex_unlock(Memory::memorylock);
     170    entry->isIgnored = false;
    100171  }
    101172
     
    105176      return;
    106177
     178    mutex_lock(memorylock);
    107179    if(entry->prev){
    108180      entry->prev->next = entry->next;
     
    120192      end = entry->prev;
    121193    }
     194    Memory::state  -= entry->info.nbytes;
     195    mutex_unlock(memorylock);
    122196    entry->isIgnored = true;
    123     Memory::state  -= entry->info.nbytes;
     197
    124198  }
    125199
     
    130204    deleteEntry(entry);
    131205  }
    132 }
    133 
    134 void *operator new(size_t nbytes,const char* file, int line) throw(std::bad_alloc) {
    135 
    136   // we need to lock, so that no one changes the linked list while we are here
    137   boost::mutex::scoped_lock guard(Memory::memorylock);
     206
     207#ifdef __GNUC__
     208  // this function let's us find the caller's name
     209  char* getCaller(){
     210    // stack looks like this:
     211    // getCaller();
     212    // operator new();
     213    // function_we_are_looking_for(); <-
     214    const size_t max_depth = 3;
     215    void* stack_addrs[max_depth];
     216    size_t stack_depth;
     217    char **stack_strings=0;
     218    const char *func_name=0;
     219    const char *toplevel = "Global scope";
     220    char *retval=0;
     221
     222    // get the backtrace, depth three
     223    stack_depth   = backtrace(stack_addrs,max_depth);
     224    stack_strings = backtrace_symbols(stack_addrs, stack_depth);
     225    // used later for demangling
     226    // reserved here, so we can free it unconditionally
     227    char *dm_function = static_cast<char*>(malloc(entry_t::info_t::length2));
     228    if(!dm_function){
     229      // malloc failed... we are out of luck
     230      throw std::bad_alloc();
     231    }
     232
     233    // see if we found our function name
     234    if(stack_depth==max_depth){
     235      // find the mangled function name
     236      char *begin = stack_strings[max_depth-1];
     237      // function name starts with a (
     238      while(*begin && *begin!='(') ++begin;
     239      char *end=begin;
     240      while(*end && *end!='+') ++end;
     241
     242      // see if we found our function name
     243      if(*begin && *end){
     244        *begin++ = 0;
     245        *end = 0;
     246        // use the C++ demangler
     247
     248        size_t sz = entry_t::info_t::length2;
     249        int status;
     250        char *func_ret = abi::__cxa_demangle(begin, dm_function, &sz, &status);
     251        if(func_ret){
     252          // abi might have realloced...
     253          dm_function = func_ret;
     254          func_name = dm_function;
     255        }
     256        else{
     257          // demangling failed... get the function name without demangling
     258          func_name = begin;
     259        }
     260      }
     261      else{
     262        // function name not found... get the whole line
     263        func_name = stack_strings[max_depth-1];
     264      }
     265
     266    }
     267    else{
     268      func_name = toplevel;
     269    }
     270
     271    // now we copy the desired function name
     272    if((retval = static_cast<char*>(malloc(strlen(func_name)+1)))){
     273      // we know that the string will fit, so strcpy is safe here
     274      strcpy(retval,func_name);
     275    }
     276    else{
     277      free(stack_strings); // malloc()ed by backtrace_symbols
     278      free(dm_function);
     279      // uh-uh ... seems we are out of luck for allocations now
     280      throw std::bad_alloc();
     281    }
     282    free(dm_function);
     283    free(stack_strings); // malloc()ed by backtrace_symbols
     284    return retval;
     285  }
     286#endif
     287}
     288
     289#ifdef __GNUC__
     290
     291void *operator new(size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc) {
    138292
    139293  // to avoid allocations of 0 bytes if someone screws up
     
    153307  }
    154308
    155   // we got the space, so update the global info
    156   Memory::state += nbytes;
    157   if(Memory::state>Memory::max){
    158     Memory::max = Memory::state;
    159   }
    160   Memory::allocs++;
     309  // build the entry in front of the space
     310  Memory::entry_t *entry = (Memory::entry_t*) res;
     311  memset(res,0,entrySpace);
     312  entry->info.nbytes = nbytes;
     313  entry->info.isUsed = true;
     314  strncpy(entry->info.file,file,Memory::entry_t::info_t::length);
     315  entry->info.file[Memory::entry_t::info_t::length] = '\0';
     316  entry->info.line=line;
     317  strncpy(entry->info.function,func,Memory::entry_t::info_t::length2);
     318  entry->info.function[Memory::entry_t::info_t::length2] = '\0';
     319  // the space starts behind the info
     320  entry->info.location = (char*)res + entrySpace;
     321
     322  // mark the block as not in the list (will be changed by addEntry)
     323  entry->isIgnored = true;
     324  Memory::addEntry(entry);
     325
     326  // get the checksum...
     327  entry->checksum = Memory::calcChecksum(&entry->info);
     328
     329  // ok, space is prepared... the user can have it.
     330  // the rest (constructor, deleting when something is thrown etc)
     331  // is handled automatically
     332  return entry->info.location;
     333}
     334
     335#else
     336
     337void *operator new(size_t nbytes,const char* file, int line) throw(std::bad_alloc) {
     338
     339  // to avoid allocations of 0 bytes if someone screws up
     340  // allocation with 0 byte size are undefined behavior, so we are
     341  // free to handle it this way
     342  if(!nbytes) {
     343    nbytes = 1;
     344  }
     345
     346  // get the size of the entry, including alignment
     347  static const size_t entrySpace = Memory::doAlign(sizeof(Memory::entry_t));
     348
     349  void *res;
     350  if(!(res=malloc(entrySpace + nbytes))){
     351    // new must throw, when space is low
     352    throw std::bad_alloc();
     353  }
    161354
    162355  // build the entry in front of the space
     
    171364  entry->info.location = (char*)res + entrySpace;
    172365
    173   // add the entry at the end of the list
    174   entry->next=0;            // the created block is last in the list
    175   entry->prev=Memory::end;  // the created block is last in the list
    176   if(!Memory::begin){
    177     // the list was empty... start a new one
    178     Memory::begin=entry;
    179   }
    180   else {
    181     // other blocks present... we can add to the last one
    182     Memory::end->next=entry;
    183   }
    184   Memory::end=entry;
     366  // mark the block as not in the list (will be changed by addEntry)
     367  entry->isIgnored = true;
     368  Memory::addEntry(entry);
    185369
    186370  // get the checksum...
     
    196380}
    197381
     382#endif
     383
    198384void *operator new(size_t nbytes) throw(std::bad_alloc) {
    199385  // Just forward to the other operator, when we do not know from
    200386  // where the allocation came
     387#ifdef __GNUC__
     388  // this might throw bad_alloc
     389  char *caller = Memory::getCaller();
     390  void* retval = 0;
     391
     392  // if this throws, we have to clean up the caller anyway
     393  try{
     394    retval = operator new(nbytes,"Unknown",0,caller);
     395  }
     396  catch(...)
     397  {
     398    free(caller); // malloc()ed by Memory::getCaller();
     399    throw;
     400  }
     401  free(caller); // malloc()ed by Memory::getCaller();
     402  return retval;
     403#else
    201404  return operator new(nbytes,"Unknown",0);
    202 }
     405#endif
     406}
     407
     408#ifdef __GNUC__
     409
     410void *operator new[] (size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc) {
     411  // The difference between new and new[] is just for compiler bookkeeping.
     412  return operator new(nbytes,file,line,func);
     413}
     414
     415#else
    203416
    204417void *operator new[] (size_t nbytes,const char* file, int line) throw(std::bad_alloc) {
     
    207420}
    208421
     422#endif
     423
    209424void *operator new[] (size_t nbytes) throw(std::bad_alloc) {
    210425  // Forward again
     426#ifdef __GNUC__
     427  // this might throw bad_alloc
     428    char *caller = Memory::getCaller();
     429    void *retval=0;
     430
     431    // if this throws, we have to clean up the caller anyway
     432    try{
     433      retval = operator new[] (nbytes,"Unknown",0,caller);
     434    }
     435    catch(...)
     436    {
     437      free(caller); // malloc()ed by Memory::getCaller();
     438      throw;
     439    }
     440    free(caller); // malloc()ed by Memory::getCaller();
     441    return retval;
     442#else
    211443  return operator new[] (nbytes,"Unknown",0);
     444#endif
    212445}
    213446
     
    217450    return;
    218451  }
    219 
    220   // we need to lock, so the linked list does not changed while we are in here
    221   boost::mutex::scoped_lock guard(Memory::memorylock);
    222452
    223453  // get the size for the entry, including alignment
  • src/Helpers/MemDebug.hpp

    rc39cc4 rbdb143  
    2828#endif
    2929
     30#include <new>
     31
     32// some light header files, that do weird new stuff and therefore need
     33// to be loaded before the define
     34#include <string>
     35#include <boost/optional.hpp>
     36#include <boost/shared_ptr.hpp>
     37#include <boost/function.hpp>
     38#include <boost/program_options.hpp>
     39
     40
    3041namespace Memory {
    3142
     
    5061  }
    5162}
    52 
     63#ifdef __GNUC__
     64void *operator new   (size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc);
     65void *operator new[] (size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc);
     66#else
    5367void *operator new   (size_t nbytes,const char* file, int line) throw(std::bad_alloc);
    5468void *operator new[] (size_t nbytes,const char* file, int line) throw(std::bad_alloc);
     69#endif
    5570void operator delete   (void *ptr,const char*, int) throw();
    5671void operator delete[] (void *ptr,const char*, int) throw();
     72
     73
    5774
    5875/**
     
    6077 * version that allows tracking.
    6178 */
     79#ifdef __GNUC__
     80#define new new(__FILE__,__LINE__,__PRETTY_FUNCTION__)
     81#else
    6282#define new new(__FILE__,__LINE__)
     83#endif
    6384
    6485#endif
    6586#endif
    6687
     88
     89#ifdef NDEBUG
     90#undef MEMDEBUG
     91#endif
    6792
    6893#ifndef MEMDEBUG
  • src/Legacy/oldmenu.cpp

    rc39cc4 rbdb143  
    66 *
    77 */
     8
     9#include "Helpers/MemDebug.hpp"
    810
    911#include "Legacy/oldmenu.hpp"
     
    3739#include "Menu/DisplayMenuItem.hpp"
    3840#include "Menu/SubMenuItem.hpp"
     41#include "Actions/MapOfActions.hpp"
    3942#include "Actions/MethodAction.hpp"
    4043#include "Actions/ErrorAction.hpp"
     
    8588        Dialog *dialog = UIFactory::getInstance().makeDialog();
    8689        first = World::getInstance().createAtom();
     90        std::vector<element *> elements;
    8791        dialog->queryVector("Please enter coordinates: ",&first->x,World::getInstance().getDomain(), false);
    88         dialog->queryElement("Please choose element: ",&first->type);
     92        dialog->queryElement("Please choose element: ",&elements);
    8993        if(dialog->display()){
    90           mol->AddAtom(first);  // add to molecule
     94          if (elements.size() == 1) {
     95            first->type = elements.at(0);
     96            mol->AddAtom(first);  // add to molecule
     97          } else {
     98            DoeLog(1) && (eLog() << Verbose(1) << "Unequal to one element given for element of new atom." << endl);
     99          }
    91100        }
    92101        else{
     
    425434void oldmenu::RemoveAtoms(molecule *mol)
    426435{
    427   atom *first, *second;
     436  atom *second;
    428437  int axis;
    429438  double tmp1, tmp2;
     
    448457      break;
    449458    case 'b':
    450       second = mol->AskAtom("Enter number of atom as reference point: ");
    451       Log() << Verbose(0) << "Enter radius: ";
    452       cin >> tmp1;
    453       first = mol->start;
    454       second = first->next;
    455       while(second != mol->end) {
    456         first = second;
    457         second = first->next;
    458         if (first->x.DistanceSquared(second->x) > tmp1*tmp1) // distance to first above radius ...
    459           mol->RemoveAtom(first);
     459      {
     460        second = mol->AskAtom("Enter number of atom as reference point: ");
     461        Log() << Verbose(0) << "Enter radius: ";
     462        cin >> tmp1;
     463        molecule::iterator runner;
     464        for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
     465          runner = iter++;
     466          if ((*runner)->x.DistanceSquared((*runner)->x) > tmp1*tmp1) // distance to first above radius ...
     467            mol->RemoveAtom((*runner));
     468        }
    460469      }
    461470      break;
     
    467476      Log() << Verbose(0) << "Upper boundary: ";
    468477      cin >> tmp2;
    469       first = mol->start;
    470       second = first->next;
    471       while(second != mol->end) {
    472         first = second;
    473         second = first->next;
    474         if ((first->x[axis] < tmp1) || (first->x[axis] > tmp2)) {// out of boundary ...
    475           //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
    476           mol->RemoveAtom(first);
     478      molecule::iterator runner;
     479      for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
     480        runner = iter++;
     481        if (((*runner)->x[axis] < tmp1) || ((*runner)->x[axis] > tmp2)) {// out of boundary ...
     482          //Log() << Verbose(0) << "Atom " << *(*runner) << " with " << (*runner)->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
     483          mol->RemoveAtom((*runner));
    477484        }
    478485      }
     
    518525        min[i] = 0.;
    519526
    520       second = mol->start;
    521       while ((second->next != mol->end)) {
    522         second = second->next; // advance
    523         Z = second->type->Z;
     527      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     528        Z = (*iter)->type->Z;
    524529        tmp1 = 0.;
    525         if (first != second) {
    526           x = first->x - second->x;
     530        if (first != (*iter)) {
     531          x = first->x - (*iter)->x;
    527532          tmp1 = x.Norm();
    528533        }
    529534        if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
    530         //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;
     535        //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << ((*iter)->nr << ": " << tmp1 << " a.u." << endl;
    531536      }
    532537      for (int i=MAX_ELEMENTS;i--;)
     
    619624{
    620625  int Order1;
     626  std::string path;
    621627  clock_t start, end;
    622628
     
    624630  Log() << Verbose(0) << "What's the desired bond order: ";
    625631  cin >> Order1;
    626   if (mol->first->next != mol->last) {  // there are bonds
     632  DoLog(0) && (Log() << Verbose(0) << "What's the output path and prefix [e.g. /home/foo/BondFragment]: ");
     633  cin >> path;
     634  if (mol->hasBondStructure()) {
    627635    start = clock();
    628     mol->FragmentMolecule(Order1, configuration);
     636    mol->FragmentMolecule(Order1, path);
    629637    end = clock();
    630638    Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
     
    770778    Log() << Verbose(0) << "State the factor: ";
    771779    cin >> faktor;
    772 
    773     mol->CountAtoms(); // recount atoms
    774     if (mol->AtomCount != 0) {  // if there is more than none
    775       count = mol->AtomCount;  // is changed becausing of adding, thus has to be stored away beforehand
     780    if (mol->getAtomCount() != 0) {  // if there is more than none
     781      count = mol->getAtomCount();  // is changed becausing of adding, thus has to be stored away beforehand
    776782      Elements = new const element *[count];
    777783      vectors = new Vector *[count];
    778784      j = 0;
    779       first = mol->start;
    780       while (first->next != mol->end) { // make a list of all atoms with coordinates and element
    781         first = first->next;
    782         Elements[j] = first->type;
    783         vectors[j] = &first->x;
     785      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     786        Elements[j] = (*iter)->type;
     787        vectors[j] = &(*iter)->x;
    784788        j++;
    785789      }
     
    798802        }
    799803      }
    800       if (mol->first->next != mol->last) // if connect matrix is present already, redo it
     804      if (mol->hasBondStructure())
    801805        mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    802806      // free memory
     
    924928  molecule *srcmol = NULL, *destmol = NULL;
    925929  Dialog *dialog = UIFactory::getInstance().makeDialog();
    926   dialog->queryMolecule("Enter index of destination molecule: ",&destmol, molecules);
    927   dialog->queryMolecule("Enter index of source molecule to add from: ",&srcmol, molecules);
     930  dialog->queryMolecule("molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     931  dialog->queryMolecule("molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
    928932  if(dialog->display()) {
    929933    molecules->SimpleAdd(srcmol, destmol);
     
    938942  molecule *srcmol = NULL, *destmol = NULL;
    939943  Dialog *dialog = UIFactory::getInstance().makeDialog();
    940   dialog->queryMolecule("Enter index of matrix molecule (the variable one): ",&srcmol,molecules);
    941   dialog->queryMolecule("Enter index of molecule to merge into (the fixed one): ",&destmol,molecules);
     944  dialog->queryMolecule("molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     945  dialog->queryMolecule("molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
    942946  if(dialog->display()) {
    943947    molecules->EmbedMerge(destmol, srcmol);
     
    10401044    return;
    10411045  }
    1042   atom *Walker = mol->start;
    10431046
    10441047  // generate some KeySets
    10451048  Log() << Verbose(0) << "Generating KeySets." << endl;
    1046   KeySet TestSets[mol->AtomCount+1];
     1049  KeySet TestSets[mol->getAtomCount()+1];
    10471050  i=1;
    1048   while (Walker->next != mol->end) {
    1049     Walker = Walker->next;
     1051  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    10501052    for (int j=0;j<i;j++) {
    1051       TestSets[j].insert(Walker->nr);
     1053      TestSets[j].insert((*iter)->nr);
    10521054    }
    10531055    i++;
     
    10551057  Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl;
    10561058  KeySetTestPair test;
    1057   test = TestSets[mol->AtomCount-1].insert(Walker->nr);
    1058   if (test.second) {
    1059     Log() << Verbose(1) << "Insertion worked?!" << endl;
     1059  molecule::const_iterator iter = mol->begin();
     1060  if (iter != mol->end()) {
     1061    test = TestSets[mol->getAtomCount()-1].insert((*iter)->nr);
     1062    if (test.second) {
     1063      Log() << Verbose(1) << "Insertion worked?!" << endl;
     1064    } else {
     1065      Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
     1066    }
    10601067  } else {
    1061     Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
    1062   }
    1063   TestSets[mol->AtomCount].insert(mol->end->previous->nr);
    1064   TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);
     1068    eLog() << Verbose(1) << "No atoms to test double insertion." << endl;
     1069  }
    10651070
    10661071  // constructing Graph structure
     
    10701075  // insert KeySets into Subgraphs
    10711076  Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl;
    1072   for (int j=0;j<mol->AtomCount;j++) {
     1077  for (int j=0;j<mol->getAtomCount();j++) {
    10731078    Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
    10741079  }
    10751080  Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl;
    10761081  GraphTestPair test2;
    1077   test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.)));
     1082  test2 = Subgraphs.insert(GraphPair (TestSets[mol->getAtomCount()],pair<int, double>(counter++, 1.)));
    10781083  if (test2.second) {
    10791084    Log() << Verbose(1) << "Insertion worked?!" << endl;
  • src/Line.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "Line.hpp"
  • src/Makefile.am

    rc39cc4 rbdb143  
     1# PLEASE adhere to the alphabetical ordering in this Makefile!
     2# Also indentation by a single tab
     3
     4SUBDIRS = Actions UIElements
     5
    16# this includes source files that need to be present at multiple points
    2 HELPERSOURCE =  Helpers/Assert.cpp \
    3                                 Helpers/MemDebug.cpp
     7HELPERSOURCE =  \
     8  Helpers/Assert.cpp \
     9  Helpers/MemDebug.cpp
    410                       
    5 ATOMSOURCE = atom.cpp atom_atominfo.cpp atom_bondedparticle.cpp atom_bondedparticleinfo.cpp atom_graphnode.cpp atom_graphnodeinfo.cpp atom_particleinfo.cpp atom_trajectoryparticle.cpp atom_trajectoryparticleinfo.cpp
    6 ATOMHEADER = atom.hpp atom_atominfo.hpp atom_bondedparticle.hpp atom_bondedparticleinfo.hpp atom_graphnode.hpp atom_graphnodeinfo.hpp atom_particleinfo.hpp atom_trajectoryparticle.hpp atom_trajectoryparticleinfo.hpp
    7 
    8 LINALGSOURCE = ${HELPERSOURCE} \
    9                gslmatrix.cpp \
    10                            gslvector.cpp \
    11                            linearsystemofequations.cpp \
    12                            Space.cpp \
    13                            vector.cpp
     11ATOMSOURCE = \
     12  atom.cpp \
     13  atom_atominfo.cpp \
     14  atom_bondedparticle.cpp \
     15  atom_bondedparticleinfo.cpp \
     16  atom_graphnode.cpp \
     17  atom_graphnodeinfo.cpp \
     18  atom_particleinfo.cpp \
     19  atom_trajectoryparticle.cpp \
     20  atom_trajectoryparticleinfo.cpp
     21ATOMHEADER = \
     22  atom.hpp \
     23  atom_atominfo.hpp \
     24  atom_bondedparticle.hpp \
     25  atom_bondedparticleinfo.hpp \
     26  atom_graphnode.hpp \
     27  atom_graphnodeinfo.hpp \
     28  atom_particleinfo.hpp \
     29  atom_trajectoryparticle.hpp \
     30  atom_trajectoryparticleinfo.hpp
     31
     32LINALGSOURCE = \
     33  ${HELPERSOURCE} \
     34  gslmatrix.cpp \
     35  gslvector.cpp \
     36  linearsystemofequations.cpp \
     37  Space.cpp \
     38  vector.cpp
    1439                           
    1540LINALGHEADER = gslmatrix.hpp \
    16                            gslvector.hpp \
    17                            linearsystemofequations.hpp \
    18                            Space.hpp \
    19                            vector.hpp
     41  gslvector.hpp \
     42  linearsystemofequations.hpp \
     43  Space.hpp \
     44  vector.hpp
    2045                           
    21 
    22 ANALYSISSOURCE = analysis_bonds.cpp analysis_correlation.cpp
    23 ANALYSISHEADER = analysis_bonds.hpp analysis_correlation.hpp
    24 
    25 ACTIONSSOURCE = Actions/Action.cpp \
    26                                 Actions/ActionHistory.cpp \
    27                                 Actions/ActionRegistry.cpp \
    28                                 Actions/ActionSequence.cpp \
    29                                 Actions/ErrorAction.cpp \
    30                                 Actions/MakroAction.cpp \
    31                                 Actions/ManipulateAtomsProcess.cpp \
    32                                 Actions/MethodAction.cpp \
    33                 Actions/Process.cpp \
    34                 Actions/small_actions.cpp
    35                
    36                  
    37 ACTIONSHEADER = Actions/Action.hpp \
    38                                 Actions/ActionHistory.hpp \
    39                                 Actions/ActionRegistry.hpp \
    40                                 Actions/ActionSequence.hpp \
    41                             Actions/Calculation.hpp \
    42                             Actions/Calculation_impl.hpp \
    43                             Actions/ErrorAction.hpp \
    44                             Actions/MakroAction.hpp \
    45                             Actions/ManipulateAtomsProcess.hpp \
    46                             Actions/MethodAction.hpp \
    47                             Actions/Process.hpp \
    48                             Actions/small_actions.hpp
    49                            
    50                            
    51 
    52 PATTERNSOURCE = Patterns/Observer.cpp
    53 PATTERNHEADER = Patterns/Cacheable.hpp \
    54                                 Patterns/Observer.hpp \
    55                 Patterns/Singleton.hpp
    56 
    57 VIEWSOURCE = Views/View.cpp Views/StringView.cpp Views/MethodStringView.cpp Views/StreamStringView.cpp
    58 VIEWHEADER = Views/View.hpp Views/StringView.hpp Views/MethodStringView.hpp Views/StreamStringView.hpp
    59 
    60 MENUSOURCE = Menu/Menu.cpp Menu/TextMenu.cpp Menu/MenuItem.cpp Menu/SubMenuItem.cpp Menu/ActionMenuItem.cpp Menu/SeperatorItem.cpp Menu/DisplayMenuItem.cpp
    61 MENUHEADER = Menu/Menu.hpp Menu/TextMenu.hpp Menu/MenuItem.hpp Menu/SubMenuItem.hpp Menu/ActionMenuItem.hpp Menu/SeperatorItem.hpp Menu/DisplayMenuItem.hpp
    62 
    63 UISOURCE = ${ACTIONSSOURCE} ${VIEWSOURCE} ${MENUSOURCE} UIElements/UIFactory.cpp UIElements/TextUIFactory.cpp UIElements/MainWindow.cpp UIElements/TextWindow.cpp UIElements/TextStatusIndicator.cpp UIElements/Dialog.cpp UIElements/TextDialog.cpp
    64 UIHEADER = ${ACTIONSHEADER} ${VIEWHEADER} ${MENUHEADER} UIElements/UIFactory.hpp UIElements/TextUIFactory.hpp UIElements/MainWindow.hpp UIElements/TextWindow.hpp UIElements/TextStatusIndicator.hpp UIElements/Dialog.hpp UIElements/TextDialog.hpp
    65 
    66 # all these files are only used for legacy reasons while the transition is in progress
    67 # they are only needed to keep the program usable at any point of the transition and will be
    68 # deleted once everything is fully refactored
    69 LEGACYSOURCE = Legacy/oldmenu.cpp
    70 LEGACYHEADER = Legacy/oldmenu.hpp
     46ANALYSISSOURCE = \
     47  analysis_bonds.cpp \
     48  analysis_correlation.cpp
     49ANALYSISHEADER = \
     50  analysis_bonds.hpp \
     51  analysis_correlation.hpp
     52
     53ACTIONSSOURCE = \
     54  Actions/Action.cpp \
     55  Actions/ActionHistory.cpp \
     56  Actions/ActionRegistry.cpp \
     57  Actions/ActionSequence.cpp \
     58  Actions/ErrorAction.cpp \
     59  Actions/MakroAction.cpp \
     60  Actions/ManipulateAtomsProcess.cpp \
     61  Actions/MethodAction.cpp \
     62  Actions/Process.cpp
     63
     64ACTIONSHEADER = \
     65  Actions/Action.hpp \
     66  Actions/ActionHistory.hpp \
     67  Actions/ActionRegistry.hpp \
     68  Actions/ActionSequence.hpp \
     69  Actions/Calculation.hpp \
     70  Actions/Calculation_impl.hpp \
     71  Actions/ErrorAction.hpp \
     72  Actions/MakroAction.hpp \
     73  Actions/ManipulateAtomsProcess.hpp \
     74  Actions/MapOfActions.hpp \
     75  Actions/MethodAction.hpp \
     76  Actions/Process.hpp
     77 
     78
     79PARSERSOURCE = \
     80  Parser/ChangeTracker.cpp \
     81  Parser/FormatParser.cpp \
     82  Parser/FormatParserStorage.cpp \
     83  Parser/MpqcParser.cpp \
     84  Parser/PcpParser.cpp \
     85  Parser/TremoloParser.cpp \
     86  Parser/XyzParser.cpp
     87
     88PARSERHEADER = \
     89  Parser/ChangeTracker.hpp \
     90  Parser/FormatParser.hpp \
     91  Parser/FormatParserStorage.hpp \
     92  Parser/MpqcParser.hpp \
     93  Parser/PcpParser.hpp \
     94  Parser/TremoloParser.hpp \
     95  Parser/XyzParser.hpp
     96
     97PATTERNSOURCE = \
     98  Patterns/Observer.cpp
     99PATTERNHEADER = \
     100  Patterns/Cacheable.hpp \
     101  Patterns/Observer.hpp \
     102  Patterns/Singleton.hpp
     103
     104QTUIMOC_HEADER = UIElements/QT4/QTDialog.hpp \
     105                                 UIElements/QT4/QTMainWindow.hpp \
     106                                 UIElements/Menu/QT4/QTMenu.hpp \
     107                                 UIElements/Views/QT4/QTWorldView.hpp \
     108                                 UIElements/Views/QT4/GLMoleculeView.hpp \
     109                                 UIElements/Views/QT4/QTMoleculeView.hpp \
     110                                 UIElements/Views/QT4/QTStatusBar.hpp
     111 
     112QTUIMOC_TARGETS = QTMainWindow.moc.cpp \
     113                      QTMenu.moc.cpp\
     114                      QTDialog.moc.cpp \
     115                      QTWorldView.moc.cpp \
     116                      GLMoleculeView.moc.cpp \
     117                      QTMoleculeView.moc.cpp \
     118                      QTStatusBar.moc.cpp
    71119
    72120DESCRIPTORSOURCE = Descriptors/AtomDescriptor.cpp \
    73                                    Descriptors/AtomIdDescriptor.cpp \
    74                                    Descriptors/AtomTypeDescriptor.cpp \
    75                                    Descriptors/MoleculeDescriptor.cpp \
    76                                    Descriptors/MoleculeIdDescriptor.cpp
     121  Descriptors/AtomIdDescriptor.cpp \
     122  Descriptors/AtomTypeDescriptor.cpp \
     123  Descriptors/MoleculeDescriptor.cpp \
     124  Descriptors/MoleculeIdDescriptor.cpp \
     125  Descriptors/MoleculeNameDescriptor.cpp \
     126  Descriptors/MoleculePtrDescriptor.cpp
    77127                                   
     128
     129DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp \
     130  Descriptors/AtomIdDescriptor.hpp \
     131  Descriptors/AtomTypeDescriptor.hpp \
     132  Descriptors/MoleculeDescriptor.hpp \
     133  Descriptors/MoleculeIdDescriptor.hpp \
     134  Descriptors/MoleculeNameDescriptor.hpp \
     135  Descriptors/MoleculePtrDescriptor.hpp
    78136                                   
    79 DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp \
    80                                    Descriptors/AtomIdDescriptor.hpp \
    81                                    Descriptors/AtomTypeDescriptor.hpp \
    82                                    Descriptors/MoleculeDescriptor.hpp \
    83                                    Descriptors/MoleculeIdDescriptor.hpp
    84                                    
    85 
    86 
    87137EXCEPTIONSOURCE = Exceptions/CustomException.cpp \
    88138                                  Exceptions/LinearDependenceException.cpp \
     
    96146                                  Exceptions/SkewException.hpp \
    97147                                  Exceptions/ZeroVectorException.hpp
    98 
    99 SOURCE = ${ANALYSISSOURCE} \
    100                  ${ATOMSOURCE} \
    101                  ${PATTERNSOURCE} \
    102                  ${UISOURCE} \
    103                  ${DESCRIPTORSOURCE} \
    104                  ${HELPERSOURCE} \
    105                  ${LEGACYSOURCE} \
    106                  ${EXCEPTIONSOURCE} \
    107                  bond.cpp \
    108                  bondgraph.cpp \
    109                  boundary.cpp \
    110                  config.cpp \
    111                  element.cpp \
    112                  ellipsoid.cpp \
    113                  errorlogger.cpp \
    114                  graph.cpp \
    115                  helpers.cpp \
    116                  info.cpp \
    117                  leastsquaremin.cpp \
    118                  Line.cpp \
    119                  linkedcell.cpp \
    120                  lists.cpp \
    121                  log.cpp \
    122                  logger.cpp \
    123                  memoryusageobserver.cpp \
    124                  moleculelist.cpp \
    125                  molecule.cpp \
    126                  molecule_dynamics.cpp \
    127                  molecule_fragmentation.cpp \
    128                  molecule_geometry.cpp \
    129                  molecule_graph.cpp \
    130                  molecule_pointcloud.cpp \
    131                  parser.cpp \
    132                  periodentafel.cpp \
    133                  Plane.cpp \
    134                  tesselation.cpp \
    135                  tesselationhelpers.cpp \
    136                  triangleintersectionlist.cpp \
    137                  verbose.cpp \
    138                  vector_ops.cpp \
    139                  World.cpp
     148                                 
     149QTUISOURCE = ${QTUIMOC_TARGETS} \
     150                         UIElements/QT4/QTMainWindow.cpp \
     151                         UIElements/QT4/QTDialog.cpp \
     152                         UIElements/QT4/QTUIFactory.cpp \
     153                         UIElements/Menu/QT4/QTMenu.cpp \
     154                         UIElements/Views/QT4/QTWorldView.cpp \
     155                         UIElements/Views/QT4/GLMoleculeView.cpp \
     156                         UIElements/Views/QT4/QTMoleculeView.cpp \
     157                         UIElements/Views/QT4/QTStatusBar.cpp
     158             
     159QTUIHEADER = ${QTUIMOC_HEADER} UIElements/QT4/QTUIFactory.hpp
     160
     161QTUI_DEFS =
     162
     163SOURCE = \
     164  ${ANALYSISSOURCE} \
     165  ${ACTIONSSOURCE} \
     166  ${ATOMSOURCE} \
     167  ${PATTERNSOURCE} \
     168  ${PARSERSOURCE} \
     169  ${DESCRIPTORSOURCE} \
     170  ${HELPERSOURCE} \
     171  ${EXCEPTIONSOURCE} \
     172  bond.cpp \
     173  bondgraph.cpp \
     174  boundary.cpp \
     175  CommandLineParser.cpp \
     176  config.cpp \
     177  ConfigFileBuffer.cpp \
     178  element.cpp \
     179  elements_db.cpp \
     180  ellipsoid.cpp \
     181  errorlogger.cpp \
     182  graph.cpp \
     183  helpers.cpp \
     184  info.cpp \
     185  leastsquaremin.cpp \
     186  Line.cpp \
     187  linkedcell.cpp \
     188  log.cpp \
     189  logger.cpp \
     190  moleculelist.cpp \
     191  molecule.cpp \
     192  molecule_dynamics.cpp \
     193  molecule_fragmentation.cpp \
     194  molecule_geometry.cpp \
     195  molecule_graph.cpp \
     196  molecule_pointcloud.cpp \
     197  parser.cpp \
     198  periodentafel.cpp \
     199  Plane.cpp \
     200  Space.cpp \
     201  tesselation.cpp \
     202  tesselationhelpers.cpp \
     203  ThermoStatContainer.cpp \
     204  triangleintersectionlist.cpp \
     205  vector.cpp \
     206  vector_ops.cpp \
     207  verbose.cpp \
     208  World.cpp
    140209
    141210HEADER = \
    142           ${ANALYSISHEADER} \
    143           ${ATOMHEADER} \
    144           ${PATTERNHEADER} \
    145           ${UIHEADER} \
    146           ${DESCRIPTORHEADER} \
    147           ${EXCEPTIONHEADER} \
    148           ${LEGACYHEADER} \
    149           bond.hpp \
    150           bondgraph.hpp \
    151           boundary.hpp \
    152           config.hpp \
    153           defs.hpp \
    154           element.hpp \
    155           ellipsoid.hpp \
    156           errorlogger.hpp \
    157           graph.hpp \
    158           helpers.hpp \
    159           info.hpp \
    160           leastsquaremin.hpp \
    161           Line.hpp \
    162           linkedcell.hpp \
    163           lists.hpp \
    164           log.hpp \
    165           logger.hpp \
    166           memoryallocator.hpp \
    167           memoryusageobserver.hpp \
    168           molecule.hpp \
    169           molecule_template.hpp \
    170           parser.hpp \
    171           periodentafel.hpp \
    172           Plane.hpp \
    173           stackclass.hpp \
    174           tesselation.hpp \
    175           tesselationhelpers.hpp \
    176           triangleintersectionlist.hpp \
    177           verbose.hpp \
    178           vector_ops.hpp \
    179           World.hpp
     211  ${ANALYSISHEADER} \
     212  ${ACTIONSHEADER} \
     213  ${ATOMHEADER} \
     214  ${PARSERHEADER} \
     215  ${PATTERNHEADER} \
     216  ${DESCRIPTORHEADER} \
     217  ${EXCEPTIONHEADER} \
     218  bond.hpp \
     219  bondgraph.hpp \
     220  boundary.hpp \
     221  CommandLineParser.hpp \
     222  config.hpp \
     223  ConfigFileBuffer.hpp \
     224  defs.hpp \
     225  element.hpp \
     226  elements_db.hpp \
     227  ellipsoid.hpp \
     228  errorlogger.hpp \
     229  graph.hpp \
     230  helpers.hpp \
     231  info.hpp \
     232  leastsquaremin.hpp \
     233  Line.hpp \
     234  linkedcell.hpp \
     235  lists.hpp \
     236  log.hpp \
     237  logger.hpp \
     238  molecule.hpp \
     239  molecule_template.hpp \
     240  parser.hpp \
     241  periodentafel.hpp \
     242  Plane.hpp \
     243  stackclass.hpp \
     244  tesselation.hpp \
     245  tesselationhelpers.hpp \
     246  ThermoStatContainer.hpp \
     247  triangleintersectionlist.hpp \
     248  verbose.hpp \
     249  vector_ops.hpp \
     250  World.hpp
     251
     252# the following files are no longer used:
     253#  memoryallocator.hpp \
     254#  memoryallocator.cpp \
     255#  memoryusageobserver.hpp \
     256#  memoryusageobserver.cpp
    180257
    181258BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB)
    182 INCLUDES = -I$(top_srcdir)/src/unittests
    183 
    184 noinst_LIBRARIES = libmolecuilder.a libgslwrapper.a
    185 bin_PROGRAMS = molecuilder joiner analyzer
     259GUI_LIBS = ${QT_LDADD} ${QT_LIB_GUI} -lQtOpenGL ${GLU_LIBS}
     260INCLUDES = -I$(top_srcdir)/src/unittests -I$(top_srcdir)/src/Actions -I$(top_srcdir)/src/UIElements
     261
     262noinst_LIBRARIES = libmolecuilder.a libgslwrapper.a libmenu.a libparser.a
     263bin_PROGRAMS = molecuilder molecuildergui joiner analyzer
     264
    186265molecuilderdir = ${bindir}
     266
    187267libmolecuilder_a_SOURCES = ${SOURCE} ${HEADER}
     268
     269libmenu_a_SOURCES = ${UISOURCE} ${UIHEADER}
     270libparser_a_SOURCES = ${PARSERSOURCE} ${PARSERHEADER}
    188271libgslwrapper_a_SOURCES = ${LINALGSOURCE} ${LINALGHEADER}
     272
    189273molecuilder_DATA = elements.db valence.db orbitals.db Hbonddistance.db Hbondangle.db
    190 molecuilder_LDFLAGS = $(BOOST_LDFLAGS)
    191 molecuilder_SOURCES = builder.cpp
    192 molecuilder_LDADD = libmolecuilder.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
     274
     275molecuilder_CXXFLAGS = $(BOOST_CPPFLAGS)
     276#molecuilder_CXXFLAGS += -DNO_CACHING
     277molecuilder_LDFLAGS = $(BOOST_LIB)
     278molecuilder_SOURCES = ${LEGACYSOURCE} builder.cpp
     279molecuilder_SOURCES += $(srcdir)/version.c
     280molecuilder_LDADD = UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilder.a libparser.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}
     281
     282#Stuff for building the GUI using QT
     283molecuildergui_SOURCES = ${QTUISOURCE} ${LEGACYSOURCE} builder.cpp
     284molecuildergui_SOURCES += $(srcdir)/version.c
     285molecuildergui_CXXFLAGS = ${QT_CXXFLAGS} ${GLU_CXXFLAGS} -DUSE_GUI_QT
     286molecuildergui_LDFLAGS = $(BOOST_LIB) ${QT_LDFLAGS} ${GLU_LDFLAGS}
     287molecuildergui_LDADD = UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilder.a libparser.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}  ${GUI_LIBS}
     288
    193289joiner_SOURCES = joiner.cpp datacreator.cpp parser.cpp datacreator.hpp helpers.hpp parser.hpp periodentafel.hpp
    194290joiner_LDADD = libmolecuilder.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
     291
    195292analyzer_SOURCES = analyzer.cpp datacreator.cpp parser.cpp helpers.hpp periodentafel.hpp parser.hpp datacreator.hpp
    196293analyzer_LDADD = libmolecuilder.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
    197294
     295#Rules needed for QT4
     296# UI-Files are scattered throughout several subdirectories
     297# Therfore `%'-rules do not seem to work
     298#Quick fix to get it done otherwise
     299${QTUIMOC_TARGETS}: ${QTUIMOC_HEADER}
     300        list='$(QTUIMOC_HEADER)'; for header in $$list; do \
     301        echo "Making mocfile for $$header"; \
     302        target=`basename $$header | sed "s/\(.*\)\..*/\1.moc.cpp/"`;\
     303        $(MOC) $(srcdir)/$$header -o $$target \
     304        || eval $$failcom; \
     305        done;
     306
     307MOSTLYCLEANFILES = ${QTUIMOC_TARGETS}
     308       
    198309#EXTRA_DIST = ${molecuilder_DATA}
    199310
     
    212323        echo "const char *ESPACKVersion = \"$(PACKAGE_NAME) -- git version: "`cat $(srcdir)/.git-version`"\";" > $@
    213324
    214 molecuilder_SOURCES += $(srcdir)/version.c
     325
  • src/Patterns/Cacheable.hpp

    rc39cc4 rbdb143  
    2828        owner(_owner)
    2929        {}
    30       virtual T getValue()=0;
     30      virtual T& getValue()=0;
    3131      virtual void invalidate()=0;
    3232      virtual bool isValid()=0;
     
    3535        return busy;
    3636      }
     37    virtual std::string getName()=0;
    3738    protected:
    3839      bool busy;
     
    4647        {}
    4748
    48       virtual T getValue(){
     49      virtual T& getValue(){
    4950        // set the state to valid
    5051        State::owner->switchState(State::owner->validState);
     
    6465        // nothing to do when entering this
    6566      }
     67
     68      virtual std::string getName(){
     69        return "invalid";
     70      }
    6671    };
    6772
     
    7277        {}
    7378
    74       virtual T getValue(){
     79      virtual T& getValue(){
    7580        return content;
    7681      }
     
    9095        State::busy = false;
    9196      }
     97
     98      virtual std::string getName(){
     99        return "valid";
     100      }
    92101    private:
    93102      T content;
     
    100109        {}
    101110
    102       virtual T getValue(){
     111      virtual T& getValue(){
    103112        ASSERT(0,"Cannot get a value from a Cacheable after it's Observable has died");
    104113        // we have to return a grossly invalid reference, because no value can be produced anymore
     
    118127        // nothing to do when entering this state
    119128      }
     129
     130      virtual std::string getName(){
     131        return "destroyed";
     132      }
    120133    };
    121134
     
    124137
    125138  public:
    126     Cacheable(Observable *_owner, boost::function<T()> _recalcMethod);
     139    Cacheable(Observable *_owner, boost::function<T()> _recalcMethod, std::string name);
    127140    virtual ~Cacheable();
    128141
     
    134147    void subjectKilled(Observable *subject);
    135148  private:
    136 
    137149    void switchState(state_ptr newState);
    138150
     
    144156
    145157    Observable *owner;
    146 
    147158    boost::function<T()> recalcMethod;
    148159
     
    153164
    154165  template<typename T>
    155   Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod) :
     166  Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod, std::string name) :
     167    Observer(name + "(Cached)"),
    156168    owner(_owner),
    157169    recalcMethod(_recalcMethod)
     
    208220  void Cacheable<T>::switchState(state_ptr newState){
    209221    ASSERT(!state->isBusy(),"LOOP DETECTED: Cacheable state switched while recalculating.\nDid the recalculation trigger the Observable?");
     222#ifdef LOG_OBSERVER
     223    observerLog().addMessage() << "## Cacheable " << observerLog().getName(this) << " changed state (" << state->getName()
     224                               << "->" << newState->getName() << ")" << std::endl;
     225#endif
    210226    state = newState;
    211227    state->enter();
     
    217233  {
    218234  public:
    219     Cacheable(Observable *_owner, boost::function<T()> _recalcMethod);
     235    Cacheable(Observable *_owner, boost::function<T()> _recalcMethod,std::string name);
    220236    virtual ~Cacheable();
    221237
     
    232248
    233249  template<typename T>
    234   Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod) :
     250  Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod, std::string name) :
     251    Observer(name),
    235252    recalcMethod(_recalcMethod)
    236253  {}
  • src/Patterns/Observer.cpp

    rc39cc4 rbdb143  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include "Observer.hpp"
    911
     
    1214
    1315#include "Helpers/Assert.hpp"
     16#include "Helpers/MemDebug.hpp"
    1417
    1518using namespace std;
     
    4346  // if no entry for this observable is found, an new one is created
    4447  // by the STL and initialized to 0 (see STL documentation)
     48#ifdef LOG_OBSERVER
     49  observerLog().addMessage(depth[publisher]) << ">> Locking " << observerLog().getName(publisher) << endl;
     50#endif
    4551  depth[publisher]++;
    4652}
     
    6066  // if zero is reached all observed blocks are done and we can
    6167  // start to notify our observers
    62   if(--(depth[publisher])){}
     68  --depth[publisher];
     69#ifdef LOG_OBSERVER
     70  observerLog().addMessage(depth[publisher]) << "<< Unlocking " << observerLog().getName(publisher) << endl;
     71#endif
     72  if(depth[publisher]){}
    6373  else{
    6474    publisher->notifyAll();
     
    8292Observable::_Observable_protector::_Observable_protector(Observable *_protege) :
    8393  protege(_protege)
     94{
     95  start_observer_internal(protege);
     96}
     97
     98Observable::_Observable_protector::_Observable_protector(const _Observable_protector &dest) :
     99    protege(dest.protege)
    84100{
    85101  start_observer_internal(protege);
     
    117133      callees_t::iterator iter;
    118134      for(iter=callees.begin();iter!=callees.end();++iter){
     135#ifdef LOG_OBSERVER
     136        observerLog().addMessage() << "-> Sending update from " << observerLog().getName(this)
     137                                   << " to " << observerLog().getName((*iter).second)
     138                                   << " (priority=" << (*iter).first << ")"<< endl;
     139#endif
    119140        (*iter).second->update(this);
    120141      }
     
    159180    // we do not need to publish all the changes at each time we are called
    160181    if(depth.find(this)==depth.end()) {
     182#ifdef LOG_OBSERVER
     183      observerLog().addMessage() << "-* Update from " << observerLog().getName(publisher)
     184                                 << " propagated by " << observerLog().getName(this) << endl;
     185#endif
    161186      notifyAll();
     187    }
     188    else{
     189#ifdef LOG_OBSERVER
     190      observerLog().addMessage() << "-| Update from " <<  observerLog().getName(publisher)
     191                                 << " not propagated by " << observerLog().getName(this) << endl;
     192#endif
    162193    }
    163194  }
     
    171202void Observable::signOn(Observer *target,int priority) {
    172203  ASSERT(priority>=-20 && priority<=+20, "Priority out of range [-20:+20] when signing on Observer");
     204#ifdef LOG_OBSERVER
     205  observerLog().addMessage() << "@@ Signing on " << observerLog().getName(target) << " to " << observerLog().getName(this) << endl;
     206#endif
    173207  bool res = false;
    174208  callees_t &callees = callTable[this];
     
    188222void Observable::signOff(Observer *target) {
    189223  ASSERT(callTable.count(this),"SignOff called for an Observable without Observers.");
     224#ifdef LOG_OBSERVER
     225  observerLog().addMessage() << "** Signing off " << observerLog().getName(target) << " from " << observerLog().getName(this) << endl;
     226#endif
    190227  callees_t &callees = callTable[this];
     228
    191229  callees_t::iterator iter;
    192230  callees_t::iterator deliter;
     
    231269/** Constructor for class Observable.
    232270 */
    233 Observable::Observable()
    234 {}
     271Observable::Observable(string name) :
     272  Observer(Observer::BaseConstructor())
     273{
     274#ifdef LOG_OBSERVER
     275  observerLog().addName(this,name);
     276  observerLog().addMessage() << "++ Creating Observable " << observerLog().getName(this) << endl;
     277#endif
     278}
    235279
    236280/** Destructor for class Observable.
     
    239283Observable::~Observable()
    240284{
     285#ifdef LOG_OBSERVER
     286  observerLog().addMessage() << "-- Destroying Observable " << observerLog().getName(this) << endl;
     287#endif
    241288  if(callTable.count(this)) {
    242289    // delete all entries for this observable
     
    252299/** Constructor for class Observer.
    253300 */
    254 Observer::Observer()
    255 {}
     301Observer::Observer(string name)
     302{
     303#ifdef LOG_OBSERVER
     304  observerLog().addName(this,name);
     305  observerLog().addMessage() << "++ Creating Observer " << observerLog().getName(this) << endl;
     306#endif
     307}
     308
     309/**
     310 * Base Constructor for class Observer
     311 *
     312 * only called from Observable Constructor
     313 */
     314Observer::Observer(Observer::BaseConstructor){
     315#ifdef LOG_OBSERVER
     316  observerLog().addObservable(this);
     317#endif
     318}
    256319
    257320/** Destructor for class Observer.
    258321 */
    259322Observer::~Observer()
    260 {}
     323{
     324#ifdef LOG_OBSERVER
     325  if(!observerLog().isObservable(this)){
     326    observerLog().addMessage() << "-- Destroying Observer " << observerLog().getName(this) << endl;
     327  }
     328#endif
     329}
    261330
    262331/**
     
    289358  }
    290359}
     360
     361#ifdef LOG_OBSERVER
     362
     363/************************* Methods to do logging of the Observer Mechanism *********/
     364
     365// The log needs to exist fairly early, so we make it construct on first use,
     366// and never destroy it
     367ObserverLog &observerLog(){
     368  // yes, this memory is never freed... we need it around for the whole programm,
     369  // so no freeing is possible
     370  static ObserverLog *theLog = Memory::ignore(new ObserverLog());
     371  return *theLog;
     372}
     373
     374
     375ObserverLog::ObserverLog() :
     376  count (0)
     377{}
     378
     379ObserverLog::~ObserverLog(){}
     380
     381string ObserverLog::getLog(){return log.str();}
     382
     383std::string ObserverLog::getName(void* obj){
     384  return names[obj];
     385}
     386
     387bool ObserverLog::isObservable(void* obj){
     388  return observables.count(obj);
     389}
     390
     391void ObserverLog::addName(void* obj , string name){
     392  stringstream sstr;
     393  sstr << name << "_" << count++;
     394  names[obj] = sstr.str();
     395}
     396
     397void ObserverLog::addObservable(void* obj){
     398  observables.insert(obj);
     399}
     400
     401void ObserverLog::deleteName(void* obj){
     402  names.erase(obj);
     403}
     404
     405void ObserverLog::deleteObservable(void* obj){
     406  observables.erase(obj);
     407}
     408
     409stringstream &ObserverLog::addMessage(int depth){
     410  for(int i=depth;i--;)
     411    log << "  ";
     412  return log;
     413}
     414
     415#endif
  • src/Patterns/Observer.hpp

    rc39cc4 rbdb143  
    1111#include <map>
    1212#include <set>
     13#include <string>
     14#include <sstream>
    1315
    1416/**
     
    2830 */
    2931
     32// Deactivate any logging when we are not in debug mode
     33#ifdef NDEBUG
     34#undef LOG_OBSERVER
     35#endif
     36
    3037class Observable;
    3138class Notification;
     
    3542// identification process
    3643typedef Notification *const Notification_ptr;
     44
     45template<class _Set>
     46class ObservedIterator;
    3747
    3848/**
     
    5363  friend class Observable;
    5464  friend class Notification;
    55 public:
    56   Observer();
     65  template<class> friend class ObservedIterator;
     66
     67  // indicates the constructor called from Observables
     68  struct BaseConstructor{};
     69
     70public:
     71  Observer(BaseConstructor);
     72  Observer(std::string);
    5773  virtual ~Observer();
    5874
     
    86102class Observable : public Observer {
    87103public:
    88   Observable();
     104  Observable(std::string _name);
    89105  virtual ~Observable();
    90106
     
    152168  static std::set<Observable*> busyObservables;
    153169
    154 
    155170  //! @cond
    156171  // Structure for RAII-Style notification
     
    164179  public:
    165180    _Observable_protector(Observable *);
     181    _Observable_protector(const _Observable_protector&);
    166182    ~_Observable_protector();
    167183  private:
     
    187203};
    188204
     205#ifdef LOG_OBSERVER
     206
     207/**
     208 * This class is used to log the working of the observer mechanism
     209 *
     210 * TODO: make this conditional dependent on compiler Flag.
     211 */
     212class ObserverLog{
     213  friend class Observable;
     214  friend class Observer;
     215  template <typename> friend class Cacheable;
     216public:
     217  ObserverLog();
     218  ~ObserverLog();
     219  std::string getLog();                        // get everything that has been logged
     220  std::string getName(void*);                  // get the name of an actor
     221  bool isObservable(void*);
     222private:
     223  int count;                                   // number to reference each actor in this framework
     224  std::map<void*,std::string> names;           // List of names assigned to actors
     225  std::set<void*> observables;                 // List of pointers to Observables. Needed to distinguish Observers and Observables
     226  void addName(void*, std::string);            // Assign a name to an Actor
     227  void addObservable(void*);
     228  void deleteName(void*);                      // delete the name of an Actor
     229  void deleteObservable(void*);
     230  std::stringstream &addMessage(int depth=0);  // Add a Message to the logging
     231  std::stringstream log;                       // The internal log object
     232};
     233
     234ObserverLog &observerLog();
     235
     236#endif
     237
    189238// extra macro is necessary to work with __LINE__
    190239#define PASTE(a,b) PASTE_HELPER(a,b)
  • src/Patterns/Singleton.hpp

    rc39cc4 rbdb143  
    99#define SINGLETON_HPP_
    1010
    11 #include <cassert>
    1211#include <boost/thread.hpp>
    1312
     13#include "Helpers/Assert.hpp"
    1414#include "defs.hpp"
    1515
     
    181181
    182182    inline static void set(creator_T*&,creator_T*){
    183       assert(0 && "Cannot set the Instance for a singleton of this type");
     183      ASSERT(0, "Cannot set the Instance for a singleton of this type");
    184184    }
    185185  };
     
    191191  struct creator_t<creator_T,false>{
    192192    inline static creator_T* make(){
    193       assert(0 && "Cannot create a singleton of this type directly");
     193      ASSERT(0, "Cannot create a singleton of this type directly");
     194      return 0;
    194195    }
    195196    inline static void set(ptr_t& dest,creator_T* src){
  • src/Patterns/Singleton_impl.hpp

    rc39cc4 rbdb143  
    7272template <class T,bool _may_create>
    7373void Singleton<T,_may_create>::setInstance(T* newInstance){
    74   assert(!theInstance.get() && "Trying to set the instance of an already created singleton");
     74  ASSERT(!theInstance.get(), "Trying to set the instance of an already created singleton");
    7575  boost::recursive_mutex::scoped_lock guard(instanceLock);
    7676  theInstance.reset(newInstance);
     
    8383template <class T, bool _may_create>
    8484Singleton<T,_may_create>::Singleton(const Singleton<T,_may_create>&){
    85   assert(0 && "Copy constructor of singleton template called");
     85  ASSERT(0, "Copy constructor of singleton template called");
    8686}
    8787
  • src/Plane.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "Plane.hpp"
  • src/Space.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "Space.hpp"
  • src/UIElements/Dialog.cpp

    rc39cc4 rbdb143  
    66 */
    77
    8 #include <cassert>
    9 
    10 #include "UIElements/Dialog.hpp"
    11 
     8#include "Helpers/MemDebug.hpp"
     9
     10#include "Dialog.hpp"
     11
     12#include "atom.hpp"
     13#include "element.hpp"
     14#include "molecule.hpp"
    1215#include "vector.hpp"
    1316
     
    3134
    3235bool Dialog::display(){
     36  if(checkAll()){
     37    setAll();
     38    return true;
     39  }
     40  else{
     41    return false;
     42  }
     43}
     44
     45bool Dialog::checkAll(){
    3346  list<Query*>::iterator iter;
    3447  bool retval = true;
     
    3649    retval &= (*iter)->handle();
    3750    // if any query fails (is canceled), we can end the handling process
    38     if(!retval)
     51    if(!retval) {
     52      DoeLog(1) && (eLog() << Verbose(1) << "The following query failed: " << (**iter).getTitle() << "." << endl);
    3953      break;
    40   }
    41   if (retval){
    42     // if all queries succeeded we can set the targets to appropriate values
    43     for(iter=queries.begin(); iter!=queries.end(); iter++) {
    44       (*iter)->setResult();
    4554    }
    4655  }
     
    4857}
    4958
     59void Dialog::setAll(){
     60  list<Query*>::iterator iter;
     61  for(iter=queries.begin(); iter!=queries.end(); iter++) {
     62    (*iter)->setResult();
     63  }
     64}
     65
    5066/****************** Query types Infrastructure **************************/
    5167
    5268// Base class
    53 Dialog::Query::Query(string _title) :
    54     title(_title)
     69Dialog::Query::Query(string _title, string _description) :
     70    title(_title),
     71    description(_description)
    5572{}
    5673
     
    6178}
    6279
     80const std::string Dialog::Query::getDescription() const{
     81  return description;
     82}
     83// empty Queries
     84
     85Dialog::EmptyQuery::EmptyQuery(string title, std::string description) :
     86    Query(title, description)
     87{}
     88
     89Dialog::EmptyQuery::~EmptyQuery() {}
     90
     91void Dialog::EmptyQuery::setResult() {
     92}
     93
    6394// Int Queries
    6495
    65 Dialog::IntQuery::IntQuery(string title,int *_target) :
    66     Query(title), target(_target)
     96Dialog::IntQuery::IntQuery(string title,int *_target, std::string description) :
     97    Query(title, description), target(_target)
    6798{}
    6899
     
    73104}
    74105
     106// Int Queries
     107
     108Dialog::BooleanQuery::BooleanQuery(string title,bool *_target, std::string description) :
     109    Query(title, description), target(_target)
     110{}
     111
     112Dialog::BooleanQuery::~BooleanQuery() {}
     113
     114void Dialog::BooleanQuery::setResult() {
     115  *target = tmp;
     116}
     117
    75118// String Queries
    76119
    77 Dialog::StringQuery::StringQuery(string title,string *_target) :
    78     Query(title), target(_target)
     120Dialog::StringQuery::StringQuery(string title,string *_target, std::string _description) :
     121    Query(title, _description), target(_target)
    79122{}
    80123
     
    87130// Double Queries
    88131
    89 Dialog::DoubleQuery::DoubleQuery(string title,double *_target) :
    90     Query(title), target(_target)
     132Dialog::DoubleQuery::DoubleQuery(string title,double *_target, std::string _description) :
     133    Query(title, _description), target(_target)
    91134{}
    92135
     
    98141
    99142
     143// Atom Queries
     144
     145Dialog::AtomQuery::AtomQuery(string title, atom **_target, std::string _description) :
     146    Query(title, _description),
     147    tmp(0),
     148    target(_target)
     149
     150{}
     151
     152Dialog::AtomQuery::~AtomQuery() {}
     153
     154void Dialog::AtomQuery::setResult() {
     155  *target = tmp;
     156}
     157
    100158// Molecule Queries
    101159
    102 Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target, MoleculeListClass *_molecules) :
    103     Query(title),
     160Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target, std::string _description) :
     161    Query(title, _description),
    104162    tmp(0),
    105     molecules(_molecules),
    106163    target(_target)
    107164
     
    116173// Vector Queries
    117174
    118 Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check) :
    119   Query(title),
     175Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description) :
     176  Query(title, _description),
    120177  cellSize(_cellSize),
    121178  check(_check),
    122179  target(_target)
    123180{
    124 tmp = new Vector();
     181  tmp = new Vector();
    125182}
    126183
     
    134191}
    135192
     193// Box Queries
     194
     195Dialog::BoxQuery::BoxQuery(std::string title, double ** const _cellSize, std::string _description) :
     196  Query(title, _description),
     197  target(_cellSize)
     198{
     199    tmp = new double[6];
     200}
     201
     202Dialog::BoxQuery::~BoxQuery()
     203{
     204  delete[] tmp;
     205}
     206
     207void Dialog::BoxQuery::setResult() {
     208  for (int i=0;i<6;i++) {
     209    (*target)[i] = tmp[i];
     210  }
     211}
     212
    136213// Element Queries
    137 Dialog::ElementQuery::ElementQuery(std::string title, const element **_target) :
    138   Query(title),
    139   tmp(0),
     214Dialog::ElementQuery::ElementQuery(std::string title, std::vector<element *> *_target, std::string _description) :
     215  Query(title, _description),
    140216  target(_target)
    141217  {}
     
    144220
    145221void Dialog::ElementQuery::setResult(){
    146   *target=tmp;
    147 }
     222  *target=elements;
     223}
  • src/UIElements/Dialog.hpp

    rc39cc4 rbdb143  
    1111#include<string>
    1212#include<list>
     13#include<vector>
    1314
    14 class MoleculeListClass;
     15class atom;
     16class element;
    1517class molecule;
    1618class Vector;
    17 class element;
    1819
    1920class Dialog
     
    2324  virtual ~Dialog();
    2425
    25   virtual void queryInt(const char *, int *)=0;
    26   virtual void queryDouble(const char*,double *)=0;
    27   virtual void queryString(const char*, std::string *)=0;
    28   virtual void queryMolecule(const char*,molecule**,MoleculeListClass*)=0;
    29   virtual void queryVector(const char*,Vector *,const double *const,bool)=0;
    30   virtual void queryElement(const char*,const element **)=0;
     26  virtual void queryEmpty(const char *, std::string = "")=0;
     27  virtual void queryBoolean(const char *, bool *, std::string = "")=0;
     28  virtual void queryInt(const char *, int *, std::string = "")=0;
     29  virtual void queryDouble(const char*,double *, std::string = "")=0;
     30  virtual void queryString(const char*, std::string *, std::string = "")=0;
     31  virtual void queryAtom(const char*,atom**,std::string = "")=0;
     32  virtual void queryMolecule(const char*,molecule**, std::string = "")=0;
     33  virtual void queryVector(const char*,Vector *,const double *const,bool, std::string = "")=0;
     34  virtual void queryBox(const char*,double ** const, std::string = "")=0;
     35  virtual void queryElement(const char*, std::vector<element *> *, std::string = "")=0;
    3136
    3237  virtual bool display();
     38
     39  virtual bool checkAll();
     40  virtual void setAll();
    3341
    3442protected:
     
    4553  //base class for all queries
    4654  class Query {
     55    friend class Dialog;
    4756  public:
    48     Query(std::string _title);
     57    Query(std::string _title, std::string _description = "");
    4958    virtual ~Query();
    5059    virtual bool handle()=0;
     
    5261  protected:
    5362    const std::string getTitle() const;
     63    const std::string getDescription() const;
    5464  private:
    55     std::string title;
     65    std::string title;  //!< short title of the query
     66    std::string description; //!< longer description for tooltips or for help
     67  };
     68
     69  // Empty Query is just meant for showing text, such as version, help, initial message or alike
     70  class EmptyQuery : public Query {
     71  public:
     72    EmptyQuery(std::string title, std::string _description = "");
     73    virtual ~EmptyQuery();
     74    virtual bool handle()=0;
     75    virtual void setResult();
    5676  };
    5777
    5878  //Specialized classes for certain types. GUI-Types are not specialized at this time
     79  class BooleanQuery : public Query {
     80  public:
     81    BooleanQuery(std::string title,bool *_target, std::string _description = "");
     82    virtual ~BooleanQuery();
     83    virtual bool handle()=0;
     84    virtual void setResult();
     85  protected:
     86    bool tmp;
     87  private:
     88    bool *target;
     89  };
     90
    5991  class IntQuery : public Query {
    6092  public:
    61     IntQuery(std::string title,int *_target);
     93    IntQuery(std::string title,int *_target, std::string _description = "");
    6294    virtual ~IntQuery();
    6395    virtual bool handle()=0;
     
    71103  class DoubleQuery : public Query {
    72104  public:
    73     DoubleQuery(std::string title,double *_target);
     105    DoubleQuery(std::string title,double *_target, std::string _description = "");
    74106    virtual ~DoubleQuery();
    75107    virtual bool handle()=0;
     
    83115  class StringQuery : public Query {
    84116  public:
    85     StringQuery(std::string title,std::string *_target);
     117    StringQuery(std::string title,std::string *_target, std::string _description = "");
    86118    virtual ~StringQuery();
    87119    virtual bool handle()=0;
     
    93125  };
    94126
    95 
    96127  class MoleculeQuery : public Query {
    97128  public:
    98     MoleculeQuery(std::string title, molecule **_target, MoleculeListClass *_molecules);
     129    MoleculeQuery(std::string title, molecule **_target, std::string _description = "");
    99130    virtual ~MoleculeQuery();
    100131    virtual bool handle()=0;
     
    102133  protected:
    103134    molecule *tmp;
    104     MoleculeListClass *molecules;
    105135  private:
    106136    molecule **target;
    107137  };
    108138
     139  class AtomQuery : public Query {
     140  public:
     141    AtomQuery(std::string title, atom **_target, std::string _description = "");
     142    virtual ~AtomQuery();
     143    virtual bool handle()=0;
     144    virtual void setResult();
     145  protected:
     146    atom *tmp;
     147  private:
     148    atom **target;
     149  };
     150
    109151  class VectorQuery : public Query {
    110152  public:
    111       VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check);
     153      VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description = "");
    112154      virtual ~VectorQuery();
    113155      virtual bool handle()=0;
     
    121163  };
    122164
     165  class BoxQuery : public Query {
     166  public:
     167      BoxQuery(std::string title,double ** const _cellSize, std::string _description = "");
     168      virtual ~BoxQuery();
     169      virtual bool handle()=0;
     170      virtual void setResult();
     171    protected:
     172      double *tmp;
     173    private:
     174      double **target;
     175  };
     176
    123177  class ElementQuery : public Query {
    124178  public:
    125     ElementQuery(std::string title, const element**_target);
     179    ElementQuery(std::string title, std::vector<element *> *_target, std::string _description = "");
    126180    virtual ~ElementQuery();
    127181    virtual bool handle()=0;
    128182    virtual void setResult();
    129183  protected:
    130     const element *tmp;
     184    std::vector<element *> elements;
    131185  private:
    132     const element **target;
     186    std::vector<element *> * const target;
    133187  };
    134188
     
    140194};
    141195
     196
    142197#endif /* DIALOG_HPP_ */
  • src/UIElements/MainWindow.cpp

    rc39cc4 rbdb143  
    66 */
    77
    8 #include "UIElements/MainWindow.hpp"
     8#include "Helpers/MemDebug.hpp"
     9
     10#include "MainWindow.hpp"
    911
    1012MainWindow::MainWindow()
    11 {
    12   // TODO Auto-generated constructor stub
    13 
    14 }
     13{}
    1514
    1615MainWindow::~MainWindow()
    17 {
    18   // TODO Auto-generated destructor stub
    19 }
     16{}
  • src/UIElements/MainWindow.hpp

    rc39cc4 rbdb143  
    2525};
    2626
    27 /**
    28  * The type of menuPopulators
    29  */
    30 typedef void (*MenuMaker)(Menu*,MoleculeListClass*, config*, periodentafel*);
    31 
    32 /**
    33  * This contains all Functions that are used to create the menus.
    34  * Needs a specific funtion for each menu. All populators will be called
    35  * by the UIFactory upon creation of the main menu. Thus the actuall construction
    36  * of the Menus can be kept independent of the concrete type of UI that is being
    37  * built.
    38  */
    39 struct menuPopulaters{
    40   MenuMaker MakeEditMoleculesMenu;
    41 };
    4227
    4328#endif /* MAINWINDOW_HPP_ */
  • src/UIElements/UIFactory.cpp

    rc39cc4 rbdb143  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
    89
    9 #include <cassert>
     10#include <utility>
    1011#include "Patterns/Singleton_impl.hpp"
    1112#include "UIElements/UIFactory.hpp"
     13#include "Helpers/Assert.hpp"
     14#include "Helpers/MemDebug.hpp"
    1215
    13 // all factories that can be used:
    14 #include "UIElements/TextUIFactory.hpp"
     16using namespace std;
     17
     18std::map<std::string,boost::shared_ptr<UIFactory::factoryDescription> > UIFactory::factories;
    1519
    1620UIFactory::UIFactory()
    17 {
    18   // TODO Auto-generated constructor stub
     21{}
    1922
     23UIFactory::~UIFactory()
     24{}
     25
     26void UIFactory::makeUserInterface(std::string type) {
     27  ASSERT(factories.count(type),"Selected factory was not registered before creation.");
     28  // call the factory factory
     29  setInstance(factories[type]->makeFactory());
    2030}
    2131
    22 UIFactory::~UIFactory()
    23 {
    24   // TODO Auto-generated destructor stub
    25 }
    26 
    27 void UIFactory::makeUserInterface(InterfaceTypes type) {
    28   switch(type) {
    29     case Text :
    30       setInstance(new TextUIFactory());
    31       break;
    32 
    33     default:
    34       assert(0 && "No such Factory in stock");
    35       break;
    36   }
     32void UIFactory::registerFactory(factoryDescription *factoryDesc) {
     33  ASSERT(!factories.count(factoryDesc->name),"Trying to re-register an already registered factory.");
     34  factories.insert(make_pair(factoryDesc->name,
     35                             boost::shared_ptr<factoryDescription>(factoryDesc)));
    3736}
    3837
    3938CONSTRUCT_SINGLETON(UIFactory)
     39
     40UIFactory::factoryDescription::factoryDescription(string _name) :
     41  name(_name)
     42{}
     43
     44UIFactory::factoryDescription::~factoryDescription()
     45{}
  • src/UIElements/UIFactory.hpp

    rc39cc4 rbdb143  
    1111class MainWindow;
    1212class Dialog;
    13 
    14 class MoleculeListClass;
    15 class config;
    16 class periodentafel;
    17 
    18 struct menuPopulaters;
     13class DialogDescription;
    1914
    2015#include "Patterns/Singleton.hpp"
     16
     17#include <string>
     18#include <map>
     19#include <boost/smart_ptr.hpp>
    2120
    2221/**
     
    2928class UIFactory : public Singleton<UIFactory,false>
    3029{
    31 
     30  friend class Singleton<UIFactory,false>;
    3231public:
    33   enum InterfaceTypes {Text};
    34   virtual ~UIFactory();
    3532
    3633  /**
    3734   * Produce some kind of main window, of whichever type was chosen when the factory was created
    3835   */
    39   virtual MainWindow* makeMainWindow(menuPopulaters,MoleculeListClass *, config *, periodentafel *, char *)=0;
     36  virtual MainWindow* makeMainWindow()=0;
    4037
    4138  /**
     
    4744protected:
    4845  UIFactory();
     46  virtual ~UIFactory();
    4947
    5048public:
     49  struct factoryDescription {
     50    factoryDescription(std::string _name);
     51    virtual ~factoryDescription();
     52
     53    const std::string name;
     54    // yes this method really is a factory factory, to allow insertion of
     55    // arbitrary factories
     56    virtual UIFactory* makeFactory()=0;
     57  };
    5158  /**
    5259   * create a Factory of a certain type. From that moment on only those UIElements can be produced by the factory
    5360   */
    54   static void makeUserInterface(InterfaceTypes type);
    55 
     61  static void makeUserInterface(std::string type);
     62  static void registerFactory(factoryDescription *factoryDesc);
     63protected:
     64private:
     65  static std::map<std::string,boost::shared_ptr<factoryDescription> > factories;
    5666};
    5767
  • src/World.cpp

    rc39cc4 rbdb143  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include "World.hpp"
    911
    1012#include "atom.hpp"
     13#include "config.hpp"
    1114#include "molecule.hpp"
    1215#include "periodentafel.hpp"
     16#include "ThermoStatContainer.hpp"
    1317#include "Descriptors/AtomDescriptor.hpp"
    1418#include "Descriptors/AtomDescriptor_impl.hpp"
     
    1721#include "Descriptors/SelectiveIterator_impl.hpp"
    1822#include "Actions/ManipulateAtomsProcess.hpp"
     23#include "Helpers/Assert.hpp"
    1924
    2025#include "Patterns/Singleton_impl.hpp"
     
    2732}
    2833
     34config *&World::getConfig(){
     35  return configuration;
     36}
     37
    2938// Atoms
    3039
     
    5564}
    5665
     66std::vector<molecule*> World::getAllMolecules(){
     67  return getAllMolecules(AllMolecules());
     68}
     69
    5770int World::numMolecules(){
    5871  return molecules_deprecated->ListOfMolecules.size();
     
    7083}
    7184
    72 char * World::getDefaultName() {
     85std::string World::getDefaultName() {
    7386  return defaultName;
    7487}
    7588
    76 void World::setDefaultName(char * name)
    77 {
    78   delete[](defaultName);
    79   const int length = strlen(name);
    80   defaultName = new char[length+2];
    81   if (length < MAXSTRINGSIZE)
    82     strncpy(defaultName, name, length);
    83   else
    84     strcpy(defaultName, "none");
     89void World::setDefaultName(std::string name)
     90{
     91  defaultName = name;
    8592};
    8693
     94class ThermoStatContainer * World::getThermostats()
     95{
     96  return Thermostats;
     97}
     98
     99
     100int World::getExitFlag() {
     101  return ExitFlag;
     102}
     103
     104void World::setExitFlag(int flag) {
     105  if (ExitFlag < flag)
     106    ExitFlag = flag;
     107}
    87108
    88109/******************** Methods to change World state *********************/
     
    92113  molecule *mol = NULL;
    93114  mol = NewMolecule();
    94   assert(!molecules.count(currMoleculeId));
     115  ASSERT(!molecules.count(currMoleculeId),"currMoleculeId did not specify an unused ID");
    95116  mol->setId(currMoleculeId++);
    96117  // store the molecule by ID
     
    108129  OBSERVE;
    109130  molecule *mol = molecules[id];
    110   assert(mol);
     131  ASSERT(mol,"Molecule id that was meant to be destroyed did not exist");
    111132  DeleteMolecule(mol);
    112133  molecules.erase(id);
     
    114135
    115136double *World::cell_size = NULL;
    116 char *World::defaultName = NULL;
    117137
    118138atom *World::createAtom(){
     
    145165  OBSERVE;
    146166  atom *atom = atoms[id];
    147   assert(atom);
     167  ASSERT(atom,"Atom ID that was meant to be destroyed did not exist");
    148168  DeleteAtom(atom);
    149169  atoms.erase(id);
     
    157177  if(!target){
    158178    target = atoms[oldId];
    159     assert(target && "Atom with that ID not found");
     179    ASSERT(target,"Atom with that ID not found");
    160180    return target->changeId(newId);
    161181  }
     
    266286
    267287World::World() :
     288    Observable("World"),
    268289    periode(new periodentafel),
     290    configuration(new config),
     291    Thermostats(new ThermoStatContainer),
     292    ExitFlag(0),
    269293    atoms(),
    270294    currAtomId(0),
     
    280304  cell_size[4] = 0.;
    281305  cell_size[5] = 20.;
    282   defaultName = new char[MAXSTRINGSIZE];
    283   strcpy(defaultName, "none");
     306  defaultName = "none";
    284307  molecules_deprecated->signOn(this);
    285308}
     
    289312  molecules_deprecated->signOff(this);
    290313  delete[] cell_size;
    291   delete[] defaultName;
    292314  delete molecules_deprecated;
    293315  delete periode;
     316  delete configuration;
     317  delete Thermostats;
    294318  MoleculeSet::iterator molIter;
    295319  for(molIter=molecules.begin();molIter!=molecules.end();++molIter){
  • src/World.hpp

    rc39cc4 rbdb143  
    3030
    3131// forward declarations
    32 class periodentafel;
    33 class MoleculeListClass;
    3432class atom;
    35 class molecule;
    3633class AtomDescriptor;
    3734class AtomDescriptor_impl;
     35template<typename T> class AtomsCalculation;
     36class config;
     37class ManipulateAtomsProcess;
     38class molecule;
    3839class MoleculeDescriptor;
    3940class MoleculeDescriptor_impl;
    40 class ManipulateAtomsProcess;
    41 template<typename T>
    42 class AtomsCalculation;
     41class MoleculeListClass;
     42class periodentafel;
     43class ThermoStatContainer;
    4344
    4445/****************************************** forward declarations *****************************/
     
    7576
    7677  /**
     78   * returns the configuration for the world.
     79   */
     80  config *&getConfig();
     81
     82  /**
    7783   * returns the first atom that matches a given descriptor.
    7884   * Do not rely on ordering for descriptors that match more than one atom.
     
    109115   */
    110116  std::vector<molecule*> getAllMolecules(MoleculeDescriptor descriptor);
     117  std::vector<molecule*> getAllMolecules();
    111118
    112119  /**
     
    128135   * get the default name
    129136   */
    130   char * getDefaultName();
     137  std::string getDefaultName();
    131138
    132139  /**
    133140   * set the default name
    134141   */
    135   void setDefaultName(char * name);
     142  void setDefaultName(std::string name);
     143
     144  /**
     145   * get pointer to World's ThermoStatContainer
     146   */
     147  ThermoStatContainer * getThermostats();
     148
     149  /*
     150   * get the ExitFlag
     151   */
     152  int getExitFlag();
     153
     154  /*
     155   * set the ExitFlag
     156   */
     157  void setExitFlag(int flag);
    136158
    137159  /***** Methods to work with the World *****/
     
    234256
    235257  periodentafel *periode;
     258  config *configuration;
    236259  static double *cell_size;
    237   static char *defaultName;
     260  std::string defaultName;
     261  class ThermoStatContainer *Thermostats;
     262  int ExitFlag;
    238263public:
    239264  AtomSet atoms;
  • src/analysis_bonds.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "analysis_bonds.hpp"
     
    2628  Mean = 0.;
    2729
    28   atom *Walker = mol->start;
    2930  int AtomCount = 0;
    30   while (Walker->next != mol->end) {
    31     Walker = Walker->next;
    32     const int count = Walker->ListOfBonds.size();
     31  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     32    const int count = (*iter)->ListOfBonds.size();
    3333    if (Max < count)
    3434      Max = count;
     
    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;
     
    5858
    5959  int AtomNo = 0;
    60   atom *Walker = mol->start;
    61   while (Walker->next != mol->end) {
    62     Walker = Walker->next;
    63     if (Walker->type == type1)
    64       for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++)
    65         if ((*BondRunner)->GetOtherAtom(Walker)->type == type2) {
     60  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     61    if ((*iter)->type == type1)
     62      for (BondList::const_iterator BondRunner = (*iter)->ListOfBonds.begin(); BondRunner != (*iter)->ListOfBonds.end(); BondRunner++)
     63        if ((*BondRunner)->GetOtherAtom((*iter))->type == type2) {
    6664          const double distance = (*BondRunner)->GetDistanceSquared();
    6765          if (Min > distance)
     
    127125int CountHydrogenBridgeBonds(MoleculeListClass *molecules, const element * InterfaceElement = NULL, const element * Interface2Element = NULL)
    128126{
    129   atom *Walker = NULL;
    130   atom *Runner = NULL;
    131127  int count = 0;
    132128  int OtherHydrogens = 0;
     
    135131  bool Interface2Flag = false;
    136132  bool OtherHydrogenFlag = true;
    137   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
    138     Walker = (*MolWalker)->start;
    139     while (Walker->next != (*MolWalker)->end) {
    140       Walker = Walker->next;
    141       for (MoleculeList::const_iterator MolRunner = molecules->ListOfMolecules.begin();MolRunner != molecules->ListOfMolecules.end(); MolRunner++) {
    142         Runner = (*MolRunner)->start;
    143         while (Runner->next != (*MolRunner)->end) {
    144           Runner = Runner->next;
    145           if ((Walker->type->Z  == 8) && (Runner->type->Z  == 8)) {
     133  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); ++MolWalker) {
     134    molecule::iterator Walker = (*MolWalker)->begin();
     135    for(;Walker!=(*MolWalker)->end();++Walker){
     136      for (MoleculeList::const_iterator MolRunner = molecules->ListOfMolecules.begin();MolRunner != molecules->ListOfMolecules.end(); ++MolRunner) {
     137        molecule::iterator Runner = (*MolRunner)->begin();
     138        for(;Runner!=(*MolRunner)->end();++Runner){
     139          if (((*Walker)->type->Z  == 8) && ((*Runner)->type->Z  == 8)) {
    146140            // check distance
    147             const double distance = Runner->x.DistanceSquared(Walker->x);
     141            const double distance = (*Runner)->x.DistanceSquared((*Walker)->x);
    148142            if ((distance > MYEPSILON) && (distance < HBRIDGEDISTANCE*HBRIDGEDISTANCE)) { // distance >0 means  different atoms
    149143              // on other atom(Runner) we check for bond to interface element and
     
    154148              InterfaceFlag = (InterfaceElement == NULL);
    155149              Interface2Flag = (Interface2Element == NULL);
    156               for (BondList::const_iterator BondRunner = Runner->ListOfBonds.begin(); BondRunner != Runner->ListOfBonds.end(); BondRunner++) {
    157                 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Runner);
     150              for (BondList::const_iterator BondRunner = (*Runner)->ListOfBonds.begin(); BondRunner != (*Runner)->ListOfBonds.end(); BondRunner++) {
     151                atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Runner);
    158152                // if hydrogen, check angle to be greater(!) than 30 degrees
    159153                if (OtherAtom->type->Z == 1) {
    160                   const double angle = CalculateAngle(&OtherAtom->x, &Runner->x, &Walker->x);
     154                  const double angle = CalculateAngle(&OtherAtom->x, &(*Runner)->x, &(*Walker)->x);
    161155                  OtherHydrogenFlag = OtherHydrogenFlag && (angle > M_PI*(30./180.) + MYEPSILON);
    162156                  Otherangle += angle;
     
    180174              if (InterfaceFlag && Interface2Flag && OtherHydrogenFlag) {
    181175                // on this element (Walker) we check for bond to hydrogen, i.e. part of water molecule
    182                 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {
    183                   atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
     176                for (BondList::const_iterator BondRunner = (*Walker)->ListOfBonds.begin(); BondRunner != (*Walker)->ListOfBonds.end(); BondRunner++) {
     177                  atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Walker);
    184178                  if (OtherAtom->type->Z == 1) {
    185179                    // check angle
    186                     if (CheckHydrogenBridgeBondAngle(Walker, OtherAtom, Runner)) {
    187                       DoLog(1) && (Log() << Verbose(1) << Walker->getName() << ", " << OtherAtom->getName() << " and " << Runner->getName() << " has a hydrogen bridge bond with distance " << sqrt(distance) << " and angle " << CalculateAngle(&OtherAtom->x, &Walker->x, &Runner->x)*(180./M_PI) << "." << endl);
     180                    if (CheckHydrogenBridgeBondAngle(*Walker, OtherAtom, *Runner)) {
     181                      DoLog(1) && (Log() << Verbose(1) << (*Walker)->getName() << ", " << OtherAtom->getName() << " and " << (*Runner)->getName() << " has a hydrogen bridge bond with distance " << sqrt(distance) << " and angle " << CalculateAngle(&OtherAtom->x, &(*Walker)->x, &(*Runner)->x)*(180./M_PI) << "." << endl);
    188182                      count++;
    189183                      break;
     
    209203int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second)
    210204{
    211   atom *Walker = NULL;
    212205  int count = 0;
    213206
    214207  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
    215     Walker = (*MolWalker)->start;
    216     while (Walker->next != (*MolWalker)->end) {
    217       Walker = Walker->next;
    218       if ((Walker->type == first) || (Walker->type == second)) {  // first element matches
    219         for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {
    220           atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
    221           if (((OtherAtom->type == first) || (OtherAtom->type == second)) && (Walker->nr < OtherAtom->nr)) {
     208    molecule::iterator Walker = (*MolWalker)->begin();
     209    for(;Walker!=(*MolWalker)->end();++Walker){
     210      atom * theAtom = *Walker;
     211      if ((theAtom->type == first) || (theAtom->type == second)) {  // first element matches
     212        for (BondList::const_iterator BondRunner = theAtom->ListOfBonds.begin(); BondRunner != theAtom->ListOfBonds.end(); BondRunner++) {
     213          atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom);
     214          if (((OtherAtom->type == first) || (OtherAtom->type == second)) && (theAtom->nr < OtherAtom->nr)) {
    222215            count++;
    223216            DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl);
     
    244237  bool MatchFlag[2];
    245238  bool result = false;
    246   atom *Walker = NULL;
    247239  const element * ElementArray[2];
    248240  ElementArray[0] = first;
     
    250242
    251243  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
    252     Walker = (*MolWalker)->start;
    253     while (Walker->next != (*MolWalker)->end) {
    254       Walker = Walker->next;
    255       if (Walker->type == second) {  // first element matches
     244    molecule::iterator Walker = (*MolWalker)->begin();
     245    for(;Walker!=(*MolWalker)->end();++Walker){
     246      atom *theAtom = *Walker;
     247      if (theAtom->type == second) {  // first element matches
    256248        for (int i=0;i<2;i++)
    257249          MatchFlag[i] = false;
    258         for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {
    259           atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
     250        for (BondList::const_iterator BondRunner = theAtom->ListOfBonds.begin(); BondRunner != theAtom->ListOfBonds.end(); BondRunner++) {
     251          atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom);
    260252          for (int i=0;i<2;i++)
    261253            if ((!MatchFlag[i]) && (OtherAtom->type == ElementArray[i])) {
  • src/analysis_bonds.hpp

    rc39cc4 rbdb143  
    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
    3535int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, const element * InterfaceElement, const element * Interface2Element);
  • src/analysis_correlation.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <iostream>
     
    2325/** Calculates the pair correlation between given elements.
    2426 * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
    25  * \param *out output stream for debugging
    26  * \param *molecules list of molecules structure
    27  * \param *type1 first element or NULL (if any element)
    28  * \param *type2 second element or NULL (if any element)
     27 * \param *molecules list of molecules structure
     28 * \param &elements vector of elements to correlate
    2929 * \return Map of doubles with values the pair of the two atoms.
    3030 */
    31 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2 )
     31PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements)
    3232{
    3333  Info FunctionInfo(__func__);
    3434  PairCorrelationMap *outmap = NULL;
    3535  double distance = 0.;
     36  double *domain = World::getInstance().getDomain();
    3637
    3738  if (molecules->ListOfMolecules.empty()) {
     
    3940    return outmap;
    4041  }
     42  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     43    (*MolWalker)->doCountAtoms();
     44
     45  // create all possible pairs of elements
     46  set <pair<element *, element *> > PairsOfElements;
     47  if (elements.size() >= 2) {
     48    for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
     49      for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
     50        if (type1 != type2) {
     51          PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );
     52          DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << endl);
     53        }
     54  } else if (elements.size() == 1) { // one to all are valid
     55    element *elemental = *elements.begin();
     56    PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) );
     57    PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) );
     58  } else { // all elements valid
     59    PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
     60  }
     61
    4162  outmap = new PairCorrelationMap;
    42   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     63  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){
    4364    if ((*MolWalker)->ActiveFlag) {
    4465      DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    45       atom *Walker = (*MolWalker)->start;
    46       while (Walker->next != (*MolWalker)->end) {
    47         Walker = Walker->next;
    48         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    49         if ((type1 == NULL) || (Walker->type == type1)) {
    50           for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
    51             if ((*MolOtherWalker)->ActiveFlag) {
    52               DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    53               atom *OtherWalker = (*MolOtherWalker)->start;
    54               while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
    55                 OtherWalker = OtherWalker->next;
    56                 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl);
    57                 if (Walker->nr < OtherWalker->nr)
    58                   if ((type2 == NULL) || (OtherWalker->type == type2)) {
    59                     distance = Walker->node->PeriodicDistance(*OtherWalker->node, World::getInstance().getDomain());
    60                     //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
    61                     outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
     66      eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
     67      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     68        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     69        for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){
     70          if ((*MolOtherWalker)->ActiveFlag) {
     71            DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
     72            for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
     73              DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
     74              if ((*iter)->getId() < (*runner)->getId()){
     75                for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
     76                  if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
     77                    distance = (*iter)->node->PeriodicDistance(*(*runner)->node,  domain);
     78                    //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
     79                    outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
    6280                  }
    6381              }
     82            }
    6483          }
    6584        }
    6685      }
    6786    }
    68 
     87  }
    6988  return outmap;
    7089};
     
    7291/** Calculates the pair correlation between given elements.
    7392 * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
    74  * \param *out output stream for debugging
    75  * \param *molecules list of molecules structure
    76  * \param *type1 first element or NULL (if any element)
    77  * \param *type2 second element or NULL (if any element)
     93 * \param *molecules list of molecules structure
     94 * \param &elements vector of elements to correlate
    7895 * \param ranges[NDIM] interval boundaries for the periodic images to scan also
    7996 * \return Map of doubles with values the pair of the two atoms.
    8097 */
    81 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2, const int ranges[NDIM] )
     98PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const int ranges[NDIM] )
    8299{
    83100  Info FunctionInfo(__func__);
     
    95112    return outmap;
    96113  }
     114  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     115    (*MolWalker)->doCountAtoms();
     116
     117  // create all possible pairs of elements
     118  set <pair<element *, element *> > PairsOfElements;
     119  if (elements.size() >= 2) {
     120    for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
     121      for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
     122        if (type1 != type2) {
     123          PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );
     124          DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << endl);
     125        }
     126  } else if (elements.size() == 1) { // one to all are valid
     127    element *elemental = *elements.begin();
     128    PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) );
     129    PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) );
     130  } else { // all elements valid
     131    PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
     132  }
     133
    97134  outmap = new PairCorrelationMap;
    98   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     135  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){
    99136    if ((*MolWalker)->ActiveFlag) {
    100137      double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
    101138      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    102139      DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    103       atom *Walker = (*MolWalker)->start;
    104       while (Walker->next != (*MolWalker)->end) {
    105         Walker = Walker->next;
    106         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    107         if ((type1 == NULL) || (Walker->type == type1)) {
    108           periodicX = *(Walker->node);
    109           periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    110           // go through every range in xyz and get distance
    111           for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
    112             for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    113               for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    114                 checkX = Vector(n[0], n[1], n[2]) + periodicX;
    115                 checkX.MatrixMultiplication(FullMatrix);
    116                 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
    117                   if ((*MolOtherWalker)->ActiveFlag) {
    118                     DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    119                     atom *OtherWalker = (*MolOtherWalker)->start;
    120                     while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
    121                       OtherWalker = OtherWalker->next;
    122                       DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl);
    123                       if (Walker->nr < OtherWalker->nr)
    124                         if ((type2 == NULL) || (OtherWalker->type == type2)) {
    125                           periodicOtherX = *(OtherWalker->node);
     140      eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
     141      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     142        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     143        periodicX = *(*iter)->node;
     144        periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
     145        // go through every range in xyz and get distance
     146        for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
     147          for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
     148            for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
     149              checkX = Vector(n[0], n[1], n[2]) + periodicX;
     150              checkX.MatrixMultiplication(FullMatrix);
     151              for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){
     152                if ((*MolOtherWalker)->ActiveFlag) {
     153                  DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
     154                  for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
     155                    DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
     156                    if ((*iter)->getId() < (*runner)->getId()){
     157                      for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
     158                        if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
     159                          periodicOtherX = *(*runner)->node;
    126160                          periodicOtherX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    127161                          // go through every range in xyz and get distance
     
    132166                                checkOtherX.MatrixMultiplication(FullMatrix);
    133167                                distance = checkX.distance(checkOtherX);
    134                                 //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
    135                                 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
     168                                //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
     169                                outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
    136170                              }
    137171                        }
     172                    }
    138173                  }
     174                }
    139175              }
    140176            }
    141         }
    142       }
    143       Free(&FullMatrix);
    144       Free(&FullInverseMatrix);
    145     }
     177      }
     178      delete[](FullMatrix);
     179      delete[](FullInverseMatrix);
     180    }
     181  }
    146182
    147183  return outmap;
     
    149185
    150186/** Calculates the distance (pair) correlation between a given element and a point.
    151  * \param *out output stream for debugging
    152  * \param *molecules list of molecules structure
    153  * \param *type element or NULL (if any element)
     187 * \param *molecules list of molecules structure
     188 * \param &elements vector of elements to correlate with point
    154189 * \param *point vector to the correlation point
    155190 * \return Map of dobules with values as pairs of atom and the vector
    156191 */
    157 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point )
     192CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point )
    158193{
    159194  Info FunctionInfo(__func__);
    160195  CorrelationToPointMap *outmap = NULL;
    161196  double distance = 0.;
     197  double *cell_size = World::getInstance().getDomain();
    162198
    163199  if (molecules->ListOfMolecules.empty()) {
     
    165201    return outmap;
    166202  }
     203  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     204    (*MolWalker)->doCountAtoms();
    167205  outmap = new CorrelationToPointMap;
    168206  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    169207    if ((*MolWalker)->ActiveFlag) {
    170208      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    171       atom *Walker = (*MolWalker)->start;
    172       while (Walker->next != (*MolWalker)->end) {
    173         Walker = Walker->next;
    174         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    175         if ((type == NULL) || (Walker->type == type)) {
    176           distance = Walker->node->PeriodicDistance(*point, World::getInstance().getDomain());
    177           DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    178           outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
    179         }
     209      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     210        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     211        for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     212          if ((*type == NULL) || ((*iter)->type == *type)) {
     213            distance = (*iter)->node->PeriodicDistance(*point, cell_size);
     214            DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
     215            outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
     216          }
    180217      }
    181218    }
     
    185222
    186223/** Calculates the distance (pair) correlation between a given element, all its periodic images and a point.
    187  * \param *out output stream for debugging
    188  * \param *molecules list of molecules structure
    189  * \param *type element or NULL (if any element)
     224 * \param *molecules list of molecules structure
     225 * \param &elements vector of elements to correlate to point
    190226 * \param *point vector to the correlation point
    191227 * \param ranges[NDIM] interval boundaries for the periodic images to scan also
    192228 * \return Map of dobules with values as pairs of atom and the vector
    193229 */
    194 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] )
     230CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] )
    195231{
    196232  Info FunctionInfo(__func__);
     
    205241    return outmap;
    206242  }
     243  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     244    (*MolWalker)->doCountAtoms();
    207245  outmap = new CorrelationToPointMap;
    208246  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     
    211249      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    212250      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    213       atom *Walker = (*MolWalker)->start;
    214       while (Walker->next != (*MolWalker)->end) {
    215         Walker = Walker->next;
    216         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    217         if ((type == NULL) || (Walker->type == type)) {
    218           periodicX = *(Walker->node);
    219           periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    220           // go through every range in xyz and get distance
    221           for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
    222             for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    223               for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    224                 checkX = Vector(n[0], n[1], n[2]) + periodicX;
    225                 checkX.MatrixMultiplication(FullMatrix);
    226                 distance = checkX.distance(*point);
    227                 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    228                 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
    229               }
    230         }
    231       }
    232       Free(&FullMatrix);
    233       Free(&FullInverseMatrix);
     251      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     252        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     253        for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     254          if ((*type == NULL) || ((*iter)->type == *type)) {
     255            periodicX = *(*iter)->node;
     256            periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
     257            // go through every range in xyz and get distance
     258            for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
     259              for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
     260                for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
     261                  checkX = Vector(n[0], n[1], n[2]) + periodicX;
     262                  checkX.MatrixMultiplication(FullMatrix);
     263                  distance = checkX.distance(*point);
     264                  DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
     265                  outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) );
     266                }
     267          }
     268      }
     269      delete[](FullMatrix);
     270      delete[](FullInverseMatrix);
    234271    }
    235272
     
    238275
    239276/** Calculates the distance (pair) correlation between a given element and a surface.
    240  * \param *out output stream for debugging
    241  * \param *molecules list of molecules structure
    242  * \param *type element or NULL (if any element)
     277 * \param *molecules list of molecules structure
     278 * \param &elements vector of elements to correlate to surface
    243279 * \param *Surface pointer to Tesselation class surface
    244280 * \param *LC LinkedCell structure to quickly find neighbouring atoms
    245281 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
    246282 */
    247 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC )
     283CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
    248284{
    249285  Info FunctionInfo(__func__);
     
    257293    return outmap;
    258294  }
     295  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     296    (*MolWalker)->doCountAtoms();
    259297  outmap = new CorrelationToSurfaceMap;
    260298  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    261299    if ((*MolWalker)->ActiveFlag) {
    262300      DoLog(1) && (Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl);
    263       atom *Walker = (*MolWalker)->start;
    264       while (Walker->next != (*MolWalker)->end) {
    265         Walker = Walker->next;
    266         //Log() << Verbose(1) << "Current atom is " << *Walker << "." << endl;
    267         if ((type == NULL) || (Walker->type == type)) {
    268           TriangleIntersectionList Intersections(Walker->node,Surface,LC);
    269           distance = Intersections.GetSmallestDistance();
    270           triangle = Intersections.GetClosestTriangle();
    271           outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) );
    272         }
    273       }
    274     } else
     301      if ((*MolWalker)->empty())
     302        DoLog(1) && (1) && (Log() << Verbose(1) << "\t is empty." << endl);
     303      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     304        DoLog(1) && (Log() << Verbose(1) << "\tCurrent atom is " << *(*iter) << "." << endl);
     305        for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     306          if ((*type == NULL) || ((*iter)->type == *type)) {
     307            TriangleIntersectionList Intersections((*iter)->node,Surface,LC);
     308            distance = Intersections.GetSmallestDistance();
     309            triangle = Intersections.GetClosestTriangle();
     310            outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) );
     311          }
     312      }
     313    } else {
    275314      DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl);
     315    }
    276316
    277317  return outmap;
     
    283323 * axis an integer from [ -ranges[i], ranges[i] ] onto it and multiply with the domain matrix to bring it back into
    284324 * the real space. Then, we Tesselation::FindClosestTriangleToPoint() and DistanceToTrianglePlane().
    285  * \param *out output stream for debugging
    286  * \param *molecules list of molecules structure
    287  * \param *type element or NULL (if any element)
     325 * \param *molecules list of molecules structure
     326 * \param &elements vector of elements to correlate to surface
    288327 * \param *Surface pointer to Tesselation class surface
    289328 * \param *LC LinkedCell structure to quickly find neighbouring atoms
     
    291330 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
    292331 */
    293 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
     332CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
    294333{
    295334  Info FunctionInfo(__func__);
     
    306345    return outmap;
    307346  }
     347  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     348    (*MolWalker)->doCountAtoms();
    308349  outmap = new CorrelationToSurfaceMap;
    309350  double ShortestDistance = 0.;
     
    314355      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    315356      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    316       atom *Walker = (*MolWalker)->start;
    317       while (Walker->next != (*MolWalker)->end) {
    318         Walker = Walker->next;
    319         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    320         if ((type == NULL) || (Walker->type == type)) {
    321           periodicX = *(Walker->node);
    322           periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    323           // go through every range in xyz and get distance
    324           ShortestDistance = -1.;
    325           for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
    326             for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    327               for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    328                 checkX = Vector(n[0], n[1], n[2]) + periodicX;
    329                 checkX.MatrixMultiplication(FullMatrix);
    330                 TriangleIntersectionList Intersections(&checkX,Surface,LC);
    331                 distance = Intersections.GetSmallestDistance();
    332                 triangle = Intersections.GetClosestTriangle();
    333                 if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
    334                   ShortestDistance = distance;
    335                   ShortestTriangle = triangle;
     357      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     358        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     359        for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     360          if ((*type == NULL) || ((*iter)->type == *type)) {
     361            periodicX = *(*iter)->node;
     362            periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
     363            // go through every range in xyz and get distance
     364            ShortestDistance = -1.;
     365            for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
     366              for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
     367                for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
     368                  checkX = Vector(n[0], n[1], n[2]) + periodicX;
     369                  checkX.MatrixMultiplication(FullMatrix);
     370                  TriangleIntersectionList Intersections(&checkX,Surface,LC);
     371                  distance = Intersections.GetSmallestDistance();
     372                  triangle = Intersections.GetClosestTriangle();
     373                  if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
     374                    ShortestDistance = distance;
     375                    ShortestTriangle = triangle;
     376                  }
    336377                }
    337               }
    338           // insert
    339           outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (Walker, ShortestTriangle) ) );
    340           //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
    341         }
    342       }
    343       Free(&FullMatrix);
    344       Free(&FullInverseMatrix);
     378            // insert
     379            outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) );
     380            //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
     381          }
     382      }
     383      delete[](FullMatrix);
     384      delete[](FullInverseMatrix);
    345385    }
    346386
  • src/analysis_correlation.hpp

    rc39cc4 rbdb143  
    4545/********************************************** declarations *******************************/
    4646
    47 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const  type2 );
    48 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point );
    49 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC );
    50 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const  type2, const int ranges[NDIM] );
    51 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] );
    52 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );
     47PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements);
     48CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point );
     49CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC );
     50PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const int ranges[NDIM] );
     51CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] );
     52CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );
    5353int GetBin ( const double value, const double BinWidth, const double BinStart );
    5454void OutputCorrelation( ofstream * const file, const BinPairMap * const map );
  • src/analyzer.cpp

    rc39cc4 rbdb143  
    77
    88//============================ INCLUDES ===========================
     9
     10#include "Helpers/MemDebug.hpp"
    911
    1012#include <cstring>
     
    7577    return 1;
    7678  } else {
    77     dir = Malloc<char>(strlen(argv[2]) + 2, "main: *dir");
     79    dir = new char[strlen(argv[2]) + 2];
    7880    strcpy(dir, "/");
    7981    strcat(dir, argv[2]);
     
    8284  if (argc > 4) {
    8385    DoLog(0) && (Log() << Verbose(0) << "Loading periodentafel." << endl);
    84     periode = Malloc<periodentafel>(1, "main - periode");
     86    periode = new periodentafel;
    8587    periode->LoadPeriodentafel(argv[4]);
    8688  }
     
    558560  // ++++++++++++++++ exit ++++++++++++++++++++++++++++++++++
    559561  delete(periode);
    560   Free(&dir);
     562  delete[](dir);
    561563  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    562564  return 0;
  • src/atom.cpp

    rc39cc4 rbdb143  
    44 *
    55 */
     6
     7#include "Helpers/MemDebug.hpp"
    68
    79#include "atom.hpp"
     
    1416#include "vector.hpp"
    1517#include "World.hpp"
     18#include "molecule.hpp"
    1619
    1720/************************************* Functions for class atom *************************************/
     
    2124 */
    2225atom::atom() :
    23   previous(NULL), next(NULL), father(this), sort(&nr)
     26  father(this), sort(&nr), mol(0)
    2427{
    2528  node = &x;  // TesselPoint::x can only be referenced from here
     
    2932 */
    3033atom::atom(atom *pointer) :
    31     ParticleInfo(pointer),
    32     previous(NULL), next(NULL), father(pointer), sort(&nr)
     34    ParticleInfo(pointer),father(pointer), sort(&nr)
    3335{
    3436  type = pointer->type;  // copy element of atom
     
    3739  FixedIon = pointer->FixedIon;
    3840  node = &x;
     41  mol = 0;
    3942};
    4043
    4144atom *atom::clone(){
    4245  atom *res = new atom(this);
    43   res->previous=0;
    44   res->next=0;
    4546  res->father = this;
    4647  res->sort = &res->nr;
     
    5051  res->FixedIon = FixedIon;
    5152  res->node = &x;
     53  res->mol = 0;
    5254  World::getInstance().registerAtom(res);
    5355  return res;
     
    5961atom::~atom()
    6062{
    61   unlink(this);
     63  removeFromMolecule();
     64  for(BondList::iterator iter=ListOfBonds.begin(); iter!=ListOfBonds.end();){
     65    // deleting the bond will invalidate the iterator !!!
     66    bond *bond =*(iter++);
     67    delete(bond);
     68  }
    6269};
    6370
     
    152159  * \return true - \a *out present, false - \a *out is NULL
    153160 */
    154 bool atom::OutputArrayIndexed(ofstream * const out, const int *ElementNo, int *AtomNo, const char *comment) const
     161bool atom::OutputArrayIndexed(ostream * const out, const int *ElementNo, int *AtomNo, const char *comment) const
    155162{
    156163  AtomNo[type->Z]++;  // increment number
     
    229236 * \param *AtomNo pointer to atom counter that is increased by one
    230237 */
    231 void atom::OutputMPQCLine(ofstream * const out, const Vector *center, int *AtomNo = NULL) const
     238void atom::OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo = NULL) const
    232239{
    233240  *out << "\t\t" << type->symbol << " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl;
     
    272279{
    273280  if (ComponentNr != NULL)
    274     Free(&ComponentNr);
    275   ComponentNr = Malloc<int>(ListOfBonds.size()+1, "atom::InitComponentNumbers: *ComponentNr");
     281    delete[](ComponentNr);
     282  ComponentNr = new int[ListOfBonds.size()+1];
    276283  for (int i=ListOfBonds.size()+1;i--;)
    277284    ComponentNr[i] = -1;
     
    308315}
    309316
    310 atomId_t atom::getId() {
     317atomId_t atom::getId() const {
    311318  return id;
    312319}
     320
     321void atom::setMolecule(molecule *_mol){
     322  // take this atom from the old molecule
     323  removeFromMolecule();
     324  mol = _mol;
     325  if(!mol->containsAtom(this)){
     326    mol->AddAtom(this);
     327  }
     328}
     329
     330void atom::removeFromMolecule(){
     331  if(mol){
     332    if(mol->containsAtom(this)){
     333      mol->erase(this);
     334    }
     335    mol=0;
     336  }
     337}
     338
    313339
    314340atom* NewAtom(atomId_t _id){
  • src/atom.hpp

    rc39cc4 rbdb143  
    3434class Vector;
    3535class World;
     36class molecule;
    3637
    3738/********************************************** declarations *******************************/
     
    4445  friend void  DeleteAtom(atom*);
    4546  public:
    46     atom *previous; //!< previous atom in molecule list
    47     atom *next;     //!< next atom in molecule list
    4847    atom *father;   //!< In many-body bond order fragmentations points to originating atom
    4948    int *sort;      //!< sort criteria
     
    5251
    5352  bool OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment = NULL) const;
    54   bool OutputArrayIndexed(ofstream * const out, const int *ElementNo, int *AtomNo, const char *comment = NULL) const;
     53  bool OutputArrayIndexed(ostream * const out, const int *ElementNo, int *AtomNo, const char *comment = NULL) const;
    5554  bool OutputXYZLine(ofstream *out) const;
    5655  bool OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const;
    5756  bool OutputTrajectoryXYZ(ofstream * const out, const int step) const;
    58   void OutputMPQCLine(ofstream * const out, const Vector *center, int *AtomNo) const;
     57  void OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo) const;
    5958
    6059  void InitComponentNr();
     
    8079  void setWorld(World*);
    8180
    82   virtual atomId_t getId();
     81  virtual atomId_t getId() const;
    8382  virtual bool changeId(atomId_t newId);
    8483
     
    8988   virtual void setId(atomId_t);
    9089
     90   void setMolecule(molecule*);
     91   void removeFromMolecule();
     92
    9193  protected:
     94
    9295    /**
    9396     * Protected constructor to ensure construction of atoms through the world.
     
    108111    virtual ~atom();
    109112  private:
     113    molecule *mol; // !< the molecule this atom belongs to
    110114    World* world;
    111115    atomId_t id;
  • src/atom_atominfo.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "periodentafel.hpp"
  • src/atom_bondedparticle.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "atom.hpp"
     
    7476      *BondFile << nr << "\t" << (*Runner)->GetOtherAtom(this)->nr << "\n";
    7577};
     78
     79/**
     80 * Adds a bond between this bonded particle and another. Does nothing if this
     81 * bond already exists.
     82 *
     83 * \param bonding partner
     84 */
     85void BondedParticle::addBond(BondedParticle* Partner) {
     86  if (IsBondedTo(Partner)) {
     87    return;
     88  }
     89
     90  bond* newBond = new bond((atom*) this, (atom*) Partner, 1, 0);
     91  RegisterBond(newBond);
     92  Partner->RegisterBond(newBond);
     93}
    7694
    7795/** Puts a given bond into atom::ListOfBonds.
  • src/atom_bondedparticle.hpp

    rc39cc4 rbdb143  
    3737  virtual ~BondedParticle();
    3838
     39  void addBond(BondedParticle* Partner);
    3940  bool RegisterBond(bond *Binder);
    4041  bool UnregisterBond(bond *Binder);
  • src/atom_bondedparticleinfo.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "atom_bondedparticleinfo.hpp"
  • src/atom_graphnode.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "atom_graphnode.hpp"
  • src/atom_graphnodeinfo.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "atom_graphnodeinfo.hpp"
     
    1719GraphNodeInfo::~GraphNodeInfo()
    1820{
    19   Free<int>(&ComponentNr, "atom::~atom: *ComponentNr");
     21  delete[](ComponentNr);
    2022};
  • src/atom_particleinfo.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "atom_particleinfo.hpp"
  • src/atom_trajectoryparticle.cpp

    rc39cc4 rbdb143  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include "atom.hpp"
    911#include "atom_trajectoryparticle.hpp"
    1012#include "config.hpp"
    1113#include "element.hpp"
     14#include "info.hpp"
    1215#include "log.hpp"
    1316#include "parser.hpp"
     17#include "ThermoStatContainer.hpp"
    1418#include "verbose.hpp"
    1519
     
    7175void TrajectoryParticle::ResizeTrajectory(int MaxSteps)
    7276{
     77  Info FunctionInfo(__func__);
    7378  if (Trajectory.R.size() <= (unsigned int)(MaxSteps)) {
    74     //Log() << Verbose(0) << "Increasing size for trajectory array of " << keyword << " to " << (MaxSteps+1) << "." << endl;
     79    DoLog(0) && (Log() << Verbose(0) << "Increasing size for trajectory array of " << nr << " from " << Trajectory.R.size() << " to " << (MaxSteps+1) << "." << endl);
    7580    Trajectory.R.resize(MaxSteps+1);
    7681    Trajectory.U.resize(MaxSteps+1);
     
    193198void TrajectoryParticle::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration)
    194199{
    195   double sigma  = sqrt(configuration->TargetTemp/type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)
     200  double sigma  = sqrt(configuration->Thermostats->TargetTemp/type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)
    196201  Vector &U = Trajectory.U.at(Step);
    197202  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    198203    // throw a dice to determine whether it gets hit by a heat bath particle
    199     if (((((rand()/(double)RAND_MAX))*configuration->TempFrequency) < 1.)) {
     204    if (((((rand()/(double)RAND_MAX))*configuration->Thermostats->TempFrequency) < 1.)) {
    200205      DoLog(3) && (Log() << Verbose(3) << "Particle " << *this << " was hit (sigma " << sigma << "): " << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << " -> ");
    201206      // pick three random numbers from a Boltzmann distribution around the desired temperature T for each momenta axis
     
    221226  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    222227    for (int d=0; d<NDIM; d++) {
    223       U[d] *= sqrt(1+(configuration->Deltat/configuration->TempFrequency)*(ScaleTempFactor-1));
     228      U[d] *= sqrt(1+(configuration->Deltat/configuration->Thermostats->TempFrequency)*(ScaleTempFactor-1));
    224229      *ekin += 0.5*type->mass * U[d]*U[d];
    225230    }
     
    251256  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    252257    for (int d=0; d<NDIM; d++) {
    253         U[d] += configuration->Deltat/type->mass * (configuration->alpha * (U[d] * type->mass));
     258        U[d] += configuration->Deltat/type->mass * (configuration->Thermostats->alpha * (U[d] * type->mass));
    254259        *ekin += (0.5*type->mass) * U[d]*U[d];
    255260      }
  • src/atom_trajectoryparticleinfo.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "atom_trajectoryparticleinfo.hpp"
  • src/atom_trajectoryparticleinfo.hpp

    rc39cc4 rbdb143  
    2121
    2222#include "vector.hpp"
     23#include "VectorSet.hpp"
    2324
    2425/********************************************** declarations *******************************/
     
    2829  struct
    2930  {
    30     vector<Vector> R;  //!< position vector
    31     vector<Vector> U;  //!< velocity vector
    32     vector<Vector> F;  //!< last force vector
     31    VectorSet<vector<Vector> > R;  //!< position vector
     32    VectorSet<vector<Vector> > U;  //!< velocity vector
     33    VectorSet<vector<Vector> > F;  //!< last force vector
    3334  } Trajectory;
    3435  int FixedIon;   //!< config variable that states whether forces act on the ion or not
  • src/bond.cpp

    rc39cc4 rbdb143  
    44 *
    55 */
     6
     7#include "Helpers/MemDebug.hpp"
    68
    79#include "atom.hpp"
     
    1517/** Empty Constructor for class bond.
    1618 */
    17 bond::bond() : leftatom(NULL), rightatom(NULL), previous(NULL), next(NULL), HydrogenBond(0), BondDegree(0), nr(-1), Cyclic(false), Type(Undetermined), Used(white)
     19bond::bond()
     20  : leftatom(NULL), rightatom(NULL), previous(NULL), next(NULL), HydrogenBond(0),
     21    BondDegree(0), nr(-1), Cyclic(false), Type(Undetermined), Used(white)
    1822{
    1923};
     
    2529 * \param number increasing index
    2630 */
    27 bond::bond(atom *left, atom *right, const int degree, const int number) : leftatom(left), rightatom(right), previous(NULL), next(NULL), HydrogenBond(0), BondDegree(degree), nr(number), Cyclic(false), Type(Undetermined), Used(white)
     31bond::bond(atom *left, atom *right, const int degree, const int number)
     32  : leftatom(left), rightatom(right), previous(NULL), next(NULL), HydrogenBond(0),
     33    BondDegree(degree), nr(number), Cyclic(false), Type(Undetermined), Used(white)
    2834{
    2935  if ((left != NULL) && (right != NULL)) {
  • src/bondgraph.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <iostream>
     
    8890{
    8991  Info FunctionInfo(__func__);
    90 bool status = true;
     92  bool status = true;
    9193
    92   if (mol->start->next == mol->end) // only construct if molecule is not empty
     94  if (mol->empty()) // only construct if molecule is not empty
    9395    return false;
    9496
     
    124126  max_distance = 0.;
    125127
    126   atom *Runner = mol->start;
    127   while (Runner->next != mol->end) {
    128     Runner = Runner->next;
    129     if (Runner->type->CovalentRadius > max_distance)
    130       max_distance = Runner->type->CovalentRadius;
     128  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     129    if ((*iter)->type->CovalentRadius > max_distance)
     130      max_distance = (*iter)->type->CovalentRadius;
    131131  }
    132132  max_distance *= 2.;
  • src/bondgraph.hpp

    rc39cc4 rbdb143  
    2727
    2828class molecule;
    29 class periodentafel;
     29class BondedParticle;
    3030class MatrixContainer;
    3131
  • src/boundary.cpp

    rc39cc4 rbdb143  
    33 * Implementations and super-function for envelopes
    44 */
     5
     6#include "Helpers/MemDebug.hpp"
    57
    68#include "World.hpp"
     
    139141{
    140142        Info FunctionInfo(__func__);
    141   atom *Walker = NULL;
    142143  PointMap PointsOnBoundary;
    143144  LineMap LinesOnBoundary;
     
    165166
    166167    // 3b. construct set of all points, transformed into cylindrical system and with left and right neighbours
    167     Walker = mol->start;
    168     while (Walker->next != mol->end) {
    169       Walker = Walker->next;
    170       ProjectedVector = Walker->x - (*MolCenter);
     168    for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     169      ProjectedVector = (*iter)->x - (*MolCenter);
    171170      ProjectedVector.ProjectOntoPlane(AxisVector);
    172171
     
    182181        angle = 2. * M_PI - angle;
    183182      }
    184       DoLog(1) && (Log() << Verbose(1) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl);
    185       BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, Walker)));
     183    DoLog(1) && (Log() << Verbose(1) << "Inserting " << **iter << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl);
     184      BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, (*iter))));
    186185      if (!BoundaryTestPair.second) { // same point exists, check first r, then distance of original vectors to center of gravity
    187186        DoLog(2) && (Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl);
    188187        DoLog(2) && (Log() << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl);
    189         DoLog(2) && (Log() << Verbose(2) << "New vector: " << *Walker << endl);
     188        DoLog(2) && (Log() << Verbose(2) << "New vector: " << **iter << endl);
    190189        const double ProjectedVectorNorm = ProjectedVector.NormSquared();
    191190        if ((ProjectedVectorNorm - BoundaryTestPair.first->second.first) > MYEPSILON) {
    192191          BoundaryTestPair.first->second.first = ProjectedVectorNorm;
    193           BoundaryTestPair.first->second.second = Walker;
     192          BoundaryTestPair.first->second.second = (*iter);
    194193          DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl);
    195194        } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) {
    196           helper = Walker->x - (*MolCenter);
     195          helper = (*iter)->x;
     196          helper -= *MolCenter;
    197197          const double oldhelperNorm = helper.NormSquared();
    198198          helper = BoundaryTestPair.first->second.second->x - (*MolCenter);
    199199          if (helper.NormSquared() < oldhelperNorm) {
    200             BoundaryTestPair.first->second.second = Walker;
     200            BoundaryTestPair.first->second.second = (*iter);
    201201            DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl);
    202202          } else {
     
    226226    do { // do as long as we still throw one out per round
    227227      flag = false;
    228       Boundaries::iterator left = BoundaryPoints[axis].end();
    229       Boundaries::iterator right = BoundaryPoints[axis].end();
    230       for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {
     228      Boundaries::iterator left = BoundaryPoints[axis].begin();
     229      Boundaries::iterator right = BoundaryPoints[axis].begin();
     230      Boundaries::iterator runner = BoundaryPoints[axis].begin();
     231      bool LoopOnceDone = false;
     232      while (!LoopOnceDone) {
     233        runner = right;
     234        right++;
    231235        // set neighbours correctly
    232236        if (runner == BoundaryPoints[axis].begin()) {
     
    236240        }
    237241        left--;
    238         right = runner;
    239         right++;
    240242        if (right == BoundaryPoints[axis].end()) {
    241243          right = BoundaryPoints[axis].begin();
     244          LoopOnceDone = true;
    242245        }
    243246        // check distance
     
    279282            DoLog(1) && (Log() << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl);
    280283            BoundaryPoints[axis].erase(runner);
     284            runner = right;
    281285            flag = true;
    282286          }
     
    359363
    360364  // 4. Store triangles in tecplot file
    361   if (filename != NULL) {
    362     if (DoTecplotOutput) {
    363       string OutputName(filename);
    364       OutputName.append("_intermed");
    365       OutputName.append(TecplotSuffix);
    366       ofstream *tecplot = new ofstream(OutputName.c_str());
    367       WriteTecplotFile(tecplot, TesselStruct, mol, 0);
    368       tecplot->close();
    369       delete(tecplot);
    370     }
    371     if (DoRaster3DOutput) {
    372       string OutputName(filename);
    373       OutputName.append("_intermed");
    374       OutputName.append(Raster3DSuffix);
    375       ofstream *rasterplot = new ofstream(OutputName.c_str());
    376       WriteRaster3dFile(rasterplot, TesselStruct, mol);
    377       rasterplot->close();
    378       delete(rasterplot);
    379     }
    380   }
     365  StoreTrianglesinFile(mol, TesselStruct, filename, "_intermed");
    381366
    382367  // 3d. check all baselines whether the peaks of the two adjacent triangles with respect to center of baseline are convex, if not, make the baseline between the two peaks and baseline endpoints become the new peaks
     
    397382          TesselStruct->FlipBaseline(line);
    398383          DoLog(1) && (Log() << Verbose(1) << "INFO: Correction of concave baselines worked." << endl);
     384          LineRunner = TesselStruct->LinesOnBoundary.begin(); // LineRunner may have been erase if line was deleted from LinesOnBoundary
    399385        }
    400386      }
     
    409395
    410396  // 4. Store triangles in tecplot file
    411   if (filename != NULL) {
    412     if (DoTecplotOutput) {
    413       string OutputName(filename);
    414       OutputName.append(TecplotSuffix);
    415       ofstream *tecplot = new ofstream(OutputName.c_str());
    416       WriteTecplotFile(tecplot, TesselStruct, mol, 0);
    417       tecplot->close();
    418       delete(tecplot);
    419     }
    420     if (DoRaster3DOutput) {
    421       string OutputName(filename);
    422       OutputName.append(Raster3DSuffix);
    423       ofstream *rasterplot = new ofstream(OutputName.c_str());
    424       WriteRaster3dFile(rasterplot, TesselStruct, mol);
    425       rasterplot->close();
    426       delete(rasterplot);
    427     }
    428   }
    429 
     397  StoreTrianglesinFile(mol, TesselStruct, filename, "");
    430398
    431399  // free reference lists
     
    678646/** Creates multiples of the by \a *mol given cluster and suspends them in water with a given final density.
    679647 * We get cluster volume by VolumeOfConvexEnvelope() and its diameters by GetDiametersOfCluster()
     648 * TODO: Here, we need a VolumeOfGeneralEnvelope (i.e. non-convex one)
    680649 * \param *out output stream for debugging
    681650 * \param *configuration needed for path to store convex envelope file
     
    695664  int repetition[NDIM] = { 1, 1, 1 };
    696665  int TotalNoClusters = 1;
    697   atom *Walker = NULL;
    698666  double totalmass = 0.;
    699667  double clustervolume = 0.;
     
    706674  GreatestDiameter = GetDiametersOfCluster(BoundaryPoints, mol, TesselStruct, IsAngstroem);
    707675  BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
    708   LinkedCell LCList(mol, 10.);
    709   FindConvexBorder(mol, TesselStruct, &LCList, NULL);
     676  LinkedCell *LCList = new LinkedCell(mol, 10.);
     677  FindConvexBorder(mol, TesselStruct, (const LinkedCell *&)LCList, NULL);
     678  delete (LCList);
     679
    710680
    711681  // some preparations beforehand
     
    719689
    720690  // sum up the atomic masses
    721   Walker = mol->start;
    722   while (Walker->next != mol->end) {
    723       Walker = Walker->next;
    724       totalmass += Walker->type->mass;
     691  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     692      totalmass += (*iter)->type->mass;
    725693  }
    726694  DoLog(0) && (Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl);
     
    804772  Vector Inserter;
    805773  double FillIt = false;
    806   atom *Walker = NULL;
    807774  bond *Binder = NULL;
    808775  double phi[NDIM];
     
    811778
    812779  for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++)
    813     if ((*ListRunner)->AtomCount > 0) {
     780    if ((*ListRunner)->getAtomCount() > 0) {
    814781      DoLog(1) && (Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl);
    815782      LCList[(*ListRunner)] = new LinkedCell((*ListRunner), 10.); // get linked cell list
     
    822789  filler->CenterEdge(&Inserter);
    823790  filler->Center.Zero();
     791  const int FillerCount = filler->getAtomCount();
    824792  DoLog(2) && (Log() << Verbose(2) << "INFO: Filler molecule has the following bonds:" << endl);
    825   Binder = filler->first;
    826   while(Binder->next != filler->last) {
    827     Binder = Binder->next;
    828     DoLog(2) && (Log() << Verbose(2) << "  " << *Binder << endl);
    829   }
    830 
    831   filler->CountAtoms();
    832   atom * CopyAtoms[filler->AtomCount];
     793  for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner)
     794    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     795      if ((*BondRunner)->leftatom == *AtomRunner)
     796        DoLog(2) && (Log() << Verbose(2) << "  " << *(*BondRunner) << endl);
     797
     798  atom * CopyAtoms[FillerCount];
    833799
    834800  // calculate filler grid in [0,1]^3
     
    855821
    856822        // go through all atoms
    857         for (int i=0;i<filler->AtomCount;i++)
     823        for (int i=0;i<FillerCount;i++)
    858824          CopyAtoms[i] = NULL;
    859         Walker = filler->start;
    860         while (Walker->next != filler->end) {
    861           Walker = Walker->next;
     825        for(molecule::const_iterator iter = filler->begin(); iter !=filler->end();++iter){
    862826
    863827          // create atomic random translation vector ...
     
    883847
    884848          // ... and put at new position
    885           Inserter = Walker->x;
     849          Inserter = (*iter)->x;
    886850          if (DoRandomRotation)
    887851            Inserter.MatrixMultiplication(Rotations);
     
    907871            DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is outer point." << endl);
    908872            // copy atom ...
    909             CopyAtoms[Walker->nr] = Walker->clone();
    910             CopyAtoms[Walker->nr]->x = Inserter;
    911             Filling->AddAtom(CopyAtoms[Walker->nr]);
    912             DoLog(4) && (Log() << Verbose(4) << "Filling atom " << *Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl);
     873            CopyAtoms[(*iter)->nr] = (*iter)->clone();
     874            CopyAtoms[(*iter)->nr]->x = Inserter;
     875            Filling->AddAtom(CopyAtoms[(*iter)->nr]);
     876            DoLog(4) && (Log() << Verbose(4) << "Filling atom " << **iter << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[(*iter)->nr]->x) << "." << endl);
    913877          } else {
    914878            DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl);
    915             CopyAtoms[Walker->nr] = NULL;
     879            CopyAtoms[(*iter)->nr] = NULL;
    916880            continue;
    917881          }
    918882        }
    919883        // go through all bonds and add as well
    920         Binder = filler->first;
    921         while(Binder->next != filler->last) {
    922           Binder = Binder->next;
    923           if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) {
    924             Log()  << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;
    925             Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
    926           }
    927         }
     884        for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner)
     885          for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     886            if ((*BondRunner)->leftatom == *AtomRunner) {
     887              Binder = (*BondRunner);
     888              if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) {
     889                Log()  << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;
     890                Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
     891              }
     892            }
    928893      }
    929   Free(&M);
    930   Free(&MInverse);
     894  delete[](M);
     895  delete[](MInverse);
    931896
    932897  return Filling;
     
    952917  bool TesselationFailFlag = false;
    953918
     919  mol->getAtomCount();
     920
    954921  if (TesselStruct == NULL) {
    955922    DoLog(1) && (Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl);
     
    1023990//  // look whether all points are inside of the convex envelope, otherwise add them via degenerated triangles
    1024991//  //->InsertStraddlingPoints(mol, LCList);
    1025 //  mol->GoToFirst();
     992//  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    1026993//  class TesselPoint *Runner = NULL;
    1027 //  while (!mol->IsEnd()) {
    1028 //    Runner = mol->GetPoint();
     994//    Runner = *iter;
    1029995//    Log() << Verbose(1) << "Checking on " << Runner->Name << " ... " << endl;
    1030996//    if (!->IsInnerPoint(Runner, LCList)) {
     
    10341000//      Log() << Verbose(2) << Runner->Name << " is inside of or on envelope." << endl;
    10351001//    }
    1036 //    mol->GoToNext();
    10371002//  }
    10381003
     
    10431008//  status = CheckListOfBaselines(TesselStruct);
    10441009
     1010  cout << "before correction" << endl;
     1011
    10451012  // store before correction
    1046   StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, "");
     1013  StoreTrianglesinFile(mol, TesselStruct, filename, "");
    10471014
    10481015//  // correct degenerated polygons
     
    10541021  // write final envelope
    10551022  CalculateConcavityPerBoundaryPoint(TesselStruct);
    1056   StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, "");
     1023  cout << "after correction" << endl;
     1024  StoreTrianglesinFile(mol, TesselStruct, filename, "");
    10571025
    10581026  if (freeLC)
  • src/builder.cpp

    rc39cc4 rbdb143  
    11/** \file builder.cpp
    22 *
    3  * By stating absolute positions or binding angles and distances atomic positions of a molecule can be constructed.
    4  * The output is the complete configuration file for PCP for direct use.
    5  * Features:
    6  * -# Atomic data is retrieved from a file, if not found requested and stored there for later re-use
    7  * -# step-by-step construction of the molecule beginning either at a centre of with a certain atom
     3 *  date: Jan 1, 2007
     4 *  author: heber
    85 *
    96 */
    107
    11 /*! \mainpage Molecuilder - a molecular set builder
     8/*! \mainpage MoleCuilder - a molecular set builder
    129 *
    13  * This introductory shall briefly make aquainted with the program, helping in installing and a first run.
     10 * This introductory shall briefly make acquainted with the program, helping in installing and a first run.
    1411 *
    1512 * \section about About the Program
    1613 *
    17  *  Molecuilder is a short program, written in C++, that enables the construction of a coordinate set for the
    18  *  atoms making up an molecule by the successive statement of binding angles and distances and referencing to
    19  *  already constructed atoms.
     14 *  MoleCuilder is a program, written entirely in C++, that enables the construction of a coordinate set for the
     15 *  atoms making up an molecule. It allows for both building of simple molecules by adding atom-wise giving bond
     16 *  angles and distances or absolute coordinates, but also using them as templates. Regions can be specified and
     17 *  ordered to be filled with a molecule in a certain manner. Greater conglomerations of molecules can be tesselated
     18 *  and recognized as a region themselves to be subsequently surrounded by other (surface solvated) molecules.
     19 *  In the end, MoleCuilder allows the construction of arbitrary nano structures, whether they be crystalline or
     20 *  amorphic in nature.
    2021 *
    21  *  A configuration file may be written that is compatible to the format used by PCP - a parallel Car-Parrinello
    22  *  molecular dynamics implementation.
    2322 *
    2423 * \section install Installation
     
    3231 *  -# make clean uninstall: deletes .o-files and removes executable from the given binary directory\n
    3332 *  -# make doxygen-doc: Creates these html pages out of the documented source
     33 *  -# make check: Runs an extensive set of unit tests and a testsuite which also gives a good overview on the set of
     34 *                 functions.
    3435 *
    3536 * \section run Running
     
    3738 *  The program can be executed by running: ./molecuilder
    3839 *
    39  *  Note, that it uses a database, called "elements.db", in the executable's directory. If the file is not found,
    40  *  it is created and any given data on elements of the periodic table will be stored therein and re-used on
    41  *  later re-execution.
     40 *  MoleCuilder has three interfaces at your disposal:
     41 *  -# Textmenu: A simple interactive console-based menu, where awaits your choices and inputs in order to set atoms
     42 *               as you like
     43 *  -# CommandLineUI: Every command can also be chained up as a sequence of actions on the command line to be executed
     44 *               with any user interaction.
     45 *  -# GraphicalUI: A graphical user interface that also display the molecular structure being built and lots of other
     46 *               informations to ease the construction of bigger geometries.
    4247 *
    43  * \section ref References
    44  *
    45  *  For the special configuration file format, see the documentation of pcp.
     48 *  The supported output formats right now are:
     49 *  -# mpqc: Configuration files of the Massively Parallel Quantum Chemistry package (Sandia labs)
     50 *  -# pcp: Configuration files of the Parallel Car-Parrinello program (Institute for Numerical Simulation)
     51 *  -# tremolo: Configuration files of TREMOLO (Institute for Numerical Simulation)
     52 *  -# xyz: the most basic format for the 3d arrangement of atoms consisting of a list of element and 3 coordinates.
    4653 *
    4754 */
    4855
     56#include "Helpers/MemDebug.hpp"
    4957
    50 #include <boost/bind.hpp>
    51 
    52 using namespace std;
    53 
    54 #include <cstring>
    55 
    56 #include "analysis_bonds.hpp"
    57 #include "analysis_correlation.hpp"
    58 #include "atom.hpp"
    59 #include "bond.hpp"
    6058#include "bondgraph.hpp"
    61 #include "boundary.hpp"
     59#include "CommandLineParser.hpp"
    6260#include "config.hpp"
    63 #include "element.hpp"
    64 #include "ellipsoid.hpp"
    65 #include "helpers.hpp"
    66 #include "leastsquaremin.hpp"
    67 #include "linkedcell.hpp"
    6861#include "log.hpp"
    6962#include "memoryusageobserver.hpp"
     
    7265#include "tesselationhelpers.hpp"
    7366#include "UIElements/UIFactory.hpp"
     67#include "UIElements/TextUI/TextUIFactory.hpp"
     68#include "UIElements/CommandLineUI/CommandLineUIFactory.hpp"
     69#ifdef USE_GUI_QT
     70#include "UIElements/QT4/QTUIFactory.hpp"
     71#endif
    7472#include "UIElements/MainWindow.hpp"
    7573#include "UIElements/Dialog.hpp"
    7674#include "Menu/ActionMenuItem.hpp"
     75#include "verbose.hpp"
     76#include "World.hpp"
     77
    7778#include "Actions/ActionRegistry.hpp"
    7879#include "Actions/ActionHistory.hpp"
    79 #include "Actions/MethodAction.hpp"
    80 #include "Actions/small_actions.hpp"
    81 #include "World.hpp"
     80#include "Actions/MapOfActions.hpp"
     81
     82#include "Parser/ChangeTracker.hpp"
     83#include "Parser/FormatParserStorage.hpp"
     84
     85#include "UIElements/UIFactory.hpp"
     86#include "UIElements/TextUI/TextUIFactory.hpp"
     87#include "UIElements/CommandLineUI/CommandLineUIFactory.hpp"
     88#include "UIElements/MainWindow.hpp"
     89#include "UIElements/Dialog.hpp"
     90
    8291#include "version.h"
    83 #include "World.hpp"
    84 #include "Helpers/MemDebug.hpp"
    85 
    86 /********************************************* Subsubmenu routine ************************************/
    87 #if 0
    88 /** Submenu for adding atoms to the molecule.
    89  * \param *periode periodentafel
    90  * \param *molecule molecules with atoms
    91  */
    92 static void AddAtoms(periodentafel *periode, molecule *mol)
    93 {
    94   atom *first, *second, *third, *fourth;
    95   Vector **atoms;
    96   Vector x,y,z,n;  // coordinates for absolute point in cell volume
    97   double a,b,c;
    98   char choice;  // menu choice char
    99   bool valid;
    100 
    101   cout << Verbose(0) << "===========ADD ATOM============================" << endl;
    102   cout << Verbose(0) << " a - state absolute coordinates of atom" << endl;
    103   cout << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;
    104   cout << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;
    105   cout << Verbose(0) << " d - state two atoms, two angles and a distance" << endl;
    106   cout << Verbose(0) << " e - least square distance position to a set of atoms" << endl;
    107   cout << Verbose(0) << "all else - go back" << endl;
    108   cout << Verbose(0) << "===============================================" << endl;
    109   cout << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;
    110   cout << Verbose(0) << "INPUT: ";
    111   cin >> choice;
    112 
    113   switch (choice) {
    114     default:
    115       DoeLog(2) && (eLog()<< Verbose(2) << "Not a valid choice." << endl);
    116       break;
    117       case 'a': // absolute coordinates of atom
    118         cout << Verbose(0) << "Enter absolute coordinates." << endl;
    119         first = new atom;
    120         first->x.AskPosition(World::getInstance().getDomain(), false);
    121         first->type = periode->AskElement();  // give type
    122         mol->AddAtom(first);  // add to molecule
    123         break;
    124 
    125       case 'b': // relative coordinates of atom wrt to reference point
    126         first = new atom;
    127         valid = true;
    128         do {
    129           if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl);
    130           cout << Verbose(0) << "Enter reference coordinates." << endl;
    131           x.AskPosition(World::getInstance().getDomain(), true);
    132           cout << Verbose(0) << "Enter relative coordinates." << endl;
    133           first->x.AskPosition(World::getInstance().getDomain(), false);
    134           first->x.AddVector((const Vector *)&x);
    135           cout << Verbose(0) << "\n";
    136         } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    137         first->type = periode->AskElement();  // give type
    138         mol->AddAtom(first);  // add to molecule
    139         break;
    140 
    141       case 'c': // relative coordinates of atom wrt to already placed atom
    142         first = new atom;
    143         valid = true;
    144         do {
    145           if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl);
    146           second = mol->AskAtom("Enter atom number: ");
    147           DoLog(0) && (Log() << Verbose(0) << "Enter relative coordinates." << endl);
    148           first->x.AskPosition(World::getInstance().getDomain(), false);
    149           for (int i=NDIM;i--;) {
    150             first->x.x[i] += second->x.x[i];
    151           }
    152         } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    153         first->type = periode->AskElement();  // give type
    154         mol->AddAtom(first);  // add to molecule
    155         break;
    156 
    157     case 'd': // two atoms, two angles and a distance
    158         first = new atom;
    159         valid = true;
    160         do {
    161           if (!valid) {
    162             DoeLog(2) && (eLog()<< Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl);
    163           }
    164           cout << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl;
    165           second = mol->AskAtom("Enter central atom: ");
    166           third = mol->AskAtom("Enter second atom (specifying the axis for first angle): ");
    167           fourth = mol->AskAtom("Enter third atom (specifying a plane for second angle): ");
    168           a = ask_value("Enter distance between central (first) and new atom: ");
    169           b = ask_value("Enter angle between new, first and second atom (degrees): ");
    170           b *= M_PI/180.;
    171           bound(&b, 0., 2.*M_PI);
    172           c = ask_value("Enter second angle between new and normal vector of plane defined by first, second and third atom (degrees): ");
    173           c *= M_PI/180.;
    174           bound(&c, -M_PI, M_PI);
    175           cout << Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl;
    176 /*
    177           second->Output(1,1,(ofstream *)&cout);
    178           third->Output(1,2,(ofstream *)&cout);
    179           fourth->Output(1,3,(ofstream *)&cout);
    180           n.MakeNormalvector((const vector *)&second->x, (const vector *)&third->x, (const vector *)&fourth->x);
    181           x.Copyvector(&second->x);
    182           x.SubtractVector(&third->x);
    183           x.Copyvector(&fourth->x);
    184           x.SubtractVector(&third->x);
    185 
    186           if (!z.SolveSystem(&x,&y,&n, b, c, a)) {
    187          coutg() << Verbose(0) << "Failure solving self-dependent linear system!" << endl;
    188             continue;
    189           }
    190           DoLog(0) && (Log() << Verbose(0) << "resulting relative coordinates: ");
    191           z.Output();
    192           DoLog(0) && (Log() << Verbose(0) << endl);
    193           */
    194           // calc axis vector
    195           x.CopyVector(&second->x);
    196           x.SubtractVector(&third->x);
    197           x.Normalize();
    198           Log() << Verbose(0) << "x: ",
    199           x.Output();
    200           DoLog(0) && (Log() << Verbose(0) << endl);
    201           z.MakeNormalVector(&second->x,&third->x,&fourth->x);
    202           Log() << Verbose(0) << "z: ",
    203           z.Output();
    204           DoLog(0) && (Log() << Verbose(0) << endl);
    205           y.MakeNormalVector(&x,&z);
    206           Log() << Verbose(0) << "y: ",
    207           y.Output();
    208           DoLog(0) && (Log() << Verbose(0) << endl);
    209 
    210           // rotate vector around first angle
    211           first->x.CopyVector(&x);
    212           first->x.RotateVector(&z,b - M_PI);
    213           Log() << Verbose(0) << "Rotated vector: ",
    214           first->x.Output();
    215           DoLog(0) && (Log() << Verbose(0) << endl);
    216           // remove the projection onto the rotation plane of the second angle
    217           n.CopyVector(&y);
    218           n.Scale(first->x.ScalarProduct(&y));
    219           Log() << Verbose(0) << "N1: ",
    220           n.Output();
    221           DoLog(0) && (Log() << Verbose(0) << endl);
    222           first->x.SubtractVector(&n);
    223           Log() << Verbose(0) << "Subtracted vector: ",
    224           first->x.Output();
    225           DoLog(0) && (Log() << Verbose(0) << endl);
    226           n.CopyVector(&z);
    227           n.Scale(first->x.ScalarProduct(&z));
    228           Log() << Verbose(0) << "N2: ",
    229           n.Output();
    230           DoLog(0) && (Log() << Verbose(0) << endl);
    231           first->x.SubtractVector(&n);
    232           Log() << Verbose(0) << "2nd subtracted vector: ",
    233           first->x.Output();
    234           DoLog(0) && (Log() << Verbose(0) << endl);
    235 
    236           // rotate another vector around second angle
    237           n.CopyVector(&y);
    238           n.RotateVector(&x,c - M_PI);
    239           Log() << Verbose(0) << "2nd Rotated vector: ",
    240           n.Output();
    241           DoLog(0) && (Log() << Verbose(0) << endl);
    242 
    243           // add the two linear independent vectors
    244           first->x.AddVector(&n);
    245           first->x.Normalize();
    246           first->x.Scale(a);
    247           first->x.AddVector(&second->x);
    248 
    249           DoLog(0) && (Log() << Verbose(0) << "resulting coordinates: ");
    250           first->x.Output();
    251           DoLog(0) && (Log() << Verbose(0) << endl);
    252         } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    253         first->type = periode->AskElement();  // give type
    254         mol->AddAtom(first);  // add to molecule
    255         break;
    256 
    257       case 'e': // least square distance position to a set of atoms
    258         first = new atom;
    259         atoms = new (Vector*[128]);
    260         valid = true;
    261         for(int i=128;i--;)
    262           atoms[i] = NULL;
    263         int i=0, j=0;
    264         cout << Verbose(0) << "Now we need at least three molecules.\n";
    265         do {
    266           cout << Verbose(0) << "Enter " << i+1 << "th atom: ";
    267           cin >> j;
    268           if (j != -1) {
    269             second = mol->FindAtom(j);
    270             atoms[i++] = &(second->x);
    271           }
    272         } while ((j != -1) && (i<128));
    273         if (i >= 2) {
    274           first->x.LSQdistance((const Vector **)atoms, i);
    275           first->x.Output();
    276           first->type = periode->AskElement();  // give type
    277           mol->AddAtom(first);  // add to molecule
    278         } else {
    279           delete first;
    280           cout << Verbose(0) << "Please enter at least two vectors!\n";
    281         }
    282         break;
    283   };
    284 };
    285 
    286 /** Submenu for centering the atoms in the molecule.
    287  * \param *mol molecule with all the atoms
    288  */
    289 static void CenterAtoms(molecule *mol)
    290 {
    291   Vector x, y, helper;
    292   char choice;  // menu choice char
    293 
    294   cout << Verbose(0) << "===========CENTER ATOMS=========================" << endl;
    295   cout << Verbose(0) << " a - on origin" << endl;
    296   cout << Verbose(0) << " b - on center of gravity" << endl;
    297   cout << Verbose(0) << " c - within box with additional boundary" << endl;
    298   cout << Verbose(0) << " d - within given simulation box" << endl;
    299   cout << Verbose(0) << "all else - go back" << endl;
    300   cout << Verbose(0) << "===============================================" << endl;
    301   cout << Verbose(0) << "INPUT: ";
    302   cin >> choice;
    303 
    304   switch (choice) {
    305     default:
    306       cout << Verbose(0) << "Not a valid choice." << endl;
    307       break;
    308     case 'a':
    309       cout << Verbose(0) << "Centering atoms in config file on origin." << endl;
    310       mol->CenterOrigin();
    311       break;
    312     case 'b':
    313       cout << Verbose(0) << "Centering atoms in config file on center of gravity." << endl;
    314       mol->CenterPeriodic();
    315       break;
    316     case 'c':
    317       cout << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;
    318       for (int i=0;i<NDIM;i++) {
    319         cout << Verbose(0) << "Enter axis " << i << " boundary: ";
    320         cin >> y.x[i];
    321       }
    322       mol->CenterEdge(&x);  // make every coordinate positive
    323       mol->Center.AddVector(&y); // translate by boundary
    324       helper.CopyVector(&y);
    325       helper.Scale(2.);
    326       helper.AddVector(&x);
    327       mol->SetBoxDimension(&helper);  // update Box of atoms by boundary
    328       break;
    329     case 'd':
    330       cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
    331       for (int i=0;i<NDIM;i++) {
    332         cout << Verbose(0) << "Enter axis " << i << " boundary: ";
    333         cin >> x.x[i];
    334       }
    335       // update Box of atoms by boundary
    336       mol->SetBoxDimension(&x);
    337       // center
    338       mol->CenterInBox();
    339       break;
    340   }
    341 };
    342 
    343 /** Submenu for aligning the atoms in the molecule.
    344  * \param *periode periodentafel
    345  * \param *mol molecule with all the atoms
    346  */
    347 static void AlignAtoms(periodentafel *periode, molecule *mol)
    348 {
    349   atom *first, *second, *third;
    350   Vector x,n;
    351   char choice;  // menu choice char
    352 
    353   cout << Verbose(0) << "===========ALIGN ATOMS=========================" << endl;
    354   cout << Verbose(0) << " a - state three atoms defining align plane" << endl;
    355   cout << Verbose(0) << " b - state alignment vector" << endl;
    356   cout << Verbose(0) << " c - state two atoms in alignment direction" << endl;
    357   cout << Verbose(0) << " d - align automatically by least square fit" << endl;
    358   cout << Verbose(0) << "all else - go back" << endl;
    359   cout << Verbose(0) << "===============================================" << endl;
    360   cout << Verbose(0) << "INPUT: ";
    361   cin >> choice;
    362 
    363   switch (choice) {
    364     default:
    365     case 'a': // three atoms defining mirror plane
    366       first = mol->AskAtom("Enter first atom: ");
    367       second = mol->AskAtom("Enter second atom: ");
    368       third = mol->AskAtom("Enter third atom: ");
    369 
    370       n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
    371       break;
    372     case 'b': // normal vector of mirror plane
    373       cout << Verbose(0) << "Enter normal vector of mirror plane." << endl;
    374       n.AskPosition(World::getInstance().getDomain(),0);
    375       n.Normalize();
    376       break;
    377     case 'c': // three atoms defining mirror plane
    378       first = mol->AskAtom("Enter first atom: ");
    379       second = mol->AskAtom("Enter second atom: ");
    380 
    381       n.CopyVector((const Vector *)&first->x);
    382       n.SubtractVector((const Vector *)&second->x);
    383       n.Normalize();
    384       break;
    385     case 'd':
    386       char shorthand[4];
    387       Vector a;
    388       struct lsq_params param;
    389       do {
    390         fprintf(stdout, "Enter the element of atoms to be chosen: ");
    391         fscanf(stdin, "%3s", shorthand);
    392       } while ((param.type = periode->FindElement(shorthand)) == NULL);
    393       cout << Verbose(0) << "Element is " << param.type->name << endl;
    394       mol->GetAlignvector(&param);
    395       for (int i=NDIM;i--;) {
    396         x.x[i] = gsl_vector_get(param.x,i);
    397         n.x[i] = gsl_vector_get(param.x,i+NDIM);
    398       }
    399       gsl_vector_free(param.x);
    400       cout << Verbose(0) << "Offset vector: ";
    401       x.Output();
    402       DoLog(0) && (Log() << Verbose(0) << endl);
    403       n.Normalize();
    404       break;
    405   };
    406   DoLog(0) && (Log() << Verbose(0) << "Alignment vector: ");
    407   n.Output();
    408   DoLog(0) && (Log() << Verbose(0) << endl);
    409   mol->Align(&n);
    410 };
    411 
    412 /** Submenu for mirroring the atoms in the molecule.
    413  * \param *mol molecule with all the atoms
    414  */
    415 static void MirrorAtoms(molecule *mol)
    416 {
    417   atom *first, *second, *third;
    418   Vector n;
    419   char choice;  // menu choice char
    420 
    421   DoLog(0) && (Log() << Verbose(0) << "===========MIRROR ATOMS=========================" << endl);
    422   DoLog(0) && (Log() << Verbose(0) << " a - state three atoms defining mirror plane" << endl);
    423   DoLog(0) && (Log() << Verbose(0) << " b - state normal vector of mirror plane" << endl);
    424   DoLog(0) && (Log() << Verbose(0) << " c - state two atoms in normal direction" << endl);
    425   DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
    426   DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    427   DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    428   cin >> choice;
    429 
    430   switch (choice) {
    431     default:
    432     case 'a': // three atoms defining mirror plane
    433       first = mol->AskAtom("Enter first atom: ");
    434       second = mol->AskAtom("Enter second atom: ");
    435       third = mol->AskAtom("Enter third atom: ");
    436 
    437       n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
    438       break;
    439     case 'b': // normal vector of mirror plane
    440       DoLog(0) && (Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl);
    441       n.AskPosition(World::getInstance().getDomain(),0);
    442       n.Normalize();
    443       break;
    444     case 'c': // three atoms defining mirror plane
    445       first = mol->AskAtom("Enter first atom: ");
    446       second = mol->AskAtom("Enter second atom: ");
    447 
    448       n.CopyVector((const Vector *)&first->x);
    449       n.SubtractVector((const Vector *)&second->x);
    450       n.Normalize();
    451       break;
    452   };
    453   DoLog(0) && (Log() << Verbose(0) << "Normal vector: ");
    454   n.Output();
    455   DoLog(0) && (Log() << Verbose(0) << endl);
    456   mol->Mirror((const Vector *)&n);
    457 };
    458 
    459 /** Submenu for removing the atoms from the molecule.
    460  * \param *mol molecule with all the atoms
    461  */
    462 static void RemoveAtoms(molecule *mol)
    463 {
    464   atom *first, *second;
    465   int axis;
    466   double tmp1, tmp2;
    467   char choice;  // menu choice char
    468 
    469   DoLog(0) && (Log() << Verbose(0) << "===========REMOVE ATOMS=========================" << endl);
    470   DoLog(0) && (Log() << Verbose(0) << " a - state atom for removal by number" << endl);
    471   DoLog(0) && (Log() << Verbose(0) << " b - keep only in radius around atom" << endl);
    472   DoLog(0) && (Log() << Verbose(0) << " c - remove this with one axis greater value" << endl);
    473   DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
    474   DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    475   DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    476   cin >> choice;
    477 
    478   switch (choice) {
    479     default:
    480     case 'a':
    481       if (mol->RemoveAtom(mol->AskAtom("Enter number of atom within molecule: ")))
    482         DoLog(1) && (Log() << Verbose(1) << "Atom removed." << endl);
    483       else
    484         DoLog(1) && (Log() << Verbose(1) << "Atom not found." << endl);
    485       break;
    486     case 'b':
    487       second = mol->AskAtom("Enter number of atom as reference point: ");
    488       DoLog(0) && (Log() << Verbose(0) << "Enter radius: ");
    489       cin >> tmp1;
    490       first = mol->start;
    491       second = first->next;
    492       while(second != mol->end) {
    493         first = second;
    494         second = first->next;
    495         if (first->x.DistanceSquared((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ...
    496           mol->RemoveAtom(first);
    497       }
    498       break;
    499     case 'c':
    500       DoLog(0) && (Log() << Verbose(0) << "Which axis is it: ");
    501       cin >> axis;
    502       DoLog(0) && (Log() << Verbose(0) << "Lower boundary: ");
    503       cin >> tmp1;
    504       DoLog(0) && (Log() << Verbose(0) << "Upper boundary: ");
    505       cin >> tmp2;
    506       first = mol->start;
    507       second = first->next;
    508       while(second != mol->end) {
    509         first = second;
    510         second = first->next;
    511         if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...
    512           //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
    513           mol->RemoveAtom(first);
    514         }
    515       }
    516       break;
    517   };
    518   //mol->Output();
    519   choice = 'r';
    520 };
    521 
    522 /** Submenu for measuring out the atoms in the molecule.
    523  * \param *periode periodentafel
    524  * \param *mol molecule with all the atoms
    525  */
    526 static void MeasureAtoms(periodentafel *periode, molecule *mol, config *configuration)
    527 {
    528   atom *first, *second, *third;
    529   Vector x,y;
    530   double min[256], tmp1, tmp2, tmp3;
    531   int Z;
    532   char choice;  // menu choice char
    533 
    534   DoLog(0) && (Log() << Verbose(0) << "===========MEASURE ATOMS=========================" << endl);
    535   DoLog(0) && (Log() << Verbose(0) << " a - calculate bond length between one atom and all others" << endl);
    536   DoLog(0) && (Log() << Verbose(0) << " b - calculate bond length between two atoms" << endl);
    537   DoLog(0) && (Log() << Verbose(0) << " c - calculate bond angle" << endl);
    538   DoLog(0) && (Log() << Verbose(0) << " d - calculate principal axis of the system" << endl);
    539   DoLog(0) && (Log() << Verbose(0) << " e - calculate volume of the convex envelope" << endl);
    540   DoLog(0) && (Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl);
    541   DoLog(0) && (Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl);
    542   DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
    543   DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    544   DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    545   cin >> choice;
    546 
    547   switch(choice) {
    548     default:
    549       DoLog(1) && (Log() << Verbose(1) << "Not a valid choice." << endl);
    550       break;
    551     case 'a':
    552       first = mol->AskAtom("Enter first atom: ");
    553       for (int i=MAX_ELEMENTS;i--;)
    554         min[i] = 0.;
    555 
    556       second = mol->start;
    557       while ((second->next != mol->end)) {
    558         second = second->next; // advance
    559         Z = second->type->Z;
    560         tmp1 = 0.;
    561         if (first != second) {
    562           x.CopyVector((const Vector *)&first->x);
    563           x.SubtractVector((const Vector *)&second->x);
    564           tmp1 = x.Norm();
    565         }
    566         if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
    567         //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;
    568       }
    569       for (int i=MAX_ELEMENTS;i--;)
    570         if (min[i] != 0.) Log() << Verbose(0) << "Minimum Bond length between " << first->type->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl;
    571       break;
    572 
    573     case 'b':
    574       first = mol->AskAtom("Enter first atom: ");
    575       second = mol->AskAtom("Enter second atom: ");
    576       for (int i=NDIM;i--;)
    577         min[i] = 0.;
    578       x.CopyVector((const Vector *)&first->x);
    579       x.SubtractVector((const Vector *)&second->x);
    580       tmp1 = x.Norm();
    581       DoLog(1) && (Log() << Verbose(1) << "Distance vector is ");
    582       x.Output();
    583       DoLog(0) && (Log() << Verbose(0) << "." << endl << "Norm of distance is " << tmp1 << "." << endl);
    584       break;
    585 
    586     case 'c':
    587       DoLog(0) && (Log() << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl);
    588       first = mol->AskAtom("Enter first atom: ");
    589       second = mol->AskAtom("Enter central atom: ");
    590       third  = mol->AskAtom("Enter last atom: ");
    591       tmp1 = tmp2 = tmp3 = 0.;
    592       x.CopyVector((const Vector *)&first->x);
    593       x.SubtractVector((const Vector *)&second->x);
    594       y.CopyVector((const Vector *)&third->x);
    595       y.SubtractVector((const Vector *)&second->x);
    596       DoLog(0) && (Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ");
    597       DoLog(0) && (Log() << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl);
    598       break;
    599     case 'd':
    600       DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
    601       DoLog(0) && (Log() << Verbose(0) << "Shall we rotate? [0/1]: ");
    602       cin >> Z;
    603       if ((Z >=0) && (Z <=1))
    604         mol->PrincipalAxisSystem((bool)Z);
    605       else
    606         mol->PrincipalAxisSystem(false);
    607       break;
    608     case 'e':
    609       {
    610         DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope.");
    611         class Tesselation *TesselStruct = NULL;
    612         const LinkedCell *LCList = NULL;
    613         LCList = new LinkedCell(mol, 10.);
    614         FindConvexBorder(mol, TesselStruct, LCList, NULL);
    615         double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
    616         DoLog(0) && (Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl);\
    617         delete(LCList);
    618         delete(TesselStruct);
    619       }
    620       break;
    621     case 'f':
    622       mol->OutputTemperatureFromTrajectories((ofstream *)&cout, mol->MDSteps-1, mol->MDSteps);
    623       break;
    624     case 'g':
    625       {
    626         char filename[255];
    627         DoLog(0) && (Log() << Verbose(0) << "Please enter filename: " << endl);
    628         cin >> filename;
    629         DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl);
    630         ofstream *output = new ofstream(filename, ios::trunc);
    631         if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps))
    632           DoLog(2) && (Log() << Verbose(2) << "File could not be written." << endl);
    633         else
    634           DoLog(2) && (Log() << Verbose(2) << "File stored." << endl);
    635         output->close();
    636         delete(output);
    637       }
    638       break;
    639   }
    640 };
    641 
    642 /** Submenu for measuring out the atoms in the molecule.
    643  * \param *mol molecule with all the atoms
    644  * \param *configuration configuration structure for the to be written config files of all fragments
    645  */
    646 static void FragmentAtoms(molecule *mol, config *configuration)
    647 {
    648   int Order1;
    649   clock_t start, end;
    650 
    651   DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
    652   DoLog(0) && (Log() << Verbose(0) << "What's the desired bond order: ");
    653   cin >> Order1;
    654   if (mol->first->next != mol->last) {  // there are bonds
    655     start = clock();
    656     mol->FragmentMolecule(Order1, configuration);
    657     end = clock();
    658     DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    659   } else
    660     DoLog(0) && (Log() << Verbose(0) << "Connection matrix has not yet been generated!" << endl);
    661 };
    662 
    663 /********************************************** Submenu routine **************************************/
    664 
    665 /** Submenu for manipulating atoms.
    666  * \param *periode periodentafel
    667  * \param *molecules list of molecules whose atoms are to be manipulated
    668  */
    669 static void ManipulateAtoms(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
    670 {
    671   atom *first, *second, *third;
    672   molecule *mol = NULL;
    673   Vector x,y,z,n; // coordinates for absolute point in cell volume
    674   double *factor; // unit factor if desired
    675   double bond, minBond;
    676   char choice;  // menu choice char
    677   bool valid;
    678 
    679   DoLog(0) && (Log() << Verbose(0) << "=========MANIPULATE ATOMS======================" << endl);
    680   DoLog(0) && (Log() << Verbose(0) << "a - add an atom" << endl);
    681   DoLog(0) && (Log() << Verbose(0) << "r - remove an atom" << endl);
    682   DoLog(0) && (Log() << Verbose(0) << "b - scale a bond between atoms" << endl);
    683   DoLog(0) && (Log() << Verbose(0) << "t - turn an atom round another bond" << endl);
    684   DoLog(0) && (Log() << Verbose(0) << "u - change an atoms element" << endl);
    685   DoLog(0) && (Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl);
    686   DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
    687   DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    688   if (molecules->NumberOfActiveMolecules() > 1)
    689     DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl);
    690   DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    691   cin >> choice;
    692 
    693   switch (choice) {
    694     default:
    695       DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
    696       break;
    697 
    698     case 'a': // add atom
    699       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    700         if ((*ListRunner)->ActiveFlag) {
    701         mol = *ListRunner;
    702         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    703         AddAtoms(periode, mol);
    704       }
    705       break;
    706 
    707     case 'b': // scale a bond
    708       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    709         if ((*ListRunner)->ActiveFlag) {
    710         mol = *ListRunner;
    711         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    712         DoLog(0) && (Log() << Verbose(0) << "Scaling bond length between two atoms." << endl);
    713         first = mol->AskAtom("Enter first (fixed) atom: ");
    714         second = mol->AskAtom("Enter second (shifting) atom: ");
    715         minBond = 0.;
    716         for (int i=NDIM;i--;)
    717           minBond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]);
    718         minBond = sqrt(minBond);
    719         DoLog(0) && (Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl);
    720         DoLog(0) && (Log() << Verbose(0) << "Enter new bond length [a.u.]: ");
    721         cin >> bond;
    722         for (int i=NDIM;i--;) {
    723           second->x.x[i] -= (second->x.x[i]-first->x.x[i])/minBond*(minBond-bond);
    724         }
    725         //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: ";
    726         //second->Output(second->type->No, 1);
    727       }
    728       break;
    729 
    730     case 'c': // unit scaling of the metric
    731       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    732         if ((*ListRunner)->ActiveFlag) {
    733         mol = *ListRunner;
    734         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    735        DoLog(0) && (Log() << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl);
    736        DoLog(0) && (Log() << Verbose(0) << "Enter three factors: ");
    737        factor = new double[NDIM];
    738        cin >> factor[0];
    739        cin >> factor[1];
    740        cin >> factor[2];
    741        valid = true;
    742        mol->Scale((const double ** const)&factor);
    743        delete[](factor);
    744       }
    745      break;
    746 
    747     case 'l': // measure distances or angles
    748       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    749         if ((*ListRunner)->ActiveFlag) {
    750         mol = *ListRunner;
    751         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    752         MeasureAtoms(periode, mol, configuration);
    753       }
    754       break;
    755 
    756     case 'r': // remove atom
    757       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    758         if ((*ListRunner)->ActiveFlag) {
    759         mol = *ListRunner;
    760         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    761         RemoveAtoms(mol);
    762       }
    763       break;
    764 
    765     case 't': // turn/rotate atom
    766       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    767         if ((*ListRunner)->ActiveFlag) {
    768           mol = *ListRunner;
    769           DoLog(0) && (Log() << Verbose(0) << "Turning atom around another bond - first is atom to turn, second (central) and third specify bond" << endl);
    770           first = mol->AskAtom("Enter turning atom: ");
    771           second = mol->AskAtom("Enter central atom: ");
    772           third  = mol->AskAtom("Enter bond atom: ");
    773           cout << Verbose(0) << "Enter new angle in degrees: ";
    774           double tmp = 0.;
    775           cin >> tmp;
    776           // calculate old angle
    777           x.CopyVector((const Vector *)&first->x);
    778           x.SubtractVector((const Vector *)&second->x);
    779           y.CopyVector((const Vector *)&third->x);
    780           y.SubtractVector((const Vector *)&second->x);
    781           double alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.);
    782           cout << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
    783           cout << Verbose(0) << alpha << " degrees" << endl;
    784           // rotate
    785           z.MakeNormalVector(&x,&y);
    786           x.RotateVector(&z,(alpha-tmp)*M_PI/180.);
    787           x.AddVector(&second->x);
    788           first->x.CopyVector(&x);
    789           // check new angle
    790           x.CopyVector((const Vector *)&first->x);
    791           x.SubtractVector((const Vector *)&second->x);
    792           alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.);
    793           cout << Verbose(0) << "new Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
    794           cout << Verbose(0) << alpha << " degrees" << endl;
    795         }
    796       break;
    797 
    798     case 'u': // change an atom's element
    799       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    800         if ((*ListRunner)->ActiveFlag) {
    801         int Z;
    802         mol = *ListRunner;
    803         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    804         first = NULL;
    805         do {
    806           DoLog(0) && (Log() << Verbose(0) << "Change the element of which atom: ");
    807           cin >> Z;
    808         } while ((first = mol->FindAtom(Z)) == NULL);
    809         DoLog(0) && (Log() << Verbose(0) << "New element by atomic number Z: ");
    810         cin >> Z;
    811         first->type = periode->FindElement(Z);
    812         DoLog(0) && (Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl);
    813       }
    814       break;
    815   }
    816 };
    817 
    818 /** Submenu for manipulating molecules.
    819  * \param *periode periodentafel
    820  * \param *molecules list of molecule to manipulate
    821  */
    822 static void ManipulateMolecules(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
    823 {
    824   atom *first = NULL;
    825   Vector x,y,z,n; // coordinates for absolute point in cell volume
    826   int j, axis, count, faktor;
    827   char choice;  // menu choice char
    828   molecule *mol = NULL;
    829   element **Elements;
    830   Vector **vectors;
    831   MoleculeLeafClass *Subgraphs = NULL;
    832 
    833   DoLog(0) && (Log() << Verbose(0) << "=========MANIPULATE GLOBALLY===================" << endl);
    834   DoLog(0) && (Log() << Verbose(0) << "c - scale by unit transformation" << endl);
    835   DoLog(0) && (Log() << Verbose(0) << "d - duplicate molecule/periodic cell" << endl);
    836   DoLog(0) && (Log() << Verbose(0) << "f - fragment molecule many-body bond order style" << endl);
    837   DoLog(0) && (Log() << Verbose(0) << "g - center atoms in box" << endl);
    838   DoLog(0) && (Log() << Verbose(0) << "i - realign molecule" << endl);
    839   DoLog(0) && (Log() << Verbose(0) << "m - mirror all molecules" << endl);
    840   DoLog(0) && (Log() << Verbose(0) << "o - create connection matrix" << endl);
    841   DoLog(0) && (Log() << Verbose(0) << "t - translate molecule by vector" << endl);
    842   DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
    843   DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    844   if (molecules->NumberOfActiveMolecules() > 1)
    845     DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl);
    846   DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    847   cin >> choice;
    848 
    849   switch (choice) {
    850     default:
    851       DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
    852       break;
    853 
    854     case 'd': // duplicate the periodic cell along a given axis, given times
    855       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    856         if ((*ListRunner)->ActiveFlag) {
    857         mol = *ListRunner;
    858         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    859         DoLog(0) && (Log() << Verbose(0) << "State the axis [(+-)123]: ");
    860         cin >> axis;
    861         DoLog(0) && (Log() << Verbose(0) << "State the factor: ");
    862         cin >> faktor;
    863 
    864         mol->CountAtoms(); // recount atoms
    865         if (mol->AtomCount != 0) {  // if there is more than none
    866           count = mol->AtomCount;  // is changed becausing of adding, thus has to be stored away beforehand
    867           Elements = new element *[count];
    868           vectors = new Vector *[count];
    869           j = 0;
    870           first = mol->start;
    871           while (first->next != mol->end) { // make a list of all atoms with coordinates and element
    872             first = first->next;
    873             Elements[j] = first->type;
    874             vectors[j] = &first->x;
    875             j++;
    876           }
    877           if (count != j)
    878             DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
    879           x.Zero();
    880           y.Zero();
    881           y.x[abs(axis)-1] = World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
    882           for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
    883             x.AddVector(&y); // per factor one cell width further
    884             for (int k=count;k--;) { // go through every atom of the original cell
    885               first = new atom(); // create a new body
    886               first->x.CopyVector(vectors[k]);  // use coordinate of original atom
    887               first->x.AddVector(&x);     // translate the coordinates
    888               first->type = Elements[k];  // insert original element
    889               mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
    890             }
    891           }
    892           if (mol->first->next != mol->last) // if connect matrix is present already, redo it
    893             mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    894           // free memory
    895           delete[](Elements);
    896           delete[](vectors);
    897           // correct cell size
    898           if (axis < 0) { // if sign was negative, we have to translate everything
    899             x.Zero();
    900             x.AddVector(&y);
    901             x.Scale(-(faktor-1));
    902             mol->Translate(&x);
    903           }
    904           World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
    905         }
    906       }
    907       break;
    908 
    909     case 'f':
    910       FragmentAtoms(mol, configuration);
    911       break;
    912 
    913     case 'g': // center the atoms
    914       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    915         if ((*ListRunner)->ActiveFlag) {
    916         mol = *ListRunner;
    917         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    918         CenterAtoms(mol);
    919       }
    920       break;
    921 
    922     case 'i': // align all atoms
    923       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    924         if ((*ListRunner)->ActiveFlag) {
    925         mol = *ListRunner;
    926         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    927         AlignAtoms(periode, mol);
    928       }
    929       break;
    930 
    931     case 'm': // mirror atoms along a given axis
    932       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    933         if ((*ListRunner)->ActiveFlag) {
    934         mol = *ListRunner;
    935         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    936         MirrorAtoms(mol);
    937       }
    938       break;
    939 
    940     case 'o': // create the connection matrix
    941       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    942         if ((*ListRunner)->ActiveFlag) {
    943           mol = *ListRunner;
    944           double bonddistance;
    945           clock_t start,end;
    946           DoLog(0) && (Log() << Verbose(0) << "What's the maximum bond distance: ");
    947           cin >> bonddistance;
    948           start = clock();
    949           mol->CreateAdjacencyList(bonddistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    950           end = clock();
    951           DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    952         }
    953       break;
    954 
    955     case 't': // translate all atoms
    956       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    957         if ((*ListRunner)->ActiveFlag) {
    958         mol = *ListRunner;
    959         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    960         DoLog(0) && (Log() << Verbose(0) << "Enter translation vector." << endl);
    961         x.AskPosition(World::getInstance().getDomain(),0);
    962         mol->Center.AddVector((const Vector *)&x);
    963      }
    964      break;
    965   }
    966   // Free all
    967   if (Subgraphs != NULL) {  // free disconnected subgraph list of DFS analysis was performed
    968     while (Subgraphs->next != NULL) {
    969       Subgraphs = Subgraphs->next;
    970       delete(Subgraphs->previous);
    971     }
    972     delete(Subgraphs);
    973   }
    974 };
    975 
    976 
    977 /** Submenu for creating new molecules.
    978  * \param *periode periodentafel
    979  * \param *molecules list of molecules to add to
    980  */
    981 static void EditMolecules(periodentafel *periode, MoleculeListClass *molecules)
    982 {
    983   char choice;  // menu choice char
    984   Vector center;
    985   int nr, count;
    986   molecule *mol = NULL;
    987 
    988   DoLog(0) && (Log() << Verbose(0) << "==========EDIT MOLECULES=====================" << endl);
    989   DoLog(0) && (Log() << Verbose(0) << "c - create new molecule" << endl);
    990   DoLog(0) && (Log() << Verbose(0) << "l - load molecule from xyz file" << endl);
    991   DoLog(0) && (Log() << Verbose(0) << "n - change molecule's name" << endl);
    992   DoLog(0) && (Log() << Verbose(0) << "N - give molecules filename" << endl);
    993   DoLog(0) && (Log() << Verbose(0) << "p - parse atoms in xyz file into molecule" << endl);
    994   DoLog(0) && (Log() << Verbose(0) << "r - remove a molecule" << endl);
    995   DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
    996   DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    997   DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    998   cin >> choice;
    999 
    1000   switch (choice) {
    1001     default:
    1002       DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
    1003       break;
    1004     case 'c':
    1005       mol = World::getInstance().createMolecule();
    1006       molecules->insert(mol);
    1007       break;
    1008 
    1009     case 'l': // load from XYZ file
    1010       {
    1011         char filename[MAXSTRINGSIZE];
    1012         DoLog(0) && (Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl);
    1013         mol = World::getInstance().createMolecule();
    1014         do {
    1015           DoLog(0) && (Log() << Verbose(0) << "Enter file name: ");
    1016           cin >> filename;
    1017         } while (!mol->AddXYZFile(filename));
    1018         mol->SetNameFromFilename(filename);
    1019         // center at set box dimensions
    1020         mol->CenterEdge(&center);
    1021         double * const cell_size = World::getInstance().getDomain();
    1022         cell_size[0] = center.x[0];
    1023         cell_size[1] = 0;
    1024         cell_size[2] = center.x[1];
    1025         cell_size[3] = 0;
    1026         cell_size[4] = 0;
    1027         cell_size[5] = center.x[2];
    1028         molecules->insert(mol);
    1029       }
    1030       break;
    1031 
    1032     case 'n':
    1033       {
    1034         char filename[MAXSTRINGSIZE];
    1035         do {
    1036           DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
    1037           cin >> nr;
    1038           mol = molecules->ReturnIndex(nr);
    1039         } while (mol == NULL);
    1040         DoLog(0) && (Log() << Verbose(0) << "Enter name: ");
    1041         cin >> filename;
    1042         strcpy(mol->name, filename);
    1043       }
    1044       break;
    1045 
    1046     case 'N':
    1047       {
    1048         char filename[MAXSTRINGSIZE];
    1049         do {
    1050           DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
    1051           cin >> nr;
    1052           mol = molecules->ReturnIndex(nr);
    1053         } while (mol == NULL);
    1054         DoLog(0) && (Log() << Verbose(0) << "Enter name: ");
    1055         cin >> filename;
    1056         mol->SetNameFromFilename(filename);
    1057       }
    1058       break;
    1059 
    1060     case 'p': // parse XYZ file
    1061       {
    1062         char filename[MAXSTRINGSIZE];
    1063         mol = NULL;
    1064         do {
    1065           DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
    1066           cin >> nr;
    1067           mol = molecules->ReturnIndex(nr);
    1068         } while (mol == NULL);
    1069         DoLog(0) && (Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl);
    1070         do {
    1071           DoLog(0) && (Log() << Verbose(0) << "Enter file name: ");
    1072           cin >> filename;
    1073         } while (!mol->AddXYZFile(filename));
    1074         mol->SetNameFromFilename(filename);
    1075       }
    1076       break;
    1077 
    1078     case 'r':
    1079       DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
    1080       cin >> nr;
    1081       count = 1;
    1082       for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    1083         if (nr == (*ListRunner)->IndexNr) {
    1084           mol = *ListRunner;
    1085           molecules->ListOfMolecules.erase(ListRunner);
    1086           delete(mol);
    1087           break;
    1088         }
    1089       break;
    1090   }
    1091 };
    1092 
    1093 
    1094 /** Submenu for merging molecules.
    1095  * \param *periode periodentafel
    1096  * \param *molecules list of molecules to add to
    1097  */
    1098 static void MergeMolecules(periodentafel *periode, MoleculeListClass *molecules)
    1099 {
    1100   char choice;  // menu choice char
    1101 
    1102   DoLog(0) && (Log() << Verbose(0) << "===========MERGE MOLECULES=====================" << endl);
    1103   DoLog(0) && (Log() << Verbose(0) << "a - simple add of one molecule to another" << endl);
    1104   DoLog(0) && (Log() << Verbose(0) << "b - count the number of bonds of two elements" << endl);
    1105   DoLog(0) && (Log() << Verbose(0) << "B - count the number of bonds of three elements " << endl);
    1106   DoLog(0) && (Log() << Verbose(0) << "e - embedding merge of two molecules" << endl);
    1107   DoLog(0) && (Log() << Verbose(0) << "h - count the number of hydrogen bonds" << endl);
    1108   DoLog(0) && (Log() << Verbose(0) << "b - count the number of hydrogen bonds" << endl);
    1109   DoLog(0) && (Log() << Verbose(0) << "m - multi-merge of all molecules" << endl);
    1110   DoLog(0) && (Log() << Verbose(0) << "s - scatter merge of two molecules" << endl);
    1111   DoLog(0) && (Log() << Verbose(0) << "t - simple merge of two molecules" << endl);
    1112   DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
    1113   DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    1114   DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    1115   cin >> choice;
    1116 
    1117   switch (choice) {
    1118     default:
    1119       DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
    1120       break;
    1121 
    1122     case 'a':
    1123       {
    1124         int src, dest;
    1125         molecule *srcmol = NULL, *destmol = NULL;
    1126         {
    1127           do {
    1128             DoLog(0) && (Log() << Verbose(0) << "Enter index of destination molecule: ");
    1129             cin >> dest;
    1130             destmol = molecules->ReturnIndex(dest);
    1131           } while ((destmol == NULL) && (dest != -1));
    1132           do {
    1133             DoLog(0) && (Log() << Verbose(0) << "Enter index of source molecule to add from: ");
    1134             cin >> src;
    1135             srcmol = molecules->ReturnIndex(src);
    1136           } while ((srcmol == NULL) && (src != -1));
    1137           if ((src != -1) && (dest != -1))
    1138             molecules->SimpleAdd(srcmol, destmol);
    1139         }
    1140       }
    1141       break;
    1142 
    1143     case 'b':
    1144       {
    1145         const int nr = 2;
    1146         char *names[nr] = {"first", "second"};
    1147         int Z[nr];
    1148         element *elements[nr];
    1149         for (int i=0;i<nr;i++) {
    1150           Z[i] = 0;
    1151           do {
    1152             cout << "Enter " << names[i] << " element: ";
    1153             cin >> Z[i];
    1154           } while ((Z[i] <= 0) && (Z[i] > MAX_ELEMENTS));
    1155           elements[i] = periode->FindElement(Z[i]);
    1156         }
    1157         const int count = CountBondsOfTwo(molecules, elements[0], elements[1]);
    1158         cout << endl << "There are " << count << " ";
    1159         for (int i=0;i<nr;i++) {
    1160           if (i==0)
    1161             cout << elements[i]->symbol;
    1162           else
    1163             cout << "-" << elements[i]->symbol;
    1164         }
    1165         cout << " bonds." << endl;
    1166       }
    1167     break;
    1168 
    1169     case 'B':
    1170       {
    1171         const int nr = 3;
    1172         char *names[nr] = {"first", "second", "third"};
    1173         int Z[nr];
    1174         element *elements[nr];
    1175         for (int i=0;i<nr;i++) {
    1176           Z[i] = 0;
    1177           do {
    1178             cout << "Enter " << names[i] << " element: ";
    1179             cin >> Z[i];
    1180           } while ((Z[i] <= 0) && (Z[i] > MAX_ELEMENTS));
    1181           elements[i] = periode->FindElement(Z[i]);
    1182         }
    1183         const int count = CountBondsOfThree(molecules, elements[0], elements[1], elements[2]);
    1184         cout << endl << "There are " << count << " ";
    1185         for (int i=0;i<nr;i++) {
    1186           if (i==0)
    1187             cout << elements[i]->symbol;
    1188           else
    1189             cout << "-" << elements[i]->symbol;
    1190         }
    1191         cout << " bonds." << endl;
    1192       }
    1193     break;
    1194 
    1195     case 'e':
    1196       {
    1197         int src, dest;
    1198         molecule *srcmol = NULL, *destmol = NULL;
    1199         do {
    1200           DoLog(0) && (Log() << Verbose(0) << "Enter index of matrix molecule (the variable one): ");
    1201           cin >> src;
    1202           srcmol = molecules->ReturnIndex(src);
    1203         } while ((srcmol == NULL) && (src != -1));
    1204         do {
    1205           DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule to merge into (the fixed one): ");
    1206           cin >> dest;
    1207           destmol = molecules->ReturnIndex(dest);
    1208         } while ((destmol == NULL) && (dest != -1));
    1209         if ((src != -1) && (dest != -1))
    1210           molecules->EmbedMerge(destmol, srcmol);
    1211       }
    1212       break;
    1213 
    1214     case 'h':
    1215       {
    1216         int Z;
    1217         cout << "Please enter interface element: ";
    1218         cin >> Z;
    1219         element * const InterfaceElement = periode->FindElement(Z);
    1220         cout << endl << "There are " << CountHydrogenBridgeBonds(molecules, InterfaceElement) << " hydrogen bridges with connections to " << (InterfaceElement != 0 ? InterfaceElement->name : "None") << "." << endl;
    1221       }
    1222       break;
    1223 
    1224     case 'm':
    1225       {
    1226         int nr;
    1227         molecule *mol = NULL;
    1228         do {
    1229           DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule to merge into: ");
    1230           cin >> nr;
    1231           mol = molecules->ReturnIndex(nr);
    1232         } while ((mol == NULL) && (nr != -1));
    1233         if (nr != -1) {
    1234           int N = molecules->ListOfMolecules.size()-1;
    1235           int *src = new int(N);
    1236           for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    1237             if ((*ListRunner)->IndexNr != nr)
    1238               src[N++] = (*ListRunner)->IndexNr;       
    1239           molecules->SimpleMultiMerge(mol, src, N);
    1240           delete[](src);
    1241         }
    1242       }
    1243       break;
    1244 
    1245     case 's':
    1246       DoLog(0) && (Log() << Verbose(0) << "Not implemented yet." << endl);
    1247       break;
    1248 
    1249     case 't':
    1250       {
    1251         int src, dest;
    1252         molecule *srcmol = NULL, *destmol = NULL;
    1253         {
    1254           do {
    1255             DoLog(0) && (Log() << Verbose(0) << "Enter index of destination molecule: ");
    1256             cin >> dest;
    1257             destmol = molecules->ReturnIndex(dest);
    1258           } while ((destmol == NULL) && (dest != -1));
    1259           do {
    1260             DoLog(0) && (Log() << Verbose(0) << "Enter index of source molecule to merge into: ");
    1261             cin >> src;
    1262             srcmol = molecules->ReturnIndex(src);
    1263           } while ((srcmol == NULL) && (src != -1));
    1264           if ((src != -1) && (dest != -1))
    1265             molecules->SimpleMerge(srcmol, destmol);
    1266         }
    1267       }
    1268       break;
    1269   }
    1270 };
    1271 
    1272 /********************************************** Test routine **************************************/
    1273 
    1274 /** Is called always as option 'T' in the menu.
    1275  * \param *molecules list of molecules
    1276  */
    1277 static void testroutine(MoleculeListClass *molecules)
    1278 {
    1279   // the current test routine checks the functionality of the KeySet&Graph concept:
    1280   // We want to have a multiindex (the KeySet) describing a unique subgraph
    1281   int i, comp, counter=0;
    1282 
    1283   // create a clone
    1284   molecule *mol = NULL;
    1285   if (molecules->ListOfMolecules.size() != 0) // clone
    1286     mol = (molecules->ListOfMolecules.front())->CopyMolecule();
    1287   else {
    1288     DoeLog(0) && (eLog()<< Verbose(0) << "I don't have anything to test on ... ");
    1289     performCriticalExit();
    1290     return;
    1291   }
    1292   atom *Walker = mol->start;
    1293 
    1294   // generate some KeySets
    1295   DoLog(0) && (Log() << Verbose(0) << "Generating KeySets." << endl);
    1296   KeySet TestSets[mol->AtomCount+1];
    1297   i=1;
    1298   while (Walker->next != mol->end) {
    1299     Walker = Walker->next;
    1300     for (int j=0;j<i;j++) {
    1301       TestSets[j].insert(Walker->nr);
    1302     }
    1303     i++;
    1304   }
    1305   DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl);
    1306   KeySetTestPair test;
    1307   test = TestSets[mol->AtomCount-1].insert(Walker->nr);
    1308   if (test.second) {
    1309     DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
    1310   } else {
    1311     DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl);
    1312   }
    1313   TestSets[mol->AtomCount].insert(mol->end->previous->nr);
    1314   TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);
    1315 
    1316   // constructing Graph structure
    1317   DoLog(0) && (Log() << Verbose(0) << "Generating Subgraph class." << endl);
    1318   Graph Subgraphs;
    1319 
    1320   // insert KeySets into Subgraphs
    1321   DoLog(0) && (Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl);
    1322   for (int j=0;j<mol->AtomCount;j++) {
    1323     Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
    1324   }
    1325   DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl);
    1326   GraphTestPair test2;
    1327   test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.)));
    1328   if (test2.second) {
    1329     DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
    1330   } else {
    1331     DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl);
    1332   }
    1333 
    1334   // show graphs
    1335   DoLog(0) && (Log() << Verbose(0) << "Showing Subgraph's contents, checking that it's sorted." << endl);
    1336   Graph::iterator A = Subgraphs.begin();
    1337   while (A !=  Subgraphs.end()) {
    1338     DoLog(0) && (Log() << Verbose(0) << (*A).second.first << ": ");
    1339     KeySet::iterator key = (*A).first.begin();
    1340     comp = -1;
    1341     while (key != (*A).first.end()) {
    1342       if ((*key) > comp)
    1343         DoLog(0) && (Log() << Verbose(0) << (*key) << " ");
    1344       else
    1345         DoLog(0) && (Log() << Verbose(0) << (*key) << "! ");
    1346       comp = (*key);
    1347       key++;
    1348     }
    1349     DoLog(0) && (Log() << Verbose(0) << endl);
    1350     A++;
    1351   }
    1352   delete(mol);
    1353 };
    1354 
    1355 #endif
    1356 
    1357 /** Tries given filename or standard on saving the config file.
    1358  * \param *ConfigFileName name of file
    1359  * \param *configuration pointer to configuration structure with all the values
    1360  * \param *periode pointer to periodentafel structure with all the elements
    1361  * \param *molecules list of molecules structure with all the atoms and coordinates
    1362  */
    1363 static void SaveConfig(char *ConfigFileName, config *configuration, periodentafel *periode, MoleculeListClass *molecules)
    1364 {
    1365   char filename[MAXSTRINGSIZE];
    1366   ofstream output;
    1367   molecule *mol = World::getInstance().createMolecule();
    1368   mol->SetNameFromFilename(ConfigFileName);
    1369 
    1370   if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
    1371     DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl);
    1372   }
    1373 
    1374 
    1375   // first save as PDB data
    1376   if (ConfigFileName != NULL)
    1377     strcpy(filename, ConfigFileName);
    1378   if (output == NULL)
    1379     strcpy(filename,"main_pcp_linux");
    1380   DoLog(0) && (Log() << Verbose(0) << "Saving as pdb input ");
    1381   if (configuration->SavePDB(filename, molecules))
    1382     DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    1383   else
    1384     DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    1385 
    1386   // then save as tremolo data file
    1387   if (ConfigFileName != NULL)
    1388     strcpy(filename, ConfigFileName);
    1389   if (output == NULL)
    1390     strcpy(filename,"main_pcp_linux");
    1391   DoLog(0) && (Log() << Verbose(0) << "Saving as tremolo data input ");
    1392   if (configuration->SaveTREMOLO(filename, molecules))
    1393     DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    1394   else
    1395     DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    1396 
    1397   // translate each to its center and merge all molecules in MoleculeListClass into this molecule
    1398   int N = molecules->ListOfMolecules.size();
    1399   int *src = new int[N];
    1400   N=0;
    1401   for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
    1402     src[N++] = (*ListRunner)->IndexNr;
    1403     (*ListRunner)->Translate(&(*ListRunner)->Center);
    1404   }
    1405   molecules->SimpleMultiAdd(mol, src, N);
    1406   delete[](src);
    1407 
    1408   // ... and translate back
    1409   for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
    1410     (*ListRunner)->Center.Scale(-1.);
    1411     (*ListRunner)->Translate(&(*ListRunner)->Center);
    1412     (*ListRunner)->Center.Scale(-1.);
    1413   }
    1414 
    1415   DoLog(0) && (Log() << Verbose(0) << "Storing configuration ... " << endl);
    1416   // get correct valence orbitals
    1417   mol->CalculateOrbitals(*configuration);
    1418   configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble;
    1419   if (ConfigFileName != NULL) { // test the file name
    1420     strcpy(filename, ConfigFileName);
    1421     output.open(filename, ios::trunc);
    1422   } else if (strlen(configuration->configname) != 0) {
    1423     strcpy(filename, configuration->configname);
    1424     output.open(configuration->configname, ios::trunc);
    1425     } else {
    1426       strcpy(filename, DEFAULTCONFIG);
    1427       output.open(DEFAULTCONFIG, ios::trunc);
    1428     }
    1429   output.close();
    1430   output.clear();
    1431   DoLog(0) && (Log() << Verbose(0) << "Saving of config file ");
    1432   if (configuration->Save(filename, periode, mol))
    1433     DoLog(0) && (Log() << Verbose(0) << "successful." << endl);
    1434   else
    1435     DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    1436 
    1437   // and save to xyz file
    1438   if (ConfigFileName != NULL) {
    1439     strcpy(filename, ConfigFileName);
    1440     strcat(filename, ".xyz");
    1441     output.open(filename, ios::trunc);
    1442   }
    1443   if (output == NULL) {
    1444     strcpy(filename,"main_pcp_linux");
    1445     strcat(filename, ".xyz");
    1446     output.open(filename, ios::trunc);
    1447   }
    1448   DoLog(0) && (Log() << Verbose(0) << "Saving of XYZ file ");
    1449   if (mol->MDSteps <= 1) {
    1450     if (mol->OutputXYZ(&output))
    1451       DoLog(0) && (Log() << Verbose(0) << "successful." << endl);
    1452     else
    1453       DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    1454   } else {
    1455     if (mol->OutputTrajectoriesXYZ(&output))
    1456       DoLog(0) && (Log() << Verbose(0) << "successful." << endl);
    1457     else
    1458       DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    1459   }
    1460   output.close();
    1461   output.clear();
    1462 
    1463   // and save as MPQC configuration
    1464   if (ConfigFileName != NULL)
    1465     strcpy(filename, ConfigFileName);
    1466   if (output == NULL)
    1467     strcpy(filename,"main_pcp_linux");
    1468   DoLog(0) && (Log() << Verbose(0) << "Saving as mpqc input ");
    1469   if (configuration->SaveMPQC(filename, mol))
    1470     DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    1471   else
    1472     DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    1473 
    1474   if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
    1475     DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl);
    1476   }
    1477 
    1478   World::getInstance().destroyMolecule(mol);
    1479 };
    1480 
    1481 /** Parses the command line options.
    1482  * \param argc argument count
    1483  * \param **argv arguments array
    1484  * \param *molecules list of molecules structure
    1485  * \param *periode elements structure
    1486  * \param configuration config file structure
    1487  * \param *ConfigFileName pointer to config file name in **argv
    1488  * \param *PathToDatabases pointer to db's path in **argv
    1489  * \return exit code (0 - successful, all else - something's wrong)
    1490  */
    1491 static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode,\
    1492                                    config& configuration, char *&ConfigFileName)
    1493 {
    1494   Vector x,y,z,n;  // coordinates for absolute point in cell volume
    1495   double *factor; // unit factor if desired
    1496   ifstream test;
    1497   ofstream output;
    1498   string line;
    1499   atom *first;
    1500   bool SaveFlag = false;
    1501   int ExitFlag = 0;
    1502   int j;
    1503   double volume = 0.;
    1504   enum ConfigStatus configPresent = absent;
    1505   clock_t start,end;
    1506   double MaxDistance = -1;
    1507   int argptr;
    1508   molecule *mol = NULL;
    1509   string BondGraphFileName("\n");
    1510   int verbosity = 0;
    1511   strncpy(configuration.databasepath, LocalPath, MAXSTRINGSIZE-1);
    1512 
    1513   if (argc > 1) { // config file specified as option
    1514     // 1. : Parse options that just set variables or print help
    1515     argptr = 1;
    1516     do {
    1517       if (argv[argptr][0] == '-') {
    1518         DoLog(0) && (Log() << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n");
    1519         argptr++;
    1520         switch(argv[argptr-1][1]) {
    1521           case 'h':
    1522           case '?':
    1523             DoLog(0) && (Log() << Verbose(0) << "MoleCuilder suite" << endl << "==================" << endl << endl);
    1524             DoLog(0) && (Log() << Verbose(0) << "Usage: " << argv[0] << "[config file] [-{acefpsthH?vfrp}] [further arguments]" << endl);
    1525             DoLog(0) && (Log() << Verbose(0) << "or simply " << argv[0] << " without arguments for interactive session." << endl);
    1526             DoLog(0) && (Log() << Verbose(0) << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl);
    1527             DoLog(0) && (Log() << Verbose(0) << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl);
    1528             DoLog(0) && (Log() << Verbose(0) << "\t-b xx xy xz yy yz zz\tCenter atoms in domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl);
    1529             DoLog(0) && (Log() << Verbose(0) << "\t-B xx xy xz yy yz zz\tBound atoms by domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl);
    1530             DoLog(0) && (Log() << Verbose(0) << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl);
    1531             DoLog(0) && (Log() << Verbose(0) << "\t-C <type> [params] <output> <bin output> <BinWidth> <BinStart> <BinEnd>\tPair Correlation analysis." << endl);
    1532             DoLog(0) && (Log() << Verbose(0) << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl);
    1533             DoLog(0) && (Log() << Verbose(0) << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl);
    1534             DoLog(0) && (Log() << Verbose(0) << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl);
    1535             DoLog(0) && (Log() << Verbose(0) << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl);
    1536             DoLog(0) && (Log() << Verbose(0) << "\t-f <dist> <order>\tFragments the molecule in BOSSANOVA manner (with/out rings compressed) and stores config files in same dir as config (return code 0 - fragmented, 2 - no fragmentation necessary)." << endl);
    1537             DoLog(0) && (Log() << Verbose(0) << "\t-F <xyz of filler> <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl);
    1538             DoLog(0) && (Log() << Verbose(0) << "\t-FF <MaxDistance> <xyz of filler> <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl);
    1539             DoLog(0) && (Log() << Verbose(0) << "\t-g <file>\tParses a bond length table from the given file." << endl);
    1540             DoLog(0) && (Log() << Verbose(0) << "\t-h/-?\tGive this help screen." << endl);
    1541             DoLog(0) && (Log() << Verbose(0) << "\t-H\tCount Hydrogen bridge bonds." << endl);
    1542             DoLog(0) && (Log() << Verbose(0) << "\t-I\t Dissect current system of molecules into a set of disconnected (subgraphs of) molecules." << endl);
    1543             DoLog(0) && (Log() << Verbose(0) << "\t-j\t<path> Store all bonds to file." << endl);
    1544             DoLog(0) && (Log() << Verbose(0) << "\t-J\t<path> Store adjacency per atom to file." << endl);
    1545             DoLog(0) && (Log() << Verbose(0) << "\t-L <step0> <step1> <prefix>\tStore a linear interpolation between two configurations <step0> and <step1> into single config files with prefix <prefix> and as Trajectories into the current config file." << endl);
    1546             DoLog(0) && (Log() << Verbose(0) << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl);
    1547             DoLog(0) && (Log() << Verbose(0) << "\t-M <basis>\tSetting basis to store to MPQC config files." << endl);
    1548             DoLog(0) && (Log() << Verbose(0) << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl);
    1549             DoLog(0) && (Log() << Verbose(0) << "\t-N <radius> <file>\tGet non-convex-envelope." << endl);
    1550             DoLog(0) && (Log() << Verbose(0) << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl);
    1551             DoLog(0) && (Log() << Verbose(0) << "\t-O\tCenter atoms in origin." << endl);
    1552             DoLog(0) && (Log() << Verbose(0) << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl);
    1553             DoLog(0) && (Log() << Verbose(0) << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl);
    1554             DoLog(0) && (Log() << Verbose(0) << "\t-r <id>\t\tRemove an atom with given id." << endl);
    1555             DoLog(0) && (Log() << Verbose(0) << "\t-R <id> <radius>\t\tRemove all atoms out of sphere around a given one." << endl);
    1556             DoLog(0) && (Log() << Verbose(0) << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl);
    1557             DoLog(0) && (Log() << Verbose(0) << "\t-S <file> Store temperatures from the config file in <file>." << endl);
    1558             DoLog(0) && (Log() << Verbose(0) << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl);
    1559             DoLog(0) && (Log() << Verbose(0) << "\t-T x1 x2 x3\tTranslate periodically all atoms by this vector (x1,x2,x3)." << endl);
    1560             DoLog(0) && (Log() << Verbose(0) << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl);
    1561             DoLog(0) && (Log() << Verbose(0) << "\t-v\t\tsets verbosity (more is more)." << endl);
    1562             DoLog(0) && (Log() << Verbose(0) << "\t-V\t\tGives version information." << endl);
    1563             DoLog(0) && (Log() << Verbose(0) << "\t-X\t\tset default name of a molecule." << endl);
    1564             DoLog(0) && (Log() << Verbose(0) << "Note: config files must not begin with '-' !" << endl);
    1565             return (1);
    1566             break;
    1567           case 'v':
    1568             while (argv[argptr-1][verbosity+1] == 'v') {
    1569               verbosity++;
    1570             }
    1571             setVerbosity(verbosity);
    1572             DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl);
    1573             break;
    1574           case 'V':
    1575             DoLog(0) && (Log() << Verbose(0) << argv[0] << " " << VERSIONSTRING << endl);
    1576             DoLog(0) && (Log() << Verbose(0) << "Build your own molecule position set." << endl);
    1577             return (1);
    1578             break;
    1579           case 'B':
    1580             if (ExitFlag == 0) ExitFlag = 1;
    1581             if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {
    1582               ExitFlag = 255;
    1583               DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl);
    1584               performCriticalExit();
    1585             } else {
    1586               SaveFlag = true;
    1587               j = -1;
    1588               DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl);
    1589               double * const cell_size = World::getInstance().getDomain();
    1590               for (int i=0;i<6;i++) {
    1591                 cell_size[i] = atof(argv[argptr+i]);
    1592               }
    1593               argptr+=6;
    1594             }
    1595             break;
    1596           case 'e':
    1597             if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1598               DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl);
    1599               performCriticalExit();
    1600             } else {
    1601               DoLog(0) && (Log() << Verbose(0) << "Using " << argv[argptr] << " as elements database." << endl);
    1602               strncpy (configuration.databasepath, argv[argptr], MAXSTRINGSIZE-1);
    1603               argptr+=1;
    1604             }
    1605             break;
    1606           case 'g':
    1607             if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1608               DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying bond length table: -g <table file>" << endl);
    1609               performCriticalExit();
    1610             } else {
    1611               BondGraphFileName = argv[argptr];
    1612               DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl);
    1613               argptr+=1;
    1614             }
    1615             break;
    1616           case 'n':
    1617             DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl);
    1618             configuration.FastParsing = true;
    1619             break;
    1620           case 'X':
    1621             {
    1622               World::getInstance().setDefaultName(argv[argptr]);
    1623               DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << *World::getInstance().getDefaultName() << "." << endl);
    1624             }
    1625             break;
    1626           default:   // no match? Step on
    1627             argptr++;
    1628             break;
    1629         }
    1630       } else
    1631         argptr++;
    1632     } while (argptr < argc);
    1633 
    1634     // 3a. Parse the element database
    1635     if (periode->LoadPeriodentafel(configuration.databasepath)) {
    1636       DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);
    1637       //periode->Output();
    1638     } else {
    1639       DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
    1640       return 1;
    1641     }
    1642     // 3b. Find config file name and parse if possible, also BondGraphFileName
    1643     if (argv[1][0] != '-') {
    1644       // simply create a new molecule, wherein the config file is loaded and the manipulation takes place
    1645       DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl);
    1646       test.open(argv[1], ios::in);
    1647       if (test == NULL) {
    1648         //return (1);
    1649         output.open(argv[1], ios::out);
    1650         if (output == NULL) {
    1651           DoLog(1) && (Log() << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl);
    1652           configPresent = absent;
    1653         } else {
    1654           DoLog(0) && (Log() << Verbose(0) << "Empty configuration file." << endl);
    1655           ConfigFileName = argv[1];
    1656           configPresent = empty;
    1657           output.close();
    1658         }
    1659       } else {
    1660         test.close();
    1661         ConfigFileName = argv[1];
    1662         DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
    1663         switch (configuration.TestSyntax(ConfigFileName, periode)) {
    1664           case 1:
    1665             DoLog(0) && (Log() << Verbose(0) << "new syntax." << endl);
    1666             configuration.Load(ConfigFileName, BondGraphFileName, periode, molecules);
    1667             configPresent = present;
    1668             break;
    1669           case 0:
    1670             DoLog(0) && (Log() << Verbose(0) << "old syntax." << endl);
    1671             configuration.LoadOld(ConfigFileName, BondGraphFileName, periode, molecules);
    1672             configPresent = present;
    1673             break;
    1674           default:
    1675             DoLog(0) && (Log() << Verbose(0) << "Unknown syntax or empty, yet present file." << endl);
    1676             configPresent = empty;
    1677        }
    1678       }
    1679     } else
    1680       configPresent = absent;
    1681      // set mol to first active molecule
    1682      if (molecules->ListOfMolecules.size() != 0) {
    1683        for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    1684          if ((*ListRunner)->ActiveFlag) {
    1685            mol = *ListRunner;
    1686            break;
    1687          }
    1688      }
    1689      if (mol == NULL) {
    1690        mol = World::getInstance().createMolecule();
    1691        mol->ActiveFlag = true;
    1692        if (ConfigFileName != NULL)
    1693          mol->SetNameFromFilename(ConfigFileName);
    1694        molecules->insert(mol);
    1695      }
    1696      if (configuration.BG == NULL) {
    1697        configuration.BG = new BondGraph(configuration.GetIsAngstroem());
    1698        if ((!BondGraphFileName.empty()) && (configuration.BG->LoadBondLengthTable(BondGraphFileName))) {
    1699          DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
    1700        } else {
    1701          DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
    1702        }
    1703      }
    1704 
    1705     // 4. parse again through options, now for those depending on elements db and config presence
    1706     argptr = 1;
    1707     do {
    1708       DoLog(0) && (Log() << Verbose(0) << "Current Command line argument: " << argv[argptr] << "." << endl);
    1709       if (argv[argptr][0] == '-') {
    1710         argptr++;
    1711         if ((configPresent == present) || (configPresent == empty)) {
    1712           switch(argv[argptr-1][1]) {
    1713             case 'p':
    1714               if (ExitFlag == 0) ExitFlag = 1;
    1715               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1716                 ExitFlag = 255;
    1717                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough arguments for parsing: -p <xyz file>" << endl);
    1718                 performCriticalExit();
    1719               } else {
    1720                 SaveFlag = true;
    1721                 DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl);
    1722                 if (!mol->AddXYZFile(argv[argptr]))
    1723                   DoLog(2) && (Log() << Verbose(2) << "File not found." << endl);
    1724                 else {
    1725                   DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl);
    1726                   configPresent = present;
    1727                 }
    1728               }
    1729               break;
    1730             case 'a':
    1731               if (ExitFlag == 0) ExitFlag = 1;
    1732               if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3]))) {
    1733                 ExitFlag = 255;
    1734                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl);
    1735                 performCriticalExit();
    1736               } else {
    1737                 SaveFlag = true;
    1738                 Log() << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), ";
    1739                 first = World::getInstance().createAtom();
    1740                 first->type = periode->FindElement(atoi(argv[argptr]));
    1741                 if (first->type != NULL)
    1742                   DoLog(2) && (Log() << Verbose(2) << "found element " << first->type->name << endl);
    1743                 for (int i=NDIM;i--;)
    1744                   first->x[i] = atof(argv[argptr+1+i]);
    1745                 if (first->type != NULL) {
    1746                   mol->AddAtom(first);  // add to molecule
    1747                   if ((configPresent == empty) && (mol->AtomCount != 0))
    1748                     configPresent = present;
    1749                 } else
    1750                   DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the specified element." << endl);
    1751                 argptr+=4;
    1752               }
    1753               break;
    1754             default:   // no match? Don't step on (this is done in next switch's default)
    1755               break;
    1756           }
    1757         }
    1758         if (configPresent == present) {
    1759           switch(argv[argptr-1][1]) {
    1760             case 'M':
    1761               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1762                 ExitFlag = 255;
    1763                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -B <basis name>" << endl);
    1764                 performCriticalExit();
    1765               } else {
    1766                 configuration.basis = argv[argptr];
    1767                 DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration.basis << "." << endl);
    1768                 argptr+=1;
    1769               }
    1770               break;
    1771             case 'D':
    1772               if (ExitFlag == 0) ExitFlag = 1;
    1773               {
    1774                 DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
    1775                 MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
    1776                 int *MinimumRingSize = new int[mol->AtomCount];
    1777                 atom ***ListOfLocalAtoms = NULL;
    1778                 class StackClass<bond *> *BackEdgeStack = NULL;
    1779                 class StackClass<bond *> *LocalBackEdgeStack = NULL;
    1780                 mol->CreateAdjacencyList(atof(argv[argptr]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    1781                 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
    1782                 if (Subgraphs != NULL) {
    1783                   int FragmentCounter = 0;
    1784                   while (Subgraphs->next != NULL) {
    1785                     Subgraphs = Subgraphs->next;
    1786                     Subgraphs->FillBondStructureFromReference(mol, FragmentCounter, ListOfLocalAtoms, false);  // we want to keep the created ListOfLocalAtoms
    1787                     LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
    1788                     Subgraphs->Leaf->PickLocalBackEdges(ListOfLocalAtoms[FragmentCounter], BackEdgeStack, LocalBackEdgeStack);
    1789                     Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
    1790                     delete(LocalBackEdgeStack);
    1791                     delete(Subgraphs->previous);
    1792                     FragmentCounter++;
    1793                   }
    1794                   delete(Subgraphs);
    1795                   for (int i=0;i<FragmentCounter;i++)
    1796                     Free(&ListOfLocalAtoms[i]);
    1797                   Free(&ListOfLocalAtoms);
    1798                 }
    1799                 delete(BackEdgeStack);
    1800                 delete[](MinimumRingSize);
    1801               }
    1802               //argptr+=1;
    1803               break;
    1804             case 'I':
    1805               DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);
    1806               // @TODO rather do the dissection afterwards
    1807               molecules->DissectMoleculeIntoConnectedSubgraphs(periode, &configuration);
    1808               mol = NULL;
    1809               if (molecules->ListOfMolecules.size() != 0) {
    1810                 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    1811                   if ((*ListRunner)->ActiveFlag) {
    1812                     mol = *ListRunner;
    1813                     break;
    1814                   }
    1815               }
    1816               if ((mol == NULL) && (!molecules->ListOfMolecules.empty())) {
    1817                 mol = *(molecules->ListOfMolecules.begin());
    1818                 if (mol != NULL)
    1819                   mol->ActiveFlag = true;
    1820               }
    1821               break;
    1822             case 'H':
    1823               if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (argv[argptr+1][0] == '-')) {
    1824                 ExitFlag = 255;
    1825                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for calculating hydrogen bridge bonds: -H <Z1> <Z2>" << endl);
    1826                 performCriticalExit();
    1827               } else {
    1828                 if (ExitFlag == 0) ExitFlag = 1;
    1829                 const element *elemental = periode->FindElement((const int) atoi(argv[argptr]));
    1830                 const element *elemental2 = periode->FindElement((const int) atoi(argv[argptr+1]));
    1831                 cout << endl << "There are " << CountHydrogenBridgeBonds(molecules, elemental, elemental2) << " hydrogen bridges with connections to " << (elemental != 0 ? elemental->name : "None") << " and " << (elemental2 != 0 ? elemental2->name : "None") << "." << endl;
    1832                 argptr+=1;
    1833               }
    1834               break;
    1835             case 'C':
    1836               {
    1837                 int ranges[3] = {1, 1, 1};
    1838                 bool periodic = (argv[argptr-1][2] =='p');
    1839                 if (ExitFlag == 0) ExitFlag = 1;
    1840                 if ((argptr >= argc)) {
    1841                   ExitFlag = 255;
    1842                   DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C[p] <type: E/P/S> [more params] <output> <bin output> <BinStart> <BinEnd>" << endl);
    1843                   performCriticalExit();
    1844                 } else {
    1845                   switch(argv[argptr][0]) {
    1846                     case 'E':
    1847                       {
    1848                         if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (!IsValidNumber(argv[argptr+2])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-') || (argv[argptr+4][0] == '-')) {
    1849                           ExitFlag = 255;
    1850                           DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C E <Z1> <Z2> <output> <bin output>" << endl);
    1851                           performCriticalExit();
    1852                         } else {
    1853                           ofstream output(argv[argptr+3]);
    1854                           ofstream binoutput(argv[argptr+4]);
    1855                           const double BinStart = atof(argv[argptr+5]);
    1856                           const double BinEnd = atof(argv[argptr+6]);
    1857 
    1858                           const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
    1859                           const element *elemental2 = periode->FindElement((const int) atoi(argv[argptr+2]));
    1860                           PairCorrelationMap *correlationmap = NULL;
    1861                           if (periodic)
    1862                             correlationmap = PeriodicPairCorrelation(molecules, elemental, elemental2, ranges);
    1863                           else
    1864                             correlationmap = PairCorrelation(molecules, elemental, elemental2);
    1865                           //OutputCorrelationToSurface(&output, correlationmap);
    1866                           BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
    1867                           OutputCorrelation ( &binoutput, binmap );
    1868                           output.close();
    1869                           binoutput.close();
    1870                           delete(binmap);
    1871                           delete(correlationmap);
    1872                           argptr+=7;
    1873                         }
    1874                       }
    1875                       break;
    1876 
    1877                     case 'P':
    1878                       {
    1879                         if ((argptr+8 >= argc) || (!IsValidNumber(argv[argptr+1])) ||  (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+7])) || (!IsValidNumber(argv[argptr+8])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-') || (argv[argptr+4][0] == '-') || (argv[argptr+5][0] == '-') || (argv[argptr+6][0] == '-')) {
    1880                           ExitFlag = 255;
    1881                           DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C P <Z1> <x> <y> <z> <output> <bin output>" << endl);
    1882                           performCriticalExit();
    1883                         } else {
    1884                           ofstream output(argv[argptr+5]);
    1885                           ofstream binoutput(argv[argptr+6]);
    1886                           const double BinStart = atof(argv[argptr+7]);
    1887                           const double BinEnd = atof(argv[argptr+8]);
    1888 
    1889                           const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
    1890                           Vector *Point = new Vector((const double) atof(argv[argptr+1]),(const double) atof(argv[argptr+2]),(const double) atof(argv[argptr+3]));
    1891                           CorrelationToPointMap *correlationmap = NULL;
    1892                           if (periodic)
    1893                             correlationmap  = PeriodicCorrelationToPoint(molecules, elemental, Point, ranges);
    1894                           else
    1895                             correlationmap = CorrelationToPoint(molecules, elemental, Point);
    1896                           //OutputCorrelationToSurface(&output, correlationmap);
    1897                           BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
    1898                           OutputCorrelation ( &binoutput, binmap );
    1899                           output.close();
    1900                           binoutput.close();
    1901                           delete(Point);
    1902                           delete(binmap);
    1903                           delete(correlationmap);
    1904                           argptr+=9;
    1905                         }
    1906                       }
    1907                       break;
    1908 
    1909                     case 'S':
    1910                       {
    1911                         if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-')) {
    1912                           ExitFlag = 255;
    1913                           DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C S <Z> <output> <bin output> <BinWidth> <BinStart> <BinEnd>" << endl);
    1914                           performCriticalExit();
    1915                         } else {
    1916                           ofstream output(argv[argptr+2]);
    1917                           ofstream binoutput(argv[argptr+3]);
    1918                           const double radius = 4.;
    1919                           const double BinWidth = atof(argv[argptr+4]);
    1920                           const double BinStart = atof(argv[argptr+5]);
    1921                           const double BinEnd = atof(argv[argptr+6]);
    1922                           double LCWidth = 20.;
    1923                           if (BinEnd > 0) {
    1924                             if (BinEnd > 2.*radius)
    1925                                 LCWidth = BinEnd;
    1926                             else
    1927                               LCWidth = 2.*radius;
    1928                           }
    1929 
    1930                           // get the boundary
    1931                           class molecule *Boundary = NULL;
    1932                           class Tesselation *TesselStruct = NULL;
    1933                           const LinkedCell *LCList = NULL;
    1934                           // find biggest molecule
    1935                           int counter  = 0;
    1936                           for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    1937                             if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) {
    1938                               Boundary = *BigFinder;
    1939                             }
    1940                             counter++;
    1941                           }
    1942                           bool *Actives = Malloc<bool>(counter, "ParseCommandLineOptions() - case C -- *Actives");
    1943                           counter = 0;
    1944                           for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    1945                             Actives[counter++] = (*BigFinder)->ActiveFlag;
    1946                             (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true;
    1947                           }
    1948                           LCList = new LinkedCell(Boundary, LCWidth);
    1949                           const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
    1950                           FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
    1951                           CorrelationToSurfaceMap *surfacemap = NULL;
    1952                           if (periodic)
    1953                             surfacemap = PeriodicCorrelationToSurface( molecules, elemental, TesselStruct, LCList, ranges);
    1954                           else
    1955                             surfacemap = CorrelationToSurface( molecules, elemental, TesselStruct, LCList);
    1956                           OutputCorrelationToSurface(&output, surfacemap);
    1957                           // check whether radius was appropriate
    1958                           {
    1959                             double start; double end;
    1960                             GetMinMax( surfacemap, start, end);
    1961                             if (LCWidth < end)
    1962                               DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl);
    1963                           }
    1964                           BinPairMap *binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
    1965                           OutputCorrelation ( &binoutput, binmap );
    1966                           output.close();
    1967                           binoutput.close();
    1968                           for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++)
    1969                             (*BigFinder)->ActiveFlag = Actives[counter++];
    1970                           Free(&Actives);
    1971                           delete(LCList);
    1972                           delete(TesselStruct);
    1973                           delete(binmap);
    1974                           delete(surfacemap);
    1975                           argptr+=7;
    1976                         }
    1977                       }
    1978                       break;
    1979 
    1980                     default:
    1981                       ExitFlag = 255;
    1982                       DoeLog(0) && (eLog()<< Verbose(0) << "Invalid type given for pair correlation analysis: -C <type: E/P/S> [more params] <output> <bin output>" << endl);
    1983                       performCriticalExit();
    1984                       break;
    1985                   }
    1986                 }
    1987                 break;
    1988               }
    1989             case 'E':
    1990               if (ExitFlag == 0) ExitFlag = 1;
    1991               if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr+1][0] == '-')) {
    1992                 ExitFlag = 255;
    1993                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl);
    1994                 performCriticalExit();
    1995               } else {
    1996                 SaveFlag = true;
    1997                 DoLog(1) && (Log() << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl);
    1998                 first = mol->FindAtom(atoi(argv[argptr]));
    1999                 first->type = periode->FindElement(atoi(argv[argptr+1]));
    2000                 argptr+=2;
    2001               }
    2002               break;
    2003             case 'F':
    2004               if (ExitFlag == 0) ExitFlag = 1;
    2005               MaxDistance = -1;
    2006               if (argv[argptr-1][2] == 'F') { // option is -FF?
    2007                 // fetch first argument as max distance to surface
    2008                 MaxDistance = atof(argv[argptr++]);
    2009                 DoLog(0) && (Log() << Verbose(0) << "Filling with maximum layer distance of " << MaxDistance << "." << endl);
    2010               }
    2011               if ((argptr+7 >=argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (!IsValidNumber(argv[argptr+7]))) {
    2012                 ExitFlag = 255;
    2013                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for filling box with water: -F <xyz of filler> <dist_x> <dist_y> <dist_z> <boundary> <randatom> <randmol> <DoRotate>" << endl);
    2014                 performCriticalExit();
    2015               } else {
    2016                 SaveFlag = true;
    2017                 DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules." << endl);
    2018                 // construct water molecule
    2019                 molecule *filler = World::getInstance().createMolecule();
    2020                 if (!filler->AddXYZFile(argv[argptr])) {
    2021                   DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << argv[argptr] << "." << endl);
    2022                 }
    2023                 filler->SetNameFromFilename(argv[argptr]);
    2024                 configuration.BG->ConstructBondGraph(filler);
    2025                 molecule *Filling = NULL;
    2026                 atom *second = NULL, *third = NULL;
    2027                 first = World::getInstance().createAtom();
    2028                 first->type = periode->FindElement(1);
    2029                 first->x = Vector(0.441, -0.143, 0.);
    2030                 filler->AddAtom(first);
    2031                 second = World::getInstance().createAtom();
    2032                 second->type = periode->FindElement(1);
    2033                 second->x = Vector(-0.464, 1.137, 0.0);
    2034                 filler->AddAtom(second);
    2035                 third = World::getInstance().createAtom();
    2036                 third->type = periode->FindElement(8);
    2037                 third->x = Vector(-0.464, 0.177, 0.);
    2038                 filler->AddAtom(third);
    2039                 filler->AddBond(first, third, 1);
    2040                 filler->AddBond(second, third, 1);
    2041                 // call routine
    2042                 double distance[NDIM];
    2043                 for (int i=0;i<NDIM;i++)
    2044                   distance[i] = atof(argv[argptr+i+1]);
    2045                 Filling = FillBoxWithMolecule(molecules, filler, configuration, MaxDistance, distance, atof(argv[argptr+4]), atof(argv[argptr+5]), atof(argv[argptr+6]), atoi(argv[argptr+7]));
    2046                 if (Filling != NULL) {
    2047                   Filling->ActiveFlag = false;
    2048                   molecules->insert(Filling);
    2049                 }
    2050                 World::getInstance().destroyMolecule(filler);
    2051                 argptr+=6;
    2052               }
    2053               break;
    2054             case 'A':
    2055               if (ExitFlag == 0) ExitFlag = 1;
    2056               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    2057                 ExitFlag =255;
    2058                 DoeLog(0) && (eLog()<< Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile>" << endl);
    2059                 performCriticalExit();
    2060               } else {
    2061                 DoLog(0) && (Log() << Verbose(0) << "Parsing bonds from " << argv[argptr] << "." << endl);
    2062                 ifstream *input = new ifstream(argv[argptr]);
    2063                 mol->CreateAdjacencyListFromDbondFile(input);
    2064                 input->close();
    2065                 argptr+=1;
    2066               }
    2067               break;
    2068 
    2069             case 'J':
    2070               if (ExitFlag == 0) ExitFlag = 1;
    2071               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    2072                 ExitFlag =255;
    2073                 DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of adjacency file: -j <path>" << endl);
    2074                 performCriticalExit();
    2075               } else {
    2076                 DoLog(0) && (Log() << Verbose(0) << "Storing adjacency to path " << argv[argptr] << "." << endl);
    2077                 configuration.BG->ConstructBondGraph(mol);
    2078                 mol->StoreAdjacencyToFile(NULL, argv[argptr]);
    2079                 argptr+=1;
    2080               }
    2081               break;
    2082 
    2083             case 'j':
    2084               if (ExitFlag == 0) ExitFlag = 1;
    2085               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    2086                 ExitFlag =255;
    2087                 DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of bonds file: -j <path>" << endl);
    2088                 performCriticalExit();
    2089               } else {
    2090                 DoLog(0) && (Log() << Verbose(0) << "Storing bonds to path " << argv[argptr] << "." << endl);
    2091                 configuration.BG->ConstructBondGraph(mol);
    2092                 mol->StoreBondsToFile(NULL, argv[argptr]);
    2093                 argptr+=1;
    2094               }
    2095               break;
    2096 
    2097             case 'N':
    2098               if (ExitFlag == 0) ExitFlag = 1;
    2099               if ((argptr+1 >= argc) || (argv[argptr+1][0] == '-')){
    2100                 ExitFlag = 255;
    2101                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl);
    2102                 performCriticalExit();
    2103               } else {
    2104                 class Tesselation *T = NULL;
    2105                 class Tesselation *Convex = NULL;
    2106                 const LinkedCell *LCList = NULL;
    2107                 const LinkedCell *LCListConvex = NULL;
    2108                 molecule * Boundary = NULL;
    2109                 //string filename(argv[argptr+1]);
    2110                 //filename.append(".csv");
    2111                 DoLog(0) && (Log() << Verbose(0) << "Evaluating non-convex envelope of biggest molecule.");
    2112                 DoLog(1) && (Log() << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl);
    2113                 // find biggest molecule
    2114                 int counter  = 0;
    2115                 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    2116                   (*BigFinder)->CountAtoms();
    2117                   if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) {
    2118                     Boundary = *BigFinder;
    2119                   }
    2120                   counter++;
    2121                 }
    2122                 DoLog(1) && (Log() << Verbose(1) << "Biggest molecule has " << Boundary->AtomCount << " atoms." << endl);
    2123                 start = clock();
    2124                 LCList = new LinkedCell(Boundary, atof(argv[argptr])*2.);
    2125                 if (!FindNonConvexBorder(Boundary, T, LCList, atof(argv[argptr]), argv[argptr+1]))
    2126                   ExitFlag = 255;
    2127                 const double ConvexRadius = 20.;
    2128                 LCListConvex = new LinkedCell(Boundary, 2.*ConvexRadius);
    2129 //                setVerbosity(3);
    2130                 if (!FindNonConvexBorder(Boundary, Convex, LCListConvex, ConvexRadius, "ConvexEnvelope"))
    2131                   ExitFlag = 255;
    2132                 CalculateConstrictionPerBoundaryPoint(T, Convex);
    2133                 StoreTrianglesinFile(mol, (const Tesselation *&)T, argv[argptr+1], "");
    2134                 //FindDistributionOfEllipsoids(T, &LCList, N, number, filename.c_str());
    2135                 end = clock();
    2136                 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    2137                 delete(LCList);
    2138                 delete(T);
    2139                 argptr+=2;
    2140               }
    2141               break;
    2142             case 'S':
    2143               if (ExitFlag == 0) ExitFlag = 1;
    2144               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    2145                 ExitFlag = 255;
    2146                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file>" << endl);
    2147                 performCriticalExit();
    2148               } else {
    2149                 DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl);
    2150                 ofstream *output = new ofstream(argv[argptr], ios::trunc);
    2151                 if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps))
    2152                   DoLog(2) && (Log() << Verbose(2) << "File could not be written." << endl);
    2153                 else
    2154                   DoLog(2) && (Log() << Verbose(2) << "File stored." << endl);
    2155                 output->close();
    2156                 delete(output);
    2157                 argptr+=1;
    2158               }
    2159               break;
    2160             case 'L':
    2161               if (ExitFlag == 0) ExitFlag = 1;
    2162               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    2163                 ExitFlag = 255;
    2164                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -L <step0> <step1> <prefix> <identity mapping?>" << endl);
    2165                 performCriticalExit();
    2166               } else {
    2167                 SaveFlag = true;
    2168                 DoLog(1) && (Log() << Verbose(1) << "Linear interpolation between configuration " << argv[argptr] << " and " << argv[argptr+1] << "." << endl);
    2169                 if (atoi(argv[argptr+3]) == 1)
    2170                   DoLog(1) && (Log() << Verbose(1) << "Using Identity for the permutation map." << endl);
    2171                 if (!mol->LinearInterpolationBetweenConfiguration(atoi(argv[argptr]), atoi(argv[argptr+1]), argv[argptr+2], configuration, atoi(argv[argptr+3])) == 1 ? true : false)
    2172                   DoLog(2) && (Log() << Verbose(2) << "Could not store " << argv[argptr+2] << " files." << endl);
    2173                 else
    2174                   DoLog(2) && (Log() << Verbose(2) << "Steps created and " << argv[argptr+2] << " files stored." << endl);
    2175                 argptr+=4;
    2176               }
    2177               break;
    2178             case 'P':
    2179               if (ExitFlag == 0) ExitFlag = 1;
    2180               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    2181                 ExitFlag = 255;
    2182                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl);
    2183                 performCriticalExit();
    2184               } else {
    2185                 SaveFlag = true;
    2186                 DoLog(1) && (Log() << Verbose(1) << "Parsing forces file and Verlet integrating." << endl);
    2187                 if (!mol->VerletForceIntegration(argv[argptr], configuration))
    2188                   DoLog(2) && (Log() << Verbose(2) << "File not found." << endl);
    2189                 else
    2190                   DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl);
    2191                 argptr+=1;
    2192               }
    2193               break;
    2194             case 'R':
    2195               if (ExitFlag == 0) ExitFlag = 1;
    2196               if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])))  {
    2197                 ExitFlag = 255;
    2198                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl);
    2199                 performCriticalExit();
    2200               } else {
    2201                 SaveFlag = true;
    2202                 DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << argv[argptr] << " with radius " << argv[argptr+1] << "." << endl);
    2203                 double tmp1 = atof(argv[argptr+1]);
    2204                 atom *third = mol->FindAtom(atoi(argv[argptr]));
    2205                 atom *first = mol->start;
    2206                 if ((third != NULL) && (first != mol->end)) {
    2207                   atom *second = first->next;
    2208                   while(second != mol->end) {
    2209                     first = second;
    2210                     second = first->next;
    2211                     if (first->x.DistanceSquared(third->x) > tmp1*tmp1) // distance to first above radius ...
    2212                       mol->RemoveAtom(first);
    2213                   }
    2214                 } else {
    2215                   DoeLog(1) && (eLog()<< Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl);
    2216                 }
    2217                 argptr+=2;
    2218               }
    2219               break;
    2220             case 't':
    2221               if (ExitFlag == 0) ExitFlag = 1;
    2222               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    2223                 ExitFlag = 255;
    2224                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl);
    2225                 performCriticalExit();
    2226               } else {
    2227                 if (ExitFlag == 0) ExitFlag = 1;
    2228                 SaveFlag = true;
    2229                 DoLog(1) && (Log() << Verbose(1) << "Translating all ions by given vector." << endl);
    2230                 for (int i=NDIM;i--;)
    2231                   x[i] = atof(argv[argptr+i]);
    2232                 mol->Translate((const Vector *)&x);
    2233                 argptr+=3;
    2234               }
    2235               break;
    2236             case 'T':
    2237               if (ExitFlag == 0) ExitFlag = 1;
    2238               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    2239                 ExitFlag = 255;
    2240                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for periodic translation: -T <x> <y> <z>" << endl);
    2241                 performCriticalExit();
    2242               } else {
    2243                 if (ExitFlag == 0) ExitFlag = 1;
    2244                 SaveFlag = true;
    2245                 DoLog(1) && (Log() << Verbose(1) << "Translating all ions periodically by given vector." << endl);
    2246                 for (int i=NDIM;i--;)
    2247                   x[i] = atof(argv[argptr+i]);
    2248                 mol->TranslatePeriodically((const Vector *)&x);
    2249                 argptr+=3;
    2250               }
    2251               break;
    2252             case 's':
    2253               if (ExitFlag == 0) ExitFlag = 1;
    2254               if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    2255                 ExitFlag = 255;
    2256                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl);
    2257                 performCriticalExit();
    2258               } else {
    2259                 SaveFlag = true;
    2260                 j = -1;
    2261                 DoLog(1) && (Log() << Verbose(1) << "Scaling all ion positions by factor." << endl);
    2262                 factor = new double[NDIM];
    2263                 factor[0] = atof(argv[argptr]);
    2264                 factor[1] = atof(argv[argptr+1]);
    2265                 factor[2] = atof(argv[argptr+2]);
    2266                 mol->Scale((const double ** const)&factor);
    2267                 double * const cell_size = World::getInstance().getDomain();
    2268                 for (int i=0;i<NDIM;i++) {
    2269                   j += i+1;
    2270                   x[i] = atof(argv[NDIM+i]);
    2271                   cell_size[j]*=factor[i];
    2272                 }
    2273                 delete[](factor);
    2274                 argptr+=3;
    2275               }
    2276               break;
    2277             case 'b':
    2278               if (ExitFlag == 0) ExitFlag = 1;
    2279               if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {
    2280                 ExitFlag = 255;
    2281                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering in box: -b <xx> <xy> <xz> <yy> <yz> <zz>" << endl);
    2282                 performCriticalExit();
    2283               } else {
    2284                 SaveFlag = true;
    2285                 j = -1;
    2286                 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl);
    2287                 double * const cell_size = World::getInstance().getDomain();
    2288                 for (int i=0;i<6;i++) {
    2289                   cell_size[i] = atof(argv[argptr+i]);
    2290                 }
    2291                 // center
    2292                 mol->CenterInBox();
    2293                 argptr+=6;
    2294               }
    2295               break;
    2296             case 'B':
    2297               if (ExitFlag == 0) ExitFlag = 1;
    2298               if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {
    2299                 ExitFlag = 255;
    2300                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl);
    2301                 performCriticalExit();
    2302               } else {
    2303                 SaveFlag = true;
    2304                 j = -1;
    2305                 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl);
    2306                 double * const cell_size = World::getInstance().getDomain();
    2307                 for (int i=0;i<6;i++) {
    2308                   cell_size[i] = atof(argv[argptr+i]);
    2309                 }
    2310                 // center
    2311                 mol->BoundInBox();
    2312                 argptr+=6;
    2313               }
    2314               break;
    2315             case 'c':
    2316               if (ExitFlag == 0) ExitFlag = 1;
    2317               if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    2318                 ExitFlag = 255;
    2319                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl);
    2320                 performCriticalExit();
    2321               } else {
    2322                 SaveFlag = true;
    2323                 j = -1;
    2324                 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl);
    2325                 // make every coordinate positive
    2326                 mol->CenterEdge(&x);
    2327                 // update Box of atoms by boundary
    2328                 mol->SetBoxDimension(&x);
    2329                 // translate each coordinate by boundary
    2330                 double * const cell_size = World::getInstance().getDomain();
    2331                 j=-1;
    2332                 for (int i=0;i<NDIM;i++) {
    2333                   j += i+1;
    2334                   x[i] = atof(argv[argptr+i]);
    2335                   cell_size[j] += x[i]*2.;
    2336                 }
    2337                 mol->Translate((const Vector *)&x);
    2338                 argptr+=3;
    2339               }
    2340               break;
    2341             case 'O':
    2342               if (ExitFlag == 0) ExitFlag = 1;
    2343               SaveFlag = true;
    2344               DoLog(1) && (Log() << Verbose(1) << "Centering atoms on edge and setting box dimensions." << endl);
    2345               x.Zero();
    2346               mol->CenterEdge(&x);
    2347               mol->SetBoxDimension(&x);
    2348               argptr+=0;
    2349               break;
    2350             case 'r':
    2351               if (ExitFlag == 0) ExitFlag = 1;
    2352               if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])))  {
    2353                 ExitFlag = 255;
    2354                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -r <id>" << endl);
    2355                 performCriticalExit();
    2356               } else {
    2357                 SaveFlag = true;
    2358                 DoLog(1) && (Log() << Verbose(1) << "Removing atom " << argv[argptr] << "." << endl);
    2359                 atom *first = mol->FindAtom(atoi(argv[argptr]));
    2360                 mol->RemoveAtom(first);
    2361                 argptr+=1;
    2362               }
    2363               break;
    2364             case 'f':
    2365               if (ExitFlag == 0) ExitFlag = 1;
    2366               if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {
    2367                 ExitFlag = 255;
    2368                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl);
    2369                 performCriticalExit();
    2370               } else {
    2371                 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl);
    2372                 DoLog(0) && (Log() << Verbose(0) << "Creating connection matrix..." << endl);
    2373                 start = clock();
    2374                 mol->CreateAdjacencyList(atof(argv[argptr]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    2375                 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
    2376                 if (mol->first->next != mol->last) {
    2377                   ExitFlag = mol->FragmentMolecule(atoi(argv[argptr+1]), &configuration);
    2378                 }
    2379                 end = clock();
    2380                 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    2381                 argptr+=2;
    2382               }
    2383               break;
    2384             case 'm':
    2385               if (ExitFlag == 0) ExitFlag = 1;
    2386               j = atoi(argv[argptr++]);
    2387               if ((j<0) || (j>1)) {
    2388                 DoeLog(1) && (eLog()<< Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl);
    2389                 j = 0;
    2390               }
    2391               if (j) {
    2392                 SaveFlag = true;
    2393                 DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
    2394               } else
    2395                 DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
    2396               mol->PrincipalAxisSystem((bool)j);
    2397               break;
    2398             case 'o':
    2399               if (ExitFlag == 0) ExitFlag = 1;
    2400               if ((argptr+1 >= argc) || (argv[argptr][0] == '-')){
    2401                 ExitFlag = 255;
    2402                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <convex output file> <non-convex output file>" << endl);
    2403                 performCriticalExit();
    2404               } else {
    2405                 class Tesselation *TesselStruct = NULL;
    2406                 const LinkedCell *LCList = NULL;
    2407                 DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope.");
    2408                 DoLog(1) && (Log() << Verbose(1) << "Storing tecplot convex data in " << argv[argptr] << "." << endl);
    2409                 DoLog(1) && (Log() << Verbose(1) << "Storing tecplot non-convex data in " << argv[argptr+1] << "." << endl);
    2410                 LCList = new LinkedCell(mol, 10.);
    2411                 //FindConvexBorder(mol, LCList, argv[argptr]);
    2412                 FindNonConvexBorder(mol, TesselStruct, LCList, 5., argv[argptr+1]);
    2413 //                RemoveAllBoundaryPoints(TesselStruct, mol, argv[argptr]);
    2414                 double volumedifference = ConvexizeNonconvexEnvelope(TesselStruct, mol, argv[argptr]);
    2415                 double clustervolume = VolumeOfConvexEnvelope(TesselStruct, &configuration);
    2416                 DoLog(0) && (Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
    2417                 DoLog(0) && (Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
    2418                 delete(TesselStruct);
    2419                 delete(LCList);
    2420                 argptr+=2;
    2421               }
    2422               break;
    2423             case 'U':
    2424               if (ExitFlag == 0) ExitFlag = 1;
    2425               if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) {
    2426                 ExitFlag = 255;
    2427                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl);
    2428                 performCriticalExit();
    2429               } else {
    2430                 volume = atof(argv[argptr++]);
    2431                 DoLog(0) && (Log() << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl);
    2432               }
    2433             case 'u':
    2434               if (ExitFlag == 0) ExitFlag = 1;
    2435               if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) ) {
    2436                 if (volume != -1)
    2437                   ExitFlag = 255;
    2438                   DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension: -u <density>" << endl);
    2439                   performCriticalExit();
    2440               } else {
    2441                 double density;
    2442                 SaveFlag = true;
    2443                 DoLog(0) && (Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.");
    2444                 density = atof(argv[argptr++]);
    2445                 if (density < 1.0) {
    2446                   DoeLog(1) && (eLog()<< Verbose(1) << "Density must be greater than 1.0g/cm^3 !" << endl);
    2447                   density = 1.3;
    2448                 }
    2449 //                for(int i=0;i<NDIM;i++) {
    2450 //                  repetition[i] = atoi(argv[argptr++]);
    2451 //                  if (repetition[i] < 1)
    2452 //                    DoeLog(1) && (eLog()<< Verbose(1) << "repetition value must be greater 1!" << endl);
    2453 //                  repetition[i] = 1;
    2454 //                }
    2455                 PrepareClustersinWater(&configuration, mol, volume, density);  // if volume == 0, will calculate from ConvexEnvelope
    2456               }
    2457               break;
    2458             case 'd':
    2459               if (ExitFlag == 0) ExitFlag = 1;
    2460               if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    2461                 ExitFlag = 255;
    2462                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl);
    2463                 performCriticalExit();
    2464               } else {
    2465                 SaveFlag = true;
    2466                 double * const cell_size = World::getInstance().getDomain();
    2467                 for (int axis = 1; axis <= NDIM; axis++) {
    2468                   int faktor = atoi(argv[argptr++]);
    2469                   int count;
    2470                   const element ** Elements;
    2471                   Vector ** vectors;
    2472                   if (faktor < 1) {
    2473                     DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor mus be greater than 1!" << endl);
    2474                     faktor = 1;
    2475                   }
    2476                   mol->CountAtoms();  // recount atoms
    2477                   if (mol->AtomCount != 0) {  // if there is more than none
    2478                     count = mol->AtomCount;   // is changed becausing of adding, thus has to be stored away beforehand
    2479                     Elements = new const element *[count];
    2480                     vectors = new Vector *[count];
    2481                     j = 0;
    2482                     first = mol->start;
    2483                     while (first->next != mol->end) {  // make a list of all atoms with coordinates and element
    2484                       first = first->next;
    2485                       Elements[j] = first->type;
    2486                       vectors[j] = &first->x;
    2487                       j++;
    2488                     }
    2489                     if (count != j)
    2490                       DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
    2491                     x.Zero();
    2492                     y.Zero();
    2493                     y[abs(axis)-1] = cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
    2494                     for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
    2495                       x += y; // per factor one cell width further
    2496                       for (int k=count;k--;) { // go through every atom of the original cell
    2497                         first = World::getInstance().createAtom(); // create a new body
    2498                         first->x = (*vectors[k]) + x;
    2499                         first->type = Elements[k];  // insert original element
    2500                         mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
    2501                       }
    2502                     }
    2503                     // free memory
    2504                     delete[](Elements);
    2505                     delete[](vectors);
    2506                     // correct cell size
    2507                     if (axis < 0) { // if sign was negative, we have to translate everything
    2508                       x =(-(faktor-1)) * y;
    2509                       mol->Translate(&x);
    2510                     }
    2511                     cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
    2512                   }
    2513                 }
    2514               }
    2515               break;
    2516             default:   // no match? Step on
    2517               if ((argptr < argc) && (argv[argptr][0] != '-')) // if it started with a '-' we've already made a step!
    2518                 argptr++;
    2519               break;
    2520           }
    2521         }
    2522       } else argptr++;
    2523     } while (argptr < argc);
    2524     if (SaveFlag)
    2525       configuration.SaveAll(ConfigFileName, periode, molecules);
    2526   } else {  // no arguments, hence scan the elements db
    2527     if (periode->LoadPeriodentafel(configuration.databasepath))
    2528       DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);
    2529     else
    2530       DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
    2531     configuration.RetrieveConfigPathAndName("main_pcp_linux");
    2532   }
    2533   return(ExitFlag);
    2534 };
    2535 
    2536 /***************************************** Functions used to build all menus **********************/
    2537 
    2538 void populateEditMoleculesMenu(Menu* editMoleculesMenu,MoleculeListClass *molecules, config *configuration, periodentafel *periode){
    2539   // build the EditMoleculesMenu
    2540   Action *createMoleculeAction = new MethodAction("createMoleculeAction",boost::bind(&MoleculeListClass::createNewMolecule,molecules,periode));
    2541   new ActionMenuItem('c',"create new molecule",editMoleculesMenu,createMoleculeAction);
    2542 
    2543   Action *loadMoleculeAction = new MethodAction("loadMoleculeAction",boost::bind(&MoleculeListClass::loadFromXYZ,molecules,periode));
    2544   new ActionMenuItem('l',"load molecule from xyz file",editMoleculesMenu,loadMoleculeAction);
    2545 
    2546   Action *changeFilenameAction = new ChangeMoleculeNameAction(molecules);
    2547   new ActionMenuItem('n',"change molecule's name",editMoleculesMenu,changeFilenameAction);
    2548 
    2549   Action *giveFilenameAction = new MethodAction("giveFilenameAction",boost::bind(&MoleculeListClass::setMoleculeFilename,molecules));
    2550   new ActionMenuItem('N',"give molecules filename",editMoleculesMenu,giveFilenameAction);
    2551 
    2552   Action *parseAtomsAction = new MethodAction("parseAtomsAction",boost::bind(&MoleculeListClass::parseXYZIntoMolecule,molecules));
    2553   new ActionMenuItem('p',"parse atoms in xyz file into molecule",editMoleculesMenu,parseAtomsAction);
    2554 
    2555   Action *eraseMoleculeAction = new MethodAction("eraseMoleculeAction",boost::bind(&MoleculeListClass::eraseMolecule,molecules));
    2556   new ActionMenuItem('r',"remove a molecule",editMoleculesMenu,eraseMoleculeAction);
    2557 
    2558 }
    255992
    256093
    256194/********************************************** Main routine **************************************/
    256295
    2563 void cleanUp(config *configuration){
    2564   UIFactory::purgeInstance();
     96void cleanUp(){
     97  FormatParserStorage::purgeInstance();
     98  ChangeTracker::purgeInstance();
    256599  World::purgeInstance();
    2566   delete(configuration);
    2567   Log() << Verbose(0) <<  "Maximum of allocated memory: "
    2568     << MemoryUsageObserver::getInstance()->getMaximumUsedMemory() << endl;
    2569   Log() << Verbose(0) <<  "Remaining non-freed memory: "
    2570     << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl;
    2571   MemoryUsageObserver::purgeInstance();
    2572100  logger::purgeInstance();
    2573101  errorLogger::purgeInstance();
     102  UIFactory::purgeInstance();
     103  MapOfActions::purgeInstance();
     104  CommandLineParser::purgeInstance();
    2574105  ActionRegistry::purgeInstance();
    2575106  ActionHistory::purgeInstance();
     107#ifdef LOG_OBSERVER
     108  cout << observerLog().getLog();
     109#endif
    2576110  Memory::getState();
    2577111}
     
    2579113int main(int argc, char **argv)
    2580114{
    2581     molecule *mol = NULL;
    2582     config *configuration = new config;
    2583     Vector x, y, z, n;
    2584     ifstream test;
    2585     ofstream output;
    2586     string line;
    2587     char *ConfigFileName = NULL;
    2588     int j;
     115  // while we are non interactive, we want to abort from asserts
     116  //ASSERT_DO(Assert::Abort);
     117  string line;
     118  char **Arguments = NULL;
     119  int ArgcSize = 0;
     120  int ExitFlag = 0;
     121  bool ArgumentsCopied = false;
     122  std::string BondGraphFileName("\n");
     123  FormatParserStorage::getInstance().addMpqc();
     124  FormatParserStorage::getInstance().addPcp();
     125  FormatParserStorage::getInstance().addXyz();
    2589126
    2590     cout << ESPACKVersion << endl;
     127  // print version check whether arguments are present at all
     128  cout << ESPACKVersion << endl;
    2591129
    2592     setVerbosity(0);
    2593     // need to init the history before any action is created
    2594     ActionHistory::init();
    2595     /* structure of ParseCommandLineOptions will be refactored later */
    2596     j = ParseCommandLineOptions(argc, argv,  World::getInstance().getMolecules(), World::getInstance().getPeriode(), *configuration, ConfigFileName);
    2597     switch (j){
    2598         case 255:
    2599         case 2:
    2600         case 1:
    2601             cleanUp(configuration);
    2602             return (j == 1 ? 0 : j);
    2603         default:
    2604             break;
     130  setVerbosity(0);
     131  // need to init the history before any action is created
     132  ActionHistory::init();
     133
     134  // In the interactive mode, we can leave the user the choice in case of error
     135  ASSERT_DO(Assert::Ask);
     136
     137  // from this moment on, we need to be sure to deeinitialize in the correct order
     138  // this is handled by the cleanup function
     139  atexit(cleanUp);
     140
     141  // Parse command line options and if present create respective UI
     142  {
     143    // construct bond graph
     144    if (World::getInstance().getConfig()->BG == NULL) {
     145      World::getInstance().getConfig()->BG = new BondGraph(World::getInstance().getConfig()->GetIsAngstroem());
     146      if (World::getInstance().getConfig()->BG->LoadBondLengthTable(BondGraphFileName)) {
     147        DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
     148      } else {
     149        DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
     150      }
    2605151    }
    2606     if(World::getInstance().numMolecules() == 0){
    2607         mol = World::getInstance().createMolecule();
    2608         World::getInstance().getMolecules()->insert(mol);
    2609         cout << "Molecule created" << endl;
    2610         if(World::getInstance().getDomain()[0] == 0.){
    2611             Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl;
    2612             for(int i = 0;i < 6;i++){
    2613                 Log() << Verbose(1) << "Cell size" << i << ": ";
    2614                 cin >> World::getInstance().getDomain()[i];
    2615             }
    2616         }
    2617         mol->ActiveFlag = true;
     152    // handle remaining arguments by CommandLineParser
     153    if (argc>1) {
     154      MapOfActions::getInstance().AddOptionsToParser();
     155      map <std::string, std::string> ShortFormToActionMap = MapOfActions::getInstance().getShortFormToActionMap();
     156      CommandLineParser::getInstance().Run(argc,argv, ShortFormToActionMap);
     157      DoLog(0) && (Log() << Verbose(0) << "Setting UI to CommandLine." << endl);
     158      UIFactory::registerFactory(new CommandLineUIFactory::description());
     159      UIFactory::makeUserInterface("CommandLine");
     160    } else {
     161      #ifdef USE_GUI_QT
     162        DoLog(0) && (Log() << Verbose(0) << "Setting UI to QT4." << endl);
     163        UIFactory::registerFactory(new QTUIFactory::description());
     164        UIFactory::makeUserInterface("QT4");
     165      #else
     166        DoLog(0) && (Log() << Verbose(0) << "Setting UI to Text." << endl);
     167        cout << ESPACKVersion << endl;
     168        UIFactory::registerFactory(new TextUIFactory::description());
     169        UIFactory::makeUserInterface("Text");
     170      #endif
    2618171    }
     172  }
    2619173
    2620     {
    2621       cout << ESPACKVersion << endl;
     174  {
     175    MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow();
     176    mainWindow->display();
     177    delete mainWindow;
     178  }
    2622179
    2623       setVerbosity(0);
     180  FormatParserStorage::getInstance().SaveAll();
     181  ChangeTracker::getInstance().saveStatus();
    2624182
    2625       menuPopulaters populaters;
    2626       populaters.MakeEditMoleculesMenu = populateEditMoleculesMenu;
     183  // free the new argv
     184  if (ArgumentsCopied) {
     185    for (int i=0; i<ArgcSize;i++)
     186      delete[](Arguments[i]);
     187    delete[](Arguments);
     188  }
     189  //delete[](ConfigFileName);
    2627190
    2628       UIFactory::makeUserInterface(UIFactory::Text);
    2629       MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow(populaters,World::getInstance().getMolecules(), configuration, World::getInstance().getPeriode(), ConfigFileName);
    2630       mainWindow->display();
    2631       delete mainWindow;
    2632     }
    2633 
    2634     if(World::getInstance().getPeriode()->StorePeriodentafel(configuration->databasepath))
    2635         Log() << Verbose(0) << "Saving of elements.db successful." << endl;
    2636 
    2637     else
    2638         Log() << Verbose(0) << "Saving of elements.db failed." << endl;
    2639 
    2640   cleanUp(configuration);
    2641 
    2642   return (0);
     191  ExitFlag = World::getInstance().getExitFlag();
     192  return (ExitFlag == 1 ? 0 : ExitFlag);
    2643193}
    2644194
  • src/config.cpp

    rc39cc4 rbdb143  
    55 */
    66
     7#include "Helpers/MemDebug.hpp"
     8
    79#include <stdio.h>
    810#include <cstring>
    911
    10 #include "World.hpp"
    1112#include "atom.hpp"
    1213#include "bond.hpp"
     14#include "bondgraph.hpp"
    1315#include "config.hpp"
     16#include "ConfigFileBuffer.hpp"
    1417#include "element.hpp"
    1518#include "helpers.hpp"
     19#include "info.hpp"
    1620#include "lists.hpp"
    1721#include "log.hpp"
     
    2024#include "molecule.hpp"
    2125#include "periodentafel.hpp"
     26#include "ThermoStatContainer.hpp"
    2227#include "World.hpp"
    23 
    24 /******************************** Functions for class ConfigFileBuffer **********************/
    25 
    26 /** Structure containing compare function for Ion_Type sorting.
    27  */
    28 struct IonTypeCompare {
    29   bool operator()(const char* s1, const char *s2) const {
    30     char number1[8];
    31     char number2[8];
    32     const char *dummy1, *dummy2;
    33     //Log() << Verbose(0) << s1 << "  " << s2 << endl;
    34     dummy1 = strchr(s1, '_')+sizeof(char)*5;  // go just after "Ion_Type"
    35     dummy2 = strchr(dummy1, '_');
    36     strncpy(number1, dummy1, dummy2-dummy1); // copy the number
    37     number1[dummy2-dummy1]='\0';
    38     dummy1 = strchr(s2, '_')+sizeof(char)*5;  // go just after "Ion_Type"
    39     dummy2 = strchr(dummy1, '_');
    40     strncpy(number2, dummy1, dummy2-dummy1); // copy the number
    41     number2[dummy2-dummy1]='\0';
    42     if (atoi(number1) != atoi(number2))
    43       return (atoi(number1) < atoi(number2));
    44     else {
    45       dummy1 = strchr(s1, '_')+sizeof(char);
    46       dummy1 = strchr(dummy1, '_')+sizeof(char);
    47       dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t');
    48       strncpy(number1, dummy1, dummy2-dummy1); // copy the number
    49       number1[dummy2-dummy1]='\0';
    50       dummy1 = strchr(s2, '_')+sizeof(char);
    51       dummy1 = strchr(dummy1, '_')+sizeof(char);
    52       dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t');
    53       strncpy(number2, dummy1, dummy2-dummy1); // copy the number
    54       number2[dummy2-dummy1]='\0';
    55       return (atoi(number1) < atoi(number2));
    56     }
    57   }
    58 };
    59 
    60 /** Constructor for ConfigFileBuffer class.
    61  */
    62 ConfigFileBuffer::ConfigFileBuffer() : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0)
    63 {
    64 };
    65 
    66 /** Constructor for ConfigFileBuffer class with filename to be parsed.
    67  * \param *filename file name
    68  */
    69 ConfigFileBuffer::ConfigFileBuffer(const char * const filename) : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0)
    70 {
    71   ifstream *file = NULL;
    72   char line[MAXSTRINGSIZE];
    73 
    74   // prescan number of lines
    75   file= new ifstream(filename);
    76   if (file == NULL) {
    77     DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl);
    78     return;
    79   }
    80   NoLines = 0; // we're overcounting by one
    81   long file_position = file->tellg(); // mark current position
    82   do {
    83     file->getline(line, 256);
    84     NoLines++;
    85   } while (!file->eof());
    86   file->clear();
    87   file->seekg(file_position, ios::beg);
    88   DoLog(1) && (Log() << Verbose(1) << NoLines-1 << " lines were recognized." << endl);
    89 
    90   // allocate buffer's 1st dimension
    91   if (buffer != NULL) {
    92     DoeLog(1) && (eLog()<< Verbose(1) << "FileBuffer->buffer is not NULL!" << endl);
    93     return;
    94   } else
    95     buffer = Malloc<char*>(NoLines, "ConfigFileBuffer::ConfigFileBuffer: **buffer");
    96 
    97   // scan each line and put into buffer
    98   int lines=0;
    99   int i;
    100   do {
    101     buffer[lines] = Malloc<char>(MAXSTRINGSIZE, "ConfigFileBuffer::ConfigFileBuffer: *buffer[]");
    102     file->getline(buffer[lines], MAXSTRINGSIZE-1);
    103     i = strlen(buffer[lines]);
    104     buffer[lines][i] = '\n';
    105     buffer[lines][i+1] = '\0';
    106     lines++;
    107   } while((!file->eof()) && (lines < NoLines));
    108   DoLog(1) && (Log() << Verbose(1) << lines-1 << " lines were read into the buffer." << endl);
    109 
    110   // close and exit
    111   file->close();
    112   file->clear();
    113   delete(file);
    114 }
    115 
    116 /** Destructor for ConfigFileBuffer class.
    117  */
    118 ConfigFileBuffer::~ConfigFileBuffer()
    119 {
    120   for(int i=0;i<NoLines;++i)
    121     Free(&buffer[i]);
    122   Free(&buffer);
    123   Free(&LineMapping);
    124 }
    125 
    126 
    127 /** Create trivial mapping.
    128  */
    129 void ConfigFileBuffer::InitMapping()
    130 {
    131   LineMapping = Malloc<int>(NoLines, "ConfigFileBuffer::InitMapping: *LineMapping");
    132   for (int i=0;i<NoLines;i++)
    133     LineMapping[i] = i;
    134 }
    135 
    136 /** Creates a mapping for the \a *FileBuffer's lines containing the Ion_Type keyword such that they are sorted.
    137  * \a *map on return contains a list of NoAtom entries such that going through the list, yields indices to the
    138  * lines in \a *FileBuffer in a sorted manner of the Ion_Type?_? keywords. We assume that ConfigFileBuffer::CurrentLine
    139  * points to first Ion_Type entry.
    140  * \param *FileBuffer pointer to buffer structure
    141  * \param NoAtoms of subsequent lines to look at
    142  */
    143 void ConfigFileBuffer::MapIonTypesInBuffer(const int NoAtoms)
    144 {
    145   map<const char *, int, IonTypeCompare> IonTypeLineMap;
    146   if (LineMapping == NULL) {
    147     DoeLog(0) && (eLog()<< Verbose(0) << "map pointer is NULL: " << LineMapping << endl);
    148     performCriticalExit();
    149     return;
    150   }
    151 
    152   // put all into hashed map
    153   for (int i=0; i<NoAtoms; ++i) {
    154     IonTypeLineMap.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i));
    155   }
    156 
    157   // fill map
    158   int nr=0;
    159   for (map<const char *, int, IonTypeCompare>::iterator runner = IonTypeLineMap.begin(); runner != IonTypeLineMap.end(); ++runner) {
    160     if (CurrentLine+nr < NoLines)
    161       LineMapping[CurrentLine+(nr++)] = runner->second;
    162     else {
    163       DoeLog(0) && (eLog()<< Verbose(0) << "config::MapIonTypesInBuffer - NoAtoms is wrong: We are past the end of the file!" << endl);
    164       performCriticalExit();
    165     }
    166   }
    167 }
    16828
    16929/************************************* Functions for class config ***************************/
     
    17131/** Constructor for config file class.
    17232 */
    173 config::config() : BG(NULL), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1), configpath(NULL),
    174     configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), Thermostat(4), ThermostatImplemented(NULL),
    175     ThermostatNames(NULL), TempFrequency(2.5), alpha(0.), HooverMass(0.), TargetTemp(0.00095004455), ScaleTempStep(25),  mainname(NULL), defaultpath(NULL), pseudopotpath(NULL),
     33config::config() : BG(NULL), Thermostats(0), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1),
     34    configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), mainname(NULL), defaultpath(NULL), pseudopotpath(NULL),
    17635    DoOutVis(0), DoOutMes(1), DoOutNICS(0), DoOutOrbitals(0), DoOutCurrent(0), DoFullCurrent(0), DoPerturbation(0), DoWannier(0), CommonWannier(0), SawtoothStart(0.01),
    17736    VectorPlane(0), VectorCut(0.), UseAddGramSch(1), Seed(1), OutVisStep(10), OutSrcStep(5), MaxPsiStep(0), EpsWannier(1e-7), MaxMinStep(100), RelEpsTotalEnergy(1e-7),
     
    17938    MaxLevel(5), RiemannTensor(0), LevRFactor(0), RiemannLevel(0), Lev0Factor(2), RTActualUse(0), AddPsis(0), RCut(20.), StructOpt(0), IsAngstroem(1), RelativeCoord(0),
    18039    MaxTypes(0) {
    181   mainname = Malloc<char>(MAXSTRINGSIZE,"config constructor: mainname");
    182   defaultpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: defaultpath");
    183   pseudopotpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: pseudopotpath");
    184   databasepath = Malloc<char>(MAXSTRINGSIZE,"config constructor: databasepath");
    185   configpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: configpath");
    186   configname = Malloc<char>(MAXSTRINGSIZE,"config constructor: configname");
     40  mainname = new char[MAXSTRINGSIZE];
     41  defaultpath = new char[MAXSTRINGSIZE];
     42  pseudopotpath = new char[MAXSTRINGSIZE];
     43  databasepath = new char[MAXSTRINGSIZE];
     44  configname = new char[MAXSTRINGSIZE];
     45  Thermostats = new ThermoStatContainer();
    18746  strcpy(mainname,"pcp");
    18847  strcpy(defaultpath,"not specified");
    18948  strcpy(pseudopotpath,"not specified");
    190   configpath[0]='\0';
    19149  configname[0]='\0';
    19250  basis = "3-21G";
    193 
    194   InitThermostats();
    19551};
    19652
     
    19955config::~config()
    20056{
    201   Free(&mainname);
    202   Free(&defaultpath);
    203   Free(&pseudopotpath);
    204   Free(&databasepath);
    205   Free(&configpath);
    206   Free(&configname);
    207   Free(&ThermostatImplemented);
    208   for (int j=0;j<MaxThermostats;j++)
    209     Free(&ThermostatNames[j]);
    210   Free(&ThermostatNames);
     57  delete[](mainname);
     58  delete[](defaultpath);
     59  delete[](pseudopotpath);
     60  delete[](databasepath);
     61  delete[](configname);
     62  if (Thermostats != NULL)
     63    delete(Thermostats);
    21164
    21265  if (BG != NULL)
    21366    delete(BG);
    21467};
    215 
    216 /** Initialises variables in class config for Thermostats.
    217  */
    218 void config::InitThermostats()
    219 {
    220   ThermostatImplemented = Malloc<int>(MaxThermostats, "config constructor: *ThermostatImplemented");
    221   ThermostatNames = Malloc<char*>(MaxThermostats, "config constructor: *ThermostatNames");
    222   for (int j=0;j<MaxThermostats;j++)
    223     ThermostatNames[j] = Malloc<char>(12, "config constructor: ThermostatNames[]");
    224 
    225   strcpy(ThermostatNames[0],"None");
    226   ThermostatImplemented[0] = 1;
    227   strcpy(ThermostatNames[1],"Woodcock");
    228   ThermostatImplemented[1] = 1;
    229   strcpy(ThermostatNames[2],"Gaussian");
    230   ThermostatImplemented[2] = 1;
    231   strcpy(ThermostatNames[3],"Langevin");
    232   ThermostatImplemented[3] = 1;
    233   strcpy(ThermostatNames[4],"Berendsen");
    234   ThermostatImplemented[4] = 1;
    235   strcpy(ThermostatNames[5],"NoseHoover");
    236   ThermostatImplemented[5] = 1;
    237 };
    238 
    239 /** Readin of Thermostat related values from parameter file.
    240  * \param *fb file buffer containing the config file
    241  */
    242 void config::ParseThermostats(class ConfigFileBuffer * const fb)
    243 {
    244   char * const thermo = Malloc<char>(12, "IonsInitRead: thermo");
    245   const int verbose = 0;
    246 
    247   // read desired Thermostat from file along with needed additional parameters
    248   if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {
    249     if (strcmp(thermo, ThermostatNames[0]) == 0) { // None
    250       if (ThermostatImplemented[0] == 1) {
    251         Thermostat = None;
    252       } else {
    253         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    254         Thermostat = None;
    255       }
    256     } else if (strcmp(thermo, ThermostatNames[1]) == 0) { // Woodcock
    257       if (ThermostatImplemented[1] == 1) {
    258         Thermostat = Woodcock;
    259         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read scaling frequency
    260       } else {
    261         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    262         Thermostat = None;
    263       }
    264     } else if (strcmp(thermo, ThermostatNames[2]) == 0) { // Gaussian
    265       if (ThermostatImplemented[2] == 1) {
    266         Thermostat = Gaussian;
    267         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read collision rate
    268       } else {
    269         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    270         Thermostat = None;
    271       }
    272     } else if (strcmp(thermo, ThermostatNames[3]) == 0) { // Langevin
    273       if (ThermostatImplemented[3] == 1) {
    274         Thermostat = Langevin;
    275         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read gamma
    276         if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &alpha, 1, optional)) {
    277           DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << alpha << "." << endl);
    278         } else {
    279           alpha = 1.;
    280         }
    281       } else {
    282         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    283         Thermostat = None;
    284       }
    285     } else if (strcmp(thermo, ThermostatNames[4]) == 0) { // Berendsen
    286       if (ThermostatImplemented[4] == 1) {
    287         Thermostat = Berendsen;
    288         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read \tau_T
    289       } else {
    290         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    291         Thermostat = None;
    292       }
    293     } else if (strcmp(thermo, ThermostatNames[5]) == 0) { // Nose-Hoover
    294       if (ThermostatImplemented[5] == 1) {
    295         Thermostat = NoseHoover;
    296         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &HooverMass, 1, critical); // read Hoovermass
    297         alpha = 0.;
    298       } else {
    299         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    300         Thermostat = None;
    301       }
    302     } else {
    303       DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);
    304       Thermostat = None;
    305     }
    306   } else {
    307     if ((MaxOuterStep > 0) && (TargetTemp != 0))
    308       DoLog(2) && (Log() << Verbose(2) <<  "No thermostat chosen despite finite temperature MD, falling back to None." << endl);
    309     Thermostat = None;
    310   }
    311   Free(thermo);
    312 };
    313 
    31468
    31569/** Displays menu for editing each entry of the config file.
     
    626380};
    627381
    628 /** Retrieves the path in the given config file name.
    629  * \param filename config file string
    630  */
    631 void config::RetrieveConfigPathAndName(const string filename)
    632 {
    633   char *ptr = NULL;
    634   char *buffer = new char[MAXSTRINGSIZE];
    635   strncpy(buffer, filename.c_str(), MAXSTRINGSIZE);
    636   int last = -1;
    637   for(last=MAXSTRINGSIZE;last--;) {
    638     if (buffer[last] == '/')
    639       break;
    640   }
    641   if (last == -1) { // no path in front, set to local directory.
    642     strcpy(configpath, "./");
    643     ptr = buffer;
    644   } else {
    645     strncpy(configpath, buffer, last+1);
    646     ptr = &buffer[last+1];
    647     if (last < 254)
    648       configpath[last+1]='\0';
    649   }
    650   strcpy(configname, ptr);
    651   DoLog(0) && (Log() << Verbose(0) << "Found configpath: " << configpath << ", dir slash was found at " << last << ", config name is " << configname << "." << endl);
    652   delete[](buffer);
    653 };
    654 
    655 /** Initializes ConfigFileBuffer from a file.
    656  * \param *file input file stream being the opened config file
    657  * \param *FileBuffer pointer to FileBuffer on return, should point to NULL
    658  */
    659 void PrepareFileBuffer(const char * const filename, struct ConfigFileBuffer *&FileBuffer)
    660 {
    661   if (FileBuffer != NULL) {
    662     DoeLog(2) && (eLog()<< Verbose(2) << "deleting present FileBuffer in PrepareFileBuffer()." << endl);
    663     delete(FileBuffer);
    664   }
    665   FileBuffer = new ConfigFileBuffer(filename);
    666 
    667   FileBuffer->InitMapping();
    668 };
    669 
    670382/** Loads a molecule from a ConfigFileBuffer.
    671383 * \param *mol molecule to load
     
    861573  file->close();
    862574  delete(file);
    863   RetrieveConfigPathAndName(filename);
    864575
    865576  // ParseParameterFile
    866   struct ConfigFileBuffer *FileBuffer = NULL;
    867   PrepareFileBuffer(filename,FileBuffer);
     577  class ConfigFileBuffer *FileBuffer = new ConfigFileBuffer(filename);
    868578
    869579  /* Oeffne Hauptparameterdatei */
     
    874584  int verbose = 0;
    875585 
     586  //TODO: This is actually sensible?: if (MaxOuterStep > 0)
    876587  ParseThermostats(FileBuffer);
    877588 
     
    938649  ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional);
    939650  ParseForParameter(verbose,FileBuffer,"OutSrcStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional);
    940   ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(config::TargetTemp), 1, optional);
     651  ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(Thermostats->TargetTemp), 1, optional);
    941652  //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional);
    942653  if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional))
     
    1098809    return;
    1099810  }
    1100   RetrieveConfigPathAndName(filename);
    1101811  // ParseParameters
    1102812
     
    1147857  ParseForParameter(verbose,file,"VisOuterStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional);
    1148858  ParseForParameter(verbose,file,"VisSrcOuterStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional);
    1149   ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &(config::TargetTemp), 1, optional);
    1150   ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional);
     859  ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &(Thermostats->TargetTemp), 1, optional);
     860  ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &(Thermostats->ScaleTempStep), 1, optional);
    1151861  config::EpsWannier = 1e-8;
    1152862
     
    13361046    *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl;
    13371047    *output << "DoConstrainedMD\t" << config::DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl;
    1338     *output << "Thermostat\t" << ThermostatNames[Thermostat] << "\t";
    1339     switch(Thermostat) {
     1048    *output << "Thermostat\t" << Thermostats->ThermostatNames[Thermostats->Thermostat] << "\t";
     1049    switch(Thermostats->Thermostat) {
    13401050      default:
    13411051      case None:
    13421052        break;
    13431053      case Woodcock:
    1344         *output << ScaleTempStep;
     1054        *output << Thermostats->ScaleTempStep;
    13451055        break;
    13461056      case Gaussian:
    1347         *output << ScaleTempStep;
     1057        *output << Thermostats->ScaleTempStep;
    13481058        break;
    13491059      case Langevin:
    1350         *output << TempFrequency << "\t" << alpha;
     1060        *output << Thermostats->TempFrequency << "\t" << Thermostats->alpha;
    13511061        break;
    13521062      case Berendsen:
    1353         *output << TempFrequency;
     1063        *output << Thermostats->TempFrequency;
    13541064        break;
    13551065      case NoseHoover:
    1356         *output << HooverMass;
     1066        *output << Thermostats->HooverMass;
    13571067        break;
    13581068    };
     
    13691079    *output << "OutVisStep\t" << config::OutVisStep << "\t# Output visual data every ...th step" << endl;
    13701080    *output << "OutSrcStep\t" << config::OutSrcStep << "\t# Output \"restart\" data every ..th step" << endl;
    1371     *output << "TargetTemp\t" << config::TargetTemp << "\t# Target temperature" << endl;
     1081    *output << "TargetTemp\t" << Thermostats->TargetTemp << "\t# Target temperature" << endl;
    13721082    *output << "MaxPsiStep\t" << config::MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl;
    13731083    *output << "EpsWannier\t" << config::EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl;
     
    14801190    // output of atoms
    14811191    AtomNo = 0;
    1482     mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
     1192    mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo );
    14831193    delete(center);
    14841194    *output << "\t}" << endl;
     
    15221232    // output of atoms
    15231233    AtomNo = 0;
    1524     mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
     1234    mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo );
    15251235    delete(center);
    15261236    *output << "\t}" << endl;
     
    15471257  int AtomNo = -1;
    15481258  int MolNo = 0;
    1549   atom *Walker = NULL;
    15501259  FILE *f = NULL;
    15511260
     
    15601269  fprintf(f, "# Created by MoleCuilder\n");
    15611270
    1562   for (MoleculeList::const_iterator Runner = MolList->ListOfMolecules.begin(); Runner != MolList->ListOfMolecules.end(); Runner++) {
    1563     Walker = (*Runner)->start;
    1564     int *elementNo = Calloc<int>(MAX_ELEMENTS, "config::SavePDB - elementNo");
     1271  for (MoleculeList::const_iterator MolRunner = MolList->ListOfMolecules.begin(); MolRunner != MolList->ListOfMolecules.end(); MolRunner++) {
     1272    int *elementNo = new int[MAX_ELEMENTS];
     1273    for (int i=0;i<MAX_ELEMENTS;i++)
     1274      elementNo[i] = 0;
    15651275    AtomNo = 0;
    1566     while (Walker->next != (*Runner)->end) {
    1567       Walker = Walker->next;
    1568       sprintf(name, "%2s%2d",Walker->type->symbol, elementNo[Walker->type->Z]);
    1569       elementNo[Walker->type->Z] = (elementNo[Walker->type->Z]+1) % 100;   // confine to two digits
     1276    for (molecule::const_iterator iter = (*MolRunner)->begin(); iter != (*MolRunner)->end(); ++iter) {
     1277      sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]);
     1278      elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100;   // confine to two digits
    15701279      fprintf(f,
    15711280             "ATOM %6u %-4s %4s%c%4u    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s%2s\n",
    1572              Walker->nr,                /* atom serial number */
     1281             (*iter)->nr,                /* atom serial number */
    15731282             name,         /* atom name */
    1574              (*Runner)->name,      /* residue name */
     1283             (*MolRunner)->name,      /* residue name */
    15751284             'a'+(unsigned char)(AtomNo % 26),           /* letter for chain */
    15761285             MolNo,         /* residue sequence number */
    1577              Walker->node->at(0),                 /* position X in Angstroem */
    1578              Walker->node->at(1),                 /* position Y in Angstroem */
    1579              Walker->node->at(2),                 /* position Z in Angstroem */
    1580              (double)Walker->type->Valence,         /* occupancy */
    1581              (double)Walker->type->NoValenceOrbitals,          /* temperature factor */
     1286             (*iter)->node->at(0),                 /* position X in Angstroem */
     1287             (*iter)->node->at(1),                 /* position Y in Angstroem */
     1288             (*iter)->node->at(2),                 /* position Z in Angstroem */
     1289             (double)(*iter)->type->Valence,         /* occupancy */
     1290             (double)(*iter)->type->NoValenceOrbitals,          /* temperature factor */
    15821291             "0",            /* segment identifier */
    1583              Walker->type->symbol,    /* element symbol */
     1292             (*iter)->type->symbol,    /* element symbol */
    15841293             "0");           /* charge */
    15851294      AtomNo++;
    15861295    }
    1587     Free(&elementNo);
     1296    delete[](elementNo);
    15881297    MolNo++;
    15891298  }
     
    16011310{
    16021311  int AtomNo = -1;
    1603   atom *Walker = NULL;
    16041312  FILE *f = NULL;
    16051313
    1606   int *elementNo = Calloc<int>(MAX_ELEMENTS, "config::SavePDB - elementNo");
     1314  int *elementNo = new int[MAX_ELEMENTS];
     1315  for (int i=0;i<MAX_ELEMENTS;i++)
     1316    elementNo[i] = 0;
    16071317  char name[MAXSTRINGSIZE];
    16081318  strncpy(name, filename, MAXSTRINGSIZE-1);
     
    16111321  if (f == NULL) {
    16121322    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl);
    1613     Free(&elementNo);
     1323    delete[](elementNo);
    16141324    return false;
    16151325  }
    16161326  fprintf(f, "# Created by MoleCuilder\n");
    16171327
    1618   Walker = mol->start;
    16191328  AtomNo = 0;
    1620   while (Walker->next != mol->end) {
    1621     Walker = Walker->next;
    1622     sprintf(name, "%2s%2d",Walker->type->symbol, elementNo[Walker->type->Z]);
    1623     elementNo[Walker->type->Z] = (elementNo[Walker->type->Z]+1) % 100;   // confine to two digits
     1329  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1330    sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]);
     1331    elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100;   // confine to two digits
    16241332    fprintf(f,
    16251333           "ATOM %6u %-4s %4s%c%4u    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s%2s\n",
    1626            Walker->nr,                /* atom serial number */
     1334           (*iter)->nr,                /* atom serial number */
    16271335           name,         /* atom name */
    16281336           mol->name,      /* residue name */
    16291337           'a'+(unsigned char)(AtomNo % 26),           /* letter for chain */
    16301338           0,         /* residue sequence number */
    1631            Walker->node->at(0),                 /* position X in Angstroem */
    1632            Walker->node->at(1),                 /* position Y in Angstroem */
    1633            Walker->node->at(2),                 /* position Z in Angstroem */
    1634            (double)Walker->type->Valence,         /* occupancy */
    1635            (double)Walker->type->NoValenceOrbitals,          /* temperature factor */
     1339           (*iter)->node->at(0),                 /* position X in Angstroem */
     1340           (*iter)->node->at(1),                 /* position Y in Angstroem */
     1341           (*iter)->node->at(2),                 /* position Z in Angstroem */
     1342           (double)(*iter)->type->Valence,         /* occupancy */
     1343           (double)(*iter)->type->NoValenceOrbitals,          /* temperature factor */
    16361344           "0",            /* segment identifier */
    1637            Walker->type->symbol,    /* element symbol */
     1345           (*iter)->type->symbol,    /* element symbol */
    16381346           "0");           /* charge */
    16391347    AtomNo++;
    16401348  }
    16411349  fclose(f);
    1642   Free(&elementNo);
     1350  delete[](elementNo);
    16431351
    16441352  return true;
     
    16531361bool config::SaveTREMOLO(const char * const filename, const molecule * const mol) const
    16541362{
    1655   atom *Walker = NULL;
    16561363  ofstream *output = NULL;
    16571364  stringstream * const fname = new stringstream;
     
    16661373
    16671374  // scan maximum number of neighbours
    1668   Walker = mol->start;
    16691375  int MaxNeighbours = 0;
    1670   while (Walker->next != mol->end) {
    1671     Walker = Walker->next;
    1672     const int count = Walker->ListOfBonds.size();
     1376  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1377    const int count = (*iter)->ListOfBonds.size();
    16731378    if (MaxNeighbours < count)
    16741379      MaxNeighbours = count;
    16751380  }
    1676   *output << "# ATOMDATA Id name resName resSeq x=3 charge type neighbors=" << MaxNeighbours << endl;
    1677 
    1678   Walker = mol->start;
    1679   while (Walker->next != mol->end) {
    1680     Walker = Walker->next;
    1681     *output << Walker->nr << "\t";
    1682     *output << Walker->getName() << "\t";
     1381  *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl;
     1382
     1383  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1384    *output << (*iter)->nr << "\t";
     1385    *output << (*iter)->getName() << "\t";
    16831386    *output << mol->name << "\t";
    16841387    *output << 0 << "\t";
    1685     *output << Walker->node->at(0) << "\t" << Walker->node->at(1) << "\t" << Walker->node->at(2) << "\t";
    1686     *output << static_cast<double>(Walker->type->Valence) << "\t";
    1687     *output << Walker->type->symbol << "\t";
    1688     for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)
    1689       *output << (*runner)->GetOtherAtom(Walker)->nr << "\t";
    1690     for(int i=Walker->ListOfBonds.size(); i < MaxNeighbours; i++)
     1388    *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t";
     1389    *output << static_cast<double>((*iter)->type->Valence) << "\t";
     1390    *output << (*iter)->type->symbol << "\t";
     1391    for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
     1392      *output << (*runner)->GetOtherAtom(*iter)->nr << "\t";
     1393    for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++)
    16911394      *output << "-\t";
    16921395    *output << endl;
     
    17081411bool config::SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const
    17091412{
    1710   atom *Walker = NULL;
     1413  Info FunctionInfo(__func__);
    17111414  ofstream *output = NULL;
    17121415  stringstream * const fname = new stringstream;
     
    17231426  int MaxNeighbours = 0;
    17241427  for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
    1725     Walker = (*MolWalker)->start;
    1726     while (Walker->next != (*MolWalker)->end) {
    1727       Walker = Walker->next;
    1728       const int count = Walker->ListOfBonds.size();
     1428    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     1429      const int count = (*iter)->ListOfBonds.size();
    17291430      if (MaxNeighbours < count)
    17301431        MaxNeighbours = count;
    17311432    }
    17321433  }
    1733   *output << "# ATOMDATA Id name resName resSeq x=3 charge type neighbors=" << MaxNeighbours << endl;
     1434  *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl;
    17341435
    17351436  // create global to local id map
    1736   int **LocalNotoGlobalNoMap = Calloc<int *>(MolList->ListOfMolecules.size(), "config::SaveTREMOLO - **LocalNotoGlobalNoMap");
     1437  map<int, int> LocalNotoGlobalNoMap;
    17371438  {
    1738     int MolCounter = 0;
    1739     int AtomNo = 0;
     1439    unsigned int MolCounter = 0;
     1440    int AtomNo = 1;
    17401441    for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
    1741       LocalNotoGlobalNoMap[MolCounter] = Calloc<int>(MolList->CountAllAtoms(), "config::SaveTREMOLO - *LocalNotoGlobalNoMap[]");
    1742 
    1743       (*MolWalker)->SetIndexedArrayForEachAtomTo( LocalNotoGlobalNoMap[MolCounter], &atom::nr, IncrementalAbsoluteValue, &AtomNo);
    1744 
     1442      for(molecule::iterator AtomRunner = (*MolWalker)->begin(); AtomRunner != (*MolWalker)->end(); ++AtomRunner) {
     1443        LocalNotoGlobalNoMap.insert( pair<int,int>((*AtomRunner)->getId(), AtomNo++) );
     1444      }
    17451445      MolCounter++;
    17461446    }
     1447    ASSERT(MolCounter == MolList->ListOfMolecules.size(), "SaveTREMOLO: LocalNotoGlobalNoMap[] has not been correctly initialized for each molecule");
    17471448  }
    17481449
     
    17521453    int AtomNo = 0;
    17531454    for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
    1754       Walker = (*MolWalker)->start;
    1755       while (Walker->next != (*MolWalker)->end) {
    1756         Walker = Walker->next;
    1757         *output << AtomNo+1 << "\t";
    1758         *output << Walker->getName() << "\t";
     1455      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     1456        *output << LocalNotoGlobalNoMap[ (*iter)->getId() ] << "\t";
     1457        *output << (*iter)->getName() << "\t";
    17591458        *output << (*MolWalker)->name << "\t";
    17601459        *output << MolCounter+1 << "\t";
    1761         *output << Walker->node->at(0) << "\t" << Walker->node->at(1) << "\t" << Walker->node->at(2) << "\t";
    1762         *output << (double)Walker->type->Valence << "\t";
    1763         *output << Walker->type->symbol << "\t";
    1764         for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)
    1765           *output << LocalNotoGlobalNoMap[MolCounter][ (*runner)->GetOtherAtom(Walker)->nr ]+1 << "\t";
    1766         for(int i=Walker->ListOfBonds.size(); i < MaxNeighbours; i++)
     1460        *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t";
     1461        *output << (double)(*iter)->type->Valence << "\t";
     1462        *output << (*iter)->type->symbol << "\t";
     1463        for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
     1464          *output << LocalNotoGlobalNoMap[ (*runner)->GetOtherAtom((*iter))->getId() ] << "\t";
     1465        for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++)
    17671466          *output << "-\t";
    17681467        *output << endl;
     
    17781477  delete(output);
    17791478  delete(fname);
    1780   for(size_t i=0;i<MolList->ListOfMolecules.size(); i++)
    1781     Free(&LocalNotoGlobalNoMap[i]);
    1782   Free(&LocalNotoGlobalNoMap);
    17831479
    17841480  return true;
     
    17951491  char filename[MAXSTRINGSIZE];
    17961492  ofstream output;
    1797   molecule *mol = World::getInstance().createMolecule();
    1798   mol->SetNameFromFilename(ConfigFileName);
    1799 
    1800   if (!strcmp(configpath, GetDefaultPath())) {
    1801     eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
    1802   }
    1803 
     1493  molecule *mol = NULL;
    18041494
    18051495  // first save as PDB data
     
    18081498  if (output == NULL)
    18091499    strcpy(filename,"main_pcp_linux");
    1810   Log() << Verbose(0) << "Saving as pdb input ";
     1500  Log() << Verbose(0) << "Saving as pdb input ... " << endl;
    18111501  if (SavePDB(filename, molecules))
    1812     Log() << Verbose(0) << "done." << endl;
     1502    Log() << Verbose(0) << "\t... done." << endl;
    18131503  else
    1814     Log() << Verbose(0) << "failed." << endl;
     1504    Log() << Verbose(0) << "\t... failed." << endl;
    18151505
    18161506  // then save as tremolo data file
     
    18191509  if (output == NULL)
    18201510    strcpy(filename,"main_pcp_linux");
    1821   Log() << Verbose(0) << "Saving as tremolo data input ";
     1511  Log() << Verbose(0) << "Saving as tremolo data input ... " << endl;
    18221512  if (SaveTREMOLO(filename, molecules))
    1823     Log() << Verbose(0) << "done." << endl;
     1513    Log() << Verbose(0) << "\t... done." << endl;
    18241514  else
    1825     Log() << Verbose(0) << "failed." << endl;
     1515    Log() << Verbose(0) << "\t... failed." << endl;
    18261516
    18271517  // translate each to its center and merge all molecules in MoleculeListClass into this molecule
    18281518  int N = molecules->ListOfMolecules.size();
    1829   int *src = new int[N];
    1830   N=0;
    1831   for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
    1832     src[N++] = (*ListRunner)->IndexNr;
    1833     (*ListRunner)->Translate(&(*ListRunner)->Center);
    1834   }
    1835   molecules->SimpleMultiAdd(mol, src, N);
    1836   delete[](src);
    1837 
    1838   // ... and translate back
    1839   for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
    1840     (*ListRunner)->Center.Scale(-1.);
    1841     (*ListRunner)->Translate(&(*ListRunner)->Center);
    1842     (*ListRunner)->Center.Scale(-1.);
     1519  if (N != 1) { // don't do anything in case of only one molecule (shifts mol ids otherwise)
     1520    int *src = new int[N];
     1521    N=0;
     1522    for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
     1523      src[N++] = (*ListRunner)->IndexNr;
     1524      (*ListRunner)->Translate(&(*ListRunner)->Center);
     1525    }
     1526    mol = World::getInstance().createMolecule();
     1527    mol->SetNameFromFilename(ConfigFileName);
     1528    molecules->SimpleMultiMerge(mol, src, N);
     1529    mol->doCountAtoms();
     1530    mol->CountElements();
     1531    //mol->CalculateOrbitals(*this);
     1532    delete[](src);
     1533  } else {
     1534    if (!molecules->ListOfMolecules.empty()) {
     1535      mol = *(molecules->ListOfMolecules.begin());
     1536      mol->doCountAtoms();
     1537      //mol->CalculateOrbitals(*this);
     1538    } else {
     1539      DoeLog(1) && (eLog() << Verbose(1) << "There are no molecules to save!" << endl);
     1540    }
    18431541  }
    18441542
    18451543  Log() << Verbose(0) << "Storing configuration ... " << endl;
    18461544  // get correct valence orbitals
    1847   mol->CalculateOrbitals(*this);
    1848   InitMaxMinStopStep = MaxMinStopStep = MaxPsiDouble;
    18491545  if (ConfigFileName != NULL) { // test the file name
    18501546    strcpy(filename, ConfigFileName);
     
    18591555  output.close();
    18601556  output.clear();
    1861   Log() << Verbose(0) << "Saving of config file ";
     1557  Log() << Verbose(0) << "Saving of config file ... " << endl;
    18621558  if (Save(filename, periode, mol))
    1863     Log() << Verbose(0) << "successful." << endl;
     1559    Log() << Verbose(0) << "\t... successful." << endl;
    18641560  else
    1865     Log() << Verbose(0) << "failed." << endl;
     1561    Log() << Verbose(0) << "\t... failed." << endl;
    18661562
    18671563  // and save to xyz file
     
    18761572    output.open(filename, ios::trunc);
    18771573  }
    1878   Log() << Verbose(0) << "Saving of XYZ file ";
     1574  Log() << Verbose(0) << "Saving of XYZ file ... " << endl;
    18791575  if (mol->MDSteps <= 1) {
    18801576    if (mol->OutputXYZ(&output))
    1881       Log() << Verbose(0) << "successful." << endl;
     1577      Log() << Verbose(0) << "\t... successful." << endl;
    18821578    else
    1883       Log() << Verbose(0) << "failed." << endl;
     1579      Log() << Verbose(0) << "\t... failed." << endl;
    18841580  } else {
    18851581    if (mol->OutputTrajectoriesXYZ(&output))
    1886       Log() << Verbose(0) << "successful." << endl;
     1582      Log() << Verbose(0) << "\t... successful." << endl;
    18871583    else
    1888       Log() << Verbose(0) << "failed." << endl;
     1584      Log() << Verbose(0) << "\t... failed." << endl;
    18891585  }
    18901586  output.close();
     
    18961592  if (output == NULL)
    18971593    strcpy(filename,"main_pcp_linux");
    1898   Log() << Verbose(0) << "Saving as mpqc input ";
     1594  Log() << Verbose(0) << "Saving as mpqc input .. " << endl;
    18991595  if (SaveMPQC(filename, mol))
    1900     Log() << Verbose(0) << "done." << endl;
     1596    Log() << Verbose(0) << "\t... done." << endl;
    19011597  else
    1902     Log() << Verbose(0) << "failed." << endl;
    1903 
    1904   if (!strcmp(configpath, GetDefaultPath())) {
    1905     eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
    1906   }
    1907 
    1908   World::getInstance().destroyMolecule(mol);
     1598    Log() << Verbose(0) << "\t... failed." << endl;
     1599
     1600  // don't destroy molecule as it contains all our atoms
     1601  //World::getInstance().destroyMolecule(mol);
    19091602};
    19101603
     
    19381631  char *dummy1 = NULL;
    19391632  char *dummy = NULL;
    1940   char * const free_dummy = Malloc<char>(256, "config::ParseForParameter: *free_dummy");    // pointers in the line that is read in per step
     1633  char free_dummy[MAXSTRINGSIZE];    // pointers in the line that is read in per step
    19411634  dummy1 = free_dummy;
    19421635
     
    19541647      if (file->eof()) {
    19551648        if ((critical) && (found == 0)) {
    1956           Free(free_dummy);
    19571649          //Error(InitReading, name);
    19581650          fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
     
    19621654          file->clear();
    19631655          file->seekg(file_position, ios::beg);  // rewind to start position
    1964           Free(free_dummy);
    19651656          return 0;
    19661657        }
     
    19931684        dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword)
    19941685        //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name);
    1995         //Free((void **)&free_dummy);
    19961686        //Error(FileOpenParams, NULL);
    19971687      } else {
     
    20141704              if (file->eof()) {
    20151705                if ((critical) && (found == 0)) {
    2016                   Free(free_dummy);
    20171706                  //Error(InitReading, name);
    20181707                  fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
     
    20221711                  file->clear();
    20231712                  file->seekg(file_position, ios::beg);  // rewind to start position
    2024                   Free(free_dummy);
    20251713                  return 0;
    20261714                }
     
    20631751                  if (critical) {
    20641752                    if (verbose) fprintf(stderr,"Error: EoL at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name);
    2065                     Free(free_dummy);
    20661753                    //return 0;
    20671754                    exit(255);
     
    20711758                    file->clear();
    20721759                    file->seekg(file_position, ios::beg);  // rewind to start position
    2073                     Free(free_dummy);
    20741760                    return 0;
    20751761                  }
     
    20841770                  file->seekg(file_position, ios::beg);  // rewind to start position
    20851771                }
    2086                 Free(free_dummy);
    20871772                return 0;
    20881773              }
     
    21401825  if ((type >= row_int) && (verbose))
    21411826    fprintf(stderr,"\n");
    2142   Free(free_dummy);
    21431827  if (!sequential) {
    21441828    file->clear();
     
    22211905        dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword)
    22221906        //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name);
    2223         //Free(&free_dummy);
    22241907        //Error(FileOpenParams, NULL);
    22251908      } else {
     
    23612044  return (found); // true if found, false if not
    23622045}
     2046
     2047/** Reading of Thermostat related values from parameter file.
     2048 * \param *fb file buffer containing the config file
     2049 */
     2050void config::ParseThermostats(class ConfigFileBuffer * const fb)
     2051{
     2052  char * const thermo = new char[12];
     2053  const int verbose = 0;
     2054
     2055  // read desired Thermostat from file along with needed additional parameters
     2056  if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {
     2057    if (strcmp(thermo, Thermostats->ThermostatNames[0]) == 0) { // None
     2058      if (Thermostats->ThermostatImplemented[0] == 1) {
     2059        Thermostats->Thermostat = None;
     2060      } else {
     2061        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2062        Thermostats->Thermostat = None;
     2063      }
     2064    } else if (strcmp(thermo, Thermostats->ThermostatNames[1]) == 0) { // Woodcock
     2065      if (Thermostats->ThermostatImplemented[1] == 1) {
     2066        Thermostats->Thermostat = Woodcock;
     2067        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read scaling frequency
     2068      } else {
     2069        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2070        Thermostats->Thermostat = None;
     2071      }
     2072    } else if (strcmp(thermo, Thermostats->ThermostatNames[2]) == 0) { // Gaussian
     2073      if (Thermostats->ThermostatImplemented[2] == 1) {
     2074        Thermostats->Thermostat = Gaussian;
     2075        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read collision rate
     2076      } else {
     2077        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2078        Thermostats->Thermostat = None;
     2079      }
     2080    } else if (strcmp(thermo, Thermostats->ThermostatNames[3]) == 0) { // Langevin
     2081      if (Thermostats->ThermostatImplemented[3] == 1) {
     2082        Thermostats->Thermostat = Langevin;
     2083        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read gamma
     2084        if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &Thermostats->alpha, 1, optional)) {
     2085          DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << Thermostats->alpha << "." << endl);
     2086        } else {
     2087          Thermostats->alpha = 1.;
     2088        }
     2089      } else {
     2090        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2091        Thermostats->Thermostat = None;
     2092      }
     2093    } else if (strcmp(thermo, Thermostats->ThermostatNames[4]) == 0) { // Berendsen
     2094      if (Thermostats->ThermostatImplemented[4] == 1) {
     2095        Thermostats->Thermostat = Berendsen;
     2096        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read \tau_T
     2097      } else {
     2098        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2099        Thermostats->Thermostat = None;
     2100      }
     2101    } else if (strcmp(thermo, Thermostats->ThermostatNames[5]) == 0) { // Nose-Hoover
     2102      if (Thermostats->ThermostatImplemented[5] == 1) {
     2103        Thermostats->Thermostat = NoseHoover;
     2104        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->HooverMass, 1, critical); // read Hoovermass
     2105        Thermostats->alpha = 0.;
     2106      } else {
     2107        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2108        Thermostats->Thermostat = None;
     2109      }
     2110    } else {
     2111      DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);
     2112      Thermostats->Thermostat = None;
     2113    }
     2114  } else {
     2115    if ((Thermostats->TargetTemp != 0))
     2116      DoLog(2) && (Log() << Verbose(2) <<  "No thermostat chosen despite finite temperature MD, falling back to None." << endl);
     2117    Thermostats->Thermostat = None;
     2118  }
     2119  delete[](thermo);
     2120};
     2121
  • src/config.hpp

    rc39cc4 rbdb143  
    2020#include <string>
    2121
    22 #include "bondgraph.hpp"
    23 
    2422/****************************************** forward declarations *****************************/
    2523
     24class BondGraph;
     25class ConfigFileBuffer;
    2626class molecule;
    2727class MoleculeListClass;
    2828class periodentafel;
     29class ThermoStatContainer;
    2930
    3031/********************************************** declarations *******************************/
    31 
    32 class ConfigFileBuffer {
    33   public:
    34     char **buffer;
    35     int *LineMapping;
    36     int CurrentLine;
    37     int NoLines;
    38 
    39     ConfigFileBuffer();
    40     ConfigFileBuffer(const char * const filename);
    41     ~ConfigFileBuffer();
    42 
    43     void InitMapping();
    44     void MapIonTypesInBuffer(const int NoAtoms);
    45 };
    4632
    4733/** The config file.
     
    5137  public:
    5238    class BondGraph *BG;
     39    class ThermoStatContainer *Thermostats;
    5340
    5441    int PsiType;
     
    6047    int ProcPEGamma;
    6148    int ProcPEPsi;
    62     char *configpath;
    6349    char *configname;
    6450    bool FastParsing;
     
    7056    int DoConstrainedMD;
    7157    int MaxOuterStep;
    72     int Thermostat;
    73     int *ThermostatImplemented;
    74     char **ThermostatNames;
    75     double TempFrequency;
    76     double alpha;
    77     double HooverMass;
    78     double TargetTemp;
    79     int ScaleTempStep;
    8058
    8159  private:
     
    138116  void Load(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList);
    139117  void LoadOld(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList);
    140   void RetrieveConfigPathAndName(const string filename);
    141118  bool Save(const char * const filename, const periodentafel * const periode, molecule * const mol) const;
    142119  bool SaveMPQC(const char * const filename, const molecule * const mol) const;
     
    152129  char *GetDefaultPath() const;
    153130  void SetDefaultPath(const char * const path);
    154   void InitThermostats();
    155131  void ParseThermostats(class ConfigFileBuffer * const fb);
    156132};
  • src/datacreator.cpp

    rc39cc4 rbdb143  
    66
    77//============================ INCLUDES ===========================
     8
     9#include "Helpers/MemDebug.hpp"
    810
    911#include "datacreator.hpp"
  • src/defs.hpp

    rc39cc4 rbdb143  
    8282#define STD_SEPERATOR_SPACER '-'
    8383
     84#define MOLECUILDER_NAME "Molecuilder"
     85
    8486#endif /*DEFS_HPP_*/
  • src/element.cpp

    rc39cc4 rbdb143  
    44 *
    55 */
     6
     7#include "Helpers/MemDebug.hpp"
    68
    79#include <iomanip>
  • src/elements.db

    • Property mode changed from 100755 to 100644
    rc39cc4 rbdb143  
    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/ellipsoid.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <gsl/gsl_multimin.h>
  • src/errorlogger.cpp

    rc39cc4 rbdb143  
    55 *      Author: metzler
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <fstream>
  • src/graph.cpp

    rc39cc4 rbdb143  
    44 *
    55 */
     6
     7#include "Helpers/MemDebug.hpp"
    68
    79using namespace std;
  • src/gslmatrix.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810using namespace std;
  • src/gslvector.cpp

    rc39cc4 rbdb143  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include <cassert>
    911#include <cmath>
     
    1113#include "gslvector.hpp"
    1214#include "defs.hpp"
     15#include "vector.hpp"
    1316
    1417/** Constructor of class GSLVector.
     
    5962  gsl_vector_memcpy (vector, &m.vector);
    6063};
     64
     65/**
     66 * This function sets the GSLvector from an ordinary vector.
     67 *
     68 * Takes access to the internal gsl_vector and copies it
     69 */
     70void GSLVector::SetFromVector(Vector &v){
     71  gsl_vector_memcpy (vector, v.get());
     72}
    6173
    6274/** This function returns the i-th element of a vector.
  • src/gslvector.hpp

    rc39cc4 rbdb143  
    2424
    2525class GSLVector;
     26class Vector;
    2627
    2728/********************************************** declarations *******************************/
     
    3839  // Accessing
    3940  void SetFromDoubleArray(double *x);
     41  void SetFromVector(Vector &v);
    4042  double Get(size_t m) const;
    4143  void Set(size_t m, double x);
  • src/helpers.cpp

    rc39cc4 rbdb143  
    44 */
    55
     6#include "Helpers/MemDebug.hpp"
    67
    78#include "helpers.hpp"
     
    5859int CountLinesinFile(ifstream &InputFile)
    5960{
    60   char *buffer = Malloc<char>(MAXSTRINGSIZE, "CountLinesinFile: *buffer");
     61  char *buffer = new char[MAXSTRINGSIZE];
    6162  int lines=0;
    6263
     
    7071  }
    7172  InputFile.seekg(PositionMarker, ios::beg);
    72   Free(&buffer);
     73  delete[](buffer);
    7374  return lines;
    7475};
     
    9091  }
    9192  // allocate string
    92   returnstring = Malloc<char>(order + 2, "FixedDigitNumber: *returnstring");
     93  returnstring = new char[order + 2];
    9394  // terminate  and fill string array from end backward
    9495  returnstring[order] = '\0';
     
    122123double * ReturnFullMatrixforSymmetric(const double * const symm)
    123124{
    124   double *matrix = Malloc<double>(NDIM * NDIM, "molecule::ReturnFullMatrixforSymmetric: *matrix");
     125  double *matrix = new double[NDIM * NDIM];
    125126  matrix[0] = symm[0];
    126127  matrix[1] = symm[1];
     
    140141double * InverseMatrix( const double * const A)
    141142{
    142   double *B = Malloc<double>(NDIM * NDIM, "Vector::InverseMatrix: *B");
     143  double *B = new double[NDIM * NDIM];
    143144  double detA = RDET3(A);
    144145  double detAReci;
     
    180181
    181182
    182 /** Allocates a memory range using malloc().
    183  * Prints the provided error message in case of a failure.
    184  *
    185  * \param number of memory slices of type X to allocate
    186  * \param failure message which is printed if the allocation fails
    187  * \return pointer to the allocated memory range, will be NULL if a failure occurred
    188  */
    189 template <> char* Malloc<char>(size_t size, const char* output)
    190 {
    191   char* buffer = NULL;
    192   buffer = (char*) malloc(sizeof(char) * (size + 1));
    193   for (size_t i = size; i--;)
    194     buffer[i] = (i % 2 == 0) ? 'p': 'c';
    195   buffer[size] = '\0';
    196 
    197   if (buffer != NULL) {
    198     MemoryUsageObserver::getInstance()->addMemory(buffer, size);
    199   } else {
    200     Log() << Verbose(0) << "Malloc for datatype " << typeid(char).name()
    201       << " failed - pointer is NULL: " << output << endl;
    202   }
    203 
    204   return buffer;
    205 };
    206 
    207183/**
    208  * Frees all memory registered by the memory observer and calls exit(225) afterwards.
     184 * Calls exit(255).
    209185 */
    210186void performCriticalExit() {
    211   map<void*, size_t> pointers = MemoryUsageObserver::getInstance()->getPointersToAllocatedMemory();
    212   for (map<void*, size_t>::iterator runner = pointers.begin(); runner != pointers.end(); runner++) {
    213     Free(((void**) &runner->first));
    214   }
    215 
    216187  exit(255);
    217188}
  • src/helpers.hpp

    rc39cc4 rbdb143  
    9797
    9898  if (LookupTable != NULL) {
    99     DoLog(0) && (Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl);
     99    DoeLog(0) && (eLog() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl);
    100100    return false;
    101101  }
     
    110110  }
    111111  if (count <= 0) {
    112     DoLog(0) && (Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl);
     112    DoeLog(1) && (eLog() << Verbose(1) << "Count of lookup list is 0 or less." << endl);
    113113    return false;
    114114  }
    115115
    116116  // allocate and fill
    117   LookupTable = Calloc<T*>(count, "CreateFatherLookupTable - **LookupTable");
     117  LookupTable = new T*[count];
    118118  if (LookupTable == NULL) {
    119119    DoeLog(0) && (eLog()<< Verbose(0) << "LookupTable memory allocation failed!" << endl);
     
    129129        LookupTable[AtomNo] = Walker;
    130130      } else {
    131         DoLog(0) && (Log() << Verbose(0) << "Walker " << *Walker << " exceeded range of nuclear ids [0, " << count << ")." << endl);
     131        DoeLog(2) && (eLog() << Verbose(2) << "Walker " << *Walker << " exceeded range of nuclear ids [0, " << count << ")." << endl);
    132132        status = false;
    133133        break;
     
    138138  return status;
    139139};
     140
    140141
    141142/** Frees a two-dimensional array.
  • src/info.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "info.hpp"
  • src/joiner.cpp

    rc39cc4 rbdb143  
    77
    88//============================ INCLUDES ===========================
     9
     10#include "Helpers/MemDebug.hpp"
    911
    1012#include <cstring>
     
    5860    return 1;
    5961  } else {
    60     dir = Malloc<char>(strlen(argv[2]) + 2, "main: *dir");
     62    dir = new char[strlen(argv[2]) + 2];
    6163    strcpy(dir, "/");
    6264    strcat(dir, argv[2]);
     
    243245  // exit
    244246  delete(periode);
    245   Free(&dir);
     247  delete[](dir);
    246248  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    247249  return 0;
  • src/leastsquaremin.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <iostream>
  • src/linearsystemofequations.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "defs.hpp"
     
    5456{
    5557  assert ( columns == NDIM && "Vector class is always three-dimensional, unlike this LEqS!");
    56   b->SetFromDoubleArray(x->get());
     58  b->SetFromVector(*x);
    5759};
    5860
  • src/linkedcell.cpp

    rc39cc4 rbdb143  
    55 */
    66
     7#include "Helpers/MemDebug.hpp"
    78
    89#include "atom.hpp"
  • src/lists.hpp

    rc39cc4 rbdb143  
    134134};
    135135
    136 /** Returns the first marker in a chain list.
    137  * \param *me one arbitrary item in chain list
    138  * \return poiner to first marker
    139  */
    140 template <typename X> X *GetFirst(X *me)
    141 {
    142   X *Binder = me;
    143   while(Binder->previous != 0)
    144     Binder = Binder->previous;
    145   return Binder;
    146 };
    147 
    148 /** Returns the last marker in a chain list.
    149  * \param *me one arbitrary item in chain list
    150  * \return poiner to last marker
    151  */
    152 template <typename X> X *GetLast(X *me)
    153 {
    154   X *Binder = me;
    155   while(Binder->next != 0)
    156     Binder = Binder->next;
    157   return Binder;
    158 };
    159 
    160136#endif /* LISTS_HPP_ */
  • src/log.cpp

    rc39cc4 rbdb143  
    55 *      Author: metzler
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "logger.hpp"
  • src/logger.cpp

    rc39cc4 rbdb143  
    55 *      Author: metzler
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <fstream>
  • src/memoryusageobserver.cpp

    rc39cc4 rbdb143  
    44 * This class represents a Singleton for observing memory usage.
    55 */
     6
     7#include "Helpers/MemDebug.hpp"
    68
    79#include <cstdlib>
  • src/molecule.cpp

    rc39cc4 rbdb143  
    44 *
    55 */
     6
     7#include "Helpers/MemDebug.hpp"
    68
    79#include <cstring>
     
    3537 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero.
    3638 */
    37 molecule::molecule(const periodentafel * const teil) : elemente(teil), start(World::getInstance().createAtom()), end(World::getInstance().createAtom()),
    38   first(new bond(start, end, 1, -1)), last(new bond(start, end, 1, -1)), MDSteps(0), AtomCount(0),
    39   BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0), NoCyclicBonds(0), BondDistance(0.),
    40   ActiveFlag(false), IndexNr(-1),
    41   formula(this,boost::bind(&molecule::calcFormula,this)),
    42   last_atom(0),
    43   InternalPointer(start)
    44 {
    45   // init atom chain list
    46   start->father = NULL;
    47   end->father = NULL;
    48   link(start,end);
    49 
    50   // init bond chain list
    51   link(first,last);
     39molecule::molecule(const periodentafel * const teil) :
     40  Observable("molecule"),
     41  elemente(teil),  MDSteps(0),  BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0),
     42  NoCyclicBonds(0), BondDistance(0.),  ActiveFlag(false), IndexNr(-1),
     43  formula(this,boost::bind(&molecule::calcFormula,this),"formula"),
     44  AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), last_atom(0),  InternalPointer(atoms.begin())
     45{
    5246
    5347  // other stuff
    5448  for(int i=MAX_ELEMENTS;i--;)
    5549    ElementsInMolecule[i] = 0;
    56   strcpy(name,World::getInstance().getDefaultName());
     50  strcpy(name,World::getInstance().getDefaultName().c_str());
    5751};
    5852
     
    6761{
    6862  CleanupMolecule();
    69   delete(first);
    70   delete(last);
    71   end->getWorld()->destroyAtom(end);
    72   start->getWorld()->destroyAtom(start);
    7363};
    7464
     
    8373}
    8474
     75int molecule::getAtomCount() const{
     76  return *AtomCount;
     77}
     78
    8579void molecule::setName(const std::string _name){
    8680  OBSERVE;
     81  cout << "Set name of molecule " << getId() << " to " << _name << endl;
    8782  strncpy(name,_name.c_str(),MAXSTRINGSIZE);
    8883}
     
    10499  stringstream sstr;
    105100  periodentafel *periode = World::getInstance().getPeriode();
    106   for(atom *Walker = start; Walker != end; Walker = Walker->next) {
    107     counts[Walker->type->getNumber()]++;
     101  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     102    counts[(*iter)->type->getNumber()]++;
    108103  }
    109104  std::map<atomicNumber_t,unsigned int>::reverse_iterator iter;
     
    115110}
    116111
     112/************************** Access to the List of Atoms ****************/
     113
     114
     115molecule::iterator molecule::begin(){
     116  return molecule::iterator(atoms.begin(),this);
     117}
     118
     119molecule::const_iterator molecule::begin() const{
     120  return atoms.begin();
     121}
     122
     123molecule::iterator molecule::end(){
     124  return molecule::iterator(atoms.end(),this);
     125}
     126
     127molecule::const_iterator molecule::end() const{
     128  return atoms.end();
     129}
     130
     131bool molecule::empty() const
     132{
     133  return (begin() == end());
     134}
     135
     136size_t molecule::size() const
     137{
     138  size_t counter = 0;
     139  for (molecule::const_iterator iter = begin(); iter != end (); ++iter)
     140    counter++;
     141  return counter;
     142}
     143
     144molecule::const_iterator molecule::erase( const_iterator loc )
     145{
     146  molecule::const_iterator iter = loc;
     147  iter--;
     148  atom* atom = *loc;
     149  atomIds.erase( atom->getId() );
     150  atoms.remove( atom );
     151  atom->removeFromMolecule();
     152  return iter;
     153}
     154
     155molecule::const_iterator molecule::erase( atom * key )
     156{
     157  molecule::const_iterator iter = find(key);
     158  if (iter != end()){
     159    atomIds.erase( key->getId() );
     160    atoms.remove( key );
     161    key->removeFromMolecule();
     162  }
     163  return iter;
     164}
     165
     166molecule::const_iterator molecule::find ( atom * key ) const
     167{
     168  molecule::const_iterator iter;
     169  for (molecule::const_iterator Runner = begin(); Runner != end(); ++Runner) {
     170    if (*Runner == key)
     171      return molecule::const_iterator(Runner);
     172  }
     173  return molecule::const_iterator(atoms.end());
     174}
     175
     176pair<molecule::iterator,bool> molecule::insert ( atom * const key )
     177{
     178  pair<atomIdSet::iterator,bool> res = atomIds.insert(key->getId());
     179  if (res.second) { // push atom if went well
     180    atoms.push_back(key);
     181    return pair<iterator,bool>(molecule::iterator(--end()),res.second);
     182  } else {
     183    return pair<iterator,bool>(molecule::iterator(end()),res.second);
     184  }
     185}
     186
     187bool molecule::containsAtom(atom* key){
     188  return (find(key) != end());
     189}
    117190
    118191/** Adds given atom \a *pointer from molecule list.
     
    123196bool molecule::AddAtom(atom *pointer)
    124197{
    125   bool retval = false;
    126198  OBSERVE;
    127199  if (pointer != NULL) {
    128200    pointer->sort = &pointer->nr;
    129     pointer->nr = last_atom++;  // increase number within molecule
    130     AtomCount++;
    131201    if (pointer->type != NULL) {
    132202      if (ElementsInMolecule[pointer->type->Z] == 0)
     
    141211      }
    142212    }
    143     retval = add(pointer, end);
    144   }
    145   return retval;
     213    insert(pointer);
     214    pointer->setMolecule(this);
     215  }
     216  return true;
    146217};
    147218
     
    157228  if (pointer != NULL) {
    158229    atom *walker = pointer->clone();
    159     stringstream sstr;
    160     sstr << pointer->getName();
    161     walker->setName(sstr.str());
     230    walker->setName(pointer->getName());
    162231    walker->nr = last_atom++;  // increase number within molecule
    163     add(walker, end);
     232    insert(walker);
    164233    if ((pointer->type != NULL) && (pointer->type->Z != 1))
    165234      NoNonHydrogen++;
    166     AtomCount++;
    167235    retval=walker;
    168236  }
     
    242310    Orthovector1.MatrixMultiplication(matrix);
    243311    InBondvector -= Orthovector1; // subtract just the additional translation
    244     Free(&matrix);
     312    delete[](matrix);
    245313    bondlength = InBondvector.Norm();
    246314//    Log() << Verbose(4) << "Corrected InBondvector is now: ";
     
    251319  InBondvector.Normalize();
    252320  // get typical bond length and store as scale factor for later
     321  ASSERT(TopOrigin->type != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given.");
    253322  BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1];
    254323  if (BondRescale == -1) {
     
    472541      break;
    473542  }
    474   Free(&matrix);
     543  delete[](matrix);
    475544
    476545//  Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl;
     
    555624
    556625  // copy all bonds
    557   bond *Binder = first;
     626  bond *Binder = NULL;
    558627  bond *NewBond = NULL;
    559   while(Binder->next != last) {
    560     Binder = Binder->next;
    561 
    562     // get the pendant atoms of current bond in the copy molecule
    563     copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->leftatom, (const atom **)&LeftAtom );
    564     copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->rightatom, (const atom **)&RightAtom );
    565 
    566     NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree);
    567     NewBond->Cyclic = Binder->Cyclic;
    568     if (Binder->Cyclic)
    569       copy->NoCyclicBonds++;
    570     NewBond->Type = Binder->Type;
    571   }
     628  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     629    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     630      if ((*BondRunner)->leftatom == *AtomRunner) {
     631        Binder = (*BondRunner);
     632
     633        // get the pendant atoms of current bond in the copy molecule
     634        copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->leftatom, (const atom **)&LeftAtom );
     635        copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->rightatom, (const atom **)&RightAtom );
     636
     637        NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree);
     638        NewBond->Cyclic = Binder->Cyclic;
     639        if (Binder->Cyclic)
     640          copy->NoCyclicBonds++;
     641        NewBond->Type = Binder->Type;
     642      }
    572643  // correct fathers
    573644  ActOnAllAtoms( &atom::CorrectFather );
    574645
    575646  // copy values
    576   copy->CountAtoms();
    577647  copy->CountElements();
    578   if (first->next != last) {  // if adjaceny list is present
     648  if (hasBondStructure()) {  // if adjaceny list is present
    579649    copy->BondDistance = BondDistance;
    580650  }
     
    608678bond * molecule::AddBond(atom *atom1, atom *atom2, int degree)
    609679{
     680  OBSERVE;
    610681  bond *Binder = NULL;
    611   if ((atom1 != NULL) && (FindAtom(atom1->nr) != NULL) && (atom2 != NULL) && (FindAtom(atom2->nr) != NULL)) {
    612     Binder = new bond(atom1, atom2, degree, BondCount++);
    613     atom1->RegisterBond(Binder);
    614     atom2->RegisterBond(Binder);
    615     if ((atom1->type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1))
    616       NoNonBonds++;
    617     add(Binder, last);
    618   } else {
    619     DoeLog(1) && (eLog()<< Verbose(1) << "Could not add bond between " << atom1->getName() << " and " << atom2->getName() << " as one or both are not present in the molecule." << endl);
    620   }
     682
     683  // some checks to make sure we are able to create the bond
     684  ASSERT(atom1, "First atom in bond-creation was an invalid pointer");
     685  ASSERT(atom2, "Second atom in bond-creation was an invalid pointer");
     686  ASSERT(FindAtom(atom1->nr),"First atom in bond-creation was not part of molecule");
     687  ASSERT(FindAtom(atom2->nr),"Second atom in bond-creation was not parto of molecule");
     688
     689  Binder = new bond(atom1, atom2, degree, BondCount++);
     690  atom1->RegisterBond(Binder);
     691  atom2->RegisterBond(Binder);
     692  if ((atom1->type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1))
     693    NoNonBonds++;
     694
    621695  return Binder;
    622696};
     
    630704{
    631705  //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);
    632   pointer->leftatom->RegisterBond(pointer);
    633   pointer->rightatom->RegisterBond(pointer);
    634   removewithoutcheck(pointer);
     706  delete(pointer);
    635707  return true;
    636708};
     
    668740  else
    669741    length = strlen(molname) - strlen(endname);
     742  cout << "Set name of molecule " << getId() << " to " << molname << endl;
    670743  strncpy(name, molname, length);
    671744  name[length]='\0';
     
    692765bool molecule::RemoveAtom(atom *pointer)
    693766{
     767  ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom().");
     768  OBSERVE;
    694769  if (ElementsInMolecule[pointer->type->Z] != 0)  { // this would indicate an error
    695770    ElementsInMolecule[pointer->type->Z]--;  // decrease number of atom of this element
    696     AtomCount--;
    697771  } else
    698772    DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->getName() << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl);
     
    700774    ElementCount--;
    701775  RemoveBonds(pointer);
    702   return remove(pointer, start, end);
     776  erase(pointer);
     777  return true;
    703778};
    704779
     
    717792  if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
    718793    ElementCount--;
    719   unlink(pointer);
     794  erase(pointer);
    720795  return true;
    721796};
     
    726801bool molecule::CleanupMolecule()
    727802{
    728   return (cleanup(first,last) && cleanup(start,end));
     803  for (molecule::iterator iter = begin(); !empty(); iter = begin())
     804      erase(iter);
     805  return empty();
    729806};
    730807
     
    733810 * \return pointer to atom or NULL
    734811 */
    735 atom * molecule::FindAtom(int Nr)  const{
    736   atom * walker = find(&Nr, start,end);
    737   if (walker != NULL) {
     812atom * molecule::FindAtom(int Nr)  const
     813{
     814  molecule::const_iterator iter = begin();
     815  for (; iter != end(); ++iter)
     816    if ((*iter)->nr == Nr)
     817      break;
     818  if (iter != end()) {
    738819    //Log() << Verbose(0) << "Found Atom Nr. " << walker->nr << endl;
    739     return walker;
     820    return (*iter);
    740821  } else {
    741822    DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl);
     
    801882        ElementNo[i] = current++;
    802883    }
    803     ActOnAllAtoms( &atom::OutputArrayIndexed, output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL );
     884    ActOnAllAtoms( &atom::OutputArrayIndexed, (ostream * const) output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL );
    804885    return true;
    805886  }
     
    867948    now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
    868949    for (int step=0;step<MDSteps;step++) {
    869       *output << AtomCount << "\n\tCreated by molecuilder, step " << step << ", on " << ctime(&now);
     950      *output << getAtomCount() << "\n\tCreated by molecuilder, step " << step << ", on " << ctime(&now);
    870951      ActOnAllAtoms( &atom::OutputTrajectoryXYZ, output, step );
    871952    }
     
    884965  if (output != NULL) {
    885966    now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
    886     *output << AtomCount << "\n\tCreated by molecuilder on " << ctime(&now);
     967    *output << getAtomCount() << "\n\tCreated by molecuilder on " << ctime(&now);
    887968    ActOnAllAtoms( &atom::OutputXYZLine, output );
    888969    return true;
     
    894975 * \param *out output stream for debugging
    895976 */
    896 void molecule::CountAtoms()
    897 {
     977int molecule::doCountAtoms()
     978{
     979  int res = size();
    898980  int i = 0;
    899   atom *Walker = start;
    900   while (Walker->next != end) {
    901     Walker = Walker->next;
     981  NoNonHydrogen = 0;
     982  for (molecule::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
     983    (*iter)->nr = i;   // update number in molecule (for easier referencing in FragmentMolecule lateron)
     984    if ((*iter)->type->Z != 1) // count non-hydrogen atoms whilst at it
     985      NoNonHydrogen++;
     986    stringstream sstr;
     987    sstr << (*iter)->type->symbol << (*iter)->nr+1;
     988    (*iter)->setName(sstr.str());
     989    DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->getName() << "." << endl);
    902990    i++;
    903991  }
    904   if ((AtomCount == 0) || (i != AtomCount)) {
    905     DoLog(3) && (Log() << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl);
    906     AtomCount = i;
    907 
    908     // count NonHydrogen atoms and give each atom a unique name
    909     if (AtomCount != 0) {
    910       i=0;
    911       NoNonHydrogen = 0;
    912       Walker = start;
    913       while (Walker->next != end) {
    914         Walker = Walker->next;
    915         Walker->nr = i;   // update number in molecule (for easier referencing in FragmentMolecule lateron)
    916         if (Walker->type->Z != 1) // count non-hydrogen atoms whilst at it
    917           NoNonHydrogen++;
    918         stringstream sstr;
    919         sstr << Walker->type->symbol << Walker->nr+1;
    920         Walker->setName(sstr.str());
    921         DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << Walker->nr << " " << Walker->getName() << "." << endl);
    922         i++;
    923       }
    924     } else
    925       DoLog(3) && (Log() << Verbose(3) << "AtomCount is still " << AtomCount << ", thus counting nothing." << endl);
    926   }
     992  return res;
    927993};
    928994
     
    9391005  for(int i=MAX_ELEMENTS;i--;)
    9401006    ElementCount += (ElementsInMolecule[i] != 0 ? 1 : 0);
    941 };
    942 
    943 
    944 /** Counts necessary number of valence electrons and returns number and SpinType.
    945  * \param configuration containing everything
    946  */
    947 void molecule::CalculateOrbitals(class config &configuration)
    948 {
    949   configuration.MaxPsiDouble = configuration.PsiMaxNoDown = configuration.PsiMaxNoUp = configuration.PsiType = 0;
    950   for(int i=MAX_ELEMENTS;i--;) {
    951     if (ElementsInMolecule[i] != 0) {
    952       //Log() << Verbose(0) << "CalculateOrbitals: " << elemente->FindElement(i)->name << " has a valence of " << (int)elemente->FindElement(i)->Valence << " and there are " << ElementsInMolecule[i] << " of it." << endl;
    953       configuration.MaxPsiDouble += ElementsInMolecule[i]*((int)elemente->FindElement(i)->Valence);
    954     }
    955   }
    956   configuration.PsiMaxNoDown = configuration.MaxPsiDouble/2 + (configuration.MaxPsiDouble % 2);
    957   configuration.PsiMaxNoUp = configuration.MaxPsiDouble/2;
    958   configuration.MaxPsiDouble /= 2;
    959   configuration.PsiType = (configuration.PsiMaxNoDown == configuration.PsiMaxNoUp) ? 0 : 1;
    960   if ((configuration.PsiType == 1) && (configuration.ProcPEPsi < 2)) {
    961     configuration.ProcPEGamma /= 2;
    962     configuration.ProcPEPsi *= 2;
    963   } else {
    964     configuration.ProcPEGamma *= configuration.ProcPEPsi;
    965     configuration.ProcPEPsi = 1;
    966   }
    967   configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.MaxPsiDouble;
    9681007};
    9691008
     
    9861025  /// first count both their atoms and elements and update lists thereby ...
    9871026  //Log() << Verbose(0) << "Counting atoms, updating list" << endl;
    988   CountAtoms();
    989   OtherMolecule->CountAtoms();
    9901027  CountElements();
    9911028  OtherMolecule->CountElements();
     
    9941031  /// -# AtomCount
    9951032  if (result) {
    996     if (AtomCount != OtherMolecule->AtomCount) {
    997       DoLog(4) && (Log() << Verbose(4) << "AtomCounts don't match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl);
     1033    if (getAtomCount() != OtherMolecule->getAtomCount()) {
     1034      DoLog(4) && (Log() << Verbose(4) << "AtomCounts don't match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl);
    9981035      result = false;
    999     } else Log() << Verbose(4) << "AtomCounts match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl;
     1036    } else Log() << Verbose(4) << "AtomCounts match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl;
    10001037  }
    10011038  /// -# ElementCount
     
    10341071  if (result) {
    10351072    DoLog(5) && (Log() << Verbose(5) << "Calculating distances" << endl);
    1036     Distances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: Distances");
    1037     OtherDistances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: OtherDistances");
     1073    Distances = new double[getAtomCount()];
     1074    OtherDistances = new double[getAtomCount()];
    10381075    SetIndexedArrayForEachAtomTo ( Distances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity);
    10391076    SetIndexedArrayForEachAtomTo ( OtherDistances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity);
     1077    for(int i=0;i<getAtomCount();i++) {
     1078      Distances[i] = 0.;
     1079      OtherDistances[i] = 0.;
     1080    }
    10401081
    10411082    /// ... sort each list (using heapsort (o(N log N)) from GSL)
    10421083    DoLog(5) && (Log() << Verbose(5) << "Sorting distances" << endl);
    1043     PermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermMap");
    1044     OtherPermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *OtherPermMap");
    1045     gsl_heapsort_index (PermMap, Distances, AtomCount, sizeof(double), CompareDoubles);
    1046     gsl_heapsort_index (OtherPermMap, OtherDistances, AtomCount, sizeof(double), CompareDoubles);
    1047     PermutationMap = Calloc<int>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermutationMap");
     1084    PermMap = new size_t[getAtomCount()];
     1085    OtherPermMap = new size_t[getAtomCount()];
     1086    for(int i=0;i<getAtomCount();i++) {
     1087      PermMap[i] = 0;
     1088      OtherPermMap[i] = 0;
     1089    }
     1090    gsl_heapsort_index (PermMap, Distances, getAtomCount(), sizeof(double), CompareDoubles);
     1091    gsl_heapsort_index (OtherPermMap, OtherDistances, getAtomCount(), sizeof(double), CompareDoubles);
     1092    PermutationMap = new int[getAtomCount()];
     1093    for(int i=0;i<getAtomCount();i++)
     1094      PermutationMap[i] = 0;
    10481095    DoLog(5) && (Log() << Verbose(5) << "Combining Permutation Maps" << endl);
    1049     for(int i=AtomCount;i--;)
     1096    for(int i=getAtomCount();i--;)
    10501097      PermutationMap[PermMap[i]] = (int) OtherPermMap[i];
    10511098
     
    10531100    DoLog(4) && (Log() << Verbose(4) << "Comparing distances" << endl);
    10541101    flag = 0;
    1055     for (int i=0;i<AtomCount;i++) {
     1102    for (int i=0;i<getAtomCount();i++) {
    10561103      DoLog(5) && (Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " <<  threshold << endl);
    10571104      if (fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) > threshold*threshold)
     
    10601107
    10611108    // free memory
    1062     Free(&PermMap);
    1063     Free(&OtherPermMap);
    1064     Free(&Distances);
    1065     Free(&OtherDistances);
     1109    delete[](PermMap);
     1110    delete[](OtherPermMap);
     1111    delete[](Distances);
     1112    delete[](OtherDistances);
    10661113    if (flag) { // if not equal
    1067       Free(&PermutationMap);
     1114      delete[](PermutationMap);
    10681115      result = false;
    10691116    }
     
    10891136int * molecule::GetFatherSonAtomicMap(molecule *OtherMolecule)
    10901137{
    1091   atom *Walker = NULL, *OtherWalker = NULL;
    10921138  DoLog(3) && (Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl);
    1093   int *AtomicMap = Malloc<int>(AtomCount, "molecule::GetAtomicMap: *AtomicMap");
    1094   for (int i=AtomCount;i--;)
     1139  int *AtomicMap = new int[getAtomCount()];
     1140  for (int i=getAtomCount();i--;)
    10951141    AtomicMap[i] = -1;
    10961142  if (OtherMolecule == this) {  // same molecule
    1097     for (int i=AtomCount;i--;) // no need as -1 means already that there is trivial correspondence
     1143    for (int i=getAtomCount();i--;) // no need as -1 means already that there is trivial correspondence
    10981144      AtomicMap[i] = i;
    10991145    DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl);
    11001146  } else {
    11011147    DoLog(4) && (Log() << Verbose(4) << "Map is ");
    1102     Walker = start;
    1103     while (Walker->next != end) {
    1104       Walker = Walker->next;
    1105       if (Walker->father == NULL) {
    1106         AtomicMap[Walker->nr] = -2;
     1148    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     1149      if ((*iter)->father == NULL) {
     1150        AtomicMap[(*iter)->nr] = -2;
    11071151      } else {
    1108         OtherWalker = OtherMolecule->start;
    1109         while (OtherWalker->next != OtherMolecule->end) {
    1110           OtherWalker = OtherWalker->next;
     1152        for (molecule::const_iterator runner = OtherMolecule->begin(); runner != OtherMolecule->end(); ++runner) {
    11111153      //for (int i=0;i<AtomCount;i++) { // search atom
    1112         //for (int j=0;j<OtherMolecule->AtomCount;j++) {
    1113           //Log() << Verbose(4) << "Comparing father " << Walker->father << " with the other one " << OtherWalker->father << "." << endl;
    1114           if (Walker->father == OtherWalker)
    1115             AtomicMap[Walker->nr] = OtherWalker->nr;
     1154        //for (int j=0;j<OtherMolecule->getAtomCount();j++) {
     1155          //Log() << Verbose(4) << "Comparing father " << (*iter)->father << " with the other one " << (*runner)->father << "." << endl;
     1156          if ((*iter)->father == (*runner))
     1157            AtomicMap[(*iter)->nr] = (*runner)->nr;
    11161158        }
    11171159      }
    1118       DoLog(0) && (Log() << Verbose(0) << AtomicMap[Walker->nr] << "\t");
     1160      DoLog(0) && (Log() << Verbose(0) << AtomicMap[(*iter)->nr] << "\t");
    11191161    }
    11201162    DoLog(0) && (Log() << Verbose(0) << endl);
     
    11501192void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index) const
    11511193{
    1152   atom *Walker = start;
    1153   while (Walker->next != end) {
    1154     Walker = Walker->next;
    1155     array[(Walker->*index)] = Walker;
     1194  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     1195    array[((*iter)->*index)] = (*iter);
    11561196  }
    11571197};
  • src/molecule.hpp

    rc39cc4 rbdb143  
    2929#include <string>
    3030
    31 #include "defs.hpp"
     31#include "types.hpp"
    3232#include "graph.hpp"
    3333#include "stackclass.hpp"
    3434#include "tesselation.hpp"
    3535#include "Patterns/Observer.hpp"
     36#include "Patterns/ObservedIterator.hpp"
    3637#include "Patterns/Cacheable.hpp"
     38
     39#include "Descriptors/MoleculeDescriptor_impl.hpp"
    3740
    3841/****************************************** forward declarations *****************************/
     
    7881};
    7982
    80 #define MaxThermostats 6      //!< maximum number of thermostat entries in Ions#ThermostatNames and Ions#ThermostatImplemented
    81 enum thermostats { None, Woodcock, Gaussian, Langevin, Berendsen, NoseHoover };   //!< Thermostat names for output
    82 
    83 
    8483/** The complete molecule.
    8584 * Class incorporates number of types
     
    8887  friend molecule *NewMolecule();
    8988  friend void DeleteMolecule(molecule *);
     89
    9090  public:
     91    typedef std::list<atom*> atomSet;
     92    typedef std::set<atomId_t> atomIdSet;
     93    typedef ObservedIterator<atomSet> iterator;
     94    typedef atomSet::const_iterator const_iterator;
     95
    9196    const periodentafel * const elemente; //!< periodic table with each element
    92     atom *start;        //!< start of atom list
    93     atom *end;          //!< end of atom list
    94     bond *first;        //!< start of bond list
    95     bond *last;         //!< end of bond list
     97    // old deprecated atom handling
     98    //atom *start;        //!< start of atom list
     99    //atom *end;          //!< end of atom list
     100    //bond *first;        //!< start of bond list
     101    //bond *last;         //!< end of bond list
    96102    int MDSteps;        //!< The number of MD steps in Trajectories
    97     int AtomCount;          //!< number of atoms, brought up-to-date by CountAtoms()
     103    //int AtomCount;          //!< number of atoms, brought up-to-date by CountAtoms()
    98104    int BondCount;          //!< number of atoms, brought up-to-date by CountBonds()
    99105    int ElementCount;       //!< how many unique elements are therein
     
    110116  private:
    111117    Cacheable<string> formula;
     118    Cacheable<int>    AtomCount;
    112119    moleculeId_t id;
     120    atomSet atoms; //<!list of atoms
     121    atomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms
    113122  protected:
     123    //void CountAtoms();
     124    /**
     125     * this iterator type should be used for internal variables, \
     126     * since it will not lock
     127     */
     128    typedef atomSet::iterator internal_iterator;
     129
     130
    114131    molecule(const periodentafel * const teil);
    115132    virtual ~molecule();
     
    119136  //getter and setter
    120137  const std::string getName();
     138  int getAtomCount() const;
     139  int doCountAtoms();
    121140  moleculeId_t getId();
    122141  void setId(moleculeId_t);
     
    125144  std::string calcFormula();
    126145
     146  iterator begin();
     147  const_iterator begin() const;
     148  iterator end();
     149  const_iterator end() const;
     150  bool empty() const;
     151  size_t size() const;
     152  const_iterator erase( const_iterator loc );
     153  const_iterator erase( atom * key );
     154  const_iterator find (  atom * key ) const;
     155  pair<iterator,bool> insert ( atom * const key );
     156  bool containsAtom(atom* key);
     157
    127158
    128159  // re-definition of virtual functions from PointCloud
     
    130161  Vector *GetCenter() const ;
    131162  TesselPoint *GetPoint() const ;
    132   TesselPoint *GetTerminalPoint() const ;
    133163  int GetMaxId() const;
    134164  void GoToNext() const ;
    135   void GoToPrevious() const ;
    136165  void GoToFirst() const ;
    137   void GoToLast() const ;
    138166  bool IsEmpty() const ;
    139167  bool IsEnd() const ;
     
    224252  bool RemoveBond(bond *pointer);
    225253  bool RemoveBonds(atom *BondPartner);
     254  bool hasBondStructure();
     255  unsigned int CountBonds() const;
    226256
    227257  /// Find atoms.
     
    230260
    231261  /// Count and change present atoms' coordination.
    232   void CountAtoms();
    233262  void CountElements();
    234   void CalculateOrbitals(class config &configuration);
    235263  bool CenterInBox();
    236264  bool BoundInBox();
     
    247275  Vector * DetermineCenterOfGravity();
    248276  Vector * DetermineCenterOfAll() const;
     277  Vector * DetermineCenterOfBox() const;
    249278  void SetNameFromFilename(const char *filename);
    250279  void SetBoxDimension(Vector *dim);
     
    258287  double MinimiseConstrainedPotential(atom **&permutation, int startstep, int endstep, bool IsAngstroem);
    259288  void EvaluateConstrainedForces(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force);
    260   bool LinearInterpolationBetweenConfiguration(int startstep, int endstep, const char *prefix, config &configuration, bool MapByIdentity);
     289  bool LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string &prefix, config &configuration, bool MapByIdentity);
    261290       
    262291  bool CheckBounds(const Vector *x) const;
     
    290319
    291320  /// Fragment molecule by two different approaches:
    292   int FragmentMolecule(int Order, config *configuration);
    293   bool CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path = NULL);
    294   bool StoreBondsToFile(char *path, char *filename);
    295   bool StoreAdjacencyToFile(char *path, char *filename);
    296   bool CheckAdjacencyFileAgainstMolecule(char *path, atom **ListOfAtoms);
    297   bool ParseOrderAtSiteFromFile(char *path);
    298   bool StoreOrderAtSiteFile(char *path);
    299   bool StoreForcesFile(MoleculeListClass *BondFragments, char *path, int *SortIndex);
     321  int FragmentMolecule(int Order, std::string &prefix);
     322  bool CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, std::string path = "");
     323  bool StoreBondsToFile(std::string &filename, std::string path = "");
     324  bool StoreAdjacencyToFile(std::string &filename, std::string path = "");
     325  bool CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms);
     326  bool ParseOrderAtSiteFromFile(std::string &path);
     327  bool StoreOrderAtSiteFile(std::string &path);
     328  bool StoreForcesFile(MoleculeListClass *BondFragments, std::string &path, int *SortIndex);
    300329  bool CreateMappingLabelsToConfigSequence(int *&SortIndex);
     330  bool CreateFatherLookupTable(atom **&LookupTable, int count = 0);
    301331  void BreadthFirstSearchAdd(molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem);
    302332  /// -# BOSSANOVA
     
    327357  private:
    328358  int last_atom;      //!< number given to last atom
    329   mutable atom *InternalPointer;  //!< internal pointer for PointCloud
     359  mutable internal_iterator InternalPointer;  //!< internal pointer for PointCloud
    330360};
    331361
     
    345375  ~MoleculeListClass();
    346376
    347   bool AddHydrogenCorrection(char *path);
    348   bool StoreForcesFile(char *path, int *SortIndex);
     377  bool AddHydrogenCorrection(std::string &path);
     378  bool StoreForcesFile(std::string &path, int *SortIndex);
    349379  void insert(molecule *mol);
     380  void erase(molecule *mol);
    350381  molecule * ReturnIndex(int index);
    351   bool OutputConfigForListOfFragments(config *configuration, int *SortIndex);
     382  bool OutputConfigForListOfFragments(std::string &prefix, int *SortIndex);
    352383  int NumberOfActiveMolecules();
    353384  void Enumerate(ostream *out);
  • src/molecule_dynamics.cpp

    rc39cc4 rbdb143  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include "World.hpp"
    911#include "atom.hpp"
    1012#include "config.hpp"
    1113#include "element.hpp"
     14#include "info.hpp"
    1215#include "log.hpp"
    1316#include "memoryallocator.hpp"
     
    1518#include "parser.hpp"
    1619#include "Plane.hpp"
     20#include "ThermoStatContainer.hpp"
    1721
    1822/************************************* Functions for class molecule *********************************/
     
    2832  gsl_matrix *A = gsl_matrix_alloc(NDIM,NDIM);
    2933  gsl_vector *x = gsl_vector_alloc(NDIM);
    30   atom * Runner = mol->start;
    3134  atom *Sprinter = NULL;
    3235  Vector trajectory1, trajectory2, normal, TestVector;
    3336  double Norm1, Norm2, tmp, result = 0.;
    3437
    35   while (Runner->next != mol->end) {
    36     Runner = Runner->next;
    37     if (Runner == Walker) // hence, we only go up to the Walker, not beyond (similar to i=0; i<j; i++)
     38  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     39    if ((*iter) == Walker) // hence, we only go up to the Walker, not beyond (similar to i=0; i<j; i++)
    3840      break;
    3941    // determine normalized trajectories direction vector (n1, n2)
     
    4244    trajectory1.Normalize();
    4345    Norm1 = trajectory1.Norm();
    44     Sprinter = Params.PermutationMap[Runner->nr];   // find second target point
    45     trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Runner->Trajectory.R.at(Params.startstep);
     46    Sprinter = Params.PermutationMap[(*iter)->nr];   // find second target point
     47    trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - (*iter)->Trajectory.R.at(Params.startstep);
    4648    trajectory2.Normalize();
    4749    Norm2 = trajectory1.Norm();
    4850    // check whether either is zero()
    4951    if ((Norm1 < MYEPSILON) && (Norm2 < MYEPSILON)) {
    50       tmp = Walker->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.startstep));
     52      tmp = Walker->Trajectory.R.at(Params.startstep).distance((*iter)->Trajectory.R.at(Params.startstep));
    5153    } else if (Norm1 < MYEPSILON) {
    5254      Sprinter = Params.PermutationMap[Walker->nr];   // find first target point
    53       trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - Runner->Trajectory.R.at(Params.startstep);
     55      trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - (*iter)->Trajectory.R.at(Params.startstep);
    5456      trajectory2 *= trajectory1.ScalarProduct(trajectory2); // trajectory2 is scaled to unity, hence we don't need to divide by anything
    5557      trajectory1 -= trajectory2;   // project the part in norm direction away
    5658      tmp = trajectory1.Norm();  // remaining norm is distance
    5759    } else if (Norm2 < MYEPSILON) {
    58       Sprinter = Params.PermutationMap[Runner->nr];   // find second target point
     60      Sprinter = Params.PermutationMap[(*iter)->nr];   // find second target point
    5961      trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Walker->Trajectory.R.at(Params.startstep);  // copy second offset
    6062      trajectory1 *= trajectory2.ScalarProduct(trajectory1); // trajectory1 is scaled to unity, hence we don't need to divide by anything
     
    6668  //        Log() << Verbose(0) << " and ";
    6769  //        Log() << Verbose(0) << trajectory2;
    68       tmp = Walker->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.startstep));
     70      tmp = Walker->Trajectory.R.at(Params.startstep).distance((*iter)->Trajectory.R.at(Params.startstep));
    6971  //        Log() << Verbose(0) << " with distance " << tmp << "." << endl;
    7072    } else { // determine distance by finding minimum distance
    71   //        Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *Runner << " are linear independent ";
     73  //        Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *(*iter) << " are linear independent ";
    7274  //        Log() << Verbose(0) << endl;
    7375  //        Log() << Verbose(0) << "First Trajectory: ";
     
    8587        gsl_matrix_set(A, 1, i, trajectory2[i]);
    8688        gsl_matrix_set(A, 2, i, normal[i]);
    87         gsl_vector_set(x,i, (Walker->Trajectory.R.at(Params.startstep)[i] - Runner->Trajectory.R.at(Params.startstep)[i]));
     89        gsl_vector_set(x,i, (Walker->Trajectory.R.at(Params.startstep)[i] - (*iter)->Trajectory.R.at(Params.startstep)[i]));
    8890      }
    8991      // solve the linear system by Householder transformations
     
    9698      trajectory2.Scale(gsl_vector_get(x,1));
    9799      normal.Scale(gsl_vector_get(x,2));
    98       TestVector = Runner->Trajectory.R.at(Params.startstep) + trajectory2 + normal
     100      TestVector = (*iter)->Trajectory.R.at(Params.startstep) + trajectory2 + normal
    99101                   - (Walker->Trajectory.R.at(Params.startstep) + trajectory1);
    100102      if (TestVector.Norm() < MYEPSILON) {
     
    125127{
    126128  double result = 0.;
    127   atom * Runner = mol->start;
    128   while (Runner->next != mol->end) {
    129     Runner = Runner->next;
    130     if ((Params.PermutationMap[Walker->nr] == Params.PermutationMap[Runner->nr]) && (Walker->nr < Runner->nr)) {
     129  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     130    if ((Params.PermutationMap[Walker->nr] == Params.PermutationMap[(*iter)->nr]) && (Walker->nr < (*iter)->nr)) {
    131131  //    atom *Sprinter = PermutationMap[Walker->nr];
    132   //        Log() << Verbose(0) << *Walker << " and " << *Runner << " are heading to the same target at ";
     132  //        Log() << Verbose(0) << *Walker << " and " << *(*iter) << " are heading to the same target at ";
    133133  //        Log() << Verbose(0) << Sprinter->Trajectory.R.at(endstep);
    134134  //        Log() << Verbose(0) << ", penalting." << endl;
     
    161161  // go through every atom
    162162  atom *Runner = NULL;
    163   atom *Walker = start;
    164   while (Walker->next != end) {
    165     Walker = Walker->next;
     163  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    166164    // first term: distance to target
    167     Runner = Params.PermutationMap[Walker->nr];   // find target point
    168     tmp = (Walker->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep)));
     165    Runner = Params.PermutationMap[(*iter)->nr];   // find target point
     166    tmp = ((*iter)->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep)));
    169167    tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem;
    170168    result += Params.PenaltyConstants[0] * tmp;
     
    172170
    173171    // second term: sum of distances to other trajectories
    174     result += SumDistanceOfTrajectories(Walker, this, Params);
     172    result += SumDistanceOfTrajectories((*iter), this, Params);
    175173
    176174    // third term: penalty for equal targets
    177     result += PenalizeEqualTargets(Walker, this, Params);
     175    result += PenalizeEqualTargets((*iter), this, Params);
    178176  }
    179177
     
    189187{
    190188  stringstream zeile1, zeile2;
    191   int *DoubleList = Calloc<int>(AtomCount, "PrintPermutationMap: *DoubleList");
     189  int *DoubleList = new int[AtomCount];
     190  for(int i=0;i<AtomCount;i++)
     191    DoubleList[i] = 0;
    192192  int doubles = 0;
    193193  zeile1 << "PermutationMap: ";
     
    203203  if (doubles >0)
    204204    DoLog(2) && (Log() << Verbose(2) << "Found " << doubles << " Doubles." << endl);
    205   Free(&DoubleList);
     205  delete[](DoubleList);
    206206//  Log() << Verbose(2) << zeile1.str() << endl << zeile2.str() << endl;
    207207};
     
    213213void FillDistanceList(molecule *mol, struct EvaluatePotential &Params)
    214214{
    215   for (int i=mol->AtomCount; i--;) {
     215  for (int i=mol->getAtomCount(); i--;) {
    216216    Params.DistanceList[i] = new DistanceMap;    // is the distance sorted target list per atom
    217217    Params.DistanceList[i]->clear();
    218218  }
    219219
    220   atom *Runner = NULL;
    221   atom *Walker = mol->start;
    222   while (Walker->next != mol->end) {
    223     Walker = Walker->next;
    224     Runner = mol->start;
    225     while(Runner->next != mol->end) {
    226       Runner = Runner->next;
    227       Params.DistanceList[Walker->nr]->insert( DistancePair(Walker->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep)), Runner) );
     220  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     221    for (molecule::const_iterator runner = mol->begin(); runner != mol->end(); ++runner) {
     222      Params.DistanceList[(*iter)->nr]->insert( DistancePair((*iter)->Trajectory.R.at(Params.startstep).distance((*runner)->Trajectory.R.at(Params.endstep)), (*runner)) );
    228223    }
    229224  }
     
    237232void CreateInitialLists(molecule *mol, struct EvaluatePotential &Params)
    238233{
    239   atom *Walker = mol->start;
    240   while (Walker->next != mol->end) {
    241     Walker = Walker->next;
    242     Params.StepList[Walker->nr] = Params.DistanceList[Walker->nr]->begin();    // stores the step to the next iterator that could be a possible next target
    243     Params.PermutationMap[Walker->nr] = Params.DistanceList[Walker->nr]->begin()->second;   // always pick target with the smallest distance
    244     Params.DoubleList[Params.DistanceList[Walker->nr]->begin()->second->nr]++;            // increase this target's source count (>1? not injective)
    245     Params.DistanceIterators[Walker->nr] = Params.DistanceList[Walker->nr]->begin();    // and remember which one we picked
    246     DoLog(2) && (Log() << Verbose(2) << *Walker << " starts with distance " << Params.DistanceList[Walker->nr]->begin()->first << "." << endl);
     234  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     235    Params.StepList[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin();    // stores the step to the next iterator that could be a possible next target
     236    Params.PermutationMap[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin()->second;   // always pick target with the smallest distance
     237    Params.DoubleList[Params.DistanceList[(*iter)->nr]->begin()->second->nr]++;            // increase this target's source count (>1? not injective)
     238    Params.DistanceIterators[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin();    // and remember which one we picked
     239    DoLog(2) && (Log() << Verbose(2) << **iter << " starts with distance " << Params.DistanceList[(*iter)->nr]->begin()->first << "." << endl);
    247240  }
    248241};
     
    285278void MakeInjectivePermutation(molecule *mol, struct EvaluatePotential &Params)
    286279{
    287   atom *Walker = mol->start;
     280  molecule::const_iterator iter = mol->begin();
    288281  DistanceMap::iterator NewBase;
    289282  double Potential = fabs(mol->ConstrainedPotential(Params));
    290283
     284  if (mol->empty()) {
     285    eLog() << Verbose(1) << "Molecule is empty." << endl;
     286    return;
     287  }
    291288  while ((Potential) > Params.PenaltyConstants[2]) {
    292     PrintPermutationMap(mol->AtomCount, Params);
    293     Walker = Walker->next;
    294     if (Walker == mol->end) // round-robin at the end
    295       Walker = mol->start->next;
    296     if (Params.DoubleList[Params.DistanceIterators[Walker->nr]->second->nr] <= 1)  // no need to make those injective that aren't
     289    PrintPermutationMap(mol->getAtomCount(), Params);
     290    iter++;
     291    if (iter == mol->end()) // round-robin at the end
     292      iter = mol->begin();
     293    if (Params.DoubleList[Params.DistanceIterators[(*iter)->nr]->second->nr] <= 1)  // no need to make those injective that aren't
    297294      continue;
    298295    // now, try finding a new one
    299     Potential = TryNextNearestNeighbourForInjectivePermutation(mol, Walker, Potential, Params);
    300   }
    301   for (int i=mol->AtomCount; i--;) // now each single entry in the DoubleList should be <=1
     296    Potential = TryNextNearestNeighbourForInjectivePermutation(mol, (*iter), Potential, Params);
     297  }
     298  for (int i=mol->getAtomCount(); i--;) // now each single entry in the DoubleList should be <=1
    302299    if (Params.DoubleList[i] > 1) {
    303300      DoeLog(0) && (eLog()<< Verbose(0) << "Failed to create an injective PermutationMap!" << endl);
     
    338335  double Potential, OldPotential, OlderPotential;
    339336  struct EvaluatePotential Params;
    340   Params.PermutationMap = Calloc<atom*>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.**PermutationMap");
    341   Params.DistanceList = Malloc<DistanceMap*>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.**DistanceList");
    342   Params.DistanceIterators = Malloc<DistanceMap::iterator>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*DistanceIterators");
    343   Params.DoubleList = Calloc<int>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*DoubleList");
    344   Params.StepList = Malloc<DistanceMap::iterator>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*StepList");
     337  Params.PermutationMap = new atom *[getAtomCount()];
     338  Params.DistanceList = new DistanceMap *[getAtomCount()];
     339  Params.DistanceIterators = new DistanceMap::iterator[getAtomCount()];
     340  Params.DoubleList = new int[getAtomCount()];
     341  Params.StepList = new DistanceMap::iterator[getAtomCount()];
    345342  int round;
    346   atom *Walker = NULL, *Runner = NULL, *Sprinter = NULL;
     343  atom *Sprinter = NULL;
    347344  DistanceMap::iterator Rider, Strider;
     345
     346  // set to zero
     347  for (int i=0;i<getAtomCount();i++) {
     348    Params.PermutationMap[i] = NULL;
     349    Params.DoubleList[i] = 0;
     350  }
    348351
    349352  /// Minimise the potential
     
    362365  DoLog(1) && (Log() << Verbose(1) << "Making the PermutationMap injective ... " << endl);
    363366  MakeInjectivePermutation(this, Params);
    364   Free(&Params.DoubleList);
     367  delete[](Params.DoubleList);
    365368
    366369  // argument minimise the constrained potential in this injective PermutationMap
     
    371374    DoLog(2) && (Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl);
    372375    OlderPotential = OldPotential;
     376    molecule::const_iterator iter;
    373377    do {
    374       Walker = start;
    375       while (Walker->next != end) { // pick one
    376         Walker = Walker->next;
    377         PrintPermutationMap(AtomCount, Params);
    378         Sprinter = Params.DistanceIterators[Walker->nr]->second;   // store initial partner
    379         Strider = Params.DistanceIterators[Walker->nr];  //remember old iterator
    380         Params.DistanceIterators[Walker->nr] = Params.StepList[Walker->nr];
    381         if (Params.DistanceIterators[Walker->nr] == Params.DistanceList[Walker->nr]->end()) {// stop, before we run through the list and still on
    382           Params.DistanceIterators[Walker->nr] == Params.DistanceList[Walker->nr]->begin();
     378      iter = begin();
     379      for (; iter != end(); ++iter) {
     380        PrintPermutationMap(getAtomCount(), Params);
     381        Sprinter = Params.DistanceIterators[(*iter)->nr]->second;   // store initial partner
     382        Strider = Params.DistanceIterators[(*iter)->nr];  //remember old iterator
     383        Params.DistanceIterators[(*iter)->nr] = Params.StepList[(*iter)->nr];
     384        if (Params.DistanceIterators[(*iter)->nr] == Params.DistanceList[(*iter)->nr]->end()) {// stop, before we run through the list and still on
     385          Params.DistanceIterators[(*iter)->nr] == Params.DistanceList[(*iter)->nr]->begin();
    383386          break;
    384387        }
    385         //Log() << Verbose(2) << "Current Walker: " << *Walker << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[Walker->nr]->second << "." << endl;
     388        //Log() << Verbose(2) << "Current Walker: " << *(*iter) << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[(*iter)->nr]->second << "." << endl;
    386389        // find source of the new target
    387         Runner = start->next;
    388         while(Runner != end) { // find the source whose toes we might be stepping on (Walker's new target should be in use by another already)
    389           if (Params.PermutationMap[Runner->nr] == Params.DistanceIterators[Walker->nr]->second) {
    390             //Log() << Verbose(2) << "Found the corresponding owner " << *Runner << " to " << *PermutationMap[Runner->nr] << "." << endl;
     390        molecule::const_iterator runner = begin();
     391        for (; runner != end(); ++runner) { // find the source whose toes we might be stepping on (Walker's new target should be in use by another already)
     392          if (Params.PermutationMap[(*runner)->nr] == Params.DistanceIterators[(*iter)->nr]->second) {
     393            //Log() << Verbose(2) << "Found the corresponding owner " << *(*runner) << " to " << *PermutationMap[(*runner)->nr] << "." << endl;
    391394            break;
    392395          }
    393           Runner = Runner->next;
    394396        }
    395         if (Runner != end) { // we found the other source
     397        if (runner != end()) { // we found the other source
    396398          // then look in its distance list for Sprinter
    397           Rider = Params.DistanceList[Runner->nr]->begin();
    398           for (; Rider != Params.DistanceList[Runner->nr]->end(); Rider++)
     399          Rider = Params.DistanceList[(*runner)->nr]->begin();
     400          for (; Rider != Params.DistanceList[(*runner)->nr]->end(); Rider++)
    399401            if (Rider->second == Sprinter)
    400402              break;
    401           if (Rider != Params.DistanceList[Runner->nr]->end()) { // if we have found one
    402             //Log() << Verbose(2) << "Current Other: " << *Runner << " with old/next candidate " << *PermutationMap[Runner->nr] << "/" << *Rider->second << "." << endl;
     403          if (Rider != Params.DistanceList[(*runner)->nr]->end()) { // if we have found one
     404            //Log() << Verbose(2) << "Current Other: " << *(*runner) << " with old/next candidate " << *PermutationMap[(*runner)->nr] << "/" << *Rider->second << "." << endl;
    403405            // exchange both
    404             Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // put next farther distance into PermutationMap
    405             Params.PermutationMap[Runner->nr] = Sprinter;  // and hand the old target to its respective owner
    406             PrintPermutationMap(AtomCount, Params);
     406            Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; // put next farther distance into PermutationMap
     407            Params.PermutationMap[(*runner)->nr] = Sprinter;  // and hand the old target to its respective owner
     408            PrintPermutationMap(getAtomCount(), Params);
    407409            // calculate the new potential
    408410            //Log() << Verbose(2) << "Checking new potential ..." << endl;
     
    410412            if (Potential > OldPotential) { // we made everything worse! Undo ...
    411413              //Log() << Verbose(3) << "Nay, made the potential worse: " << Potential << " vs. " << OldPotential << "!" << endl;
    412               //Log() << Verbose(3) << "Setting " << *Runner << "'s source to " << *Params.DistanceIterators[Runner->nr]->second << "." << endl;
     414              //Log() << Verbose(3) << "Setting " << *(*runner) << "'s source to " << *Params.DistanceIterators[(*runner)->nr]->second << "." << endl;
    413415              // Undo for Runner (note, we haven't moved the iteration yet, we may use this)
    414               Params.PermutationMap[Runner->nr] = Params.DistanceIterators[Runner->nr]->second;
     416              Params.PermutationMap[(*runner)->nr] = Params.DistanceIterators[(*runner)->nr]->second;
    415417              // Undo for Walker
    416               Params.DistanceIterators[Walker->nr] = Strider;  // take next farther distance target
    417               //Log() << Verbose(3) << "Setting " << *Walker << "'s source to " << *Params.DistanceIterators[Walker->nr]->second << "." << endl;
    418               Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second;
     418              Params.DistanceIterators[(*iter)->nr] = Strider;  // take next farther distance target
     419              //Log() << Verbose(3) << "Setting " << *(*iter) << "'s source to " << *Params.DistanceIterators[(*iter)->nr]->second << "." << endl;
     420              Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second;
    419421            } else {
    420               Params.DistanceIterators[Runner->nr] = Rider;  // if successful also move the pointer in the iterator list
     422              Params.DistanceIterators[(*runner)->nr] = Rider;  // if successful also move the pointer in the iterator list
    421423              DoLog(3) && (Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl);
    422424              OldPotential = Potential;
     
    428430            //Log() << Verbose(0) << endl;
    429431          } else {
    430             DoeLog(1) && (eLog()<< Verbose(1) << *Runner << " was not the owner of " << *Sprinter << "!" << endl);
     432            DoeLog(1) && (eLog()<< Verbose(1) << **runner << " was not the owner of " << *Sprinter << "!" << endl);
    431433            exit(255);
    432434          }
    433435        } else {
    434           Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // new target has no source!
     436          Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; // new target has no source!
    435437        }
    436         Params.StepList[Walker->nr]++; // take next farther distance target
     438        Params.StepList[(*iter)->nr]++; // take next farther distance target
    437439      }
    438     } while (Walker->next != end);
     440    } while (++iter != end());
    439441  } while ((OlderPotential - OldPotential) > 1e-3);
    440442  DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     
    442444
    443445  /// free memory and return with evaluated potential
    444   for (int i=AtomCount; i--;)
     446  for (int i=getAtomCount(); i--;)
    445447    Params.DistanceList[i]->clear();
    446   Free(&Params.DistanceList);
    447   Free(&Params.DistanceIterators);
     448  delete[](Params.DistanceList);
     449  delete[](Params.DistanceIterators);
    448450  return ConstrainedPotential(Params);
    449451};
     
    471473 * \param startstep stating initial configuration in molecule::Trajectories
    472474 * \param endstep stating final configuration in molecule::Trajectories
     475 * \param &prefix path and prefix
    473476 * \param &config configuration structure
    474477 * \param MapByIdentity if true we just use the identity to map atoms in start config to end config, if not we find mapping by \sa MinimiseConstrainedPotential()
    475478 * \return true - success in writing step files, false - error writing files or only one step in molecule::Trajectories
    476479 */
    477 bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, const char *prefix, config &configuration, bool MapByIdentity)
     480bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string &prefix, config &configuration, bool MapByIdentity)
    478481{
    479482  molecule *mol = NULL;
     
    483486  // Get the Permutation Map by MinimiseConstrainedPotential
    484487  atom **PermutationMap = NULL;
    485   atom *Walker = NULL, *Sprinter = NULL;
     488  atom *Sprinter = NULL;
    486489  if (!MapByIdentity)
    487490    MinimiseConstrainedPotential(PermutationMap, startstep, endstep, configuration.GetIsAngstroem());
    488491  else {
    489     PermutationMap = Malloc<atom *>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: **PermutationMap");
     492    PermutationMap = new atom *[getAtomCount()];
    490493    SetIndexedArrayForEachAtomTo( PermutationMap, &atom::nr );
    491494  }
     
    502505    mol = World::getInstance().createMolecule();
    503506    MoleculePerStep->insert(mol);
    504     Walker = start;
    505     while (Walker->next != end) {
    506       Walker = Walker->next;
     507    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    507508      // add to molecule list
    508       Sprinter = mol->AddCopyAtom(Walker);
     509      Sprinter = mol->AddCopyAtom((*iter));
    509510      for (int n=NDIM;n--;) {
    510         Sprinter->x[n] = Walker->Trajectory.R.at(startstep)[n] + (PermutationMap[Walker->nr]->Trajectory.R.at(endstep)[n] - Walker->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);
     511        Sprinter->x[n] = (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);
    511512        // add to Trajectories
    512513        //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl;
    513514        if (step < MaxSteps) {
    514           Walker->Trajectory.R.at(step)[n] = Walker->Trajectory.R.at(startstep)[n] + (PermutationMap[Walker->nr]->Trajectory.R.at(endstep)[n] - Walker->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);
    515           Walker->Trajectory.U.at(step)[n] = 0.;
    516           Walker->Trajectory.F.at(step)[n] = 0.;
     515          (*iter)->Trajectory.R.at(step)[n] = (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);
     516          (*iter)->Trajectory.U.at(step)[n] = 0.;
     517          (*iter)->Trajectory.F.at(step)[n] = 0.;
    517518        }
    518519      }
     
    522523
    523524  // store the list to single step files
    524   int *SortIndex = Malloc<int>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: *SortIndex");
    525   for (int i=AtomCount; i--; )
     525  int *SortIndex = new int[getAtomCount()];
     526  for (int i=getAtomCount(); i--; )
    526527    SortIndex[i] = i;
    527   status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex);
     528
     529  status = MoleculePerStep->OutputConfigForListOfFragments(prefix, SortIndex);
     530  delete[](SortIndex);
    528531
    529532  // free and return
    530   Free(&PermutationMap);
     533  delete[](PermutationMap);
    531534  delete(MoleculePerStep);
    532535  return status;
     
    548551bool molecule::VerletForceIntegration(char *file, config &configuration)
    549552{
     553  Info FunctionInfo(__func__);
    550554  ifstream input(file);
    551555  string token;
     
    567571      return false;
    568572    }
    569     if (Force.RowCounter[0] != AtomCount) {
    570       DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << AtomCount << "." << endl);
     573    if (Force.RowCounter[0] != getAtomCount()) {
     574      DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << getAtomCount() << "." << endl);
    571575      performCriticalExit();
    572576      return false;
     
    574578    // correct Forces
    575579    Velocity.Zero();
    576     for(int i=0;i<AtomCount;i++)
     580    for(int i=0;i<getAtomCount();i++)
    577581      for(int d=0;d<NDIM;d++) {
    578582        Velocity[d] += Force.Matrix[0][i][d+5];
    579583      }
    580     for(int i=0;i<AtomCount;i++)
     584    for(int i=0;i<getAtomCount();i++)
    581585      for(int d=0;d<NDIM;d++) {
    582         Force.Matrix[0][i][d+5] -= Velocity[d]/(double)AtomCount;
     586        Force.Matrix[0][i][d+5] -= Velocity[d]/static_cast<double>(getAtomCount());
    583587      }
    584588    // solve a constrained potential if we are meant to
     
    588592      ConstrainedPotentialEnergy = MinimiseConstrainedPotential(PermutationMap,configuration.DoConstrainedMD, 0, configuration.GetIsAngstroem());
    589593      EvaluateConstrainedForces(configuration.DoConstrainedMD, 0, PermutationMap, &Force);
    590       Free(&PermutationMap);
     594      delete[](PermutationMap);
    591595    }
    592596
    593597    // and perform Verlet integration for each atom with position, velocity and force vector
    594598    // check size of vectors
    595     ActOnAllAtoms( &atom::ResizeTrajectory, MDSteps+10 );
    596 
    597     ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps, &configuration, &Force);
     599    //ActOnAllAtoms( &atom::ResizeTrajectory, MDSteps+10 );
     600
     601    ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps+1, &configuration, &Force);
    598602  }
    599603  // correct velocities (rather momenta) so that center of mass remains motionless
    600604  Velocity.Zero();
    601605  IonMass = 0.;
    602   ActOnAllAtoms ( &atom::SumUpKineticEnergy, MDSteps, &IonMass, &Velocity );
     606  ActOnAllAtoms ( &atom::SumUpKineticEnergy, MDSteps+1, &IonMass, &Velocity );
    603607
    604608  // correct velocities (rather momenta) so that center of mass remains motionless
    605609  Velocity.Scale(1./IonMass);
    606610  ActualTemp = 0.;
    607   ActOnAllAtoms ( &atom::CorrectVelocity, &ActualTemp, MDSteps, &Velocity );
     611  ActOnAllAtoms ( &atom::CorrectVelocity, &ActualTemp, MDSteps+1, &Velocity );
    608612  Thermostats(configuration, ActualTemp, Berendsen);
    609613  MDSteps++;
     
    642646
    643647  // calculate scale configuration
    644   ScaleTempFactor = configuration.TargetTemp/ActualTemp;
     648  ScaleTempFactor = configuration.Thermostats->TargetTemp/ActualTemp;
    645649
    646650  // differentating between the various thermostats
     
    650654      break;
    651655     case Woodcock:
    652       if ((configuration.ScaleTempStep > 0) && ((MDSteps-1) % configuration.ScaleTempStep == 0)) {
     656      if ((configuration.Thermostats->ScaleTempStep > 0) && ((MDSteps-1) % configuration.Thermostats->ScaleTempStep == 0)) {
    653657        DoLog(2) && (Log() << Verbose(2) <<  "Applying Woodcock thermostat..." << endl);
    654658        ActOnAllAtoms( &atom::Thermostat_Woodcock, sqrt(ScaleTempFactor), MDSteps, &ekin );
     
    683687      delta_alpha = 0.;
    684688      ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha );
    685       delta_alpha = (delta_alpha - (3.*AtomCount+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass);
    686       configuration.alpha += delta_alpha*configuration.Deltat;
    687       DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl);
     689      delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.Thermostats->TargetTemp)/(configuration.Thermostats->HooverMass*Units2Electronmass);
     690      configuration.Thermostats->alpha += delta_alpha*configuration.Deltat;
     691      DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.Thermostats->alpha << "." << endl);
    688692      // apply updated alpha as additional force
    689693      ActOnAllAtoms( &atom::Thermostat_NoseHoover_scale, MDSteps, &ekin, &configuration );
  • src/molecule_fragmentation.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <cstring>
     
    3941  int FragmentCount;
    4042  // get maximum bond degree
    41   atom *Walker = start;
    42   while (Walker->next != end) {
    43     Walker = Walker->next;
    44     c = (Walker->ListOfBonds.size() > c) ? Walker->ListOfBonds.size() : c;
     43  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     44    c = ((*iter)->ListOfBonds.size() > c) ? (*iter)->ListOfBonds.size() : c;
    4545  }
    4646  FragmentCount = NoNonHydrogen*(1 << (c*order));
     
    8282 * -# Scans TEFactors file and sets the TEFactor of each key set in the temporary graph accordingly
    8383 * Finally, the temporary graph is inserted into the given \a FragmentList for return.
    84  * \param *out output stream for debugging
    85  * \param *path path to file
     84 * \param &path path to file
    8685 * \param *FragmentList empty, filled on return
    8786 * \return true - parsing successfully, false - failure on parsing (FragmentList will be NULL)
    8887 */
    89 bool ParseKeySetFile(char *path, Graph *&FragmentList)
     88bool ParseKeySetFile(std::string &path, Graph *&FragmentList)
    9089{
    9190  bool status = true;
     
    9493  GraphTestPair testGraphInsert;
    9594  int NumberOfFragments = 0;
    96   char *filename = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseKeySetFile - filename");
     95  string filename;
    9796
    9897  if (FragmentList == NULL) { // check list pointer
     
    102101  // 1st pass: open file and read
    103102  DoLog(1) && (Log() << Verbose(1) << "Parsing the KeySet file ... " << endl);
    104   sprintf(filename, "%s/%s%s", path, FRAGMENTPREFIX, KEYSETFILE);
    105   InputFile.open(filename);
    106   if (InputFile != NULL) {
     103  filename = path + KEYSETFILE;
     104  InputFile.open(filename.c_str());
     105  if (InputFile.good()) {
    107106    // each line represents a new fragment
    108     char *buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseKeySetFile - *buffer");
     107    char buffer[MAXSTRINGSIZE];
    109108    // 1. parse keysets and insert into temp. graph
    110109    while (!InputFile.eof()) {
     
    122121    InputFile.close();
    123122    InputFile.clear();
    124     Free(&buffer);
    125     DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     123    DoLog(1) && (Log() << Verbose(1) << "\t ... done." << endl);
    126124  } else {
    127     DoLog(1) && (Log() << Verbose(1) << "File " << filename << " not found." << endl);
     125    DoLog(1) && (Log() << Verbose(1) << "\t ... File " << filename << " not found." << endl);
    128126    status = false;
    129127  }
    130128
    131   Free(&filename);
    132129  return status;
    133130};
     
    148145  int NumberOfFragments = 0;
    149146  double TEFactor;
    150   char *filename = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseTEFactorsFile - filename");
     147  char filename[MAXSTRINGSIZE];
    151148
    152149  if (FragmentList == NULL) { // check list pointer
     
    179176  }
    180177
    181   // free memory
    182   Free(&filename);
    183 
    184178  return status;
    185179};
    186180
    187181/** Stores key sets to file.
    188  * \param *out output stream for debugging
    189182 * \param KeySetList Graph with Keysets
    190  * \param *path path to file
     183 * \param &path path to file
    191184 * \return true - file written successfully, false - writing failed
    192185 */
    193 bool StoreKeySetFile(Graph &KeySetList, char *path)
    194 {
    195   ofstream output;
     186bool StoreKeySetFile(Graph &KeySetList, std::string &path)
     187{
    196188  bool status =  true;
    197   string line;
     189  string line = path + KEYSETFILE;
     190  ofstream output(line.c_str());
    198191
    199192  // open KeySet file
    200   line = path;
    201   line.append("/");
    202   line += FRAGMENTPREFIX;
    203   line += KEYSETFILE;
    204   output.open(line.c_str(), ios::out);
    205193  DoLog(1) && (Log() << Verbose(1) << "Saving key sets of the total graph ... ");
    206   if(output != NULL) {
     194  if(output.good()) {
    207195    for(Graph::iterator runner = KeySetList.begin(); runner != KeySetList.end(); runner++) {
    208196      for (KeySet::iterator sprinter = (*runner).first.begin();sprinter != (*runner).first.end(); sprinter++) {
     
    307295
    308296/** Scans the adaptive order file and insert (index, value) into map.
    309  * \param *out output stream for debugging
    310  * \param *path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative)
     297 * \param &path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative)
    311298 * \param &IndexedKeySetList list to find key set for a given index \a No
    312299 * \return adaptive criteria list from file
    313300 */
    314 map<int, pair<double,int> > * ScanAdaptiveFileIntoMap(char *path, map<int,KeySet> &IndexKeySetList)
     301map<int, pair<double,int> > * ScanAdaptiveFileIntoMap(std::string &path, map<int,KeySet> &IndexKeySetList)
    315302{
    316303  map<int, pair<double,int> > *AdaptiveCriteriaList = new map<int, pair<double,int> >;
    317304  int No = 0, FragOrder = 0;
    318305  double Value = 0.;
    319   char *buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::CheckOrderAtSite: *buffer");
    320   sprintf(buffer, "%s/%s%s.dat", path, FRAGMENTPREFIX, ENERGYPERFRAGMENT);
    321   ifstream InputFile(buffer, ios::in);
     306  char buffer[MAXSTRINGSIZE];
     307  string filename = path + ENERGYPERFRAGMENT;
     308  ifstream InputFile(filename.c_str());
     309
     310  if (InputFile.fail()) {
     311    DoeLog(1) && (eLog() << Verbose(1) << "Cannot find file " << filename << "." << endl);
     312    return AdaptiveCriteriaList;
     313  }
    322314
    323315  if (CountLinesinFile(InputFile) > 0) {
     
    345337    InputFile.clear();
    346338  }
    347   Free(&buffer);
    348339
    349340  return AdaptiveCriteriaList;
     
    359350map<double, pair<int,int> >  * ReMapAdaptiveCriteriaListToValue(map<int, pair<double,int> > *AdaptiveCriteriaList, molecule *mol)
    360351{
    361   atom *Walker = mol->start;
     352  atom *Walker = NULL;
    362353  map<double, pair<int,int> > *FinalRootCandidates = new map<double, pair<int,int> > ;
    363354  DoLog(1) && (Log() << Verbose(1) << "Root candidate list is: " << endl);
     
    391382bool MarkUpdateCandidates(bool *AtomMask, map<double, pair<int,int> > &FinalRootCandidates, int Order, molecule *mol)
    392383{
    393   atom *Walker = mol->start;
     384  atom *Walker = NULL;
    394385  int No = -1;
    395386  bool status = false;
     
    425416
    426417/** Checks whether the OrderAtSite is still below \a Order at some site.
    427  * \param *out output stream for debugging
    428418 * \param *AtomMask defines true/false per global Atom::nr to mask in/out each nuclear site, used to activate given number of site to increment order adaptively
    429419 * \param *GlobalKeySetList list of keysets with global ids (valid in "this" molecule) needed for adaptive increase
    430420 * \param Order desired Order if positive, desired exponent in threshold criteria if negative (0 is single-step)
    431421 * \param *MinimumRingSize array of max. possible order to avoid loops
    432  * \param *path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative)
     422 * \param path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative)
    433423 * \return true - needs further fragmentation, false - does not need fragmentation
    434424 */
    435 bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path)
    436 {
    437   atom *Walker = start;
     425bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, std::string path)
     426{
    438427  bool status = false;
    439428
    440429  // initialize mask list
    441   for(int i=AtomCount;i--;)
     430  for(int i=getAtomCount();i--;)
    442431    AtomMask[i] = false;
    443432
    444433  if (Order < 0) { // adaptive increase of BondOrder per site
    445     if (AtomMask[AtomCount] == true)  // break after one step
     434    if (AtomMask[getAtomCount()] == true)  // break after one step
    446435      return false;
    447436
     
    457446    if (AdaptiveCriteriaList->empty()) {
    458447      DoeLog(2) && (eLog()<< Verbose(2) << "Unable to parse file, incrementing all." << endl);
    459       while (Walker->next != end) {
    460         Walker = Walker->next;
     448      for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    461449    #ifdef ADDHYDROGEN
    462         if (Walker->type->Z != 1) // skip hydrogen
     450        if ((*iter)->type->Z != 1) // skip hydrogen
    463451    #endif
    464452        {
    465           AtomMask[Walker->nr] = true;  // include all (non-hydrogen) atoms
     453          AtomMask[(*iter)->nr] = true;  // include all (non-hydrogen) atoms
    466454          status = true;
    467455        }
     
    474462    MarkUpdateCandidates(AtomMask, *FinalRootCandidates, Order, this);
    475463
    476     Free(&IndexKeySetList);
    477     Free(&AdaptiveCriteriaList);
    478     Free(&FinalRootCandidates);
     464    delete[](IndexKeySetList);
     465    delete[](AdaptiveCriteriaList);
     466    delete[](FinalRootCandidates);
    479467  } else { // global increase of Bond Order
    480     while (Walker->next != end) {
    481       Walker = Walker->next;
     468    for(molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    482469  #ifdef ADDHYDROGEN
    483       if (Walker->type->Z != 1) // skip hydrogen
     470      if ((*iter)->type->Z != 1) // skip hydrogen
    484471  #endif
    485472      {
    486         AtomMask[Walker->nr] = true;  // include all (non-hydrogen) atoms
    487         if ((Order != 0) && (Walker->AdaptiveOrder < Order)) // && (Walker->AdaptiveOrder < MinimumRingSize[Walker->nr]))
     473        AtomMask[(*iter)->nr] = true;  // include all (non-hydrogen) atoms
     474        if ((Order != 0) && ((*iter)->AdaptiveOrder < Order)) // && ((*iter)->AdaptiveOrder < MinimumRingSize[(*iter)->nr]))
    488475          status = true;
    489476      }
    490477    }
    491     if ((Order == 0) && (AtomMask[AtomCount] == false))  // single stepping, just check
     478    if ((!Order) && (!AtomMask[getAtomCount()]))  // single stepping, just check
    492479      status = true;
    493480
     
    500487  }
    501488
    502   PrintAtomMask(AtomMask, AtomCount); // for debugging
     489  PrintAtomMask(AtomMask, getAtomCount()); // for debugging
    503490
    504491  return status;
     
    516503    return false;
    517504  }
    518   SortIndex = Malloc<int>(AtomCount, "molecule::CreateMappingLabelsToConfigSequence: *SortIndex");
    519   for(int i=AtomCount;i--;)
     505  SortIndex = new int[getAtomCount()];
     506  for(int i=getAtomCount();i--;)
    520507    SortIndex[i] = -1;
    521508
     
    524511
    525512  return true;
     513};
     514
     515
     516
     517/** Creates a lookup table for true father's Atom::Nr -> atom ptr.
     518 * \param *start begin of list (STL iterator, i.e. first item)
     519 * \paran *end end of list (STL iterator, i.e. one past last item)
     520 * \param **Lookuptable pointer to return allocated lookup table (should be NULL on start)
     521 * \param count optional predetermined size for table (otherwise we set the count to highest true father id)
     522 * \return true - success, false - failure
     523 */
     524bool molecule::CreateFatherLookupTable(atom **&LookupTable, int count)
     525{
     526  bool status = true;
     527  int AtomNo;
     528
     529  if (LookupTable != NULL) {
     530    Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl;
     531    return false;
     532  }
     533
     534  // count them
     535  if (count == 0) {
     536    for (molecule::iterator iter = begin(); iter != end(); ++iter) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron
     537      count = (count < (*iter)->GetTrueFather()->nr) ? (*iter)->GetTrueFather()->nr : count;
     538    }
     539  }
     540  if (count <= 0) {
     541    Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl;
     542    return false;
     543  }
     544
     545  // allocate and fill
     546  LookupTable = new atom *[count];
     547  if (LookupTable == NULL) {
     548    eLog() << Verbose(0) << "LookupTable memory allocation failed!" << endl;
     549    performCriticalExit();
     550    status = false;
     551  } else {
     552    for (int i=0;i<count;i++)
     553      LookupTable[i] = NULL;
     554    for (molecule::iterator iter = begin(); iter != end(); ++iter) {
     555      AtomNo = (*iter)->GetTrueFather()->nr;
     556      if ((AtomNo >= 0) && (AtomNo < count)) {
     557        //*out << "Setting LookupTable[" << AtomNo << "] to " << *(*iter) << endl;
     558        LookupTable[AtomNo] = (*iter);
     559      } else {
     560        Log() << Verbose(0) << "Walker " << *(*iter) << " exceeded range of nuclear ids [0, " << count << ")." << endl;
     561        status = false;
     562        break;
     563      }
     564    }
     565  }
     566
     567  return status;
    526568};
    527569
     
    539581 * of vertex indices: Global always means the index in "this" molecule, whereas local refers to the molecule or
    540582 * subgraph in the MoleculeListClass.
    541  * \param *out output stream for debugging
    542583 * \param Order up to how many neighbouring bonds a fragment contains in BondOrderScheme::BottumUp scheme
    543  * \param *configuration configuration for writing config files for each fragment
     584 * \param &prefix path and prefix of the bond order configs to be written
    544585 * \return 1 - continue, 2 - stop (no fragmentation occured)
    545586 */
    546 int molecule::FragmentMolecule(int Order, config *configuration)
     587int molecule::FragmentMolecule(int Order, std::string &prefix)
    547588{
    548589  MoleculeListClass *BondFragments = NULL;
    549   int *SortIndex = NULL;
    550   int *MinimumRingSize = new int[AtomCount];
     590  int *MinimumRingSize = new int[getAtomCount()];
    551591  int FragmentCounter;
    552592  MoleculeLeafClass *MolecularWalker = NULL;
     
    576616
    577617  // create lookup table for Atom::nr
    578   FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(start, end, ListOfAtoms, AtomCount);
     618  FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(ListOfAtoms, getAtomCount());
    579619
    580620  // === compare it with adjacency file ===
    581   FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(configuration->configpath, ListOfAtoms);
    582   Free(&ListOfAtoms);
     621  FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(prefix, ListOfAtoms);
     622  delete[](ListOfAtoms);
    583623
    584624  // ===== 2. perform a DFS analysis to gather info on cyclic structure and a list of disconnected subgraphs =====
     
    586626
    587627  // analysis of the cycles (print rings, get minimum cycle length) for each subgraph
    588   for(int i=AtomCount;i--;)
    589     MinimumRingSize[i] = AtomCount;
     628  for(int i=getAtomCount();i--;)
     629    MinimumRingSize[i] = getAtomCount();
    590630  MolecularWalker = Subgraphs;
    591631  FragmentCounter = 0;
     
    598638//    // check the list of local atoms for debugging
    599639//    Log() << Verbose(0) << "ListOfLocalAtoms for this subgraph is:" << endl;
    600 //    for (int i=0;i<AtomCount;i++)
     640//    for (int i=0;i<getAtomCount();i++)
    601641//      if (ListOfLocalAtoms[FragmentCounter][i] == NULL)
    602642//        Log() << Verbose(0) << "\tNULL";
     
    613653
    614654  // ===== 3. if structure still valid, parse key set file and others =====
    615   FragmentationToDo = FragmentationToDo && ParseKeySetFile(configuration->configpath, ParsedFragmentList);
     655  FragmentationToDo = FragmentationToDo && ParseKeySetFile(prefix, ParsedFragmentList);
    616656
    617657  // ===== 4. check globally whether there's something to do actually (first adaptivity check)
    618   FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(configuration->configpath);
     658  FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(prefix);
    619659
    620660  // =================================== Begin of FRAGMENTATION ===============================
     
    624664  // ===== 6b. prepare and go into the adaptive (Order<0), single-step (Order==0) or incremental (Order>0) cycle
    625665  KeyStack *RootStack = new KeyStack[Subgraphs->next->Count()];
    626   AtomMask = new bool[AtomCount+1];
    627   AtomMask[AtomCount] = false;
     666  AtomMask = new bool[getAtomCount()+1];
     667  AtomMask[getAtomCount()] = false;
    628668  FragmentationToDo = false;  // if CheckOrderAtSite just ones recommends fragmentation, we will save fragments afterwards
    629   while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, configuration->configpath))) {
     669  while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, prefix))) {
    630670    FragmentationToDo = FragmentationToDo || CheckOrder;
    631     AtomMask[AtomCount] = true;   // last plus one entry is used as marker that we have been through this loop once already in CheckOrderAtSite()
     671    AtomMask[getAtomCount()] = true;   // last plus one entry is used as marker that we have been through this loop once already in CheckOrderAtSite()
    632672    // ===== 6b. fill RootStack for each subgraph (second adaptivity check) =====
    633673    Subgraphs->next->FillRootStackForSubgraphs(RootStack, AtomMask, (FragmentCounter = 0));
     
    640680      DoLog(1) && (Log() << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl);
    641681      //MolecularWalker->Leaf->OutputListOfBonds(out);  // output atom::ListOfBonds for debugging
    642       if (MolecularWalker->Leaf->first->next != MolecularWalker->Leaf->last) {
     682      if (MolecularWalker->Leaf->hasBondStructure()) {
    643683        // call BOSSANOVA method
    644684        DoLog(0) && (Log() << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl);
     
    672712    delete(Subgraphs);
    673713  }
    674   Free(&FragmentList);
     714  delete[](FragmentList);
    675715
    676716  // ===== 8b. gather keyset lists (graphs) from all subgraphs and transform into MoleculeListClass =====
     
    682722    KeySet test = (*runner).first;
    683723    DoLog(0) && (Log() << Verbose(0) << "Fragment No." << (*runner).second.first << " with TEFactor " << (*runner).second.second << "." << endl);
    684     BondFragments->insert(StoreFragmentFromKeySet(test, configuration));
     724    BondFragments->insert(StoreFragmentFromKeySet(test, World::getInstance().getConfig()));
    685725    k++;
    686726  }
     
    690730  if (BondFragments->ListOfMolecules.size() != 0) {
    691731    // create the SortIndex from BFS labels to order in the config file
     732    int *SortIndex = NULL;
    692733    CreateMappingLabelsToConfigSequence(SortIndex);
    693734
    694735    DoLog(1) && (Log() << Verbose(1) << "Writing " << BondFragments->ListOfMolecules.size() << " possible bond fragmentation configs" << endl);
    695     if (BondFragments->OutputConfigForListOfFragments(configuration, SortIndex))
     736    if (BondFragments->OutputConfigForListOfFragments(prefix, SortIndex))
    696737      DoLog(1) && (Log() << Verbose(1) << "All configs written." << endl);
    697738    else
     
    699740
    700741    // store force index reference file
    701     BondFragments->StoreForcesFile(configuration->configpath, SortIndex);
     742    BondFragments->StoreForcesFile(prefix, SortIndex);
    702743
    703744    // store keysets file
    704     StoreKeySetFile(TotalGraph, configuration->configpath);
    705 
    706     // store Adjacency file
    707     char *filename = Malloc<char> (MAXSTRINGSIZE, "molecule::FragmentMolecule - *filename");
    708     strcpy(filename, FRAGMENTPREFIX);
    709     strcat(filename, ADJACENCYFILE);
    710     StoreAdjacencyToFile(configuration->configpath, filename);
    711     Free(&filename);
     745    StoreKeySetFile(TotalGraph, prefix);
     746
     747    {
     748      // store Adjacency file
     749      std::string filename = prefix + ADJACENCYFILE;
     750      StoreAdjacencyToFile(filename);
     751    }
    712752
    713753    // store Hydrogen saturation correction file
    714     BondFragments->AddHydrogenCorrection(configuration->configpath);
     754    BondFragments->AddHydrogenCorrection(prefix);
    715755
    716756    // store adaptive orders into file
    717     StoreOrderAtSiteFile(configuration->configpath);
     757    StoreOrderAtSiteFile(prefix);
    718758
    719759    // restore orbital and Stop values
    720     CalculateOrbitals(*configuration);
     760    //CalculateOrbitals(*configuration);
    721761
    722762    // free memory for bond part
    723763    DoLog(1) && (Log() << Verbose(1) << "Freeing bond memory" << endl);
    724     Free(&FragmentList); // remove bond molecule from memory
    725     Free(&SortIndex);
     764    delete[](SortIndex);
    726765  } else {
    727766    DoLog(1) && (Log() << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl);
     
    736775/** Stores pairs (Atom::nr, Atom::AdaptiveOrder) into file.
    737776 * Atoms not present in the file get "-1".
    738  * \param *out output stream for debugging
    739  * \param *path path to file ORDERATSITEFILE
     777 * \param &path path to file ORDERATSITEFILE
    740778 * \return true - file writable, false - not writable
    741779 */
    742 bool molecule::StoreOrderAtSiteFile(char *path)
    743 {
    744   stringstream line;
     780bool molecule::StoreOrderAtSiteFile(std::string &path)
     781{
     782  string line;
    745783  ofstream file;
    746784
    747   line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE;
    748   file.open(line.str().c_str());
     785  line = path + ORDERATSITEFILE;
     786  file.open(line.c_str());
    749787  DoLog(1) && (Log() << Verbose(1) << "Writing OrderAtSite " << ORDERATSITEFILE << " ... " << endl);
    750   if (file != NULL) {
     788  if (file.good()) {
    751789    ActOnAllAtoms( &atom::OutputOrder, &file );
    752790    file.close();
     
    754792    return true;
    755793  } else {
    756     DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
     794    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line << "." << endl);
    757795    return false;
    758796  }
     
    761799/** Parses pairs(Atom::nr, Atom::AdaptiveOrder) from file and stores in molecule's Atom's.
    762800 * Atoms not present in the file get "0".
    763  * \param *out output stream for debugging
    764  * \param *path path to file ORDERATSITEFILEe
     801 * \param &path path to file ORDERATSITEFILEe
    765802 * \return true - file found and scanned, false - file not found
    766803 * \sa ParseKeySetFile() and CheckAdjacencyFileAgainstMolecule() as this is meant to be used in conjunction with the two
    767804 */
    768 bool molecule::ParseOrderAtSiteFromFile(char *path)
    769 {
    770   unsigned char *OrderArray = Calloc<unsigned char>(AtomCount, "molecule::ParseOrderAtSiteFromFile - *OrderArray");
    771   bool *MaxArray = Calloc<bool>(AtomCount, "molecule::ParseOrderAtSiteFromFile - *MaxArray");
     805bool molecule::ParseOrderAtSiteFromFile(std::string &path)
     806{
     807  unsigned char *OrderArray = new unsigned char[getAtomCount()];
     808  bool *MaxArray = new bool[getAtomCount()];
    772809  bool status;
    773810  int AtomNr, value;
    774   stringstream line;
     811  string line;
    775812  ifstream file;
    776813
     814  for(int i=0;i<getAtomCount();i++) {
     815    OrderArray[i] = 0;
     816    MaxArray[i] = false;
     817  }
     818
    777819  DoLog(1) && (Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl);
    778   line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE;
    779   file.open(line.str().c_str());
    780   if (file != NULL) {
     820  line = path + ORDERATSITEFILE;
     821  file.open(line.c_str());
     822  if (file.good()) {
    781823    while (!file.eof()) { // parse from file
    782824      AtomNr = -1;
     
    796838    SetAtomValueToIndexedArray( MaxArray, &atom::nr, &atom::MaxOrder );
    797839
    798     DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     840    DoLog(1) && (Log() << Verbose(1) << "\t ... done." << endl);
    799841    status = true;
    800842  } else {
    801     DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
     843    DoLog(1) && (Log() << Verbose(1) << "\t ... failed to open file " << line << "." << endl);
    802844    status = false;
    803845  }
    804   Free(&OrderArray);
    805   Free(&MaxArray);
     846  delete[](OrderArray);
     847  delete[](MaxArray);
    806848
    807849  DoLog(1) && (Log() << Verbose(1) << "End of ParseOrderAtSiteFromFile" << endl);
     
    872914  atom *OtherFather = NULL;
    873915  atom *FatherOfRunner = NULL;
    874   Leaf->CountAtoms();
    875 
    876   atom *Runner = Leaf->start;
    877   while (Runner->next != Leaf->end) {
    878     Runner = Runner->next;
     916
     917#ifdef ADDHYDROGEN
     918  molecule::const_iterator runner;
     919#endif
     920  // we increment the iter just before skipping the hydrogen
     921  for (molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end();) {
    879922    LonelyFlag = true;
    880     FatherOfRunner = Runner->father;
     923    FatherOfRunner = (*iter)->father;
     924    ASSERT(FatherOfRunner,"Atom without father found");
    881925    if (SonList[FatherOfRunner->nr] != NULL)  {  // check if this, our father, is present in list
    882926      // create all bonds
     
    889933//            Log() << Verbose(3) << "Adding Bond: ";
    890934//            Log() << Verbose(0) <<
    891             Leaf->AddBond(Runner, SonList[OtherFather->nr], (*BondRunner)->BondDegree);
     935            Leaf->AddBond((*iter), SonList[OtherFather->nr], (*BondRunner)->BondDegree);
    892936//            Log() << Verbose(0) << "." << endl;
    893             //NumBonds[Runner->nr]++;
     937            //NumBonds[(*iter)->nr]++;
    894938          } else {
    895939//            Log() << Verbose(3) << "Not adding bond, labels in wrong order." << endl;
     
    899943//          Log() << Verbose(0) << ", who has no son in this fragment molecule." << endl;
    900944#ifdef ADDHYDROGEN
    901           //Log() << Verbose(3) << "Adding Hydrogen to " << Runner->Name << " and a bond in between." << endl;
    902           if(!Leaf->AddHydrogenReplacementAtom((*BondRunner), Runner, FatherOfRunner, OtherFather, IsAngstroem))
     945          //Log() << Verbose(3) << "Adding Hydrogen to " << (*iter)->Name << " and a bond in between." << endl;
     946          if(!Leaf->AddHydrogenReplacementAtom((*BondRunner), (*iter), FatherOfRunner, OtherFather, IsAngstroem))
    903947            exit(1);
    904948#endif
    905           //NumBonds[Runner->nr] += Binder->BondDegree;
     949          //NumBonds[(*iter)->nr] += Binder->BondDegree;
    906950        }
    907951      }
    908952    } else {
    909       DoeLog(1) && (eLog()<< Verbose(1) << "Son " << Runner->getName() << " has father " << FatherOfRunner->getName() << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl);
    910     }
    911     if ((LonelyFlag) && (Leaf->AtomCount > 1)) {
    912       DoLog(0) && (Log() << Verbose(0) << *Runner << "has got bonds only to hydrogens!" << endl);
    913     }
     953    DoeLog(1) && (eLog()<< Verbose(1) << "Son " << (*iter)->getName() << " has father " << FatherOfRunner->getName() << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl);
     954    }
     955    if ((LonelyFlag) && (Leaf->getAtomCount() > 1)) {
     956      DoLog(0) && (Log() << Verbose(0) << **iter << "has got bonds only to hydrogens!" << endl);
     957    }
     958    ++iter;
    914959#ifdef ADDHYDROGEN
    915     while ((Runner->next != Leaf->end) && (Runner->next->type->Z == 1)) // skip added hydrogen
    916       Runner = Runner->next;
     960    while ((iter != Leaf->end()) && ((*iter)->type->Z == 1)){ // skip added hydrogen
     961      iter++;
     962    }
    917963#endif
    918964  }
     
    929975molecule * molecule::StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem)
    930976{
    931   atom **SonList = Calloc<atom*>(AtomCount, "molecule::StoreFragmentFromStack: **SonList");
     977  atom **SonList = new atom*[getAtomCount()];
    932978  molecule *Leaf = World::getInstance().createMolecule();
     979
     980  for(int i=0;i<getAtomCount();i++)
     981    SonList[i] = NULL;
    933982
    934983//  Log() << Verbose(1) << "Begin of StoreFragmentFromKeyset." << endl;
     
    939988
    940989  //Leaflet->Leaf->ScanForPeriodicCorrection(out);
    941   Free(&SonList);
     990  delete[](SonList);
    942991//  Log() << Verbose(1) << "End of StoreFragmentFromKeyset." << endl;
    943992  return Leaf;
     
    10841133  int bits, TouchedIndex, SubSetDimension, SP, Added;
    10851134  int SpaceLeft;
    1086   int *TouchedList = Malloc<int>(SubOrder + 1, "molecule::SPFragmentGenerator: *TouchedList");
    1087   bond **BondsList = NULL;
     1135  int *TouchedList = new int[SubOrder + 1];
    10881136  KeySetTestPair TestKeySetInsert;
    10891137
     
    11241172
    11251173          // then allocate and fill the list
    1126           BondsList = Malloc<bond*>(SubSetDimension, "molecule::SPFragmentGenerator: **BondsList");
     1174          bond *BondsList[SubSetDimension];
    11271175          SubSetDimension = FillBondsList(BondsList, FragmentSearch->BondsPerSPList[2*SP], FragmentSearch->BondsPerSPList[2*SP+1], TouchedList, TouchedIndex);
    11281176
     
    11301178          Log() << Verbose(2+verbosity) << "Calling subset generator " << SP << " away from root " << *FragmentSearch->Root << " with sub set dimension " << SubSetDimension << "." << endl;
    11311179          SPFragmentGenerator(FragmentSearch, SP, BondsList, SubSetDimension, SubOrder-bits);
    1132 
    1133           Free(&BondsList);
    11341180        }
    11351181      } else {
     
    11531199    }
    11541200  }
    1155   Free(&TouchedList);
     1201  delete[](TouchedList);
    11561202  Log() << Verbose(1+verbosity) << "End of SPFragmentGenerator, " << RootDistance << " away from Root " << *FragmentSearch->Root << " and SubOrder is " << SubOrder << "." << endl;
    11571203};
     
    11651211void InitialiseSPList(int Order, struct UniqueFragments &FragmentSearch)
    11661212{
    1167   FragmentSearch.BondsPerSPList = Malloc<bond*>(Order * 2, "molecule::PowerSetGenerator: ***BondsPerSPList");
    1168   FragmentSearch.BondsPerSPCount = Malloc<int>(Order, "molecule::PowerSetGenerator: *BondsPerSPCount");
     1213  FragmentSearch.BondsPerSPList = new bond* [Order * 2];
     1214  FragmentSearch.BondsPerSPCount = new int[Order];
    11691215  for (int i=Order;i--;) {
    11701216    FragmentSearch.BondsPerSPList[2*i] = new bond();    // start node
     
    11841230void FreeSPList(int Order, struct UniqueFragments &FragmentSearch)
    11851231{
    1186   Free(&FragmentSearch.BondsPerSPCount);
     1232  delete[](FragmentSearch.BondsPerSPCount);
    11871233  for (int i=Order;i--;) {
    11881234    delete(FragmentSearch.BondsPerSPList[2*i]);
    11891235    delete(FragmentSearch.BondsPerSPList[2*i+1]);
    11901236  }
    1191   Free(&FragmentSearch.BondsPerSPList);
     1237  delete[](FragmentSearch.BondsPerSPList);
    11921238};
    11931239
     
    13701416int molecule::PowerSetGenerator(int Order, struct UniqueFragments &FragmentSearch, KeySet RestrictedKeySet)
    13711417{
    1372   bond **BondsList = NULL;
    13731418  int Counter = FragmentSearch.FragmentCounter; // mark current value of counter
    13741419
     
    13941439
    13951440    // prepare the subset and call the generator
    1396     BondsList = Calloc<bond*>(FragmentSearch.BondsPerSPCount[0], "molecule::PowerSetGenerator: **BondsList");
     1441    bond* BondsList[FragmentSearch.BondsPerSPCount[0]];
     1442    for(int i=0;i<FragmentSearch.BondsPerSPCount[0];i++)
     1443      BondsList[i] = NULL;
    13971444    BondsList[0] = FragmentSearch.BondsPerSPList[0]->next;  // on SP level 0 there's only the root bond
    13981445
    13991446    SPFragmentGenerator(&FragmentSearch, 0, BondsList, FragmentSearch.BondsPerSPCount[0], Order);
    1400 
    1401     Free(&BondsList);
    14021447  } else {
    14031448    DoLog(0) && (Log() << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl);
     
    15071552      }
    15081553    }
    1509     Free(&FragmentLowerOrdersList[RootNr]);
     1554    delete[](FragmentLowerOrdersList[RootNr]);
    15101555    RootNr++;
    15111556  }
    1512   Free(&FragmentLowerOrdersList);
     1557  delete[](FragmentLowerOrdersList);
    15131558};
    15141559
     
    15491594  // FragmentLowerOrdersList is a 2D-array of pointer to MoleculeListClass objects, one dimension represents the ANOVA expansion of a single order (i.e. 5)
    15501595  // with all needed lower orders that are subtracted, the other dimension is the BondOrder (i.e. from 1 to 5)
    1551   NumMoleculesOfOrder = Calloc<int>(UpgradeCount, "molecule::FragmentBOSSANOVA: *NumMoleculesOfOrder");
    1552   FragmentLowerOrdersList = Calloc<Graph**>(UpgradeCount, "molecule::FragmentBOSSANOVA: ***FragmentLowerOrdersList");
     1596  NumMoleculesOfOrder = new int[UpgradeCount];
     1597  FragmentLowerOrdersList = new Graph**[UpgradeCount];
     1598
     1599  for(int i=0;i<UpgradeCount;i++) {
     1600    NumMoleculesOfOrder[i] = 0;
     1601    FragmentLowerOrdersList[i] = NULL;
     1602  }
    15531603
    15541604  // initialise the fragments structure
     
    15561606  FragmentSearch.FragmentSet = new KeySet;
    15571607  FragmentSearch.Root = FindAtom(RootKeyNr);
    1558   FragmentSearch.ShortestPathList = Malloc<int>(AtomCount, "molecule::PowerSetGenerator: *ShortestPathList");
    1559   for (int i=AtomCount;i--;) {
     1608  FragmentSearch.ShortestPathList = new int[getAtomCount()];
     1609  for (int i=getAtomCount();i--;) {
    15601610    FragmentSearch.ShortestPathList[i] = -1;
    15611611  }
    15621612
    15631613  // Construct the complete KeySet which we need for topmost level only (but for all Roots)
    1564   atom *Walker = start;
    15651614  KeySet CompleteMolecule;
    1566   while (Walker->next != end) {
    1567     Walker = Walker->next;
    1568     CompleteMolecule.insert(Walker->GetTrueFather()->nr);
     1615  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     1616    CompleteMolecule.insert((*iter)->GetTrueFather()->nr);
    15691617  }
    15701618
     
    15771625    RootKeyNr = RootStack.front();
    15781626    RootStack.pop_front();
    1579     Walker = FindAtom(RootKeyNr);
     1627    atom *Walker = FindAtom(RootKeyNr);
    15801628    // check cyclic lengths
    15811629    //if ((MinimumRingSize[Walker->GetTrueFather()->nr] != -1) && (Walker->GetTrueFather()->AdaptiveOrder+1 > MinimumRingSize[Walker->GetTrueFather()->nr])) {
     
    15921640      // allocate memory for all lower level orders in this 1D-array of ptrs
    15931641      NumLevels = 1 << (Order-1); // (int)pow(2,Order);
    1594       FragmentLowerOrdersList[RootNr] = Calloc<Graph*>(NumLevels, "molecule::FragmentBOSSANOVA: **FragmentLowerOrdersList[]");
     1642      FragmentLowerOrdersList[RootNr] = new Graph*[NumLevels];
     1643      for (int i=0;i<NumLevels;i++)
     1644        FragmentLowerOrdersList[RootNr][i] = NULL;
    15951645
    15961646      // create top order where nothing is reduced
     
    16281678
    16291679  // cleanup FragmentSearch structure
    1630   Free(&FragmentSearch.ShortestPathList);
     1680  delete[](FragmentSearch.ShortestPathList);
    16311681  delete(FragmentSearch.FragmentSet);
    16321682
     
    16411691  CombineAllOrderListIntoOne(FragmentList, FragmentLowerOrdersList, RootStack, this);
    16421692  FreeAllOrdersList(FragmentLowerOrdersList, RootStack, this);
    1643   Free(&NumMoleculesOfOrder);
     1693  delete[](NumMoleculesOfOrder);
    16441694
    16451695  DoLog(0) && (Log() << Verbose(0) << "End of FragmentBOSSANOVA." << endl);
     
    16641714  Vector Translationvector;
    16651715  //class StackClass<atom *> *CompStack = NULL;
    1666   class StackClass<atom *> *AtomStack = new StackClass<atom *>(AtomCount);
     1716  class StackClass<atom *> *AtomStack = new StackClass<atom *>(getAtomCount());
    16671717  bool flag = true;
    16681718
    16691719  DoLog(2) && (Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl);
    16701720
    1671   ColorList = Calloc<enum Shading>(AtomCount, "molecule::ScanForPeriodicCorrection: *ColorList");
     1721  ColorList = new enum Shading[getAtomCount()];
     1722  for (int i=0;i<getAtomCount();i++)
     1723    ColorList[i] = (enum Shading)0;
    16721724  while (flag) {
    16731725    // remove bonds that are beyond bonddistance
    16741726    Translationvector.Zero();
    16751727    // scan all bonds
    1676     Binder = first;
    16771728    flag = false;
    1678     while ((!flag) && (Binder->next != last)) {
    1679       Binder = Binder->next;
    1680       for (int i=NDIM;i--;) {
    1681         tmp = fabs(Binder->leftatom->x[i] - Binder->rightatom->x[i]);
    1682         //Log() << Verbose(3) << "Checking " << i << "th distance of " << *Binder->leftatom << " to " << *Binder->rightatom << ": " << tmp << "." << endl;
    1683         if (tmp > BondDistance) {
    1684           OtherBinder = Binder->next; // note down binding partner for later re-insertion
    1685           unlink(Binder);   // unlink bond
    1686           DoLog(2) && (Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl);
    1687           flag = true;
    1688           break;
     1729    for(molecule::iterator AtomRunner = begin(); (!flag) && (AtomRunner != end()); ++AtomRunner)
     1730      for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); (!flag) && (BondRunner != (*AtomRunner)->ListOfBonds.end()); ++BondRunner) {
     1731        Binder = (*BondRunner);
     1732        for (int i=NDIM;i--;) {
     1733          tmp = fabs(Binder->leftatom->x[i] - Binder->rightatom->x[i]);
     1734          //Log() << Verbose(3) << "Checking " << i << "th distance of " << *Binder->leftatom << " to " << *Binder->rightatom << ": " << tmp << "." << endl;
     1735          if (tmp > BondDistance) {
     1736            OtherBinder = Binder->next; // note down binding partner for later re-insertion
     1737            unlink(Binder);   // unlink bond
     1738            DoLog(2) && (Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl);
     1739            flag = true;
     1740            break;
     1741          }
    16891742        }
    16901743      }
    1691     }
    16921744    if (flag) {
    16931745      // create translation vector from their periodically modified distance
     
    17011753      Log() << Verbose(0) << Translationvector <<  endl;
    17021754      // apply to all atoms of first component via BFS
    1703       for (int i=AtomCount;i--;)
     1755      for (int i=getAtomCount();i--;)
    17041756        ColorList[i] = white;
    17051757      AtomStack->Push(Binder->leftatom);
     
    17271779  // free allocated space from ReturnFullMatrixforSymmetric()
    17281780  delete(AtomStack);
    1729   Free(&ColorList);
    1730   Free(&matrix);
     1781  delete[](ColorList);
     1782  delete[](matrix);
    17311783  DoLog(2) && (Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl);
    17321784};
  • src/molecule_geometry.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "atom.hpp"
     
    1719#include "World.hpp"
    1820#include "Plane.hpp"
     21#include <boost/foreach.hpp>
     22
    1923
    2024/************************************* Functions for class molecule *********************************/
     
    2832  bool status = true;
    2933  const Vector *Center = DetermineCenterOfAll();
     34  const Vector *CenterBox = DetermineCenterOfBox();
    3035  double * const cell_size = World::getInstance().getDomain();
    3136  double *M = ReturnFullMatrixforSymmetric(cell_size);
     
    3439  // go through all atoms
    3540  ActOnAllVectors( &Vector::SubtractVector, *Center);
     41  ActOnAllVectors( &Vector::SubtractVector, *CenterBox);
    3642  ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
    3743
    38   Free(&M);
    39   Free(&Minv);
     44  delete[](M);
     45  delete[](Minv);
    4046  delete(Center);
    4147  return status;
     
    5662  ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
    5763
    58   Free(&M);
    59   Free(&Minv);
     64  delete[](M);
     65  delete[](Minv);
    6066  return status;
    6167};
     
    7076
    7177//  Log() << Verbose(3) << "Begin of CenterEdge." << endl;
    72   atom *ptr = start->next;  // start at first in list
    73   if (ptr != end) {  //list not empty?
     78  molecule::const_iterator iter = begin();  // start at first in list
     79  if (iter != end()) { //list not empty?
    7480    for (int i=NDIM;i--;) {
    75       max->at(i) = ptr->x[i];
    76       min->at(i) = ptr->x[i];
    77     }
    78     while (ptr->next != end) {  // continue with second if present
    79       ptr = ptr->next;
    80       //ptr->Output(1,1,out);
     81      max->at(i) = (*iter)->x[i];
     82      min->at(i) = (*iter)->x[i];
     83    }
     84    for (; iter != end(); ++iter) {// continue with second if present
     85      //(*iter)->Output(1,1,out);
    8186      for (int i=NDIM;i--;) {
    82         max->at(i) = (max->at(i) < ptr->x[i]) ? ptr->x[i] : max->at(i);
    83         min->at(i) = (min->at(i) > ptr->x[i]) ? ptr->x[i] : min->at(i);
     87        max->at(i) = (max->at(i) < (*iter)->x[i]) ? (*iter)->x[i] : max->at(i);
     88        min->at(i) = (min->at(i) > (*iter)->x[i]) ? (*iter)->x[i] : min->at(i);
    8489      }
    8590    }
     
    105110{
    106111  int Num = 0;
    107   atom *ptr = start;  // start at first in list
     112  molecule::const_iterator iter = begin();  // start at first in list
    108113
    109114  Center.Zero();
    110115
    111   if (ptr->next != end) {   //list not empty?
    112     while (ptr->next != end) {  // continue with second if present
    113       ptr = ptr->next;
     116  if (iter != end()) {   //list not empty?
     117    for (; iter != end(); ++iter) {  // continue with second if present
    114118      Num++;
    115       Center += ptr->x;
     119      Center += (*iter)->x;
    116120    }
    117121    Center.Scale(-1./Num); // divide through total number (and sign for direction)
     
    126130Vector * molecule::DetermineCenterOfAll() const
    127131{
    128   atom *ptr = start->next;  // start at first in list
     132  molecule::const_iterator iter = begin();  // start at first in list
     133  Vector *a = new Vector();
     134  double Num = 0;
     135
     136  a->Zero();
     137
     138  if (iter != end()) {   //list not empty?
     139    for (; iter != end(); ++iter) {  // continue with second if present
     140      Num++;
     141      (*a) += (*iter)->x;
     142    }
     143    a->Scale(1./Num); // divide through total mass (and sign for direction)
     144  }
     145  return a;
     146};
     147
     148/** Returns vector pointing to center of the domain.
     149 * \return pointer to center of the domain
     150 */
     151Vector * molecule::DetermineCenterOfBox() const
     152{
     153  Vector *a = new Vector(0.5,0.5,0.5);
     154
     155  const double *cell_size = World::getInstance().getDomain();
     156  double *M = ReturnFullMatrixforSymmetric(cell_size);
     157  a->MatrixMultiplication(M);
     158  delete[](M);
     159
     160  return a;
     161};
     162
     163/** Returns vector pointing to center of gravity.
     164 * \param *out output stream for debugging
     165 * \return pointer to center of gravity vector
     166 */
     167Vector * molecule::DetermineCenterOfGravity()
     168{
     169  molecule::const_iterator iter = begin();  // start at first in list
    129170  Vector *a = new Vector();
    130171  Vector tmp;
     
    133174  a->Zero();
    134175
    135   if (ptr != end) {   //list not empty?
    136     while (ptr->next != end) {  // continue with second if present
    137       ptr = ptr->next;
    138       Num += 1.;
    139       tmp = ptr->x;
     176  if (iter != end()) {   //list not empty?
     177    for (; iter != end(); ++iter) {  // continue with second if present
     178      Num += (*iter)->type->mass;
     179      tmp = (*iter)->type->mass * (*iter)->x;
    140180      (*a) += tmp;
    141181    }
    142182    a->Scale(1./Num); // divide through total mass (and sign for direction)
    143   }
    144   return a;
    145 };
    146 
    147 /** Returns vector pointing to center of gravity.
    148  * \param *out output stream for debugging
    149  * \return pointer to center of gravity vector
    150  */
    151 Vector * molecule::DetermineCenterOfGravity()
    152 {
    153   atom *ptr = start->next;  // start at first in list
    154   Vector *a = new Vector();
    155   Vector tmp;
    156   double Num = 0;
    157 
    158   a->Zero();
    159 
    160   if (ptr != end) {   //list not empty?
    161     while (ptr->next != end) {  // continue with second if present
    162       ptr = ptr->next;
    163       Num += ptr->type->mass;
    164       tmp = ptr->type->mass * ptr->x;
    165       (*a) += tmp;
    166     }
    167     a->Scale(-1./Num); // divide through total mass (and sign for direction)
    168183  }
    169184//  Log() << Verbose(1) << "Resulting center of gravity: ";
     
    203218void molecule::Scale(const double ** const factor)
    204219{
    205   atom *ptr = start;
    206 
    207   while (ptr->next != end) {
    208     ptr = ptr->next;
     220  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    209221    for (int j=0;j<MDSteps;j++)
    210       ptr->Trajectory.R.at(j).ScaleAll(*factor);
    211     ptr->x.ScaleAll(*factor);
     222      (*iter)->Trajectory.R.at(j).ScaleAll(*factor);
     223    (*iter)->x.ScaleAll(*factor);
    212224  }
    213225};
     
    218230void molecule::Translate(const Vector *trans)
    219231{
    220   atom *ptr = start;
    221 
    222   while (ptr->next != end) {
    223     ptr = ptr->next;
     232  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    224233    for (int j=0;j<MDSteps;j++)
    225       ptr->Trajectory.R.at(j) += (*trans);
    226     ptr->x += (*trans);
     234      (*iter)->Trajectory.R.at(j) += (*trans);
     235    (*iter)->x += (*trans);
    227236  }
    228237};
     
    239248
    240249  // go through all atoms
    241   ActOnAllVectors( &Vector::SubtractVector, *trans);
     250  ActOnAllVectors( &Vector::AddVector, *trans);
    242251  ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
    243252
    244   Free(&M);
    245   Free(&Minv);
     253  delete[](M);
     254  delete[](Minv);
    246255};
    247256
     
    252261void molecule::Mirror(const Vector *n)
    253262{
     263  OBSERVE;
    254264  Plane p(*n,0);
    255   // TODO: replace with simpler construct (e.g. Boost::foreach)
    256   // once the structure of the atom list is fully reworked
    257   atom *Walker = start;
    258   while (Walker->next != end) {
    259     Walker = Walker->next;
    260     (*Walker->node) = p.mirrorVector(*Walker->node);
     265  BOOST_FOREACH( atom* iter, atoms ){
     266    (*iter->node) = p.mirrorVector(*iter->node);
    261267  }
    262268};
     
    267273void molecule::DeterminePeriodicCenter(Vector &center)
    268274{
    269   atom *Walker = start;
    270275  double * const cell_size = World::getInstance().getDomain();
    271276  double *matrix = ReturnFullMatrixforSymmetric(cell_size);
    272   double *inversematrix = InverseMatrix(cell_size);
     277  double *inversematrix = InverseMatrix(matrix);
    273278  double tmp;
    274279  bool flag;
     
    278283    Center.Zero();
    279284    flag = true;
    280     while (Walker->next != end) {
    281       Walker = Walker->next;
     285    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    282286#ifdef ADDHYDROGEN
    283       if (Walker->type->Z != 1) {
     287      if ((*iter)->type->Z != 1) {
    284288#endif
    285         Testvector = Walker->x;
     289        Testvector = (*iter)->x;
    286290        Testvector.MatrixMultiplication(inversematrix);
    287291        Translationvector.Zero();
    288         for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    289          if (Walker->nr < (*Runner)->GetOtherAtom(Walker)->nr) // otherwise we shift one to, the other fro and gain nothing
     292        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     293         if ((*iter)->nr < (*Runner)->GetOtherAtom((*iter))->nr) // otherwise we shift one to, the other fro and gain nothing
    290294            for (int j=0;j<NDIM;j++) {
    291               tmp = Walker->x[j] - (*Runner)->GetOtherAtom(Walker)->x[j];
     295              tmp = (*iter)->x[j] - (*Runner)->GetOtherAtom(*iter)->x[j];
    292296              if ((fabs(tmp)) > BondDistance) {
    293297                flag = false;
    294                 DoLog(0) && (Log() << Verbose(0) << "Hit: atom " << Walker->getName() << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl);
     298                DoLog(0) && (Log() << Verbose(0) << "Hit: atom " << (*iter)->getName() << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl);
    295299                if (tmp > 0)
    296300                  Translationvector[j] -= 1.;
     
    306310#ifdef ADDHYDROGEN
    307311        // now also change all hydrogens
    308         for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    309           if ((*Runner)->GetOtherAtom(Walker)->type->Z == 1) {
    310             Testvector = (*Runner)->GetOtherAtom(Walker)->x;
     312        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     313          if ((*Runner)->GetOtherAtom((*iter))->type->Z == 1) {
     314            Testvector = (*Runner)->GetOtherAtom((*iter))->x;
    311315            Testvector.MatrixMultiplication(inversematrix);
    312316            Testvector += Translationvector;
     
    320324    }
    321325  } while (!flag);
    322   Free(&matrix);
    323   Free(&inversematrix);
    324 
    325   Center.Scale(1./(double)AtomCount);
     326  delete[](matrix);
     327  delete[](inversematrix);
     328
     329  Center.Scale(1./static_cast<double>(getAtomCount()));
    326330};
    327331
     
    333337void molecule::PrincipalAxisSystem(bool DoRotate)
    334338{
    335   atom *ptr = start;  // start at first in list
    336339  double InertiaTensor[NDIM*NDIM];
    337340  Vector *CenterOfGravity = DetermineCenterOfGravity();
     
    344347
    345348  // sum up inertia tensor
    346   while (ptr->next != end) {
    347     ptr = ptr->next;
    348     Vector x = ptr->x;
     349  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     350    Vector x = (*iter)->x;
    349351    //x.SubtractVector(CenterOfGravity);
    350     InertiaTensor[0] += ptr->type->mass*(x[1]*x[1] + x[2]*x[2]);
    351     InertiaTensor[1] += ptr->type->mass*(-x[0]*x[1]);
    352     InertiaTensor[2] += ptr->type->mass*(-x[0]*x[2]);
    353     InertiaTensor[3] += ptr->type->mass*(-x[1]*x[0]);
    354     InertiaTensor[4] += ptr->type->mass*(x[0]*x[0] + x[2]*x[2]);
    355     InertiaTensor[5] += ptr->type->mass*(-x[1]*x[2]);
    356     InertiaTensor[6] += ptr->type->mass*(-x[2]*x[0]);
    357     InertiaTensor[7] += ptr->type->mass*(-x[2]*x[1]);
    358     InertiaTensor[8] += ptr->type->mass*(x[0]*x[0] + x[1]*x[1]);
     352    InertiaTensor[0] += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]);
     353    InertiaTensor[1] += (*iter)->type->mass*(-x[0]*x[1]);
     354    InertiaTensor[2] += (*iter)->type->mass*(-x[0]*x[2]);
     355    InertiaTensor[3] += (*iter)->type->mass*(-x[1]*x[0]);
     356    InertiaTensor[4] += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]);
     357    InertiaTensor[5] += (*iter)->type->mass*(-x[1]*x[2]);
     358    InertiaTensor[6] += (*iter)->type->mass*(-x[2]*x[0]);
     359    InertiaTensor[7] += (*iter)->type->mass*(-x[2]*x[1]);
     360    InertiaTensor[8] += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]);
    359361  }
    360362  // print InertiaTensor for debugging
     
    394396
    395397    // sum up inertia tensor
    396     ptr = start;
    397     while (ptr->next != end) {
    398       ptr = ptr->next;
    399       Vector x = ptr->x;
    400       //x.SubtractVector(CenterOfGravity);
    401       InertiaTensor[0] += ptr->type->mass*(x[1]*x[1] + x[2]*x[2]);
    402       InertiaTensor[1] += ptr->type->mass*(-x[0]*x[1]);
    403       InertiaTensor[2] += ptr->type->mass*(-x[0]*x[2]);
    404       InertiaTensor[3] += ptr->type->mass*(-x[1]*x[0]);
    405       InertiaTensor[4] += ptr->type->mass*(x[0]*x[0] + x[2]*x[2]);
    406       InertiaTensor[5] += ptr->type->mass*(-x[1]*x[2]);
    407       InertiaTensor[6] += ptr->type->mass*(-x[2]*x[0]);
    408       InertiaTensor[7] += ptr->type->mass*(-x[2]*x[1]);
    409       InertiaTensor[8] += ptr->type->mass*(x[0]*x[0] + x[1]*x[1]);
     398    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     399      Vector x = (*iter)->x;
     400      InertiaTensor[0] += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]);
     401      InertiaTensor[1] += (*iter)->type->mass*(-x[0]*x[1]);
     402      InertiaTensor[2] += (*iter)->type->mass*(-x[0]*x[2]);
     403      InertiaTensor[3] += (*iter)->type->mass*(-x[1]*x[0]);
     404      InertiaTensor[4] += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]);
     405      InertiaTensor[5] += (*iter)->type->mass*(-x[1]*x[2]);
     406      InertiaTensor[6] += (*iter)->type->mass*(-x[2]*x[0]);
     407      InertiaTensor[7] += (*iter)->type->mass*(-x[2]*x[1]);
     408      InertiaTensor[8] += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]);
    410409    }
    411410    // print InertiaTensor for debugging
     
    431430void molecule::Align(Vector *n)
    432431{
    433   atom *ptr = start;
    434432  double alpha, tmp;
    435433  Vector z_axis;
     
    442440  alpha = atan(-n->at(0)/n->at(2));
    443441  DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... ");
    444   while (ptr->next != end) {
    445     ptr = ptr->next;
    446     tmp = ptr->x[0];
    447     ptr->x[0] =  cos(alpha) * tmp + sin(alpha) * ptr->x[2];
    448     ptr->x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x[2];
     442  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     443    tmp = (*iter)->x[0];
     444    (*iter)->x[0] =  cos(alpha) * tmp + sin(alpha) * (*iter)->x[2];
     445    (*iter)->x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2];
    449446    for (int j=0;j<MDSteps;j++) {
    450       tmp = ptr->Trajectory.R.at(j)[0];
    451       ptr->Trajectory.R.at(j)[0] =  cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j)[2];
    452       ptr->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j)[2];
     447      tmp = (*iter)->Trajectory.R.at(j)[0];
     448      (*iter)->Trajectory.R.at(j)[0] =  cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j)[2];
     449      (*iter)->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j)[2];
    453450    }
    454451  }
     
    460457
    461458  // rotate on z-y plane
    462   ptr = start;
    463459  alpha = atan(-n->at(1)/n->at(2));
    464460  DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... ");
    465   while (ptr->next != end) {
    466     ptr = ptr->next;
    467     tmp = ptr->x[1];
    468     ptr->x[1] =  cos(alpha) * tmp + sin(alpha) * ptr->x[2];
    469     ptr->x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x[2];
     461  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     462    tmp = (*iter)->x[1];
     463    (*iter)->x[1] =  cos(alpha) * tmp + sin(alpha) * (*iter)->x[2];
     464    (*iter)->x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2];
    470465    for (int j=0;j<MDSteps;j++) {
    471       tmp = ptr->Trajectory.R.at(j)[1];
    472       ptr->Trajectory.R.at(j)[1] =  cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j)[2];
    473       ptr->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j)[2];
     466      tmp = (*iter)->Trajectory.R.at(j)[1];
     467      (*iter)->Trajectory.R.at(j)[1] =  cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j)[2];
     468      (*iter)->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j)[2];
    474469    }
    475470  }
     
    495490  Vector a,b,c,d;
    496491  struct lsq_params *par = (struct lsq_params *)params;
    497   atom *ptr = par->mol->start;
    498492
    499493  // initialize vectors
     
    505499  b[2] = gsl_vector_get(x,5);
    506500  // go through all atoms
    507   while (ptr != par->mol->end) {
    508     ptr = ptr->next;
    509     if (ptr->type == ((struct lsq_params *)params)->type) { // for specific type
    510       c = ptr->x - a;
     501  for (molecule::const_iterator iter = par->mol->begin(); iter != par->mol->end(); ++iter) {
     502    if ((*iter)->type == ((struct lsq_params *)params)->type) { // for specific type
     503      c = (*iter)->x - a;
    511504      t = c.ScalarProduct(b);           // get direction parameter
    512505      d = t*b;       // and create vector
  • src/molecule_graph.cpp

    rc39cc4 rbdb143  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include "atom.hpp"
    911#include "bond.hpp"
    1012#include "bondgraph.hpp"
    1113#include "config.hpp"
     14#include "defs.hpp"
    1215#include "element.hpp"
    1316#include "helpers.hpp"
     17#include "info.hpp"
    1418#include "linkedcell.hpp"
    1519#include "lists.hpp"
     
    1923#include "World.hpp"
    2024#include "Helpers/fast_functions.hpp"
     25#include "Helpers/Assert.hpp"
     26
    2127
    2228struct BFSAccounting
     
    5460void molecule::CreateAdjacencyListFromDbondFile(ifstream *input)
    5561{
    56 
     62  Info FunctionInfo(__func__);
    5763  // 1 We will parse bonds out of the dbond file created by tremolo.
    5864  int atom1, atom2;
    5965  atom *Walker, *OtherWalker;
    60 
    61   if (!input) {
    62     DoLog(1) && (Log() << Verbose(1) << "Opening silica failed \n");
     66  char line[MAXSTRINGSIZE];
     67
     68  if (input->fail()) {
     69    DoeLog(0) && (eLog() << Verbose(0) << "Opening of bond file failed \n");
     70    performCriticalExit();
    6371  };
    64 
    65   *input >> ws >> atom1;
    66   *input >> ws >> atom2;
    67   DoLog(1) && (Log() << Verbose(1) << "Scanning file\n");
     72  doCountAtoms();
     73
     74  // skip header
     75  input->getline(line,MAXSTRINGSIZE);
     76  DoLog(1) && (Log() << Verbose(1) << "Scanning file ... \n");
    6877  while (!input->eof()) // Check whether we read everything already
    6978  {
    70     *input >> ws >> atom1;
    71     *input >> ws >> atom2;
    72 
     79    input->getline(line,MAXSTRINGSIZE);
     80    stringstream zeile(line);
     81    zeile >> atom1;
     82    zeile >> atom2;
     83
     84    DoLog(2) && (Log() << Verbose(2) << "Looking for atoms " << atom1 << " and " << atom2 << "." << endl);
    7385    if (atom2 < atom1) //Sort indices of atoms in order
    7486      flip(atom1, atom2);
    7587    Walker = FindAtom(atom1);
     88    ASSERT(Walker,"Could not find an atom with the ID given in dbond file");
    7689    OtherWalker = FindAtom(atom2);
     90    ASSERT(OtherWalker,"Could not find an atom with the ID given in dbond file");
    7791    AddBond(Walker, OtherWalker); //Add the bond between the two atoms with respective indices.
    7892  }
     
    103117  atom *Walker = NULL;
    104118  atom *OtherWalker = NULL;
    105   atom **AtomMap = NULL;
    106119  int n[NDIM];
    107120  double MinDistance, MaxDistance;
     
    118131  DoLog(0) && (Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl);
    119132  // remove every bond from the list
    120   bond *Binder = NULL;
    121   while (last->previous != first) {
    122     Binder = last->previous;
    123     Binder->leftatom->UnregisterBond(Binder);
    124     Binder->rightatom->UnregisterBond(Binder);
    125     removewithoutcheck(Binder);
    126   }
     133  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     134    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     135      if ((*BondRunner)->leftatom == *AtomRunner)
     136        delete((*BondRunner));
    127137  BondCount = 0;
    128138
    129139  // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering)
    130   CountAtoms();
    131   DoLog(1) && (Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl);
    132 
    133   if ((AtomCount > 1) && (bonddistance > 1.)) {
     140  DoLog(1) && (Log() << Verbose(1) << "AtomCount " << getAtomCount() << " and bonddistance is " << bonddistance << "." << endl);
     141
     142  if ((getAtomCount() > 1) && (bonddistance > 1.)) {
    134143    DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl);
    135144    LC = new LinkedCell(this, bonddistance);
     
    137146    // create a list to map Tesselpoint::nr to atom *
    138147    DoLog(2) && (Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl);
    139     AtomMap = Calloc<atom *> (AtomCount, "molecule::CreateAdjacencyList - **AtomCount");
    140     Walker = start;
    141     while (Walker->next != end) {
    142       Walker = Walker->next;
    143       AtomMap[Walker->nr] = Walker;
     148
     149    // set numbers for atoms that can later be used
     150    int i=0;
     151    for(internal_iterator iter = atoms.begin();iter!= atoms.end(); ++iter){
     152      (*iter)->nr = i++;
    144153    }
    145154
     
    153162          if (List != NULL) {
    154163            for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    155               Walker = AtomMap[(*Runner)->nr];
    156 //              Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
     164              Walker = dynamic_cast<atom*>(*Runner);
     165              ASSERT(Walker,"Tesselpoint that was not an atom retrieved from LinkedNode");
     166              //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
    157167              // 3c. check for possible bond between each atom in this and every one in the 27 cells
    158168              for (n[0] = -1; n[0] <= 1; n[0]++)
     
    164174                      for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
    165175                        if ((*OtherRunner)->nr > Walker->nr) {
    166                           OtherWalker = AtomMap[(*OtherRunner)->nr];
    167 //                          Log() << Verbose(0) << "Current other Atom is " << *OtherWalker << "." << endl;
    168                           const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x, cell_size);
    169 //                          Log() << Verbose(1) << "Checking distance " << distance << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
     176                          OtherWalker = dynamic_cast<atom*>(*OtherRunner);
     177                          ASSERT(OtherWalker,"TesselPoint that was not an atom retrieved from LinkedNode");
     178                          //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
    170179                          (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
     180                          const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x,cell_size);
    171181                          const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance);
    172182//                          Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl;
     
    188198          }
    189199        }
    190     Free(&AtomMap);
    191200    delete (LC);
    192201    DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl);
     
    199208    ActOnAllAtoms( &atom::OutputBondOfAtom );
    200209  } else
    201     DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl);
     210    DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << getAtomCount() << ", thus no bonds, no connections!." << endl);
    202211  DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl);
    203212  if (free_BG)
     
    206215;
    207216
     217/** Checks for presence of bonds within atom list.
     218 * TODO: more sophisticated check for bond structure (e.g. connected subgraph, ...)
     219 * \return true - bonds present, false - no bonds
     220 */
     221bool molecule::hasBondStructure()
     222{
     223  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     224    if (!(*AtomRunner)->ListOfBonds.empty())
     225      return true;
     226  return false;
     227}
     228
     229/** Counts the number of present bonds.
     230 * \return number of bonds
     231 */
     232unsigned int molecule::CountBonds() const
     233{
     234  unsigned int counter = 0;
     235  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     236    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     237      if ((*BondRunner)->leftatom == *AtomRunner)
     238        counter++;
     239  return counter;
     240}
     241
    208242/** Prints a list of all bonds to \a *out.
    209243 * \param output stream
     
    212246{
    213247  DoLog(1) && (Log() << Verbose(1) << endl << "From contents of bond chain list:");
    214   bond *Binder = first;
    215   while (Binder->next != last) {
    216     Binder = Binder->next;
    217     DoLog(0) && (Log() << Verbose(0) << *Binder << "\t" << endl);
    218   }
     248  for(molecule::const_iterator AtomRunner = molecule::begin(); AtomRunner != molecule::end(); ++AtomRunner)
     249    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     250      if ((*BondRunner)->leftatom == *AtomRunner) {
     251        DoLog(0) && (Log() << Verbose(0) << *(*BondRunner) << "\t" << endl);
     252      }
    219253  DoLog(0) && (Log() << Verbose(0) << endl);
    220254}
     
    241275    DoLog(0) && (Log() << Verbose(0) << " done." << endl);
    242276  } else {
    243     DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl);
     277    DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << getAtomCount() << " atoms." << endl);
    244278  }
    245279  DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl);
     
    260294  MoleculeLeafClass *Subgraphs = NULL;
    261295  class StackClass<bond *> *BackEdgeStack = NULL;
    262   bond *Binder = first;
    263   if ((Binder->next != last) && (Binder->next->Type == Undetermined)) {
    264     DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl);
    265     Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack);
    266     while (Subgraphs->next != NULL) {
    267       Subgraphs = Subgraphs->next;
    268       delete (Subgraphs->previous);
    269     }
    270     delete (Subgraphs);
    271     delete[] (MinimumRingSize);
    272   }
    273   while (Binder->next != last) {
    274     Binder = Binder->next;
    275     if (Binder->Cyclic)
    276       NoCyclicBonds++;
    277   }
     296  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     297    if ((!(*AtomRunner)->ListOfBonds.empty()) && ((*(*AtomRunner)->ListOfBonds.begin())->Type == Undetermined)) {
     298      DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl);
     299      Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack);
     300      while (Subgraphs->next != NULL) {
     301        Subgraphs = Subgraphs->next;
     302        delete (Subgraphs->previous);
     303      }
     304      delete (Subgraphs);
     305      delete[] (MinimumRingSize);
     306      break;
     307    }
     308  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     309    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     310      if ((*BondRunner)->leftatom == *AtomRunner)
     311        if ((*BondRunner)->Cyclic)
     312          NoCyclicBonds++;
    278313  delete (BackEdgeStack);
    279314  return NoCyclicBonds;
     
    461496void DepthFirstSearchAnalysis_Init(struct DFSAccounting &DFS, const molecule * const mol)
    462497{
    463   DFS.AtomStack = new StackClass<atom *> (mol->AtomCount);
     498  DFS.AtomStack = new StackClass<atom *> (mol->getAtomCount());
    464499  DFS.CurrentGraphNr = 0;
    465500  DFS.ComponentNumber = 0;
     
    502537  bond *Binder = NULL;
    503538
    504   if (AtomCount == 0)
     539  if (getAtomCount() == 0)
    505540    return SubGraphs;
    506541  DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl);
    507542  DepthFirstSearchAnalysis_Init(DFS, this);
    508543
    509   DFS.Root = start->next;
    510   while (DFS.Root != end) { // if there any atoms at all
     544  for (molecule::const_iterator iter = begin(); iter != end();) {
     545    DFS.Root = *iter;
    511546    // (1) mark all edges unused, empty stack, set atom->GraphNr = -1 for all
    512547    DFS.AtomStack->ClearStack();
     
    548583
    549584    // step on to next root
    550     while ((DFS.Root != end) && (DFS.Root->GraphNr != -1)) {
    551       //Log() << Verbose(1) << "Current next subgraph root candidate is " << Root->Name << "." << endl;
    552       if (DFS.Root->GraphNr != -1) // if already discovered, step on
    553         DFS.Root = DFS.Root->next;
     585    while ((iter != end()) && ((*iter)->GraphNr != -1)) {
     586      //Log() << Verbose(1) << "Current next subgraph root candidate is " << (*iter)->Name << "." << endl;
     587      if ((*iter)->GraphNr != -1) // if already discovered, step on
     588        iter++;
    554589    }
    555590  }
     
    573608{
    574609  NoCyclicBonds = 0;
    575   bond *Binder = first;
    576   while (Binder->next != last) {
    577     Binder = Binder->next;
    578     if (Binder->rightatom->LowpointNr == Binder->leftatom->LowpointNr) { // cyclic ??
    579       Binder->Cyclic = true;
    580       NoCyclicBonds++;
    581     }
    582   }
     610  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     611    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     612      if ((*BondRunner)->leftatom == *AtomRunner)
     613        if ((*BondRunner)->rightatom->LowpointNr == (*BondRunner)->leftatom->LowpointNr) { // cyclic ??
     614          (*BondRunner)->Cyclic = true;
     615          NoCyclicBonds++;
     616        }
    583617}
    584618;
     
    599633void molecule::OutputGraphInfoPerBond() const
    600634{
     635  bond *Binder = NULL;
    601636  DoLog(1) && (Log() << Verbose(1) << "Final graph info for each bond is:" << endl);
    602   bond *Binder = first;
    603   while (Binder->next != last) {
    604     Binder = Binder->next;
    605     DoLog(2) && (Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <");
    606     DoLog(0) && (Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp.");
    607     Binder->leftatom->OutputComponentNumber();
    608     DoLog(0) && (Log() << Verbose(0) << " ===  ");
    609     DoLog(0) && (Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp.");
    610     Binder->rightatom->OutputComponentNumber();
    611     DoLog(0) && (Log() << Verbose(0) << ">." << endl);
    612     if (Binder->Cyclic) // cyclic ??
    613       DoLog(3) && (Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl);
    614   }
     637  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     638    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     639      if ((*BondRunner)->leftatom == *AtomRunner) {
     640        Binder = *BondRunner;
     641        DoLog(2) && (Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <");
     642        DoLog(0) && (Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp.");
     643        Binder->leftatom->OutputComponentNumber();
     644        DoLog(0) && (Log() << Verbose(0) << " ===  ");
     645        DoLog(0) && (Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp.");
     646        Binder->rightatom->OutputComponentNumber();
     647        DoLog(0) && (Log() << Verbose(0) << ">." << endl);
     648        if (Binder->Cyclic) // cyclic ??
     649          DoLog(3) && (Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl);
     650      }
    615651}
    616652;
     
    624660{
    625661  BFS.AtomCount = AtomCount;
    626   BFS.PredecessorList = Calloc<atom*> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: **PredecessorList");
    627   BFS.ShortestPathList = Malloc<int> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ShortestPathList");
    628   BFS.ColorList = Calloc<enum Shading> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ColorList");
     662  BFS.PredecessorList = new atom*[AtomCount];
     663  BFS.ShortestPathList = new int[AtomCount];
     664  BFS.ColorList = new enum Shading[AtomCount];
    629665  BFS.BFSStack = new StackClass<atom *> (AtomCount);
    630666
    631   for (int i = AtomCount; i--;)
     667  for (int i = AtomCount; i--;) {
    632668    BFS.ShortestPathList[i] = -1;
     669    BFS.PredecessorList[i] = 0;
     670  }
    633671};
    634672
     
    639677void FinalizeBFSAccounting(struct BFSAccounting &BFS)
    640678{
    641   Free(&BFS.PredecessorList);
    642   Free(&BFS.ShortestPathList);
    643   Free(&BFS.ColorList);
     679  delete[](BFS.PredecessorList);
     680  delete[](BFS.ShortestPathList);
     681  delete[](BFS.ColorList);
    644682  delete (BFS.BFSStack);
    645683  BFS.AtomCount = 0;
     
    854892  if (MinRingSize != -1) { // if rings are present
    855893    // go over all atoms
    856     Root = mol->start;
    857     while (Root->next != mol->end) {
    858       Root = Root->next;
    859 
    860       if (MinimumRingSize[Root->GetTrueFather()->nr] == mol->AtomCount) { // check whether MinimumRingSize is set, if not BFS to next where it is
     894    for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     895      Root = *iter;
     896
     897      if (MinimumRingSize[Root->GetTrueFather()->nr] == mol->getAtomCount()) { // check whether MinimumRingSize is set, if not BFS to next where it is
    861898        Walker = Root;
    862899
    863900        //Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl;
    864         CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol->AtomCount);
     901        CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol->getAtomCount());
    865902
    866903      }
     
    892929  int MinRingSize = -1;
    893930
    894   InitializeBFSAccounting(BFS, AtomCount);
     931  InitializeBFSAccounting(BFS, getAtomCount());
    895932
    896933  //Log() << Verbose(1) << "Back edge list - ";
     
    9661003void molecule::ResetAllBondsToUnused() const
    9671004{
    968   bond *Binder = first;
    969   while (Binder->next != last) {
    970     Binder = Binder->next;
    971     Binder->ResetUsed();
    972   }
     1005  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     1006    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     1007      if ((*BondRunner)->leftatom == *AtomRunner)
     1008        (*BondRunner)->ResetUsed();
    9731009}
    9741010;
     
    9891025/** Storing the bond structure of a molecule to file.
    9901026 * Simply stores Atom::nr and then the Atom::nr of all bond partners per line.
    991  * \param *path path to file
    992  * \param *filename name of file
     1027 * \param &filename name of file
     1028 * \param path path to file, defaults to empty
    9931029 * \return true - file written successfully, false - writing failed
    9941030 */
    995 bool molecule::StoreAdjacencyToFile(char *path, char *filename)
     1031bool molecule::StoreAdjacencyToFile(std::string &filename, std::string path)
    9961032{
    9971033  ofstream AdjacencyFile;
    998   stringstream line;
     1034  string line;
    9991035  bool status = true;
    10001036
    1001   if (path != NULL)
    1002     line << path << "/" << filename;
     1037  if (path != "")
     1038    line = path + "/" + filename;
    10031039  else
    1004     line << filename;
    1005   AdjacencyFile.open(line.str().c_str(), ios::out);
    1006   DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... ");
    1007   if (AdjacencyFile != NULL) {
     1040    line = filename;
     1041  AdjacencyFile.open(line.c_str(), ios::out);
     1042  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl);
     1043  if (AdjacencyFile.good()) {
    10081044    AdjacencyFile << "m\tn" << endl;
    10091045    ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile);
    10101046    AdjacencyFile.close();
    1011     DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     1047    DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl);
    10121048  } else {
    1013     DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
     1049    DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line << "." << endl);
    10141050    status = false;
    10151051  }
     
    10211057/** Storing the bond structure of a molecule to file.
    10221058 * Simply stores Atom::nr and then the Atom::nr of all bond partners, one per line.
    1023  * \param *path path to file
    1024  * \param *filename name of file
     1059 * \param &filename name of file
     1060 * \param path path to file, defaults to empty
    10251061 * \return true - file written successfully, false - writing failed
    10261062 */
    1027 bool molecule::StoreBondsToFile(char *path, char *filename)
     1063bool molecule::StoreBondsToFile(std::string &filename, std::string path)
    10281064{
    10291065  ofstream BondFile;
    1030   stringstream line;
     1066  string line;
    10311067  bool status = true;
    10321068
    1033   if (path != NULL)
    1034     line << path << "/" << filename;
     1069  if (path != "")
     1070    line = path + "/" + filename;
    10351071  else
    1036     line << filename;
    1037   BondFile.open(line.str().c_str(), ios::out);
    1038   DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... ");
    1039   if (BondFile != NULL) {
     1072    line = filename;
     1073  BondFile.open(line.c_str(), ios::out);
     1074  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl);
     1075  if (BondFile.good()) {
    10401076    BondFile << "m\tn" << endl;
    10411077    ActOnAllAtoms(&atom::OutputBonds, &BondFile);
    10421078    BondFile.close();
    1043     DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     1079    DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl);
    10441080  } else {
    1045     DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
     1081    DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line << "." << endl);
    10461082    status = false;
    10471083  }
     
    10511087;
    10521088
    1053 bool CheckAdjacencyFileAgainstMolecule_Init(char *path, ifstream &File, int *&CurrentBonds)
    1054 {
    1055   stringstream filename;
    1056   filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE;
    1057   File.open(filename.str().c_str(), ios::out);
    1058   DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... ");
    1059   if (File == NULL)
     1089bool CheckAdjacencyFileAgainstMolecule_Init(std::string &path, ifstream &File, int *&CurrentBonds)
     1090{
     1091  string filename;
     1092  filename = path + ADJACENCYFILE;
     1093  File.open(filename.c_str(), ios::out);
     1094  DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... " << endl);
     1095  if (File.fail())
    10601096    return false;
    10611097
    10621098  // allocate storage structure
    1063   CurrentBonds = Calloc<int> (8, "molecule::CheckAdjacencyFileAgainstMolecule - CurrentBonds"); // contains parsed bonds of current atom
     1099  CurrentBonds = new int[8]; // contains parsed bonds of current atom
     1100  for(int i=0;i<8;i++)
     1101    CurrentBonds[i] = 0;
    10641102  return true;
    10651103}
     
    10701108  File.close();
    10711109  File.clear();
    1072   Free(&CurrentBonds);
     1110  delete[](CurrentBonds);
    10731111}
    10741112;
     
    10901128        NonMatchNumber++;
    10911129        status = false;
     1130        DoeLog(2) && (eLog() << Verbose(2) << id << " can not be found in list." << endl);
     1131      } else {
    10921132        //Log() << Verbose(0) << "[" << id << "]\t";
    1093       } else {
    1094         //Log() << Verbose(0) << id << "\t";
    10951133      }
    10961134    }
     
    11091147 * \return true - structure is equal, false - not equivalence
    11101148 */
    1111 bool molecule::CheckAdjacencyFileAgainstMolecule(char *path, atom **ListOfAtoms)
     1149bool molecule::CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms)
    11121150{
    11131151  ifstream File;
    11141152  bool status = true;
    11151153  atom *Walker = NULL;
    1116   char *buffer = NULL;
    11171154  int *CurrentBonds = NULL;
    11181155  int NonMatchNumber = 0; // will number of atoms with differing bond structure
    11191156  size_t CurrentBondsOfAtom = -1;
     1157  const int AtomCount = getAtomCount();
    11201158
    11211159  if (!CheckAdjacencyFileAgainstMolecule_Init(path, File, CurrentBonds)) {
     
    11241162  }
    11251163
    1126   buffer = Malloc<char> (MAXSTRINGSIZE, "molecule::CheckAdjacencyFileAgainstMolecule: *buffer");
     1164  char buffer[MAXSTRINGSIZE];
    11271165  // Parse the file line by line and count the bonds
    11281166  while (!File.eof()) {
     
    11401178      // compare against present bonds
    11411179      CheckAdjacencyFileAgainstMolecule_CompareBonds(status, NonMatchNumber, Walker, CurrentBondsOfAtom, AtomNr, CurrentBonds, ListOfAtoms);
    1142     }
    1143   }
    1144   Free(&buffer);
     1180    } else {
     1181      if (AtomNr != -1)
     1182        DoeLog(2) && (eLog() << Verbose(2) << AtomNr << " is not valid in the range of ids [" << 0 << "," << AtomCount << ")." << endl);
     1183    }
     1184  }
    11451185  CheckAdjacencyFileAgainstMolecule_Finalize(File, CurrentBonds);
    11461186
     
    11961236  BFS.AtomCount = AtomCount;
    11971237  BFS.BondOrder = BondOrder;
    1198   BFS.PredecessorList = Calloc<atom*> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: **PredecessorList");
    1199   BFS.ShortestPathList = Calloc<int> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ShortestPathList");
    1200   BFS.ColorList = Malloc<enum Shading> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ColorList");
     1238  BFS.PredecessorList = new atom*[AtomCount];
     1239  BFS.ShortestPathList = new int[AtomCount];
     1240  BFS.ColorList = new enum Shading[AtomCount];
    12011241  BFS.BFSStack = new StackClass<atom *> (AtomCount);
    12021242
     
    12071247  // initialise each vertex as white with no predecessor, empty queue, color Root lightgray
    12081248  for (int i = AtomCount; i--;) {
     1249    BFS.PredecessorList[i] = NULL;
    12091250    BFS.ShortestPathList[i] = -1;
    12101251    if ((AddedAtomList != NULL) && (AddedAtomList[i] != NULL)) // mark already present atoms (i.e. Root and maybe others) as visited
     
    12131254      BFS.ColorList[i] = white;
    12141255  }
    1215   //BFS.ShortestPathList[Root->nr] = 0; //is set due to Calloc()
     1256  //BFS.ShortestPathList[Root->nr] = 0; // done by Calloc
    12161257}
    12171258;
     
    12191260void BreadthFirstSearchAdd_Free(struct BFSAccounting &BFS)
    12201261{
    1221   Free(&BFS.PredecessorList);
    1222   Free(&BFS.ShortestPathList);
    1223   Free(&BFS.ColorList);
     1262  delete[](BFS.PredecessorList);
     1263  delete[](BFS.ShortestPathList);
     1264  delete[](BFS.ColorList);
    12241265  delete (BFS.BFSStack);
    12251266  BFS.AtomCount = 0;
     
    13131354    AddedAtomList[Root->nr] = Mol->AddCopyAtom(Root);
    13141355
    1315   BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, AtomCount, AddedAtomList);
     1356  BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, getAtomCount(), AddedAtomList);
    13161357
    13171358  // and go on ... Queue always contains all lightgray vertices
     
    13601401{
    13611402  // reset parent list
    1362   ParentList = Calloc<atom*> (AtomCount, "molecule::BuildInducedSubgraph_Init: **ParentList");
     1403  ParentList = new atom*[AtomCount];
     1404  for (int i=0;i<AtomCount;i++)
     1405    ParentList[i] = NULL;
    13631406  DoLog(3) && (Log() << Verbose(3) << "Resetting ParentList." << endl);
    13641407}
     
    13691412  // fill parent list with sons
    13701413  DoLog(3) && (Log() << Verbose(3) << "Filling Parent List." << endl);
    1371   atom *Walker = mol->start;
    1372   while (Walker->next != mol->end) {
    1373     Walker = Walker->next;
    1374     ParentList[Walker->father->nr] = Walker;
     1414  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1415    ParentList[(*iter)->father->nr] = (*iter);
    13751416    // Outputting List for debugging
    1376     DoLog(4) && (Log() << Verbose(4) << "Son[" << Walker->father->nr << "] of " << Walker->father << " is " << ParentList[Walker->father->nr] << "." << endl);
    1377   }
    1378 
    1379 }
    1380 ;
     1417    DoLog(4) && (Log() << Verbose(4) << "Son[" << (*iter)->father->nr << "] of " << (*iter)->father << " is " << ParentList[(*iter)->father->nr] << "." << endl);
     1418  }
     1419};
    13811420
    13821421void BuildInducedSubgraph_Finalize(atom **&ParentList)
    13831422{
    1384   Free(&ParentList);
     1423  delete[](ParentList);
    13851424}
    13861425;
     
    13891428{
    13901429  bool status = true;
    1391   atom *Walker = NULL;
    13921430  atom *OtherAtom = NULL;
    13931431  // check each entry of parent list and if ok (one-to-and-onto matching) create bonds
    13941432  DoLog(3) && (Log() << Verbose(3) << "Creating bonds." << endl);
    1395   Walker = Father->start;
    1396   while (Walker->next != Father->end) {
    1397     Walker = Walker->next;
    1398     if (ParentList[Walker->nr] != NULL) {
    1399       if (ParentList[Walker->nr]->father != Walker) {
     1433  for (molecule::const_iterator iter = Father->begin(); iter != Father->end(); ++iter) {
     1434    if (ParentList[(*iter)->nr] != NULL) {
     1435      if (ParentList[(*iter)->nr]->father != (*iter)) {
    14001436        status = false;
    14011437      } else {
    1402         for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    1403           OtherAtom = (*Runner)->GetOtherAtom(Walker);
     1438        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     1439          OtherAtom = (*Runner)->GetOtherAtom((*iter));
    14041440          if (ParentList[OtherAtom->nr] != NULL) { // if otheratom is also a father of an atom on this molecule, create the bond
    1405             DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[Walker->nr]->getName() << " and " << ParentList[OtherAtom->nr]->getName() << "." << endl);
    1406             mol->AddBond(ParentList[Walker->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree);
     1441            DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[(*iter)->nr]->getName() << " and " << ParentList[OtherAtom->nr]->getName() << "." << endl);
     1442            mol->AddBond(ParentList[(*iter)->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree);
    14071443          }
    14081444        }
     
    14271463  bool status = true;
    14281464  atom **ParentList = NULL;
    1429 
    14301465  DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl);
    1431   BuildInducedSubgraph_Init(ParentList, Father->AtomCount);
     1466  BuildInducedSubgraph_Init(ParentList, Father->getAtomCount());
    14321467  BuildInducedSubgraph_FillParentList(this, Father, ParentList);
    14331468  status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList);
  • src/molecule_pointcloud.cpp

    rc39cc4 rbdb143  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include "atom.hpp"
    911#include "config.hpp"
     12#include "info.hpp"
    1013#include "memoryallocator.hpp"
    1114#include "molecule.hpp"
     
    3134};
    3235
    33 /** Return current atom in the list.
    34  * \return pointer to atom or NULL if none present
     36
     37/** PointCloud implementation of GoPoint
     38 * Uses atoms and STL stuff.
    3539 */
    36 TesselPoint *molecule::GetPoint() const
     40TesselPoint* molecule::GetPoint() const
    3741{
    38   if ((InternalPointer != start) && (InternalPointer != end))
    39     return InternalPointer;
    40   else
    41     return NULL;
     42  return (*InternalPointer);
    4243};
    4344
    44 /** Return pointer to one after last atom in the list.
    45  * \return pointer to end marker
    46  */
    47 TesselPoint *molecule::GetTerminalPoint() const
    48 {
    49   return end;
    50 };
    51 
    52 /** Return the greatest index of all atoms in the list.
    53  * \return greatest index
    54  */
    55 int molecule::GetMaxId() const
    56 {
    57   return last_atom;
    58 };
    59 
    60 /** Go to next atom.
    61  * Stops at last one.
     45/** PointCloud implementation of GoToNext.
     46 * Uses atoms and STL stuff.
    6247 */
    6348void molecule::GoToNext() const
    6449{
    65   if (InternalPointer != end)
    66     InternalPointer = InternalPointer->next;
     50  if (InternalPointer != atoms.end())
     51    InternalPointer++;
    6752};
    6853
    69 /** Go to previous atom.
    70  * Stops at first one.
    71  */
    72 void molecule::GoToPrevious() const
    73 {
    74   if (InternalPointer->previous != start)
    75     InternalPointer = InternalPointer->previous;
    76 };
    77 
    78 /** Goes to first atom.
     54/** PointCloud implementation of GoToFirst.
     55 * Uses atoms and STL stuff.
    7956 */
    8057void molecule::GoToFirst() const
    8158{
    82   InternalPointer = start->next;
     59  // evil hack necessary because
     60  // -# although InternalPointer is mutable
     61  // -# only const_iterator begin() is called due to const in the function declaration above
     62  // -# and there is no cast from const_iterator to const iterator
     63  atomSet::const_iterator test = begin();
     64  InternalPointer = *(reinterpret_cast<atomSet::iterator *>(&test));
    8365};
    8466
    85 /** Goes to last atom.
    86  */
    87 void molecule::GoToLast() const
    88 {
    89   InternalPointer = end->previous;
    90 };
    91 
    92 /** Checks whether we have any atoms in molecule.
    93  * \return true - no atoms, false - not empty
     67/** PointCloud implementation of IsEmpty.
     68 * Uses atoms and STL stuff.
    9469 */
    9570bool molecule::IsEmpty() const
    9671{
    97   return (start->next == end);
     72  return (empty());
    9873};
    9974
    100 /** Checks whether we are at the last atom
    101  * \return true - current atom is last one, false - is not last one
     75/** PointCloud implementation of IsLast.
     76 * Uses atoms and STL stuff.
    10277 */
    10378bool molecule::IsEnd() const
    10479{
    105   return (InternalPointer == end);
     80  return (InternalPointer == atoms.end());
    10681};
     82
     83int molecule::GetMaxId() const {
     84  return getAtomCount();
     85}
  • src/molecule_template.hpp

    rc39cc4 rbdb143  
    2424template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const
    2525    {
    26   atom *Walker = start;
    27   while (Walker->next != end) {
    28     Walker = Walker->next;
    29     ((Walker->node)->*f)();
     26  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     27    (((*iter)->node)->*f)();
    3028  }
    3129};
    3230template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const ) const
    3331    {
    34   atom *Walker = start;
    35   while (Walker->next != end) {
    36     Walker = Walker->next;
    37     ((Walker->node)->*f)();
     32  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     33    (((*iter)->node)->*f)();
    3834  }
    3935};
     
    4137template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const
    4238{
    43   atom *Walker = start;
    44   while (Walker->next != end) {
    45     Walker = Walker->next;
    46     ((Walker->node)->*f)(t);
     39  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     40    (((*iter)->node)->*f)(t);
    4741  }
    4842};
    4943template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const
    5044{
    51   atom *Walker = start;
    52   while (Walker->next != end) {
    53     Walker = Walker->next;
    54     ((Walker->node)->*f)(t);
     45  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     46    (((*iter)->node)->*f)(t);
    5547  }
    5648};
    5749template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&), T &t ) const
    5850{
    59   atom *Walker = start;
    60   while (Walker->next != end) {
    61     Walker = Walker->next;
    62     ((Walker->node)->*f)(t);
     51  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     52    (((*iter)->node)->*f)(t);
    6353  }
    6454};
    6555template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&) const, T &t ) const
    6656{
    67   atom *Walker = start;
    68   while (Walker->next != end) {
    69     Walker = Walker->next;
    70     ((Walker->node)->*f)(t);
     57  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     58    (((*iter)->node)->*f)(t);
    7159  }
    7260};
     
    7462template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const
    7563{
    76   atom *Walker = start;
    77   while (Walker->next != end) {
    78     Walker = Walker->next;
    79     ((Walker->node)->*f)(t, u);
     64  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     65    (((*iter)->node)->*f)(t, u);
    8066  }
    8167};
    8268template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const
    8369{
    84   atom *Walker = start;
    85   while (Walker->next != end) {
    86     Walker = Walker->next;
    87     ((Walker->node)->*f)(t, u);
     70  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     71    (((*iter)->node)->*f)(t, u);
    8872  }
    8973};
     
    9175template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const
    9276{
    93   atom *Walker = start;
    94   while (Walker->next != end) {
    95     Walker = Walker->next;
    96     ((Walker->node)->*f)(t, u, v);
     77  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     78    (((*iter)->node)->*f)(t, u, v);
    9779  }
    9880};
    9981template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const
    10082{
    101   atom *Walker = start;
    102   while (Walker->next != end) {
    103     Walker = Walker->next;
    104     ((Walker->node)->*f)(t, u, v);
     83  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     84    (((*iter)->node)->*f)(t, u, v);
    10585  }
    10686};
     
    11292{
    11393  res result = 0;
    114   atom *Walker = start;
    115   while (Walker->next != end) {
    116     Walker = Walker->next;
    117     result += (Walker->*f)();
     94  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     95    result += ((*iter)->*f)();
    11896  }
    11997  return result;
     
    122100{
    123101  res result = 0;
    124   atom *Walker = start;
    125   while (Walker->next != end) {
    126     Walker = Walker->next;
    127     result += (Walker->*f)();
     102  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     103    result += ((*iter)->*f)();
    128104  }
    129105  return result;
     
    133109{
    134110  res result = 0;
    135   atom *Walker = start;
    136   while (Walker->next != end) {
    137     Walker = Walker->next;
    138     result += (Walker->*f)(t);
     111  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     112    result += ((*iter)->*f)(t);
    139113  }
    140114  return result;
     
    143117{
    144118  res result = 0;
    145   atom *Walker = start;
    146   while (Walker->next != end) {
    147     Walker = Walker->next;
    148     result += (Walker->*f)(t);
     119  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     120    result += ((*iter)->*f)(t);
    149121  }
    150122  return result;
     
    157129template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const
    158130{
    159   atom *Walker = start;
    160   while (Walker->next != end) {
    161     Walker = Walker->next;
    162     (*f)(Walker);
     131  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     132    (*f)((*iter));
    163133  }
    164134};
    165135template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const
    166136{
    167   atom *Walker = start;
    168   while (Walker->next != end) {
    169     Walker = Walker->next;
    170     (*f)(Walker);
     137  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     138    (*f)((*iter));
    171139  }
    172140};
     
    177145template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const
    178146{
    179   atom *Walker = start;
    180   while (Walker->next != end) {
    181     Walker = Walker->next;
    182     (copy->*f)(Walker);
     147  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     148    (copy->*f)((*iter));
    183149  }
    184150};
    185151template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const
    186152{
    187   atom *Walker = start;
    188   while (Walker->next != end) {
    189     Walker = Walker->next;
    190     (copy->*f)(Walker);
     153  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     154    (copy->*f)((*iter));
    191155  }
    192156};
     
    197161template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const
    198162{
    199   atom *Walker = start;
    200   while (Walker->next != end) {
    201     Walker = Walker->next;
    202     if ((Walker->*condition)())
    203       (copy->*f)(Walker);
     163  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     164    if (((*iter)->*condition)())
     165      (copy->*f)((*iter));
    204166  }
    205167};
    206168template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const
    207169{
    208   atom *Walker = start;
    209   while (Walker->next != end) {
    210     Walker = Walker->next;
    211     if ((Walker->*condition)())
    212       (copy->*f)(Walker);
     170  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     171    if (((*iter)->*condition)())
     172      (copy->*f)((*iter));
    213173  }
    214174};
    215175template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const
    216176{
    217   atom *Walker = start;
    218   while (Walker->next != end) {
    219     Walker = Walker->next;
    220     if ((Walker->*condition)())
    221       (copy->*f)(Walker);
     177  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     178    if (((*iter)->*condition)())
     179      (copy->*f)((*iter));
    222180  }
    223181};
    224182template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) () const ) const
    225183{
    226   atom *Walker = start;
    227   while (Walker->next != end) {
    228     Walker = Walker->next;
    229     if ((Walker->*condition)())
    230       (copy->*f)(Walker);
     184  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     185    if (((*iter)->*condition)())
     186      (copy->*f)((*iter));
    231187  }
    232188};
     
    234190template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const
    235191{
    236   atom *Walker = start;
    237   while (Walker->next != end) {
    238     Walker = Walker->next;
    239     if ((Walker->*condition)(t))
    240       (copy->*f)(Walker);
     192  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     193    if (((*iter)->*condition)(t))
     194      (copy->*f)((*iter));
    241195  }
    242196};
    243197template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const
    244198{
    245   atom *Walker = start;
    246   while (Walker->next != end) {
    247     Walker = Walker->next;
    248     if ((Walker->*condition)(t))
    249       (copy->*f)(Walker);
     199  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     200    if (((*iter)->*condition)(t))
     201      (copy->*f)((*iter));
    250202  }
    251203};
    252204template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T), T t ) const
    253205{
    254   atom *Walker = start;
    255   while (Walker->next != end) {
    256     Walker = Walker->next;
    257     if ((Walker->*condition)(t))
    258       (copy->*f)(Walker);
     206  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     207    if (((*iter)->*condition)(t))
     208      (copy->*f)((*iter));
    259209  }
    260210};
    261211template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T) const, T t ) const
    262212{
    263   atom *Walker = start;
    264   while (Walker->next != end) {
    265     Walker = Walker->next;
    266     if ((Walker->*condition)(t))
    267       (copy->*f)(Walker);
     213  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     214    if (((*iter)->*condition)(t))
     215      (copy->*f)((*iter));
    268216  }
    269217};
     
    271219template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
    272220{
    273   atom *Walker = start;
    274   while (Walker->next != end) {
    275     Walker = Walker->next;
    276     if ((Walker->*condition)(t,u))
    277       (copy->*f)(Walker);
     221  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     222    if (((*iter)->*condition)(t,u))
     223      (copy->*f)((*iter));
    278224  }
    279225};
    280226template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
    281227{
    282   atom *Walker = start;
    283   while (Walker->next != end) {
    284     Walker = Walker->next;
    285     if ((Walker->*condition)(t,u))
    286       (copy->*f)(Walker);
     228  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     229    if (((*iter)->*condition)(t,u))
     230      (copy->*f)((*iter));
    287231  }
    288232};
    289233template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
    290234{
    291   atom *Walker = start;
    292   while (Walker->next != end) {
    293     Walker = Walker->next;
    294     if ((Walker->*condition)(t,u))
    295       (copy->*f)(Walker);
     235  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     236    if (((*iter)->*condition)(t,u))
     237      (copy->*f)((*iter));
    296238  }
    297239};
    298240template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
    299241{
    300   atom *Walker = start;
    301   while (Walker->next != end) {
    302     Walker = Walker->next;
    303     if ((Walker->*condition)(t,u))
    304       (copy->*f)(Walker);
     242  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     243    if (((*iter)->*condition)(t,u))
     244      (copy->*f)((*iter));
    305245  }
    306246};
     
    308248template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
    309249{
    310   atom *Walker = start;
    311   while (Walker->next != end) {
    312     Walker = Walker->next;
    313     if ((Walker->*condition)(t,u,v))
    314       (copy->*f)(Walker);
     250  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     251    if (((*iter)->*condition)(t,u,v))
     252      (copy->*f)((*iter));
    315253  }
    316254};
    317255template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
    318256{
    319   atom *Walker = start;
    320   while (Walker->next != end) {
    321     Walker = Walker->next;
    322     if ((Walker->*condition)(t,u,v))
    323       (copy->*f)(Walker);
     257  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     258    if (((*iter)->*condition)(t,u,v))
     259      (copy->*f)((*iter));
    324260  }
    325261};
    326262template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
    327263{
    328   atom *Walker = start;
    329   while (Walker->next != end) {
    330     Walker = Walker->next;
    331     if ((Walker->*condition)(t,u,v))
    332       (copy->*f)(Walker);
     264  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     265    if (((*iter)->*condition)(t,u,v))
     266      (copy->*f)((*iter));
    333267  }
    334268};
    335269template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
    336270{
    337   atom *Walker = start;
    338   while (Walker->next != end) {
    339     Walker = Walker->next;
    340     if ((Walker->*condition)(t,u,v))
    341       (copy->*f)(Walker);
     271  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     272    if (((*iter)->*condition)(t,u,v))
     273      (copy->*f)((*iter));
    342274  }
    343275};
     
    348280template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const
    349281{
    350   atom *Walker = start;
    351   while (Walker->next != end) {
    352     Walker = Walker->next;
    353     (Walker->*f)();
     282  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     283    ((*iter)->*f)();
    354284  }
    355285};
    356286template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const
    357287{
    358   atom *Walker = start;
    359   while (Walker->next != end) {
    360     Walker = Walker->next;
    361     (Walker->*f)();
     288  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     289    ((*iter)->*f)();
    362290  }
    363291};
     
    365293template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const
    366294{
    367   atom *Walker = start;
    368   while (Walker->next != end) {
    369     Walker = Walker->next;
    370     (Walker->*f)(t);
     295  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     296    ((*iter)->*f)(t);
    371297  }
    372298};
    373299template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const
    374300{
    375   atom *Walker = start;
    376   while (Walker->next != end) {
    377     Walker = Walker->next;
    378     (Walker->*f)(t);
     301  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     302    ((*iter)->*f)(t);
    379303  }
    380304};
     
    382306template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const
    383307{
    384   atom *Walker = start;
    385   while (Walker->next != end) {
    386     Walker = Walker->next;
    387     (Walker->*f)(t, u);
     308  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     309    ((*iter)->*f)(t, u);
    388310  }
    389311};
    390312template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const
    391313{
    392   atom *Walker = start;
    393   while (Walker->next != end) {
    394     Walker = Walker->next;
    395     (Walker->*f)(t, u);
     314  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     315    ((*iter)->*f)(t, u);
    396316  }
    397317};
     
    399319template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const
    400320{
    401   atom *Walker = start;
    402   while (Walker->next != end) {
    403     Walker = Walker->next;
    404     (Walker->*f)(t, u, v);
     321  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     322    ((*iter)->*f)(t, u, v);
    405323  }
    406324};
    407325template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const
    408326{
    409   atom *Walker = start;
    410   while (Walker->next != end) {
    411     Walker = Walker->next;
    412     (Walker->*f)(t, u, v);
     327  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     328    ((*iter)->*f)(t, u, v);
    413329  }
    414330};
     
    416332template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const
    417333{
    418   atom *Walker = start;
    419   while (Walker->next != end) {
    420     Walker = Walker->next;
    421     (Walker->*f)(t, u, v, w);
     334  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     335    ((*iter)->*f)(t, u, v, w);
    422336  }
    423337};
    424338template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const
    425339{
    426   atom *Walker = start;
    427   while (Walker->next != end) {
    428     Walker = Walker->next;
    429     (Walker->*f)(t, u, v, w);
     340  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     341    ((*iter)->*f)(t, u, v, w);
    430342  }
    431343};
     
    436348template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) const
    437349{
    438   atom *Walker = start;
    439350  int inc = 1;
    440   while (Walker->next != end) {
    441     Walker = Walker->next;
    442     (*Setor) (&array[(Walker->*index)], &inc);
     351  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     352    (*Setor) (&array[((*iter)->*index)], &inc);
    443353  }
    444354};
    445355template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) const
    446356{
    447   atom *Walker = start;
    448   while (Walker->next != end) {
    449     Walker = Walker->next;
    450     (*Setor) (&array[(Walker->*index)], &value);
     357  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     358    (*Setor) (&array[((*iter)->*index)], &value);
    451359  }
    452360};
    453361template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) const
    454362{
    455   atom *Walker = start;
    456   while (Walker->next != end) {
    457     Walker = Walker->next;
    458     (*Setor) (&array[(Walker->*index)], value);
     363  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     364    (*Setor) (&array[((*iter)->*index)], value);
    459365  }
    460366};
     
    462368template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) const
    463369{
    464   atom *Walker = start;
    465370  int inc = 1;
    466   while (Walker->next != end) {
    467     Walker = Walker->next;
    468     (*Setor) (&array[(Walker->type->*index)], &inc);
     371  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     372    (*Setor) (&array[((*iter)->type->*index)], &inc);
    469373  }
    470374};
    471375template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) const
    472376{
    473   atom *Walker = start;
    474   while (Walker->next != end) {
    475     Walker = Walker->next;
    476     (*Setor) (&array[(Walker->type->*index)], &value);
     377  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     378    (*Setor) (&array[((*iter)->type->*index)], &value);
    477379  }
    478380};
    479381template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) const
    480382{
    481   atom *Walker = start;
    482   while (Walker->next != end) {
    483     Walker = Walker->next;
    484     (*Setor) (&array[(Walker->type->*index)], value);
     383  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     384    (*Setor) (&array[((*iter)->type->*index)], value);
    485385  }
    486386};
     
    488388template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value ) const
    489389{
    490   atom *Walker = start;
    491   while (Walker->next != end) {
    492     Walker = Walker->next;
    493     array[(Walker->*index)] = (Walker->*Setor) (Walker->*value);
     390  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     391    array[((*iter)->*index)] = ((*iter)->*Setor) ((*iter)->*value);
    494392  }
    495393};
    496394template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value ) const
    497395{
    498   atom *Walker = start;
    499   while (Walker->next != end) {
    500     Walker = Walker->next;
    501     array[(Walker->*index)] = (Walker->*Setor) (Walker->*value);
     396  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     397    array[((*iter)->*index)] = ((*iter)->*Setor) ((*iter)->*value);
    502398  }
    503399};
    504400template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const
    505401{
    506   atom *Walker = start;
    507   while (Walker->next != end) {
    508     Walker = Walker->next;
    509     array[(Walker->*index)] = (Walker->*Setor) (vect);
     402  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     403    array[((*iter)->*index)] = ((*iter)->*Setor) (vect);
    510404  }
    511405};
    512406template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const
    513407{
    514   atom *Walker = start;
    515   while (Walker->next != end) {
    516     Walker = Walker->next;
    517     array[(Walker->*index)] = (Walker->*Setor) (vect);
     408  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     409    array[((*iter)->*index)] = ((*iter)->*Setor) (vect);
    518410  }
    519411};
    520412template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const
    521413{
    522   atom *Walker = start;
    523   while (Walker->next != end) {
    524     Walker = Walker->next;
    525     Walker->*value = array[(Walker->*index)];
    526     //Log() << Verbose(2) << *Walker << " gets " << (Walker->*value); << endl;
     414  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     415    (*iter)->*value = array[((*iter)->*index)];
     416    //Log() << Verbose(2) << *(*iter) << " gets " << ((*iter)->*value); << endl;
    527417  }
    528418};
     
    530420template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) const
    531421{
    532   atom *Walker = start;
    533   while (Walker->next != end) {
    534     Walker = Walker->next;
    535     Walker->*ptr = value;
    536     //Log() << Verbose(2) << *Walker << " gets " << (Walker->*ptr) << endl;
     422  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     423    (*iter)->*ptr = value;
     424    //Log() << Verbose(2) << *(*iter) << " gets " << ((*iter)->*ptr) << endl;
    537425  }
    538426};
  • src/moleculelist.cpp

    rc39cc4 rbdb143  
    55 */
    66
     7#include "Helpers/MemDebug.hpp"
     8
    79#include <cstring>
    810
     
    1012#include "atom.hpp"
    1113#include "bond.hpp"
     14#include "bondgraph.hpp"
    1215#include "boundary.hpp"
    1316#include "config.hpp"
     
    2023#include "memoryallocator.hpp"
    2124#include "periodentafel.hpp"
    22 #include "World.hpp"
     25#include "Helpers/Assert.hpp"
     26
     27#include "Helpers/Assert.hpp"
    2328
    2429/*********************************** Functions for class MoleculeListClass *************************/
     
    2732 */
    2833MoleculeListClass::MoleculeListClass(World *_world) :
     34  Observable("MoleculeListClass"),
    2935  world(_world)
    3036{
     
    3844MoleculeListClass::~MoleculeListClass()
    3945{
    40   DoLog(3) && (Log() << Verbose(3) << this << ": Freeing ListOfMolcules." << endl);
    41   for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
    42     DoLog(4) && (Log() << Verbose(4) << "ListOfMolecules: Freeing " << *ListRunner << "." << endl);
    43     world->destroyMolecule(*ListRunner);
    44   }
    45   DoLog(4) && (Log() << Verbose(4) << "Freeing ListOfMolecules." << endl);
     46  DoLog(4) && (Log() << Verbose(4) << "Clearing ListOfMolecules." << endl);
     47  for(MoleculeList::iterator MolRunner = ListOfMolecules.begin(); MolRunner != ListOfMolecules.end(); ++MolRunner)
     48    (*MolRunner)->signOff(this);
    4649  ListOfMolecules.clear(); // empty list
    4750};
     
    4952/** Insert a new molecule into the list and set its number.
    5053 * \param *mol molecule to add to list.
    51  * \return true - add successful
    5254 */
    5355void MoleculeListClass::insert(molecule *mol)
     
    5961};
    6062
     63/** Erases a molecule from the list.
     64 * \param *mol molecule to add to list.
     65 */
     66void MoleculeListClass::erase(molecule *mol)
     67{
     68  OBSERVE;
     69  mol->signOff(this);
     70  ListOfMolecules.remove(mol);
     71};
     72
    6173/** Compare whether two molecules are equal.
    6274 * \param *a molecule one
     
    6981  int Count, Counter, aCounter, bCounter;
    7082  int flag;
    71   atom *aWalker = NULL;
    72   atom *bWalker = NULL;
    7383
    7484  // sort each atom list and put the numbers into a list, then go through
    7585  //Log() << Verbose(0) << "Comparing fragment no. " << *(molecule **)a << " to " << *(molecule **)b << "." << endl;
    76   if ((**(molecule **) a).AtomCount < (**(molecule **) b).AtomCount) {
     86  // Yes those types are awkward... but check it for yourself it checks out this way
     87  molecule *const *mol1_ptr= static_cast<molecule *const *>(a);
     88  molecule *mol1 = *mol1_ptr;
     89  molecule *const *mol2_ptr= static_cast<molecule *const *>(b);
     90  molecule *mol2 = *mol2_ptr;
     91  if (mol1->getAtomCount() < mol2->getAtomCount()) {
    7792    return -1;
    7893  } else {
    79     if ((**(molecule **) a).AtomCount > (**(molecule **) b).AtomCount)
     94    if (mol1->getAtomCount() > mol2->getAtomCount())
    8095      return +1;
    8196    else {
    82       Count = (**(molecule **) a).AtomCount;
     97      Count = mol1->getAtomCount();
    8398      aList = new int[Count];
    8499      bList = new int[Count];
    85100
    86101      // fill the lists
    87       aWalker = (**(molecule **) a).start;
    88       bWalker = (**(molecule **) b).start;
    89102      Counter = 0;
    90103      aCounter = 0;
    91104      bCounter = 0;
    92       while ((aWalker->next != (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {
    93         aWalker = aWalker->next;
    94         bWalker = bWalker->next;
    95         if (aWalker->GetTrueFather() == NULL)
     105      molecule::const_iterator aiter = mol1->begin();
     106      molecule::const_iterator biter = mol2->begin();
     107      for (;(aiter != mol1->end()) && (biter != mol2->end());
     108          ++aiter, ++biter) {
     109        if ((*aiter)->GetTrueFather() == NULL)
    96110          aList[Counter] = Count + (aCounter++);
    97111        else
    98           aList[Counter] = aWalker->GetTrueFather()->nr;
    99         if (bWalker->GetTrueFather() == NULL)
     112          aList[Counter] = (*aiter)->GetTrueFather()->nr;
     113        if ((*biter)->GetTrueFather() == NULL)
    100114          bList[Counter] = Count + (bCounter++);
    101115        else
    102           bList[Counter] = bWalker->GetTrueFather()->nr;
     116          bList[Counter] = (*biter)->GetTrueFather()->nr;
    103117        Counter++;
    104118      }
    105119      // check if AtomCount was for real
    106120      flag = 0;
    107       if ((aWalker->next == (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {
     121      if ((aiter == mol1->end()) && (biter != mol2->end())) {
    108122        flag = -1;
    109123      } else {
    110         if ((aWalker->next != (**(molecule **) a).end) && (bWalker->next == (**(molecule **) b).end))
     124        if ((aiter != mol1->end()) && (biter == mol2->end()))
    111125          flag = 1;
    112126      }
     
    142156void MoleculeListClass::Enumerate(ostream *out)
    143157{
    144   atom *Walker = NULL;
    145158  periodentafel *periode = World::getInstance().getPeriode();
    146159  std::map<atomicNumber_t,unsigned int> counts;
     
    158171      // count atoms per element and determine size of bounding sphere
    159172      size=0.;
    160       Walker = (*ListRunner)->start;
    161       while (Walker->next != (*ListRunner)->end) {
    162         Walker = Walker->next;
    163         counts[Walker->type->getNumber()]++;
    164         if (Walker->x.DistanceSquared(Origin) > size)
    165           size = Walker->x.DistanceSquared(Origin);
     173      for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
     174        counts[(*iter)->type->getNumber()]++;
     175        if ((*iter)->x.DistanceSquared(Origin) > size)
     176          size = (*iter)->x.DistanceSquared(Origin);
    166177      }
    167178      // output Index, Name, number of atoms, chemical formula
    168       (*out) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->AtomCount << "\t";
     179      (*out) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->getAtomCount() << "\t";
    169180
    170181      std::map<atomicNumber_t,unsigned int>::reverse_iterator iter;
     
    202213
    203214  // put all molecules of src into mol
    204   atom *Walker = srcmol->start;
    205   atom *NextAtom = Walker->next;
    206   while (NextAtom != srcmol->end) {
    207     Walker = NextAtom;
    208     NextAtom = Walker->next;
     215  for (molecule::iterator iter = srcmol->begin(); !srcmol->empty(); iter=srcmol->begin()) {
     216    atom * const Walker = *iter;
    209217    srcmol->UnlinkAtom(Walker);
    210218    mol->AddAtom(Walker);
     
    228236
    229237  // put all molecules of src into mol
    230   atom *Walker = srcmol->start;
    231   atom *NextAtom = Walker->next;
    232   while (NextAtom != srcmol->end) {
    233     Walker = NextAtom;
    234     NextAtom = Walker->next;
    235     Walker = mol->AddCopyAtom(Walker);
     238  atom *Walker = NULL;
     239  for (molecule::iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) {
     240    Walker = mol->AddCopyAtom((*iter));
    236241    Walker->father = Walker;
    237242  }
     
    254259    status = status && SimpleMerge(mol, srcmol);
    255260  }
     261  insert(mol);
    256262  return status;
    257263};
     
    330336
    331337  // prepare index list for bonds
    332   srcmol->CountAtoms();
    333   atom ** CopyAtoms = new atom*[srcmol->AtomCount];
    334   for(int i=0;i<srcmol->AtomCount;i++)
     338  atom ** CopyAtoms = new atom*[srcmol->getAtomCount()];
     339  for(int i=0;i<srcmol->getAtomCount();i++)
    335340    CopyAtoms[i] = NULL;
    336341
    337342  // for each of the source atoms check whether we are in- or outside and add copy atom
    338   atom *Walker = srcmol->start;
    339343  int nr=0;
    340   while (Walker->next != srcmol->end) {
    341     Walker = Walker->next;
    342     DoLog(2) && (Log() << Verbose(2) << "INFO: Current Walker is " << *Walker << "." << endl);
    343     if (!TesselStruct->IsInnerPoint(Walker->x, LCList)) {
    344       CopyAtoms[Walker->nr] = Walker->clone();
    345       mol->AddAtom(CopyAtoms[Walker->nr]);
     344  for (molecule::const_iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) {
     345    DoLog(2) && (Log() << Verbose(2) << "INFO: Current Walker is " << **iter << "." << endl);
     346    if (!TesselStruct->IsInnerPoint((*iter)->x, LCList)) {
     347      CopyAtoms[(*iter)->nr] = (*iter)->clone();
     348      mol->AddAtom(CopyAtoms[(*iter)->nr]);
    346349      nr++;
    347350    } else {
     
    349352    }
    350353  }
    351   DoLog(1) && (Log() << Verbose(1) << nr << " of " << srcmol->AtomCount << " atoms have been merged.");
     354  DoLog(1) && (Log() << Verbose(1) << nr << " of " << srcmol->getAtomCount() << " atoms have been merged.");
    352355
    353356  // go through all bonds and add as well
    354   bond *Binder = srcmol->first;
    355   while(Binder->next != srcmol->last) {
    356     Binder = Binder->next;
    357     DoLog(3) && (Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl);
    358     mol->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
    359   }
     357  for(molecule::iterator AtomRunner = srcmol->begin(); AtomRunner != srcmol->end(); ++AtomRunner)
     358    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     359      if ((*BondRunner)->leftatom == *AtomRunner) {
     360        DoLog(3) && (Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[(*BondRunner)->leftatom->nr] << " and " << *CopyAtoms[(*BondRunner)->rightatom->nr]<< "." << endl);
     361        mol->AddBond(CopyAtoms[(*BondRunner)->leftatom->nr], CopyAtoms[(*BondRunner)->rightatom->nr], (*BondRunner)->BondDegree);
     362      }
    360363  delete(LCList);
    361364  return true;
     
    377380 * bonded to the same atom, then we add for this pair a correction term constructed from a Morse
    378381 * potential function fit to QM calculations with respecting to the interatomic hydrogen distance.
    379  * \param *out output stream for debugging
    380  * \param *path path to file
    381  */
    382 bool MoleculeListClass::AddHydrogenCorrection(char *path)
    383 {
    384   atom *Walker = NULL;
    385   atom *Runner = NULL;
     382 * \param &path path to file
     383 */
     384bool MoleculeListClass::AddHydrogenCorrection(std::string &path)
     385{
    386386  bond *Binder = NULL;
    387387  double ***FitConstant = NULL, **correction = NULL;
     
    400400  // 0a. find dimension of matrices with constants
    401401  line = path;
    402   line.append("/");
    403   line += FRAGMENTPREFIX;
    404402  line += "1";
    405403  line += FITCONSTANTSUFFIX;
    406404  input.open(line.c_str());
    407   if (input == NULL) {
     405  if (input.fail()) {
    408406    DoLog(1) && (Log() << Verbose(1) << endl << "Unable to open " << line << ", is the directory correct?" << endl);
    409407    return false;
     
    427425
    428426  // 0b. allocate memory for constants
    429   FitConstant = Calloc<double**>(3, "MoleculeListClass::AddHydrogenCorrection: ***FitConstant");
     427  FitConstant = new double**[3];
    430428  for (int k = 0; k < 3; k++) {
    431     FitConstant[k] = Calloc<double*>(a, "MoleculeListClass::AddHydrogenCorrection: **FitConstant[]");
     429    FitConstant[k] = new double*[a];
    432430    for (int i = a; i--;) {
    433       FitConstant[k][i] = Calloc<double>(b, "MoleculeListClass::AddHydrogenCorrection: *FitConstant[][]");
     431      FitConstant[k][i] = new double[b];
     432      for (int j = b; j--;) {
     433        FitConstant[k][i][j] = 0.;
     434      }
    434435    }
    435436  }
     
    477478
    478479  // 0d. allocate final correction matrix
    479   correction = Calloc<double*>(a, "MoleculeListClass::AddHydrogenCorrection: **correction");
     480  correction = new double*[a];
    480481  for (int i = a; i--;)
    481     correction[i] = Calloc<double>(b, "MoleculeListClass::AddHydrogenCorrection: *correction[]");
     482    correction[i] = new double[b];
    482483
    483484  // 1a. go through every molecule in the list
     
    488489        correction[k][j] = 0.;
    489490    // 2. take every hydrogen that is a saturated one
    490     Walker = (*ListRunner)->start;
    491     while (Walker->next != (*ListRunner)->end) {
    492       Walker = Walker->next;
    493       //Log() << Verbose(1) << "Walker: " << *Walker << " with first bond " << *(Walker->ListOfBonds.begin()) << "." << endl;
    494       if ((Walker->type->Z == 1) && ((Walker->father == NULL)
    495           || (Walker->father->type->Z != 1))) { // if it's a hydrogen
    496         Runner = (*ListRunner)->start;
    497         while (Runner->next != (*ListRunner)->end) {
    498           Runner = Runner->next;
    499           //Log() << Verbose(2) << "Runner: " << *Runner << " with first bond " << *(Walker->ListOfBonds.begin()) << "." << endl;
     491    for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
     492      //Log() << Verbose(1) << "(*iter): " << *(*iter) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl;
     493      if (((*iter)->type->Z == 1) && (((*iter)->father == NULL)
     494          || ((*iter)->father->type->Z != 1))) { // if it's a hydrogen
     495        for (molecule::const_iterator runner = (*ListRunner)->begin(); runner != (*ListRunner)->end(); ++runner) {
     496          //Log() << Verbose(2) << "Runner: " << *(*runner) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl;
    500497          // 3. take every other hydrogen that is the not the first and not bound to same bonding partner
    501           Binder = *(Runner->ListOfBonds.begin());
    502           if ((Runner->type->Z == 1) && (Runner->nr > Walker->nr) && (Binder->GetOtherAtom(Runner) != Binder->GetOtherAtom(Walker))) { // (hydrogens have only one bonding partner!)
     498          Binder = *((*runner)->ListOfBonds.begin());
     499          if (((*runner)->type->Z == 1) && ((*runner)->nr > (*iter)->nr) && (Binder->GetOtherAtom((*runner)) != Binder->GetOtherAtom((*iter)))) { // (hydrogens have only one bonding partner!)
    503500            // 4. evaluate the morse potential for each matrix component and add up
    504             distance = Runner->x.distance(Walker->x);
    505             //Log() << Verbose(0) << "Fragment " << (*ListRunner)->name << ": " << *Runner << "<= " << distance << "=>" << *Walker << ":" << endl;
     501            distance = (*runner)->x.distance((*iter)->x);
     502            //Log() << Verbose(0) << "Fragment " << (*ListRunner)->name << ": " << *(*runner) << "<= " << distance << "=>" << *(*iter) << ":" << endl;
    506503            for (int k = 0; k < a; k++) {
    507504              for (int j = 0; j < b; j++) {
     
    531528    FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), (*ListRunner)->IndexNr);
    532529    line += FragmentNumber;
    533     delete (FragmentNumber);
     530    delete[] (FragmentNumber);
    534531    line += HCORRECTIONSUFFIX;
    535532    output.open(line.c_str());
     
    542539    output.close();
    543540  }
     541  for (int i = a; i--;)
     542    delete[](correction[i]);
     543  delete[](correction);
     544
    544545  line = path;
    545546  line.append("/");
     
    556557  for (int k = 0; k < 3; k++) {
    557558    for (int i = a; i--;) {
    558       Free(&FitConstant[k][i]);
    559     }
    560     Free(&FitConstant[k]);
    561   }
    562   Free(&FitConstant);
     559      delete[](FitConstant[k][i]);
     560    }
     561    delete[](FitConstant[k]);
     562  }
     563  delete[](FitConstant);
    563564  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    564565  return true;
     
    566567
    567568/** Store force indices, i.e. the connection between the nuclear index in the total molecule config and the respective atom in fragment config.
    568  * \param *out output stream for debugging
    569  * \param *path path to file
     569 * \param &path path to file
    570570 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config
    571571 * \return true - file written successfully, false - writing failed
    572572 */
    573 bool MoleculeListClass::StoreForcesFile(char *path,
    574     int *SortIndex)
     573bool MoleculeListClass::StoreForcesFile(std::string &path, int *SortIndex)
    575574{
    576575  bool status = true;
    577   ofstream ForcesFile;
    578   stringstream line;
    579   atom *Walker = NULL;
     576  string filename(path);
     577  filename += FORCESFILE;
     578  ofstream ForcesFile(filename.c_str());
    580579  periodentafel *periode=World::getInstance().getPeriode();
    581580
    582581  // open file for the force factors
    583582  DoLog(1) && (Log() << Verbose(1) << "Saving  force factors ... ");
    584   line << path << "/" << FRAGMENTPREFIX << FORCESFILE;
    585   ForcesFile.open(line.str().c_str(), ios::out);
    586   if (ForcesFile != NULL) {
     583  if (!ForcesFile.fail()) {
    587584    //Log() << Verbose(1) << "Final AtomicForcesList: ";
    588585    //output << prefix << "Forces" << endl;
     
    590587      periodentafel::const_iterator elemIter;
    591588      for(elemIter=periode->begin();elemIter!=periode->end();++elemIter){
    592           if ((*ListRunner)->ElementsInMolecule[(*elemIter).first]) { // if this element got atoms
    593           Walker = (*ListRunner)->start;
    594           while (Walker->next != (*ListRunner)->end) { // go through every atom of this element
    595             Walker = Walker->next;
    596             if (Walker->type->getNumber() == (*elemIter).first) {
    597               if ((Walker->GetTrueFather() != NULL) && (Walker->GetTrueFather() != Walker)) {// if there is a rea
     589        if ((*ListRunner)->ElementsInMolecule[(*elemIter).first]) { // if this element got atoms
     590          for(molecule::iterator atomIter = (*ListRunner)->begin(); atomIter !=(*ListRunner)->end();++atomIter){
     591            if ((*atomIter)->type->getNumber() == (*elemIter).first) {
     592              if (((*atomIter)->GetTrueFather() != NULL) && ((*atomIter)->GetTrueFather() != (*atomIter))) {// if there is a rea
    598593                //Log() << Verbose(0) << "Walker is " << *Walker << " with true father " << *( Walker->GetTrueFather()) << ", it
    599                 ForcesFile << SortIndex[Walker->GetTrueFather()->nr] << "\t";
     594                ForcesFile << SortIndex[(*atomIter)->GetTrueFather()->nr] << "\t";
    600595              } else
    601596                // otherwise a -1 to indicate an added saturation hydrogen
     
    611606  } else {
    612607    status = false;
    613     DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
     608    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << filename << "." << endl);
    614609  }
    615610  ForcesFile.close();
     
    620615/** Writes a config file for each molecule in the given \a **FragmentList.
    621616 * \param *out output stream for debugging
    622  * \param *configuration standard configuration to attach atoms in fragment molecule to.
     617 * \param &prefix path and prefix to the fragment config files
    623618 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config
    624  * \param DoPeriodic true - call ScanForPeriodicCorrection, false - don't
    625  * \param DoCentering true - call molecule::CenterEdge(), false - don't
    626619 * \return true - success (each file was written), false - something went wrong.
    627620 */
    628 bool MoleculeListClass::OutputConfigForListOfFragments(config *configuration, int *SortIndex)
     621bool MoleculeListClass::OutputConfigForListOfFragments(std::string &prefix, int *SortIndex)
    629622{
    630623  ofstream outputFragment;
    631   char FragmentName[MAXSTRINGSIZE];
     624  std::string FragmentName;
    632625  char PathBackup[MAXSTRINGSIZE];
    633626  bool result = true;
    634627  bool intermediateResult = true;
    635   atom *Walker = NULL;
    636628  Vector BoxDimension;
    637629  char *FragmentNumber = NULL;
     
    648640  for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
    649641    // save default path as it is changed for each fragment
    650     path = configuration->GetDefaultPath();
     642    path = World::getInstance().getConfig()->GetDefaultPath();
    651643    if (path != NULL)
    652644      strcpy(PathBackup, path);
     
    661653    // output xyz file
    662654    FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), FragmentCounter++);
    663     sprintf(FragmentName, "%s/%s%s.conf.xyz", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
    664     outputFragment.open(FragmentName, ios::out);
     655    FragmentName = prefix + FragmentNumber + ".conf.xyz";
     656    outputFragment.open(FragmentName.c_str(), ios::out);
    665657    DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as XYZ ...");
    666658    if ((intermediateResult = (*ListRunner)->OutputXYZ(&outputFragment)))
     
    674666    // list atoms in fragment for debugging
    675667    DoLog(2) && (Log() << Verbose(2) << "Contained atoms: ");
    676     Walker = (*ListRunner)->start;
    677     while (Walker->next != (*ListRunner)->end) {
    678       Walker = Walker->next;
    679       DoLog(0) && (Log() << Verbose(0) << Walker->getName() << " ");
     668    for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
     669      DoLog(0) && (Log() << Verbose(0) << (*iter)->getName() << " ");
    680670    }
    681671    DoLog(0) && (Log() << Verbose(0) << endl);
     
    687677    for (int k = 0; k < NDIM; k++) {
    688678      j += k + 1;
    689       BoxDimension[k] = 2.5 * (configuration->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);
     679      BoxDimension[k] = 2.5 * (World::getInstance().getConfig()->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);
    690680      cell_size[j] = BoxDimension[k] * 2.;
    691681    }
     
    694684    // also calculate necessary orbitals
    695685    (*ListRunner)->CountElements(); // this is a bugfix, atoms should shoulds actually be added correctly to this fragment
    696     (*ListRunner)->CalculateOrbitals(*configuration);
     686    //(*ListRunner)->CalculateOrbitals(*World::getInstance().getConfig);
    697687
    698688    // change path in config
    699     //strcpy(PathBackup, configuration->configpath);
    700     sprintf(FragmentName, "%s/%s%s/", PathBackup, FRAGMENTPREFIX, FragmentNumber);
    701     configuration->SetDefaultPath(FragmentName);
     689    FragmentName = PathBackup;
     690    FragmentName += "/";
     691    FragmentName += FRAGMENTPREFIX;
     692    FragmentName += FragmentNumber;
     693    FragmentName += "/";
     694    World::getInstance().getConfig()->SetDefaultPath(FragmentName.c_str());
    702695
    703696    // and save as config
    704     sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
     697    FragmentName = prefix + FragmentNumber + ".conf";
    705698    DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as config ...");
    706     if ((intermediateResult = configuration->Save(FragmentName, (*ListRunner)->elemente, (*ListRunner))))
     699    if ((intermediateResult = World::getInstance().getConfig()->Save(FragmentName.c_str(), (*ListRunner)->elemente, (*ListRunner))))
    707700      DoLog(0) && (Log() << Verbose(0) << " done." << endl);
    708701    else
     
    711704
    712705    // restore old config
    713     configuration->SetDefaultPath(PathBackup);
     706    World::getInstance().getConfig()->SetDefaultPath(PathBackup);
    714707
    715708    // and save as mpqc input file
    716     sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
     709    FragmentName = prefix + FragmentNumber + ".conf";
    717710    DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as mpqc input ...");
    718     if ((intermediateResult = configuration->SaveMPQC(FragmentName, (*ListRunner))))
     711    if ((intermediateResult = World::getInstance().getConfig()->SaveMPQC(FragmentName.c_str(), (*ListRunner))))
    719712      DoLog(2) && (Log() << Verbose(2) << " done." << endl);
    720713    else
     
    724717    //outputFragment.close();
    725718    //outputFragment.clear();
    726     Free(&FragmentNumber);
     719    delete[](FragmentNumber);
    727720  }
    728721  DoLog(0) && (Log() << Verbose(0) << " done." << endl);
     
    756749void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration)
    757750{
     751  // 0a. remove all present molecules
     752  vector<molecule *> allmolecules = World::getInstance().getAllMolecules();
     753  for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) {
     754    erase(*MolRunner);
     755    World::getInstance().destroyMolecule(*MolRunner);
     756  }
     757  // 0b. remove all bonds and construct a molecule with all atoms
    758758  molecule *mol = World::getInstance().createMolecule();
    759   atom *Walker = NULL;
    760   atom *Advancer = NULL;
    761   bond *Binder = NULL;
    762   bond *Stepper = NULL;
    763   // 0. gather all atoms into single molecule
    764   for (MoleculeList::iterator MolRunner = ListOfMolecules.begin(); !ListOfMolecules.empty(); MolRunner = ListOfMolecules.begin()) {
    765     // shift all atoms to new molecule
    766     Advancer = (*MolRunner)->start->next;
    767     while (Advancer != (*MolRunner)->end) {
    768       Walker = Advancer;
    769       Advancer = Advancer->next;
    770       DoLog(3) && (Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl);
    771       unlink(Walker);
    772       Walker->father = Walker;
    773       mol->AddAtom(Walker);    // counting starts at 1
    774     }
    775     // remove all bonds
    776     Stepper = (*MolRunner)->first->next;
    777     while (Stepper != (*MolRunner)->last) {
    778       Binder = Stepper;
    779       Stepper = Stepper->next;
    780       delete(Binder);
    781     }
    782     // remove the molecule
    783     World::getInstance().destroyMolecule(*MolRunner);
    784     ListOfMolecules.erase(MolRunner);
     759  vector <atom *> allatoms = World::getInstance().getAllAtoms();
     760  for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
     761    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     762      delete(*BondRunner);
     763    mol->AddAtom(*AtomRunner);
    785764  }
    786765
    787766  // 1. dissect the molecule into connected subgraphs
    788   if (!configuration->BG->ConstructBondGraph(mol)) {
    789     World::getInstance().destroyMolecule(mol);
    790     DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl);
     767  if (configuration->BG != NULL) {
     768    if (!configuration->BG->ConstructBondGraph(mol)) {
     769      World::getInstance().destroyMolecule(mol);
     770      DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl);
     771      return;
     772    }
     773  } else {
     774    DoeLog(1) && (eLog()<< Verbose(1) << "There is no BondGraph class present to create bonds." << endl);
    791775    return;
    792776  }
     
    810794  const int MolCount = Subgraphs->next->Count();
    811795  char number[MAXSTRINGSIZE];
    812   molecule **molecules = Malloc<molecule *>(MolCount, "config::Load() - **molecules");
     796  molecule **molecules = new molecule *[MolCount];
     797  MoleculeLeafClass *MolecularWalker = Subgraphs;
    813798  for (int i=0;i<MolCount;i++) {
     799    MolecularWalker = MolecularWalker->next;
    814800    molecules[i] = World::getInstance().createMolecule();
    815801    molecules[i]->ActiveFlag = true;
     
    819805      strncat(molecules[i]->name, number, MAXSTRINGSIZE - strlen(mol->name) - 1);
    820806    }
    821     DoLog(1) && (Log() << Verbose(1) << "MolName is " << molecules[i]->name << endl);
     807    DoLog(1) && (Log() << Verbose(1) << "MolName is " << molecules[i]->name << ", id is " << molecules[i]->getId() << endl);
     808    for (molecule::iterator iter = MolecularWalker->Leaf->begin(); iter != MolecularWalker->Leaf->end(); ++iter) {
     809      DoLog(1) && (Log() << Verbose(1) << **iter << endl);
     810    }
    822811    insert(molecules[i]);
    823812  }
     
    825814  // 4b. create and fill map of which atom is associated to which connected molecule (note, counting starts at 1)
    826815  int FragmentCounter = 0;
    827   int *MolMap = Calloc<int>(mol->AtomCount, "config::Load() - *MolMap");
    828   MoleculeLeafClass *MolecularWalker = Subgraphs;
    829   Walker = NULL;
     816  map<int, atom *> AtomToFragmentMap;
     817  MolecularWalker = Subgraphs;
    830818  while (MolecularWalker->next != NULL) {
    831819    MolecularWalker = MolecularWalker->next;
    832     Walker = MolecularWalker->Leaf->start;
    833     while (Walker->next != MolecularWalker->Leaf->end) {
    834       Walker = Walker->next;
    835       MolMap[Walker->GetTrueFather()->nr] = FragmentCounter+1;
     820    for (molecule::iterator iter = MolecularWalker->Leaf->begin(); !MolecularWalker->Leaf->empty(); iter = MolecularWalker->Leaf->begin()) {
     821      atom * Walker = *iter;
     822      DoLog(1) && (Log() << Verbose(1) << "Re-linking " << Walker << "..." << endl);
     823      MolecularWalker->Leaf->erase(iter);
     824      molecules[FragmentCounter]->AddAtom(Walker);    // counting starts at 1
    836825    }
    837826    FragmentCounter++;
    838827  }
    839 
    840   // 4c. relocate atoms to new molecules and remove from Leafs
    841   Walker = NULL;
    842   while (mol->start->next != mol->end) {
    843     Walker = mol->start->next;
    844     if ((Walker->nr <0) || (Walker->nr >= mol->AtomCount)) {
    845       DoeLog(0) && (eLog()<< Verbose(0) << "Index of atom " << *Walker << " is invalid!" << endl);
    846       performCriticalExit();
    847     }
    848     FragmentCounter = MolMap[Walker->nr];
    849     if (FragmentCounter != 0) {
    850       DoLog(3) && (Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl);
    851       unlink(Walker);
    852       molecules[FragmentCounter-1]->AddAtom(Walker);    // counting starts at 1
    853     } else {
    854       DoeLog(0) && (eLog()<< Verbose(0) << "Atom " << *Walker << " not associated to molecule!" << endl);
    855       performCriticalExit();
    856     }
    857   }
     828  World::getInstance().destroyMolecule(mol);
     829
    858830  // 4d. we don't need to redo bonds, as they are connected subgraphs and still maintain their ListOfBonds, but we have to remove them from first..last list
    859   Binder = mol->first;
    860   while (mol->first->next != mol->last) {
    861     Binder = mol->first->next;
    862     Walker = Binder->leftatom;
    863     unlink(Binder);
    864     link(Binder,molecules[MolMap[Walker->nr]-1]->last);   // counting starts at 1
    865   }
     831  // TODO: check whether this is really not needed anymore
    866832  // 4e. free Leafs
    867833  MolecularWalker = Subgraphs;
     
    871837  }
    872838  delete(MolecularWalker);
    873   Free(&MolMap);
    874   Free(&molecules);
     839  delete[](molecules);
    875840  DoLog(1) && (Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl);
    876841};
     
    882847int MoleculeListClass::CountAllAtoms() const
    883848{
    884   atom *Walker = NULL;
    885849  int AtomNo = 0;
    886850  for (MoleculeList::const_iterator MolWalker = ListOfMolecules.begin(); MolWalker != ListOfMolecules.end(); MolWalker++) {
    887     Walker = (*MolWalker)->start;
    888     while (Walker->next != (*MolWalker)->end) {
    889       Walker = Walker->next;
    890       AtomNo++;
    891     }
     851    AtomNo += (*MolWalker)->size();
    892852  }
    893853  return AtomNo;
     
    10641024bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList)
    10651025{
    1066   atom *Walker = NULL;
    10671026  atom *OtherWalker = NULL;
    10681027  atom *Father = NULL;
     
    10721031  DoLog(1) && (Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl);
    10731032  // fill ListOfLocalAtoms if NULL was given
    1074   if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) {
     1033  if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) {
    10751034    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
    10761035    return false;
     
    10801039    DoLog(1) && (Log() << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl);
    10811040    // remove every bond from the list
    1082     bond *Binder = NULL;
    1083     while (Leaf->last->previous != Leaf->first) {
    1084       Binder = Leaf->last->previous;
    1085       Binder->leftatom->UnregisterBond(Binder);
    1086       Binder->rightatom->UnregisterBond(Binder);
    1087       removewithoutcheck(Binder);
    1088     }
    1089 
    1090     Walker = Leaf->start;
    1091     while (Walker->next != Leaf->end) {
    1092       Walker = Walker->next;
    1093       Father = Walker->GetTrueFather();
     1041    for(molecule::iterator AtomRunner = Leaf->begin(); AtomRunner != Leaf->end(); ++AtomRunner)
     1042      for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     1043        if ((*BondRunner)->leftatom == *AtomRunner)
     1044          delete((*BondRunner));
     1045
     1046    for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) {
     1047      Father = (*iter)->GetTrueFather();
    10941048      AtomNo = Father->nr; // global id of the current walker
    10951049      for (BondList::const_iterator Runner = Father->ListOfBonds.begin(); Runner != Father->ListOfBonds.end(); (++Runner)) {
    1096         OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom(Walker->GetTrueFather())->nr]; // local copy of current bond partner of walker
     1050        OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker
    10971051        if (OtherWalker != NULL) {
    1098           if (OtherWalker->nr > Walker->nr)
    1099             Leaf->AddBond(Walker, OtherWalker, (*Runner)->BondDegree);
     1052          if (OtherWalker->nr > (*iter)->nr)
     1053            Leaf->AddBond((*iter), OtherWalker, (*Runner)->BondDegree);
    11001054        } else {
    1101           DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom(Walker->GetTrueFather())->nr << "] is NULL!" << endl);
     1055          DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr << "] is NULL!" << endl);
    11021056          status = false;
    11031057        }
     
    11081062  if ((FreeList) && (ListOfLocalAtoms != NULL)) {
    11091063    // free the index lookup list
    1110     Free(&ListOfLocalAtoms[FragmentCounter]);
     1064    delete[](ListOfLocalAtoms[FragmentCounter]);
    11111065    if (FragmentCounter == 0) // first fragments frees the initial pointer to list
    1112       Free(&ListOfLocalAtoms);
     1066      delete[](ListOfLocalAtoms);
    11131067  }
    11141068  DoLog(1) && (Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl);
     
    11261080bool MoleculeLeafClass::FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter)
    11271081{
    1128   atom *Walker = NULL, *Father = NULL;
     1082  atom *Father = NULL;
    11291083
    11301084  if (RootStack != NULL) {
     
    11321086    if (&(RootStack[FragmentCounter]) != NULL) {
    11331087      RootStack[FragmentCounter].clear();
    1134       Walker = Leaf->start;
    1135       while (Walker->next != Leaf->end) { // go through all (non-hydrogen) atoms
    1136         Walker = Walker->next;
    1137         Father = Walker->GetTrueFather();
     1088      for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) {
     1089        Father = (*iter)->GetTrueFather();
    11381090        if (AtomMask[Father->nr]) // apply mask
    11391091#ifdef ADDHYDROGEN
    1140           if (Walker->type->Z != 1) // skip hydrogen
     1092          if ((*iter)->type->Z != 1) // skip hydrogen
    11411093#endif
    1142           RootStack[FragmentCounter].push_front(Walker->nr);
     1094          RootStack[FragmentCounter].push_front((*iter)->nr);
    11431095      }
    11441096      if (next != NULL)
     
    11711123    // allocate and set each field to NULL
    11721124    const int Counter = Count();
    1173     ListOfLocalAtoms = Calloc<atom**>(Counter, "MoleculeLeafClass::FillListOfLocalAtoms - ***ListOfLocalAtoms");
     1125    ASSERT(FragmentCounter < Counter, "FillListOfLocalAtoms: FragmenCounter greater than present fragments.");
     1126    ListOfLocalAtoms = new atom**[Counter];
    11741127    if (ListOfLocalAtoms == NULL) {
    11751128      FreeList = FreeList && false;
    11761129      status = false;
    11771130    }
     1131    for (int i=0;i<Counter;i++)
     1132      ListOfLocalAtoms[i] = NULL;
    11781133  }
    11791134
    11801135  if ((ListOfLocalAtoms != NULL) && (ListOfLocalAtoms[FragmentCounter] == NULL)) { // allocate and fill list of this fragment/subgraph
    1181     status = status && CreateFatherLookupTable(Leaf->start, Leaf->end, ListOfLocalAtoms[FragmentCounter], GlobalAtomCount);
     1136    status = status && Leaf->CreateFatherLookupTable(ListOfLocalAtoms[FragmentCounter], GlobalAtomCount);
    11821137    FreeList = FreeList && true;
    11831138  }
     
    12031158  DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl);
    12041159  // fill ListOfLocalAtoms if NULL was given
    1205   if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) {
     1160  if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) {
    12061161    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
    12071162    return false;
     
    12111166  if (FragmentList == NULL) {
    12121167    KeySetCounter = Count();
    1213     FragmentList = Calloc<Graph*>(KeySetCounter, "MoleculeLeafClass::AssignKeySetsToFragment - **FragmentList");
     1168    FragmentList = new Graph*[KeySetCounter];
     1169    for (int i=0;i<KeySetCounter;i++)
     1170      FragmentList[i] = NULL;
    12141171    KeySetCounter = 0;
    12151172  }
     
    12451202  if ((FreeList) && (ListOfLocalAtoms != NULL)) {
    12461203    // free the index lookup list
    1247     Free(&ListOfLocalAtoms[FragmentCounter]);
     1204    delete[](ListOfLocalAtoms[FragmentCounter]);
    12481205    if (FragmentCounter == 0) // first fragments frees the initial pointer to list
    1249       Free(&ListOfLocalAtoms);
     1206      delete[](ListOfLocalAtoms);
    12501207  }
    12511208  DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl);
  • src/orbitals.db

    rc39cc4 rbdb143  
     1# atomicnumber numberoforbitals
    121       1
    232       0
  • src/parser.cpp

    rc39cc4 rbdb143  
    66
    77// ======================================= INCLUDES ==========================================
     8
     9#include "Helpers/MemDebug.hpp"
    810
    911#include <cstring>
     
    5961MatrixContainer::MatrixContainer() {
    6062  Indices = NULL;
    61   Header = Malloc<char*>(1, "MatrixContainer::MatrixContainer: **Header");
    62   Matrix = Malloc<double**>(1, "MatrixContainer::MatrixContainer: ***Matrix"); // one more each for the total molecule
    63   RowCounter = Malloc<int>(1, "MatrixContainer::MatrixContainer: *RowCounter");
    64   ColumnCounter = Malloc<int>(1, "MatrixContainer::MatrixContainer: *ColumnCounter");
     63  Header = new char*[1];
     64  Matrix = new double**[1]; // one more each for the total molecule
     65  RowCounter = new int[1];
     66  ColumnCounter = new int[1];
    6567  Header[0] = NULL;
    6668  Matrix[0] = NULL;
     
    7779      if ((ColumnCounter != NULL) && (RowCounter != NULL)) {
    7880          for(int j=RowCounter[i]+1;j--;)
    79             Free(&Matrix[i][j]);
    80         Free(&Matrix[i]);
     81            delete[](Matrix[i][j]);
     82          delete[](Matrix[i]);
    8183      }
    8284    }
    8385    if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL))
    8486      for(int j=RowCounter[MatrixCounter]+1;j--;)
    85         Free(&Matrix[MatrixCounter][j]);
     87        delete[](Matrix[MatrixCounter][j]);
    8688    if (MatrixCounter != 0)
    87       Free(&Matrix[MatrixCounter]);
    88     Free(&Matrix);
     89      delete[](Matrix[MatrixCounter]);
     90    delete[](Matrix);
    8991  }
    9092  if (Indices != NULL)
    9193    for(int i=MatrixCounter+1;i--;) {
    92       Free(&Indices[i]);
    93     }
    94   Free(&Indices);
     94      delete[](Indices[i]);
     95    }
     96  delete[](Indices);
    9597 
    9698  if (Header != NULL)
    9799    for(int i=MatrixCounter+1;i--;)
    98       Free(&Header[i]);
    99   Free(&Header);
    100   Free(&RowCounter);
    101   Free(&ColumnCounter);
     100      delete[](Header[i]);
     101  delete[](Header);
     102  delete[](RowCounter);
     103  delete[](ColumnCounter);
    102104};
    103105
     
    112114  if (Matrix == NULL) {
    113115    DoLog(0) && (Log() << Verbose(0) << " with trivial mapping." << endl);
    114     Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices");
     116    Indices = new int*[MatrixCounter + 1];
    115117    for(int i=MatrixCounter+1;i--;) {
    116       Indices[i] = Malloc<int>(RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");
     118      Indices[i] = new int[RowCounter[i]];
    117119      for(int j=RowCounter[i];j--;)
    118120        Indices[i][j] = j;
     
    122124    if (MatrixCounter != Matrix->MatrixCounter)
    123125      return false;
    124     Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices");
     126    Indices = new int*[MatrixCounter + 1];
    125127    for(int i=MatrixCounter+1;i--;) {
    126128      if (RowCounter[i] != Matrix->RowCounter[i])
    127129        return false;
    128       Indices[i] = Malloc<int>(Matrix->RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");
     130      Indices[i] = new int[Matrix->RowCounter[i]];
    129131      for(int j=Matrix->RowCounter[i];j--;) {
    130132        Indices[i][j] = Matrix->Indices[i][j];
     
    166168
    167169  // parse header
    168   Header[MatrixNr] = Malloc<char>(1024, "MatrixContainer::ParseMatrix: *Header[]");
     170  Header[MatrixNr] = new char[1024];
    169171  for (int m=skiplines+1;m--;)
    170172    input.getline(Header[MatrixNr], 1023);
     
    205207  // allocate matrix if it's not zero dimension in one direction
    206208  if ((ColumnCounter[MatrixNr] > 0) && (RowCounter[MatrixNr] > -1)) {
    207     Matrix[MatrixNr] = Malloc<double*>(RowCounter[MatrixNr] + 1, "MatrixContainer::ParseMatrix: **Matrix[]");
     209    Matrix[MatrixNr] = new double*[RowCounter[MatrixNr] + 1];
    208210 
    209211    // parse in each entry for this matrix
     
    217219    strncpy(Header[MatrixNr], line.str().c_str(), 1023); 
    218220    for(int j=0;j<RowCounter[MatrixNr];j++) {
    219       Matrix[MatrixNr][j] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[][]");
     221      Matrix[MatrixNr][j] = new double[ColumnCounter[MatrixNr]];
    220222      input.getline(filename, 1023);
    221223      stringstream lines(filename);
     
    227229        //Log() << Verbose(1) << " " << setprecision(2) << Matrix[MatrixNr][j][k] << endl;
    228230      }
    229       Matrix[MatrixNr][ RowCounter[MatrixNr] ] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[RowCounter[MatrixNr]][]");
     231      Matrix[MatrixNr][ RowCounter[MatrixNr] ] = new double[ColumnCounter[MatrixNr]];
    230232      for(int j=ColumnCounter[MatrixNr];j--;)
    231233        Matrix[MatrixNr][ RowCounter[MatrixNr] ][j] = 0.;
     
    281283
    282284  DoLog(0) && (Log() << Verbose(0) << "Parsing through each fragment and retrieving " << prefix << suffix << "." << endl);
    283   Header = ReAlloc<char*>(Header, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: **Header"); // one more each for the total molecule
    284   Matrix = ReAlloc<double**>(Matrix, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: ***Matrix"); // one more each for the total molecule
    285   RowCounter = ReAlloc<int>(RowCounter, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: *RowCounter");
    286   ColumnCounter = ReAlloc<int>(ColumnCounter, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: *ColumnCounter");
     285  delete[](Header);
     286  delete[](Matrix);
     287  delete[](RowCounter);
     288  delete[](ColumnCounter);
     289  Header = new char*[MatrixCounter + 1]; // one more each for the total molecule
     290  Matrix = new double**[MatrixCounter + 1]; // one more each for the total molecule
     291  RowCounter = new int[MatrixCounter + 1];
     292  ColumnCounter = new int[MatrixCounter + 1];
    287293  for(int i=MatrixCounter+1;i--;) {
    288294    Matrix[i] = NULL;
     
    298304    if (!ParseMatrix(file.str().c_str(), skiplines, skipcolumns, i))
    299305      return false;
    300     Free(&FragmentNumber);
     306    delete[](FragmentNumber);
    301307  }
    302308  return true;
     
    313319{
    314320  MatrixCounter = MCounter;
    315   Header = Malloc<char*>(MatrixCounter + 1, "MatrixContainer::AllocateMatrix: *Header");
    316   Matrix = Malloc<double**>(MatrixCounter + 1, "MatrixContainer::AllocateMatrix: ***Matrix"); // one more each for the total molecule
    317   RowCounter = Malloc<int>(MatrixCounter + 1, "MatrixContainer::AllocateMatrix: *RowCounter");
    318   ColumnCounter = Malloc<int>(MatrixCounter + 1, "MatrixContainer::AllocateMatrix: *ColumnCounter");
     321  Header = new char*[MatrixCounter + 1];
     322  Matrix = new double**[MatrixCounter + 1]; // one more each for the total molecule
     323  RowCounter = new int[MatrixCounter + 1];
     324  ColumnCounter = new int[MatrixCounter + 1];
    319325  for(int i=MatrixCounter+1;i--;) {
    320     Header[i] = Malloc<char>(1024, "MatrixContainer::AllocateMatrix: *Header[i]");
     326    Header[i] = new char[1024];
    321327    strncpy(Header[i], GivenHeader[i], 1023);
    322328    RowCounter[i] = RCounter[i];
    323329    ColumnCounter[i] = CCounter[i];
    324     Matrix[i] = Malloc<double*>(RowCounter[i] + 1, "MatrixContainer::AllocateMatrix: **Matrix[]");
     330    Matrix[i] = new double*[RowCounter[i] + 1];
    325331    for(int j=RowCounter[i]+1;j--;) {
    326       Matrix[i][j] = Malloc<double>(ColumnCounter[i], "MatrixContainer::AllocateMatrix: *Matrix[][]");
     332      Matrix[i][j] = new double[ColumnCounter[i]];
    327333      for(int k=ColumnCounter[i];k--;)
    328334        Matrix[i][j][k] = 0.;
     
    474480    FragmentNumber = FixedDigitNumber(MatrixCounter, i);
    475481    line << name << FRAGMENTPREFIX << FragmentNumber << "/" << prefix;
    476     Free(&FragmentNumber);
     482    delete[](FragmentNumber);
    477483    output.open(line.str().c_str(), ios::out);
    478484    if (output == NULL) {
     
    530536{
    531537  DoLog(0) && (Log() << Verbose(0) << "Parsing energy indices." << endl);
    532   Indices = Malloc<int*>(MatrixCounter + 1, "EnergyMatrix::ParseIndices: **Indices");
     538  Indices = new int*[MatrixCounter + 1];
    533539  for(int i=MatrixCounter+1;i--;) {
    534     Indices[i] = Malloc<int>(RowCounter[i], "EnergyMatrix::ParseIndices: *Indices[]");
     540    Indices[i] = new int[RowCounter[i]];
    535541    for(int j=RowCounter[i];j--;)
    536542      Indices[i][j] = j;
     
    589595    // allocate last plus one matrix
    590596    DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);
    591     Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
     597    Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1];
    592598    for(int j=0;j<=RowCounter[MatrixCounter];j++)
    593       Matrix[MatrixCounter][j] = Malloc<double>(ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
     599      Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]];
    594600   
    595601    // try independently to parse global energysuffix file if present
     
    616622
    617623  DoLog(0) && (Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl);
    618   Indices = Malloc<int*>(MatrixCounter + 1, "ForceMatrix::ParseIndices: **Indices");
     624  Indices = new int*[MatrixCounter + 1];
    619625  line << name << FRAGMENTPREFIX << FORCESFILE;
    620626  input.open(line.str().c_str(), ios::in);
     
    629635    line.str(filename);
    630636    // parse the values
    631     Indices[i] = Malloc<int>(RowCounter[i], "ForceMatrix::ParseIndices: *Indices[]");
     637    Indices[i] = new int[RowCounter[i]];
    632638    FragmentNumber = FixedDigitNumber(MatrixCounter, i);
    633639    //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:";
    634     Free(&FragmentNumber);
     640    delete[](FragmentNumber);
    635641    for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) {
    636642      line >> Indices[i][j];
     
    639645    //Log() << Verbose(0) << endl;
    640646  }
    641   Indices[MatrixCounter] = Malloc<int>(RowCounter[MatrixCounter], "ForceMatrix::ParseIndices: *Indices[]");
     647  Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]];
    642648  for(int j=RowCounter[MatrixCounter];j--;) {
    643649    Indices[MatrixCounter][j] = j;
     
    725731    // allocate last plus one matrix
    726732    DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);
    727     Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
     733    Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1];
    728734    for(int j=0;j<=RowCounter[MatrixCounter];j++)
    729       Matrix[MatrixCounter][j] = Malloc<double>(ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
     735      Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]];
    730736
    731737    // try independently to parse global forcesuffix file if present
     
    754760 
    755761  DoLog(0) && (Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl);
    756   Indices = Malloc<int*>(MatrixCounter + 1, "HessianMatrix::ParseIndices: **Indices");
     762  Indices = new int*[MatrixCounter + 1];
    757763  line << name << FRAGMENTPREFIX << FORCESFILE;
    758764  input.open(line.str().c_str(), ios::in);
     
    767773    line.str(filename);
    768774    // parse the values
    769     Indices[i] = Malloc<int>(RowCounter[i], "HessianMatrix::ParseIndices: *Indices[]");
     775    Indices[i] = new int[RowCounter[i]];
    770776    FragmentNumber = FixedDigitNumber(MatrixCounter, i);
    771777    //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:";
    772     Free(&FragmentNumber);
     778    delete[](FragmentNumber);
    773779    for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) {
    774780      line >> Indices[i][j];
     
    777783    //Log() << Verbose(0) << endl;
    778784  }
    779   Indices[MatrixCounter] = Malloc<int>(RowCounter[MatrixCounter], "HessianMatrix::ParseIndices: *Indices[]");
     785  Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]];
    780786  for(int j=RowCounter[MatrixCounter];j--;) {
    781787    Indices[MatrixCounter][j] = j;
     
    953959    // allocate last plus one matrix
    954960    DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);
    955     Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
     961    Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1];
    956962    for(int j=0;j<=RowCounter[MatrixCounter];j++)
    957       Matrix[MatrixCounter][j] = Malloc<double>(ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
     963      Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]];
    958964
    959965    // try independently to parse global forcesuffix file if present
     
    985991KeySetsContainer::~KeySetsContainer() {
    986992  for(int i=FragmentCounter;i--;)
    987     Free(&KeySets[i]);
     993    delete[](KeySets[i]);
    988994  for(int i=Order;i--;)
    989     Free(&OrderSet[i]);
    990   Free(&KeySets);
    991   Free(&OrderSet);
    992   Free(&AtomCounter);
    993   Free(&FragmentsPerOrder);
     995    delete[](OrderSet[i]);
     996  delete[](KeySets);
     997  delete[](OrderSet);
     998  delete[](AtomCounter);
     999  delete[](FragmentsPerOrder);
    9941000};
    9951001
     
    10081014  FragmentCounter = FCounter;
    10091015  DoLog(0) && (Log() << Verbose(0) << "Parsing key sets." << endl);
    1010   KeySets = Malloc<int*>(FragmentCounter, "KeySetsContainer::ParseKeySets: **KeySets");
     1016  KeySets = new int*[FragmentCounter];
    10111017  for(int i=FragmentCounter;i--;)
    10121018    KeySets[i] = NULL;
     
    10181024  }
    10191025
    1020   AtomCounter = Malloc<int>(FragmentCounter, "KeySetsContainer::ParseKeySets: *RowCounter");
     1026  AtomCounter = new int[FragmentCounter];
    10211027  for(int i=0;(i<FragmentCounter) && (!input.eof());i++) {
    10221028    stringstream line;
    10231029    AtomCounter[i] = ACounter[i];
    10241030    // parse the values
    1025     KeySets[i] = Malloc<int>(AtomCounter[i], "KeySetsContainer::ParseKeySets: *KeySets[]");
     1031    KeySets[i] = new int[AtomCounter[i]];
    10261032    for(int j=AtomCounter[i];j--;)
    10271033      KeySets[i][j] = -1;
    10281034    FragmentNumber = FixedDigitNumber(FragmentCounter, i);
    10291035    //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << AtomCounter[i] << "]:";
    1030     Free(&FragmentNumber);
     1036    delete[](FragmentNumber);
    10311037    input.getline(filename, 1023);
    10321038    line.str(filename);
     
    10621068
    10631069  // scan through all to determine fragments per order
    1064   FragmentsPerOrder = Malloc<int>(Order, "KeySetsContainer::ParseManyBodyTerms: *FragmentsPerOrder");
     1070  FragmentsPerOrder = new int[Order];
    10651071  for(int i=Order;i--;)
    10661072    FragmentsPerOrder[i] = 0;
     
    10761082
    10771083  // scan through all to gather indices to each order set
    1078   OrderSet = Malloc<int*>(Order, "KeySetsContainer::ParseManyBodyTerms: **OrderSet");
     1084  OrderSet = new int*[Order];
    10791085  for(int i=Order;i--;)
    1080     OrderSet[i] = Malloc<int>(FragmentsPerOrder[i], "KeySetsContainer::ParseManyBodyTermsKeySetsContainer::ParseManyBodyTerms: *OrderSet[]");
     1086    OrderSet[i] = new int[FragmentsPerOrder[i]];
    10811087  for(int i=Order;i--;)
    10821088    FragmentsPerOrder[i] = 0;
  • src/periodentafel.cpp

    rc39cc4 rbdb143  
    55 */
    66
     7#include "Helpers/MemDebug.hpp"
     8
    79using namespace std;
    810
    911#include <iomanip>
     12#include <iostream>
    1013#include <fstream>
    1114#include <cstring>
    12 #include <cassert>
    13 
     15
     16#include "Helpers/Assert.hpp"
    1417#include "element.hpp"
     18#include "elements_db.hpp"
    1519#include "helpers.hpp"
    1620#include "lists.hpp"
     
    2731 */
    2832periodentafel::periodentafel()
    29 {};
     33{
     34  {
     35    stringstream input(elementsDB,ios_base::in);
     36    bool status = LoadElementsDatabase(&input);
     37    ASSERT(status,  "General element initialization failed");
     38  }
     39  {
     40    stringstream input(valenceDB,ios_base::in);
     41    bool status = LoadValenceDatabase(&input);
     42    ASSERT(status, "Valence entry of element initialization failed");
     43  }
     44  {
     45    stringstream input(orbitalsDB,ios_base::in);
     46    bool status = LoadOrbitalsDatabase(&input);
     47    ASSERT(status, "Orbitals entry of element initialization failed");
     48  }
     49  {
     50    stringstream input(HbondangleDB,ios_base::in);
     51    bool status = LoadHBondAngleDatabase(&input);
     52    ASSERT(status, "HBond angle entry of element initialization failed");
     53  }
     54  {
     55    stringstream input(HbonddistanceDB,ios_base::in);
     56    bool status = LoadHBondLengthsDatabase(&input);
     57    ASSERT(status, "HBond distance entry of element initialization failed");
     58  }
     59};
    3060
    3161/** destructor for class periodentafel
    3262 * Removes every element and afterwards deletes start and end of list.
     63 * TODO: Handle when elements have changed and store databases then
    3364 */
    3465periodentafel::~periodentafel()
     
    3970/** Adds element to period table list
    4071 * \param *pointer element to be added
    41  * \return true - succeeded, false - does not occur
     72 * \return iterator to added element
    4273 */
    4374periodentafel::iterator periodentafel::AddElement(element * const pointer)
    4475{
    4576  atomicNumber_t Z = pointer->getNumber();
    46   assert(!elements.count(Z));
     77  ASSERT(!elements.count(Z), "Element is already present.");
    4778  pointer->sort = &pointer->Z;
    4879  if (pointer->getNumber() < 1 && pointer->getNumber() >= MAX_ELEMENTS)
     
    5485/** Removes element from list.
    5586 * \param *pointer element to be removed
    56  * \return true - succeeded, false - element not found
    57  */
    58 void periodentafel::RemoveElement(element * const pointer)
    59 {
    60   atomicNumber_t Z = pointer->getNumber();
    61   elements.erase(Z);
     87 */
     88size_t periodentafel::RemoveElement(element * const pointer)
     89{
     90  return RemoveElement(pointer->getNumber());
     91};
     92
     93/** Removes element from list.
     94 * \param Z element to be removed
     95 */
     96size_t periodentafel::RemoveElement(atomicNumber_t Z)
     97{
     98  return elements.erase(Z);
    6299};
    63100
    64101/** Removes every element from the period table.
    65  * \return true - succeeded, false - does not occur
    66102 */
    67103void periodentafel::CleanupPeriodtable()
     
    78114 * \return pointer to element or NULL if not found
    79115 */
    80 const element * periodentafel::FindElement(atomicNumber_t Z) const
     116element * const periodentafel::FindElement(atomicNumber_t Z) const
    81117{
    82118  const_iterator res = elements.find(Z);
     
    89125 * \return pointer to element
    90126 */
    91 const element * periodentafel::FindElement(const char * const shorthand) const
     127element * const periodentafel::FindElement(const char * const shorthand) const
    92128{
    93129  element *res = 0;
     
    102138
    103139/** Asks for element number and returns pointer to element
    104  */
    105 const element * periodentafel::AskElement() const
    106 {
    107   const element *walker = NULL;
     140 * \return desired element or NULL
     141 */
     142element * const periodentafel::AskElement() const
     143{
     144  element * walker = NULL;
    108145  int Z;
    109146  do {
     
    118155 * \return pointer to either present or newly created element
    119156 */
    120 const element * periodentafel::EnterElement()
    121 {
    122   const element *res = NULL;
     157element * const periodentafel::EnterElement()
     158{
    123159  atomicNumber_t Z = 0;
    124160  DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl);
    125161  cin >> Z;
    126   res = FindElement(Z);
     162  element * const res = FindElement(Z);
    127163  if (!res) {
    128164    // TODO: make this using the constructor
    129     element *tmp;
    130165    DoLog(0) && (Log() << Verbose(0) << "Element not found in database, please enter." << endl);
    131     tmp = new element;
     166    element *tmp = new element;
    132167    tmp->Z = Z;
    133168    DoLog(0) && (Log() << Verbose(0) << "Mass: " << endl);
     
    138173    cin >> tmp->symbol;
    139174    AddElement(tmp);
    140     res = tmp;
     175    return tmp;
    141176  }
    142177  return res;
     
    204239bool periodentafel::LoadPeriodentafel(const char *path)
    205240{
    206   ifstream infile;
    207   element *ptr;
    208   map<atomicNumber_t,element*> parsedElems;
     241  ifstream input;
    209242  bool status = true;
    210243  bool otherstatus = true;
     
    212245
    213246  // fill elements DB
    214   snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDELEMENTSDB);
    215   infile.open(filename);
    216   if (infile != NULL) {
    217     infile.getline(header1, MAXSTRINGSIZE);
    218     infile.getline(header2, MAXSTRINGSIZE); // skip first two header lines
     247  strncpy(filename, path, MAXSTRINGSIZE);
     248  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     249  strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename));
     250  input.open(filename);
     251  if (!input.fail())
     252    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as elements database." << endl);
     253  status = status && LoadElementsDatabase(&input);
     254  input.close();
     255  input.clear();
     256
     257  // fill valence DB per element
     258  strncpy(filename, path, MAXSTRINGSIZE);
     259  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     260  strncat(filename, STANDARDVALENCEDB, MAXSTRINGSIZE-strlen(filename));
     261  input.open(filename);
     262  if (!input.fail())
     263    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as valence database." << endl);
     264  otherstatus = otherstatus && LoadValenceDatabase(&input);
     265  input.close();
     266  input.clear();
     267
     268  // fill orbitals DB per element
     269  strncpy(filename, path, MAXSTRINGSIZE);
     270  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     271  strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename));
     272  input.open(filename);
     273  if (!input.fail())
     274    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as orbitals database." << endl);
     275  otherstatus = otherstatus && LoadOrbitalsDatabase(&input);
     276  input.close();
     277  input.clear();
     278
     279  // fill H-BondAngle DB per element
     280  strncpy(filename, path, MAXSTRINGSIZE);
     281  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     282  strncat(filename, STANDARDHBONDANGLEDB, MAXSTRINGSIZE-strlen(filename));
     283  input.open(filename);
     284  if (!input.fail())
     285    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as H bond angle database." << endl);
     286  otherstatus = otherstatus && LoadHBondAngleDatabase(&input);
     287  input.close();
     288  input.clear();
     289
     290  // fill H-BondDistance DB per element
     291  strncpy(filename, path, MAXSTRINGSIZE);
     292  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     293  strncat(filename, STANDARDHBONDDISTANCEDB, MAXSTRINGSIZE-strlen(filename));
     294  input.open(filename);
     295  if (!input.fail())
     296    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as H bond length database." << endl);
     297  otherstatus = otherstatus && LoadHBondLengthsDatabase(&input);
     298  input.close();
     299  input.clear();
     300
     301  if (!otherstatus){
     302    DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl);
     303  }
     304
     305  return status;
     306};
     307
     308/** load the element info.
     309 * \param *input stream to parse from
     310 * \return true - parsing successful, false - something went wrong
     311 */
     312bool periodentafel::LoadElementsDatabase(istream *input)
     313{
     314  bool status = true;
     315  int counter = 0;
     316  pair< std::map<atomicNumber_t,element*>::iterator, bool > InserterTest;
     317  if (!(*input).fail()) {
     318    (*input).getline(header1, MAXSTRINGSIZE);
     319    (*input).getline(header2, MAXSTRINGSIZE); // skip first two header lines
    219320    DoLog(0) && (Log() << Verbose(0) <<  "Parsed elements:");
    220     while (!infile.eof()) {
     321    while (!(*input).eof()) {
    221322      element *neues = new element;
    222       infile >> neues->name;
    223       //infile >> ws;
    224       infile >> neues->symbol;
    225       //infile >> ws;
    226       infile >> neues->period;
    227       //infile >> ws;
    228       infile >> neues->group;
    229       //infile >> ws;
    230       infile >> neues->block;
    231       //infile >> ws;
    232       infile >> neues->Z;
    233       //infile >> ws;
    234       infile >> neues->mass;
    235       //infile >> ws;
    236       infile >> neues->CovalentRadius;
    237       //infile >> ws;
    238       infile >> neues->VanDerWaalsRadius;
    239       //infile >> ws;
    240       infile >> ws;
    241       DoLog(0) && (Log() << Verbose(0) << " " << neues->symbol);
     323      (*input) >> neues->name;
     324      //(*input) >> ws;
     325      (*input) >> neues->symbol;
     326      //(*input) >> ws;
     327      (*input) >> neues->period;
     328      //(*input) >> ws;
     329      (*input) >> neues->group;
     330      //(*input) >> ws;
     331      (*input) >> neues->block;
     332      //(*input) >> ws;
     333      (*input) >> neues->Z;
     334      //(*input) >> ws;
     335      (*input) >> neues->mass;
     336      //(*input) >> ws;
     337      (*input) >> neues->CovalentRadius;
     338      //(*input) >> ws;
     339      (*input) >> neues->VanDerWaalsRadius;
     340      //(*input) >> ws;
     341      (*input) >> ws;
    242342      //neues->Output((ofstream *)&cout);
    243       if ((neues->Z > 0) && (neues->Z < MAX_ELEMENTS))
    244         parsedElems[neues->getNumber()] = neues;
    245       else {
    246         DoLog(0) && (Log() << Verbose(0) << "Could not parse element: ");
    247         neues->Output((ofstream *)&cout);
     343      if ((neues->getNumber() > 0) && (neues->getNumber() < MAX_ELEMENTS)) {
     344        if (elements.count(neues->getNumber())) {// if element already present, remove and delete old one (i.e. replace it)
     345          //cout << neues->symbol << " is present already." << endl;
     346          element * const Elemental = FindElement(neues->getNumber());
     347          ASSERT(Elemental != NULL, "element should be present but is not??");
     348          *Elemental = *neues;
     349          delete(neues);
     350          neues = Elemental;
     351        } else {
     352          InserterTest = elements.insert(pair <atomicNumber_t,element*> (neues->getNumber(), neues));
     353          ASSERT(InserterTest.second, "Could not insert new element into periodentafel on LoadElementsDatabase().");
     354        }
     355        DoLog(0) && (Log() << Verbose(0) << " " << elements[neues->getNumber()]->symbol);
     356        counter++;
     357      } else {
     358        DoeLog(2) && (eLog() << Verbose(2) << "Detected empty line or invalid element in elements db, discarding." << endl);
     359        DoLog(0) && (Log() << Verbose(0) << " <?>");
    248360        delete(neues);
    249361      }
    250362    }
    251363    DoLog(0) && (Log() << Verbose(0) << endl);
    252     infile.close();
    253     infile.clear();
    254   } else
     364  } else {
     365    DoeLog(1) && (eLog() << Verbose(1) << "Could not open the database." << endl);
    255366    status = false;
    256 
    257   // fill valence DB per element
    258   snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDVALENCEDB);
    259   infile.open(filename);
    260   if (infile != NULL) {
    261     while (!infile.eof()) {
     367  }
     368
     369  if (counter == 0)
     370    status = false;
     371
     372  return status;
     373}
     374
     375/** load the valence info.
     376 * \param *input stream to parse from
     377 * \return true - parsing successful, false - something went wrong
     378 */
     379bool periodentafel::LoadValenceDatabase(istream *input)
     380{
     381  char dummy[MAXSTRINGSIZE];
     382  if (!(*input).fail()) {
     383    (*input).getline(dummy, MAXSTRINGSIZE);
     384    while (!(*input).eof()) {
    262385      atomicNumber_t Z;
    263       infile >> Z;
    264       infile >> ws;
    265       infile >> parsedElems[Z]->Valence;
    266       infile >> ws;
    267       //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->Valence << " valence electrons." << endl;
    268     }
    269     infile.close();
    270     infile.clear();
    271   } else
    272     otherstatus = false;
    273 
    274   // fill valence DB per element
    275   snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDORBITALDB);
    276   infile.open(filename);
    277   if (infile != NULL) {
    278     while (!infile.eof()) {
     386      (*input) >> Z;
     387      ASSERT(elements.count(Z), "Element not present");
     388      (*input) >> ws;
     389      (*input) >> elements[Z]->Valence;
     390      (*input) >> ws;
     391      //Log() << Verbose(3) << "Element " << Z << " has " << FindElement(Z)->Valence << " valence electrons." << endl;
     392    }
     393    return true;
     394  } else
     395                return false;
     396}
     397
     398/** load the orbitals info.
     399 * \param *input stream to parse from
     400 * \return true - parsing successful, false - something went wrong
     401 */
     402bool periodentafel::LoadOrbitalsDatabase(istream *input)
     403{
     404  char dummy[MAXSTRINGSIZE];
     405  if (!(*input).fail()) {
     406    (*input).getline(dummy, MAXSTRINGSIZE);
     407    while (!(*input).eof()) {
    279408      atomicNumber_t Z;
    280       infile >> Z;
    281       infile >> ws;
    282       infile >> parsedElems[Z]->NoValenceOrbitals;
    283       infile >> ws;
    284       //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
    285     }
    286     infile.close();
    287     infile.clear();
    288   } else
    289     otherstatus = false;
    290 
    291   // fill H-BondDistance DB per element
    292   snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDHBONDDISTANCEDB);
    293   infile.open(filename);
    294   if (infile != NULL) {
    295     while (!infile.eof()) {
     409      (*input) >> Z;
     410      ASSERT(elements.count(Z), "Element not present");
     411      (*input) >> ws;
     412      (*input) >> elements[Z]->NoValenceOrbitals;
     413      (*input) >> ws;
     414      //Log() << Verbose(3) << "Element " << Z << " has " << FindElement(Z)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
     415    }
     416    return true;
     417  } else
     418    return false;
     419}
     420
     421/** load the hbond angles info.
     422 * \param *input stream to parse from
     423 * \return true - parsing successful, false - something went wrong
     424 */
     425bool periodentafel::LoadHBondAngleDatabase(istream *input)
     426{
     427  char dummy[MAXSTRINGSIZE];
     428  if (!(*input).fail()) {
     429    (*input).getline(dummy, MAXSTRINGSIZE);
     430    while (!(*input).eof()) {
    296431      atomicNumber_t Z;
    297       infile >> Z;
    298       ptr = parsedElems[Z];
    299       infile >> ws;
    300       infile >> ptr->HBondDistance[0];
    301       infile >> ptr->HBondDistance[1];
    302       infile >> ptr->HBondDistance[2];
    303       infile >> ws;
     432      (*input) >> Z;
     433      ASSERT(elements.count(Z), "Element not present");
     434      (*input) >> ws;
     435      (*input) >> elements[Z]->HBondAngle[0];
     436      (*input) >> elements[Z]->HBondAngle[1];
     437      (*input) >> elements[Z]->HBondAngle[2];
     438      (*input) >> ws;
     439      //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;
     440    }
     441    return true;
     442  } else
     443                return false;
     444}
     445
     446/** load the hbond lengths info.
     447 * \param *input stream to parse from
     448 * \return true - parsing successful, false - something went wrong
     449 */
     450bool periodentafel::LoadHBondLengthsDatabase(istream *input)
     451{
     452  char dummy[MAXSTRINGSIZE];
     453  if (!(*input).fail()) {
     454    (*input).getline(dummy, MAXSTRINGSIZE);
     455    while (!(*input).eof()) {
     456      atomicNumber_t Z;
     457      (*input) >> Z;
     458      ASSERT(elements.count(Z), "Element not present");
     459      (*input) >> ws;
     460      (*input) >> elements[Z]->HBondDistance[0];
     461      (*input) >> elements[Z]->HBondDistance[1];
     462      (*input) >> elements[Z]->HBondDistance[2];
     463      (*input) >> ws;
    304464      //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl;
    305465    }
    306     infile.close();
    307     infile.clear();
    308   } else
    309     otherstatus = false;
    310 
    311   // fill H-BondAngle DB per element
    312   snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDHBONDANGLEDB);
    313   infile.open(filename);
    314   if (infile != NULL) {
    315     while (!infile.eof()) {
    316       atomicNumber_t Z;
    317       infile >> Z;
    318       ptr = parsedElems[Z];
    319       infile >> ws;
    320       infile >> ptr->HBondAngle[0];
    321       infile >> ptr->HBondAngle[1];
    322       infile >> ptr->HBondAngle[2];
    323       infile >> ws;
    324       //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;
    325     }
    326     infile.close();
    327   } else
    328     otherstatus = false;
    329 
    330   if (otherstatus){
    331     map<atomicNumber_t,element*>::iterator iter;
    332     for(iter=parsedElems.begin();iter!=parsedElems.end();++iter){
    333       AddElement((*iter).second);
    334     }
    335   }
    336   else{
    337     DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl);
    338     map<atomicNumber_t,element*>::iterator iter;
    339     for(iter=parsedElems.begin();iter!=parsedElems.end();++iter){
    340       AddElement((*iter).second);
    341     }
    342   }
    343 
    344   return status;
    345 };
     466    return true;
     467  } else
     468                return false;
     469}
    346470
    347471/** Stores element list to file.
     
    353477  char filename[MAXSTRINGSIZE];
    354478
    355   snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDELEMENTSDB);
     479  strncpy(filename, path, MAXSTRINGSIZE);
     480  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     481  strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename));
    356482  f.open(filename);
    357483  if (f != NULL) {
     
    362488    }
    363489    f.close();
    364   } else
    365     result = false;
    366   return result;
    367 };
     490    return true;
     491  } else
     492    return result;
     493};
  • src/periodentafel.hpp

    rc39cc4 rbdb143  
    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;
     
    4244
    4345  iterator AddElement(element * const pointer);
    44   void RemoveElement(element * const pointer);
     46  size_t RemoveElement(element * const pointer);
     47  size_t 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/stackclass.hpp

    rc39cc4 rbdb143  
    5050template <typename T> StackClass<T>::StackClass(int dimension) : StackList(NULL), EntryCount(dimension), CurrentLastEntry(0), CurrentFirstEntry(0), NextFreeField(0)
    5151{
    52   StackList = Calloc<T>(EntryCount, "StackClass::StackClass: **StackList");
     52  StackList = new T[EntryCount];
     53  for (int i=0;i<EntryCount;i++)
     54    StackList[i] = NULL;
    5355};
    5456
     
    5759template <typename T> StackClass<T>::~StackClass()
    5860{
    59   Free(&StackList);
     61  delete[](StackList);
    6062};
    6163
  • src/tesselation.cpp

    rc39cc4 rbdb143  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include <fstream>
    9 #include <assert.h>
    1011
    1112#include "helpers.hpp"
     
    387388  // get ascending order of endpoints
    388389  PointMap OrderMap;
    389   for (int i = 0; i < 3; i++)
     390  for (int i = 0; i < 3; i++) {
    390391    // for all three lines
    391392    for (int j = 0; j < 2; j++) { // for both endpoints
     
    393394      // and we don't care whether insertion fails
    394395    }
     396  }
    395397  // set endpoints
    396398  int Counter = 0;
     
    401403    Counter++;
    402404  }
    403   if (Counter < 3) {
    404     DoeLog(0) && (eLog() << Verbose(0) << "We have a triangle with only two distinct endpoints!" << endl);
    405     performCriticalExit();
    406   }
    407 }
    408 ;
     405  ASSERT(Counter >= 3,"We have a triangle with only two distinct endpoints!");
     406};
     407
    409408
    410409/** Destructor of BoundaryTriangleSet.
     
    12721271;
    12731272
    1274 /** PointCloud implementation of GetTerminalPoint.
    1275  * Uses PointsOnBoundary and STL stuff.
    1276  */
    1277 TesselPoint * Tesselation::GetTerminalPoint() const
    1278 {
    1279   Info FunctionInfo(__func__);
    1280   PointMap::const_iterator Runner = PointsOnBoundary.end();
    1281   Runner--;
    1282   return (Runner->second->node);
    1283 }
    1284 ;
    1285 
    12861273/** PointCloud implementation of GoToNext.
    12871274 * Uses PointsOnBoundary and STL stuff.
     
    12951282;
    12961283
    1297 /** PointCloud implementation of GoToPrevious.
    1298  * Uses PointsOnBoundary and STL stuff.
    1299  */
    1300 void Tesselation::GoToPrevious() const
    1301 {
    1302   Info FunctionInfo(__func__);
    1303   if (InternalPointer != PointsOnBoundary.begin())
    1304     InternalPointer--;
    1305 }
    1306 ;
    1307 
    13081284/** PointCloud implementation of GoToFirst.
    13091285 * Uses PointsOnBoundary and STL stuff.
     
    13131289  Info FunctionInfo(__func__);
    13141290  InternalPointer = PointsOnBoundary.begin();
    1315 }
    1316 ;
    1317 
    1318 /** PointCloud implementation of GoToLast.
    1319  * Uses PointsOnBoundary and STL stuff.
    1320  */
    1321 void Tesselation::GoToLast() const
    1322 {
    1323   Info FunctionInfo(__func__);
    1324   InternalPointer = PointsOnBoundary.end();
    1325   InternalPointer--;
    13261291}
    13271292;
     
    19961961        RemoveTesselationLine(triangle->lines[i]);
    19971962      } else {
    1998         DoLog(0) && (Log() << Verbose(0) << *triangle->lines[i] << " is still attached to another triangle: ");
     1963        DoLog(0) && (Log() << Verbose(0) << *triangle->lines[i] << " is still attached to another triangle: " << endl);
    19991964        OpenLines.insert(pair<BoundaryLineSet *, CandidateForTesselation *> (triangle->lines[i], NULL));
    20001965        for (TriangleMap::iterator TriangleRunner = triangle->lines[i]->triangles.begin(); TriangleRunner != triangle->lines[i]->triangles.end(); TriangleRunner++)
    2001           DoLog(0) && (Log() << Verbose(0) << "[" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t");
     1966          DoLog(0) && (Log() << Verbose(0) << "\t[" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t");
    20021967        DoLog(0) && (Log() << Verbose(0) << endl);
    20031968        //        for (int j=0;j<2;j++) {
     
    26062571    baseline = Runner->second;
    26072572    if (baseline->pointlist.empty()) {
    2608       assert((baseline->BaseLine->triangles.size() == 1) && ("Open line without exactly one attached triangle"));
     2573      ASSERT((baseline->BaseLine->triangles.size() == 1),"Open line without exactly one attached triangle");
    26092574      T = (((baseline->BaseLine->triangles.begin()))->second);
    26102575      DoLog(1) && (Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl);
     
    26332598  // fill the set of neighbours
    26342599  TesselPointSet SetOfNeighbours;
     2600
    26352601  SetOfNeighbours.insert(CandidateLine.BaseLine->endpoints[1]->node);
    26362602  for (TesselPointList::iterator Runner = CandidateLine.pointlist.begin(); Runner != CandidateLine.pointlist.end(); Runner++)
     
    30523018  OldBaseLineNr = Base->Nr;
    30533019  m = 0;
    3054   for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) {
    3055     DoLog(0) && (Log() << Verbose(0) << "INFO: Deleting triangle " << *(runner->second) << "." << endl);
    3056     OldTriangleNrs[m++] = runner->second->Nr;
    3057     RemoveTesselationTriangle(runner->second);
     3020  // first obtain all triangle to delete ... (otherwise we pull the carpet (Base) from under the for-loop's feet)
     3021  list <BoundaryTriangleSet *> TrianglesOfBase;
     3022  for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); ++runner)
     3023    TrianglesOfBase.push_back(runner->second);
     3024  // .. then delete each triangle (which deletes the line as well)
     3025  for (list <BoundaryTriangleSet *>::iterator runner = TrianglesOfBase.begin(); !TrianglesOfBase.empty(); runner = TrianglesOfBase.begin()) {
     3026    DoLog(0) && (Log() << Verbose(0) << "INFO: Deleting triangle " << *(*runner) << "." << endl);
     3027    OldTriangleNrs[m++] = (*runner)->Nr;
     3028    RemoveTesselationTriangle((*runner));
     3029    TrianglesOfBase.erase(runner);
    30583030  }
    30593031
  • src/tesselation.hpp

    rc39cc4 rbdb143  
    247247  virtual Vector *GetCenter() const { return NULL; };
    248248  virtual TesselPoint *GetPoint() const { return NULL; };
    249   virtual TesselPoint *GetTerminalPoint() const { return NULL; };
    250249  virtual int GetMaxId() const { return 0; };
    251250  virtual void GoToNext() const {};
    252   virtual void GoToPrevious() const {};
    253251  virtual void GoToFirst() const {};
    254   virtual void GoToLast() const {};
    255252  virtual bool IsEmpty() const { return true; };
    256253  virtual bool IsEnd() const { return true; };
     
    366363    virtual Vector *GetCenter(ofstream *out) const;
    367364    virtual TesselPoint *GetPoint() const;
    368     virtual TesselPoint *GetTerminalPoint() const;
    369365    virtual void GoToNext() const;
    370     virtual void GoToPrevious() const;
    371366    virtual void GoToFirst() const;
    372     virtual void GoToLast() const;
    373367    virtual bool IsEmpty() const;
    374368    virtual bool IsEnd() const;
  • src/tesselationhelpers.cpp

    rc39cc4 rbdb143  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <fstream>
     
    844846      Walker = cloud->GetPoint();
    845847      *rasterfile << "2" << endl << "  ";  // 2 is sphere type
    846       for (i=0;i<NDIM;i++)
    847         *rasterfile << Walker->node->at(i)-center->at(i) << " ";
     848      for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates
     849        const double tmp = Walker->node->at(j)-center->at(j);
     850        *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
     851      }
    848852      *rasterfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour
    849853      cloud->GoToNext();
     
    855859      *rasterfile << "1" << endl << "  ";  // 1 is triangle type
    856860      for (i=0;i<3;i++) {  // print each node
    857         for (int j=0;j<NDIM;j++)  // and for each node all NDIM coordinates
    858           *rasterfile << TriangleRunner->second->endpoints[i]->node->node->at(j)-center->at(j) << " ";
     861        for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates
     862          const double tmp = TriangleRunner->second->endpoints[i]->node->node->at(j)-center->at(j);
     863          *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
     864        }
    859865        *rasterfile << "\t";
    860866      }
     
    895901    }
    896902    *tecplot << "\", N=" << TesselStruct->PointsOnBoundary.size() << ", E=" << TesselStruct->TrianglesOnBoundary.size() << ", DATAPACKING=POINT, ZONETYPE=FETRIANGLE" << endl;
    897     int i=cloud->GetMaxId();
    898     int *LookupList = new int[i];
    899     for (cloud->GoToFirst(), i=0; !cloud->IsEnd(); cloud->GoToNext(), i++)
     903    const int MaxId=cloud->GetMaxId();
     904    int *LookupList = new int[MaxId];
     905    for (int i=0; i< MaxId ; i++){
    900906      LookupList[i] = -1;
     907    }
    901908
    902909    // print atom coordinates
    903910    int Counter = 1;
    904911    TesselPoint *Walker = NULL;
    905     for (PointMap::const_iterator target = TesselStruct->PointsOnBoundary.begin(); target != TesselStruct->PointsOnBoundary.end(); target++) {
     912    for (PointMap::const_iterator target = TesselStruct->PointsOnBoundary.begin(); target != TesselStruct->PointsOnBoundary.end(); ++target) {
    906913      Walker = target->second->node;
    907914      LookupList[Walker->nr] = Counter++;
    908       *tecplot << Walker->node->at(0) << " " << Walker->node->at(1) << " " << Walker->node->at(2) << " " << target->second->value << endl;
     915      for (int i=0;i<NDIM;i++) {
     916        const double tmp = Walker->node->at(i);
     917        *tecplot << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
     918      }
     919      *tecplot << target->second->value << endl;
    909920    }
    910921    *tecplot << endl;
  • src/triangleintersectionlist.cpp

    rc39cc4 rbdb143  
    88 *      Author: heber
    99 */
     10
     11#include "Helpers/MemDebug.hpp"
    1012
    1113#include "triangleintersectionlist.hpp"
  • src/unittests/ActOnAllUnitTest.cpp

    rc39cc4 rbdb143  
    4646  // Ref was copy constructed, hence has to be cleaned, too!
    4747  Ref.EmptyList();
    48   MemoryUsageObserver::purgeInstance();
    4948};
    5049
     
    7776
    7877  // scaling by three values
    79   double *factors = Malloc<double>(NDIM, "ActOnAllTest::ScaleTest - factors");
    80   double *inverses = Malloc<double>(NDIM, "ActOnAllTest::ScaleTest - inverses");
     78  double *factors = new double[NDIM];
     79  double *inverses = new double[NDIM];
    8180  for (int i=0;i<NDIM;++i) {
    8281    factors[i] = 2.;
     
    8887  VL.ActOnAll<Vector,void,const double*>(&Vector::ScaleAll, inverses );
    8988  CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
    90   Free(factors);
    91   Free(inverses);
     89  delete[](factors);
     90  delete[](inverses);
    9291};
    9392
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    rc39cc4 rbdb143  
    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 
     46  // construct element list
     47  std::vector<element *> elements;
     48  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     49  CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
     50  elements.push_back(hydrogen);
    6251  // construct molecule (tetraeder of hydrogens)
    6352  TestMolecule = World::getInstance().createMolecule();
     
    8069
    8170  // check that TestMolecule was correctly constructed
    82   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
     71  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    8372
    8473  TestList = World::getInstance().getMolecules();
     
    9079
    9180  // init maps
    92   pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, (const element * const)hydrogen, (const Vector *)point );
     81  pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, elements, (const Vector *)point );
    9382  binmap = NULL;
    9483
     
    10594  delete(point);
    10695  World::purgeInstance();
    107   MemoryUsageObserver::purgeInstance();
    10896  logger::purgeInstance();
    10997};
  • src/unittests/AnalysisCorrelationToPointUnitTest.hpp

    rc39cc4 rbdb143  
    1212
    1313class element;
    14 class LinkedCell;
    1514class molecule;
    1615class MoleculeListClass;
    17 class periodentafel;
    18 class Tesselation;
    1916class Vector;
    2017
     
    4138      molecule *TestMolecule;
    4239      element *hydrogen;
    43       periodentafel *tafel;
    4440
    4541      CorrelationToPointMap *pointmap;
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    rc39cc4 rbdb143  
    1717#include "AnalysisCorrelationToSurfaceUnitTest.hpp"
    1818
    19 #include "World.hpp"
    2019#include "atom.hpp"
    2120#include "boundary.hpp"
     
    2625#include "tesselation.hpp"
    2726#include "World.hpp"
     27#include "Helpers/Assert.hpp"
    2828
    2929#include "Helpers/Assert.hpp"
     
    4040void AnalysisCorrelationToSurfaceUnitTest::setUp()
    4141{
    42   //ASSERT_DO(Assert::Throw);
     42  ASSERT_DO(Assert::Throw);
    4343
    4444  atom *Walker = NULL;
     
    4747  TestList = NULL;
    4848  TestSurfaceMolecule = NULL;
    49   hydrogen = NULL;
    50   tafel = NULL;
    5149  surfacemap = NULL;
    5250  binmap = NULL;
     
    5452  LC = NULL;
    5553
    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);
     54  // prepare element list
     55  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     56  CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
     57  elements.clear();
    7058
    7159  // construct molecule (tetraeder of hydrogens) base
    7260  TestSurfaceMolecule = World::getInstance().createMolecule();
     61
    7362  Walker = World::getInstance().createAtom();
    7463  Walker->type = hydrogen;
    7564  *Walker->node = Vector(1., 0., 1. );
    76 
    77   TestSurfaceMolecule->AddAtom(Walker);
     65  TestSurfaceMolecule->AddAtom(Walker);
     66
    7867  Walker = World::getInstance().createAtom();
    7968  Walker->type = hydrogen;
    8069  *Walker->node = Vector(0., 1., 1. );
    8170  TestSurfaceMolecule->AddAtom(Walker);
     71
    8272  Walker = World::getInstance().createAtom();
    8373  Walker->type = hydrogen;
    8474  *Walker->node = Vector(1., 1., 0. );
    8575  TestSurfaceMolecule->AddAtom(Walker);
     76
    8677  Walker = World::getInstance().createAtom();
    8778  Walker->type = hydrogen;
     
    9081
    9182  // check that TestMolecule was correctly constructed
    92   CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->AtomCount, 4 );
     83  CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->getAtomCount(), 4 );
    9384
    9485  TestList = World::getInstance().getMolecules();
     
    10293
    10394  // add outer atoms
     95  carbon = World::getInstance().getPeriode()->FindElement(6);
    10496  TestSurfaceMolecule = World::getInstance().createMolecule();
    10597  Walker = World::getInstance().createAtom();
     
    10799  *Walker->node = Vector(4., 0., 4. );
    108100  TestSurfaceMolecule->AddAtom(Walker);
     101
    109102  Walker = World::getInstance().createAtom();
    110103  Walker->type = carbon;
    111104  *Walker->node = Vector(0., 4., 4. );
    112105  TestSurfaceMolecule->AddAtom(Walker);
     106
    113107  Walker = World::getInstance().createAtom();
    114108  Walker->type = carbon;
    115109  *Walker->node = Vector(4., 4., 0. );
    116110  TestSurfaceMolecule->AddAtom(Walker);
     111
    117112  // add inner atoms
    118113  Walker = World::getInstance().createAtom();
     
    120115  *Walker->node = Vector(0.5, 0.5, 0.5 );
    121116  TestSurfaceMolecule->AddAtom(Walker);
     117
    122118  TestSurfaceMolecule->ActiveFlag = true;
    123119  TestList->insert(TestSurfaceMolecule);
     
    141137  delete(LC);
    142138  World::purgeInstance();
    143   MemoryUsageObserver::purgeInstance();
    144139  logger::purgeInstance();
    145140};
     
    150145void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest()
    151146{
    152   CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->AtomCount );
     147  CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->getAtomCount() );
    153148  CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() );
    154149  CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );
     
    160155{
    161156  // do the pair correlation
    162   surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
     157  elements.push_back(hydrogen);
     158  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
    163159//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    164160  CPPUNIT_ASSERT( surfacemap != NULL );
     
    169165{
    170166  BinPairMap::iterator tester;
    171   surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
     167  elements.push_back(hydrogen);
     168  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
    172169  // put pair correlation into bins and check with no range
    173170//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
     
    184181{
    185182  BinPairMap::iterator tester;
    186   surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
     183  elements.push_back(hydrogen);
     184  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
    187185//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    188186  // ... and check with [0., 2.] range
     
    202200{
    203201  BinPairMap::iterator tester;
    204   surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC );
     202  elements.push_back(carbon);
     203  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
    205204//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    206205  // put pair correlation into bins and check with no range
     
    221220{
    222221  BinPairMap::iterator tester;
    223   surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC );
     222  elements.push_back(carbon);
     223  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
    224224//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    225225  // ... and check with [0., 2.] range
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp

    rc39cc4 rbdb143  
    4747      element *hydrogen;
    4848      element *carbon;
    49       periodentafel *tafel;
     49      std::vector<element *> elements;
    5050
    5151      CorrelationToSurfaceMap *surfacemap;
  • src/unittests/AnalysisPairCorrelationUnitTest.cpp

    rc39cc4 rbdb143  
    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);
     49  // construct element list
     50  std::vector<element *> elements;
     51  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     52  CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
     53  elements.push_back(hydrogen);
     54  elements.push_back(hydrogen);
    6055
    6156  // construct molecule (tetraeder of hydrogens)
     
    7974
    8075  // check that TestMolecule was correctly constructed
    81   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
     76  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    8277
    8378  TestList = World::getInstance().getMolecules();
     
    8681
    8782  // init maps
    88   correlationmap = PairCorrelation( TestList, hydrogen, hydrogen );
     83  correlationmap = PairCorrelation( TestList, elements);
    8984  binmap = NULL;
    9085
     
    10196  // note that all the atoms are cleaned by TestMolecule
    10297  World::purgeInstance();
    103   MemoryUsageObserver::purgeInstance();
    10498  logger::purgeInstance();
    10599  errorLogger::purgeInstance();
  • src/unittests/AnalysisPairCorrelationUnitTest.hpp

    rc39cc4 rbdb143  
    1212
    1313class element;
    14 class LinkedCell;
    1514class molecule;
    1615class MoleculeListClass;
    17 class periodentafel;
    18 class Tesselation;
    1916class Vector;
    2017
     
    4138      molecule *TestMolecule;
    4239      element *hydrogen;
    43       periodentafel *tafel;
    4440
    4541      PairCorrelationMap *correlationmap;
  • src/unittests/CacheableTest.cpp

    rc39cc4 rbdb143  
    5555
    5656  threeNumbers(int _x,int _y, int _z) :
     57    Observable("threeNumbers"),
    5758    x(_x),y(_y),z(_z),
    58     sum(this,boost::bind(&threeNumbers::calcSum,this)),
     59    sum(this,boost::bind(&threeNumbers::calcSum,this),"sum"),
    5960    hasRecalced(false)
    6061  {}
     
    8182  CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum));
    8283  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
     84  numbers->hasRecalced=false;
     85  CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum));
     86#ifndef NO_CACHING
     87  CPPUNIT_ASSERT_EQUAL( false, numbers->hasRecalced);
     88#else
     89  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
     90#endif
    8391}
  • src/unittests/CountBondsUnitTest.cpp

    rc39cc4 rbdb143  
    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);
    10292
    10393  // check that TestMolecule was correctly constructed
    104   CPPUNIT_ASSERT_EQUAL( TestMolecule1->AtomCount, 3 );
    105   Walker = TestMolecule1->start->next;
    106   CPPUNIT_ASSERT( TestMolecule1->end != Walker );
    107   CPPUNIT_ASSERT_EQUAL( TestMolecule2->AtomCount, 3 );
    108   Walker = TestMolecule2->start->next;
    109   CPPUNIT_ASSERT( TestMolecule2->end != Walker );
     94  CPPUNIT_ASSERT_EQUAL( TestMolecule1->getAtomCount(), 3 );
     95  CPPUNIT_ASSERT_EQUAL( TestMolecule2->getAtomCount(), 3 );
    11096
    11197  // create a small file with table
    11298  BG = new BondGraph(true);
     99  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
    113100
    114101  // construct bond graphs
     
    126113
    127114  World::purgeInstance();
    128   MemoryUsageObserver::purgeInstance();
    129115};
    130116
     
    158144{
    159145  double *mirror = new double[3];
     146  CPPUNIT_ASSERT(mirror != NULL && "could not create array of doubles");
    160147  for (int i=0;i<3;i++)
    161148    mirror[i] = -1.;
  • src/unittests/CountBondsUnitTest.hpp

    rc39cc4 rbdb143  
    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

    rc39cc4 rbdb143  
    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
    71   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 3*3*3 );
    72   Walker = TestMolecule->start->next;
    73   CPPUNIT_ASSERT( TestMolecule->end != Walker );
     62  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 3*3*3 );
    7463};
    7564
     
    7968  delete(LC);
    8069  World::purgeInstance();
    81   MemoryUsageObserver::purgeInstance();
    8270};
    8371
     
    197185{
    198186  // check all atoms
    199   atom *Walker = TestMolecule->start;
    200   while (Walker->next != TestMolecule->end) {
    201     Walker = Walker->next;
    202     CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToNode(Walker) );
     187  for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end();++iter){
     188    CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToNode(*iter) );
    203189  }
    204190
    205191  // check internal vectors, returns false, because this atom is not in LC-list!
    206   Walker = World::getInstance().createAtom();
    207   Walker->setName("test");
    208   Walker->x= Vector(1,1,1);
    209   CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(Walker) );
    210   World::getInstance().destroyAtom(Walker);
     192  atom *newAtom = World::getInstance().createAtom();
     193  newAtom->setName("test");
     194  newAtom->x= Vector(1,1,1);
     195  CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) );
     196  World::getInstance().destroyAtom(newAtom);
    211197
    212198  // check out of bounds vectors
    213   Walker = World::getInstance().createAtom();
    214   Walker->setName("test");
    215   Walker->x = Vector(0,-1,0);
    216   CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(Walker) );
    217   World::getInstance().destroyAtom(Walker);
     199  newAtom = World::getInstance().createAtom();
     200  newAtom->setName("test");
     201  newAtom->x = Vector(0,-1,0);
     202  CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) );
     203  World::getInstance().destroyAtom(newAtom);
    218204};
    219205
     
    278264  Vector tester;
    279265  LinkedCell::LinkedNodes *ListOfPoints = NULL;
    280   atom *Walker = NULL;
    281266  size_t size = 0;
    282267
     
    287272  size = ListOfPoints->size();
    288273  CPPUNIT_ASSERT_EQUAL( (size_t)27, size );
    289   Walker = TestMolecule->start;
    290   Walker = TestMolecule->start;
    291   while (Walker->next != TestMolecule->end) {
    292     Walker = Walker->next;
    293     ListOfPoints->remove(Walker);
     274
     275  for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){
     276    ListOfPoints->remove((*iter));
    294277    size--;
    295278    CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
     
    306289  size=ListOfPoints->size();
    307290  CPPUNIT_ASSERT_EQUAL( (size_t)8, size );
    308   Walker = TestMolecule->start;
    309   while (Walker->next != TestMolecule->end) {
    310     Walker = Walker->next;
    311     if ((Walker->x[0] <2) && (Walker->x[1] <2) && (Walker->x[2] <2)) {
    312       ListOfPoints->remove(Walker);
     291  for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){
     292    if (((*iter)->x[0] <2) && ((*iter)->x[1] <2) && ((*iter)->x[2] <2)) {
     293      ListOfPoints->remove(*iter);
    313294      size--;
    314295      CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
     
    326307  size=ListOfPoints->size();
    327308  CPPUNIT_ASSERT_EQUAL( (size_t)27, size );
    328   Walker = TestMolecule->start;
    329   while (Walker->next != TestMolecule->end) {
    330     Walker = Walker->next;
    331     ListOfPoints->remove(Walker);
     309  for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){
     310    ListOfPoints->remove(*iter);
    332311    size--;
    333312    CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
     
    346325  Vector tester;
    347326  LinkedCell::LinkedNodes *ListOfPoints = NULL;
    348   atom *Walker = NULL;
    349327  size_t size = 0;
    350328
     
    355333  size = ListOfPoints->size();
    356334  CPPUNIT_ASSERT_EQUAL( (size_t)7, size );
    357   Walker = TestMolecule->start;
    358   while (Walker->next != TestMolecule->end) {
    359     Walker = Walker->next;
    360     if ((Walker->x.DistanceSquared(tester) - 1.) < MYEPSILON ) {
    361       ListOfPoints->remove(Walker);
     335  for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){
     336    if (((*iter)->x.DistanceSquared(tester) - 1.) < MYEPSILON ) {
     337      ListOfPoints->remove(*iter);
    362338      size--;
    363339      CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
  • src/unittests/LinkedCellUnitTest.hpp

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

    rc39cc4 rbdb143  
     1# PLEASE adhere to the alphabetical ordering in this Makefile!
     2# Also indentation by a single tab
     3
    14INCLUDES = -I$(top_srcdir)/src
    25
     
    3134  MemoryAllocatorUnitTest \
    3235  MoleculeDescriptorTest \
     36  ObserverTest \
     37  ParserUnitTest \
     38  periodentafelTest \
    3339  PlaneUnittest \
    34   ObserverTest \
    3540  SingletonTest \
    3641  StackClassUnitTest \
     
    4752GSLLIBS = ../libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
    4853ALLLIBS = ../libmolecuilder.a ${GSLLIBS}
     54PARSERLIBS = ../libparser.a ${ALLLIBS}
    4955
    5056TESTSOURCES = \
     
    7379  memoryusageobserverunittest.cpp \
    7480  MoleculeDescriptorTest.cpp \
     81  ObserverTest.cpp \
     82  ParserUnitTest.cpp \
     83  periodentafelTest.cpp \
    7584  PlaneUnittest.cpp \
    76   ObserverTest.cpp \
    7785  SingletonTest.cpp \
    7886  stackclassunittest.cpp \
     
    107115  memoryusageobserverunittest.hpp \
    108116  MoleculeDescriptorTest.hpp \
     117  periodentafelTest.hpp \
    109118  PlaneUnittest.hpp \
    110119  ObserverTest.hpp \
     
    117126 
    118127
     128ActionSequenceTest_SOURCES = UnitTestMain.cpp ../../../TestRunnerClient.hpp ActionSequenceTest.cpp ActionSequenceTest.hpp
     129ActionSequenceTest_LDADD = ${ALLLIBS}
     130
    119131ActOnAllUnitTest_SOURCES = UnitTestMain.cpp ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp
    120132ActOnAllUnitTest_LDADD = ${ALLLIBS}
     
    135147atomsCalculationTest_LDADD = ${ALLLIBS}
    136148
     149AtomDescriptorTest_SOURCES = UnitTestMain.cpp AtomDescriptorTest.cpp AtomDescriptorTest.hpp
     150AtomDescriptorTest_LDADD = ${ALLLIBS}
     151
    137152BondGraphUnitTest_SOURCES = UnitTestMain.cpp bondgraphunittest.cpp bondgraphunittest.hpp
    138153BondGraphUnitTest_LDADD = ${ALLLIBS}
    139154
     155CacheableTest_SOURCES = UnitTestMain.cpp CacheableTest.cpp CacheableTest.hpp
     156CacheableTest_LDADD = ${ALLLIBS}
     157
    140158CountBondsUnitTest_SOURCES = UnitTestMain.cpp CountBondsUnitTest.cpp CountBondsUnitTest.hpp
    141159CountBondsUnitTest_LDADD = ${ALLLIBS}
     
    168186LogUnitTest_LDADD = ${ALLLIBS}
    169187
    170 MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp
     188manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp
     189manipulateAtomsTest_LDADD = ${ALLLIBS}
     190
     191MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp
    171192MemoryAllocatorUnitTest_LDADD = ${ALLLIBS}
    172193
    173 MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp
     194MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp
    174195MemoryUsageObserverUnitTest_LDADD = ${ALLLIBS}
    175196
     
    177198MoleculeDescriptorTest_LDADD = ${ALLLIBS}
    178199
     200ObserverTest_SOURCES = UnitTestMain.cpp ObserverTest.cpp ObserverTest.hpp
     201ObserverTest_LDADD = ${ALLLIBS}
     202
     203ParserUnitTest_SOURCES = UnitTestMain.cpp ParserUnitTest.cpp ParserUnitTest.hpp
     204ParserUnitTest_LDADD = ${PARSERLIBS}
     205
     206periodentafelTest_SOURCES = UnitTestMain.cpp periodentafelTest.cpp periodentafelTest.hpp
     207periodentafelTest_LDADD = ${ALLLIBS}
     208
    179209PlaneUnittest_SOURCES = UnitTestMain.cpp PlaneUnittest.cpp PlaneUnittest.hpp
    180210PlaneUnittest_LDADD = ${ALLLIBS}
    181211
    182212SingletonTest_SOURCES = UnitTestMain.cpp SingletonTest.cpp SingletonTest.hpp
    183 SingletonTest_LDADD = $(BOOST_LIB) ${BOOST_THREAD_LIB}
     213SingletonTest_LDADD = ${ALLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB}
    184214
    185215StackClassUnitTest_SOURCES = UnitTestMain.cpp stackclassunittest.cpp stackclassunittest.hpp
     
    195225Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS}
    196226
     227TestRunner_SOURCES = TestRunnerMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp $(TESTSOURCES) $(TESTHEADERS)
     228TestRunner_LDADD = ${ALLLIBS}
     229
    197230VectorUnitTest_SOURCES = UnitTestMain.cpp vectorunittest.cpp vectorunittest.hpp
    198231VectorUnitTest_LDADD = ${ALLLIBS}
    199232
    200 ActionSequenceTest_SOURCES = UnitTestMain.cpp ../../../TestRunnerClient.hpp ActionSequenceTest.cpp ActionSequenceTest.hpp
    201 ActionSequenceTest_LDADD = ${ALLLIBS}
    202 
    203 ObserverTest_SOURCES = UnitTestMain.cpp ObserverTest.cpp ObserverTest.hpp
    204 ObserverTest_LDADD = ${ALLLIBS}
    205 
    206 CacheableTest_SOURCES = UnitTestMain.cpp CacheableTest.cpp CacheableTest.hpp
    207 CacheableTest_LDADD = ${ALLLIBS}
    208 
    209 AtomDescriptorTest_SOURCES = UnitTestMain.cpp AtomDescriptorTest.cpp AtomDescriptorTest.hpp
    210 AtomDescriptorTest_LDADD = ${ALLLIBS}
    211 
    212 manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp
    213 manipulateAtomsTest_LDADD = ${ALLLIBS}
    214 
    215 TestRunner_SOURCES = UnitTestMain.cpp $(TESTSOURCES) $(TESTHEADERS)
    216 TestRunner_LDADD = ${ALLLIBS}
    217 
    218233#AUTOMAKE_OPTIONS = parallel-tests
    219 
  • src/unittests/ObserverTest.cpp

    rc39cc4 rbdb143  
    1111#include <cppunit/extensions/TestFactoryRegistry.h>
    1212#include <cppunit/ui/text/TestRunner.h>
     13#include <set>
    1314
    1415#include "Patterns/Observer.hpp"
     16#include "Patterns/ObservedIterator.hpp"
    1517#include "Helpers/Assert.hpp"
    1618
     
    3133public:
    3234  UpdateCountObserver() :
     35    Observer("UpdateCountObserver"),
    3336    updates(0)
    3437  {};
     
    4346class SimpleObservable : public Observable {
    4447public:
     48  SimpleObservable() :
     49    Observable("SimpleObservable")
     50  {}
     51
    4552  void changeMethod() {
    4653    OBSERVE;
     
    5259class CallObservable : public Observable {
    5360public:
     61  CallObservable() :
     62    Observable("CallObservable")
     63  {}
     64
    5465  void changeMethod1() {
    5566    OBSERVE;
     
    6879class BlockObservable : public Observable {
    6980public:
     81  BlockObservable() :
     82    Observable("BlockObservable")
     83  {}
     84
    7085  void changeMethod1(){
    7186    OBSERVE;
     
    102117class SuperObservable : public Observable {
    103118public:
    104   SuperObservable(){
     119  SuperObservable():
     120    Observable("SuperObservable")
     121  {
    105122    subObservable = new SimpleObservable();
    106123    subObservable->signOn(this);
     
    121138public:
    122139  NotificationObservable() :
    123       notification1(new Notification(this)),
    124       notification2(new Notification(this))
     140    Observable("NotificationObservable"),
     141    notification1(new Notification(this)),
     142    notification2(new Notification(this))
    125143  {}
    126144
     
    147165public:
    148166  NotificationObserver(Notification_ptr notification) :
     167    Observer("NotificationObserver"),
    149168    requestedNotification(notification),
    150169    wasNotified(false)
     
    162181  bool wasNotified;
    163182};
     183
     184class ObservableCollection : public Observable {
     185public:
     186  typedef std::set<SimpleObservable*> set;
     187  typedef ObservedIterator<set> iterator;
     188  typedef set::const_iterator const_iterator;
     189
     190  ObservableCollection(int _num) :
     191    Observable("ObservableCollection"),
     192    num(_num)
     193  {
     194    for(int i=0; i<num; ++i){
     195      SimpleObservable *content = new SimpleObservable();
     196      content->signOn(this);
     197      theSet.insert(content);
     198    }
     199  }
     200
     201  ~ObservableCollection(){
     202    set::iterator iter;
     203    for(iter=theSet.begin(); iter!=theSet.end(); ++iter ){
     204      delete (*iter);
     205    }
     206  }
     207
     208  iterator begin(){
     209    return iterator(theSet.begin(),this);
     210  }
     211
     212  iterator end(){
     213    return iterator(theSet.end(),this);
     214  }
     215
     216  const int num;
     217
     218private:
     219  set theSet;
     220};
     221
    164222
    165223/******************* actuall tests ***************/
     
    173231  blockObservable = new BlockObservable();
    174232  notificationObservable = new NotificationObservable();
     233  collection = new ObservableCollection(5);
    175234
    176235  observer1 = new UpdateCountObserver();
     
    181240  notificationObserver1 = new NotificationObserver(notificationObservable->notification1);
    182241  notificationObserver2 = new NotificationObserver(notificationObservable->notification2);
    183 
    184242}
    185243
     
    191249  delete blockObservable;
    192250  delete notificationObservable;
     251  delete collection;
    193252
    194253  delete observer1;
     
    279338}
    280339
     340void ObserverTest::iteratorTest(){
     341  int i = 0;
     342  // test the general iterator methods
     343  for(ObservableCollection::iterator iter=collection->begin(); iter!=collection->end();++iter){
     344    CPPUNIT_ASSERT(i< collection->num);
     345    i++;
     346  }
     347
     348  i=0;
     349  for(ObservableCollection::const_iterator iter=collection->begin(); iter!=collection->end();++iter){
     350    CPPUNIT_ASSERT(i<collection->num);
     351    i++;
     352  }
     353
     354  collection->signOn(observer1);
     355  {
     356    // we construct this out of the loop, so the iterator dies at the end of
     357    // the scope and not the end of the loop (allows more testing)
     358    ObservableCollection::iterator iter;
     359    for(iter=collection->begin(); iter!=collection->end(); ++iter){
     360      (*iter)->changeMethod();
     361    }
     362    // At this point no change should have been propagated
     363    CPPUNIT_ASSERT_EQUAL( 0, observer1->updates);
     364  }
     365  // After the Iterator has died the propagation should take place
     366  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates);
     367
     368  // when using a const_iterator no changes should be propagated
     369  for(ObservableCollection::const_iterator iter = collection->begin(); iter!=collection->end();++iter);
     370  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates);
     371  collection->signOff(observer1);
     372}
     373
    281374void ObserverTest::CircleDetectionTest() {
    282375  cout << endl << "Warning: the next test involved methods that can produce infinite loops." << endl;
     
    289382  // make this Observable its own subject. NEVER DO THIS IN ACTUAL CODE
    290383  simpleObservable1->signOn(simpleObservable1);
     384#ifndef NDEBUG
    291385  CPPUNIT_ASSERT_THROW(simpleObservable1->changeMethod(),Assert::AssertionFailure);
     386#else
     387  simpleObservable1->changeMethod();
     388#endif
    292389
    293390  // more complex test
     
    295392  simpleObservable1->signOn(simpleObservable2);
    296393  simpleObservable2->signOn(simpleObservable1);
     394#ifndef NDEBUG
    297395  CPPUNIT_ASSERT_THROW(simpleObservable1->changeMethod(),Assert::AssertionFailure);
     396#else
     397  simpleObservable1->changeMethod();
     398#endif
     399
     400
    298401  simpleObservable1->signOff(simpleObservable2);
    299402  simpleObservable2->signOff(simpleObservable1);
  • src/unittests/ObserverTest.hpp

    rc39cc4 rbdb143  
    1717class CallObservable;
    1818class SuperObservable;
     19class ObservableCollection;
    1920class BlockObservable;
    2021class NotificationObservable;
    21 
    2222
    2323class ObserverTest :  public CppUnit::TestFixture
     
    2929  CPPUNIT_TEST ( doesNotifyTest );
    3030  CPPUNIT_TEST ( doesReportTest );
     31  CPPUNIT_TEST ( iteratorTest );
    3132  CPPUNIT_TEST ( CircleDetectionTest );
    3233  CPPUNIT_TEST_SUITE_END();
     
    4142  void doesNotifyTest();
    4243  void doesReportTest();
     44  void iteratorTest();
    4345  void CircleDetectionTest();
    4446
     
    5860  SuperObservable *superObservable;
    5961  NotificationObservable *notificationObservable;
     62  ObservableCollection *collection;
     63
    6064};
    6165
  • src/unittests/SingletonTest.cpp

    rc39cc4 rbdb143  
    5252    count1++;
    5353  }
    54   // explicit copy constructor to catch if thsi is ever called
     54  // explicit copy constructor to catch if this is ever called
    5555  SingletonStub2(const SingletonStub2&){
    5656    CPPUNIT_FAIL    ( "Copy constructor of Singleton called" );
  • src/unittests/TestRunnerMain.cpp

    rc39cc4 rbdb143  
    1414// give the main function its correct name
    1515#define CPPUNIT_MAIN main
    16 
    1716// include the TestRunnerClient file containing the main class
    1817#include "../../../TestRunnerClient.h"
  • src/unittests/analysisbondsunittest.cpp

    rc39cc4 rbdb143  
    2525#include "molecule.hpp"
    2626#include "periodentafel.hpp"
     27#include "World.hpp"
    2728
    2829#ifdef HAVE_TESTRUNNER
     
    4041  atom *Walker = NULL;
    4142
    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);
     43  // get elements
     44  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     45  carbon = World::getInstance().getPeriode()->FindElement(6);
     46  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
     47  CPPUNIT_ASSERT(carbon != NULL && "could not find element carbon");
    6648
    6749  // construct molecule (tetraeder of hydrogens)
    6850  TestMolecule = World::getInstance().createMolecule();
     51  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
    6952  Walker = World::getInstance().createAtom();
     53  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7054  Walker->type = hydrogen;
    7155  *Walker->node = Vector(1.5, 0., 1.5 );
    7256  TestMolecule->AddAtom(Walker);
    7357  Walker = World::getInstance().createAtom();
     58  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7459  Walker->type = hydrogen;
    7560  *Walker->node = Vector(0., 1.5, 1.5 );
    7661  TestMolecule->AddAtom(Walker);
    7762  Walker = World::getInstance().createAtom();
     63  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7864  Walker->type = hydrogen;
    7965  *Walker->node = Vector(1.5, 1.5, 0. );
    8066  TestMolecule->AddAtom(Walker);
    8167  Walker = World::getInstance().createAtom();
     68  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8269  Walker->type = hydrogen;
    8370  *Walker->node = Vector(0., 0., 0. );
    8471  TestMolecule->AddAtom(Walker);
    8572  Walker = World::getInstance().createAtom();
     73  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8674  Walker->type = carbon;
    8775  *Walker->node = Vector(0.5, 0.5, 0.5 );
     
    8977
    9078  // check that TestMolecule was correctly constructed
    91   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 5 );
     79  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 5 );
    9280
    9381  // create a small file with table
    9482  filename = new string("test.dat");
     83  CPPUNIT_ASSERT(filename != NULL && "could not create string");
    9584  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";
     85  test << ".\tH\tHe\tLi\tBe\tB\tC\n";
     86  test << "H\t1.\t1.\t1.\t1.\t1.\t1.2\n";
     87  test << "He\t1.\t1.\t1.\t1.\t1.\t1.\n";
     88  test << "Li\t1.\t1.\t1.\t1.\t1.\t1.\n";
     89  test << "Be\t1.\t1.\t1.\t1.\t1.\t1.\n";
     90  test << "B\t1.\t1.\t1.\t1.\t1.\t1.\n";
     91  test << "C\t1.2\t1.\t1.\t1.\t1.\t1.5\n";
    9992  test.close();
    10093  BG = new BondGraph(true);
     94  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
    10195
    10296  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
    10397  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) );
     98  CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,5) );
     99  CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(5,5) );
    106100
    107101  BG->ConstructBondGraph(TestMolecule);
  • src/unittests/analysisbondsunittest.hpp

    rc39cc4 rbdb143  
    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

    rc39cc4 rbdb143  
    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. );
     
    8977
    9078  // check that TestMolecule was correctly constructed
    91   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
     79  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    9280
    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
     
    116111  // are all cleaned when the world is destroyed
    117112  World::purgeInstance();
    118   MemoryUsageObserver::purgeInstance();
    119113  logger::purgeInstance();
     114};
     115
     116/** Tests whether setup worked.
     117 */
     118void BondGraphTest::SetupTest()
     119{
     120  CPPUNIT_ASSERT_EQUAL (false, TestMolecule->empty());
     121  CPPUNIT_ASSERT_EQUAL ((size_t)4, TestMolecule->size());
    120122};
    121123
     
    126128  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
    127129  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) );
     130  CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,5) );
     131  CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(5,5) );
    130132};
    131133
     
    134136void BondGraphTest::ConstructGraphFromTableTest()
    135137{
    136   atom *Walker = TestMolecule->start->next;
    137   atom *Runner = TestMolecule->end->previous;
    138   CPPUNIT_ASSERT( TestMolecule->end != Walker );
     138  molecule::iterator Walker = TestMolecule->begin();
     139  molecule::iterator Runner = TestMolecule->begin();
     140  Runner++;
    139141  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
    140142  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
    141   CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
     143  CPPUNIT_ASSERT_EQUAL( true , (*Walker)->IsBondedTo((*Runner)) );
    142144};
    143145
     
    146148void BondGraphTest::ConstructGraphFromCovalentRadiiTest()
    147149{
    148   atom *Walker = TestMolecule->start->next;
    149   atom *Runner = TestMolecule->end->previous;
    150   CPPUNIT_ASSERT( TestMolecule->end != Walker );
     150
     151  //atom *Walker = TestMolecule->start->next;
     152  //atom *Runner = TestMolecule->end->previous;
     153  //CPPUNIT_ASSERT( TestMolecule->end != Walker );
    151154  CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(*dummyname) );
    152155  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
    153   CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
     156
     157  // this cannot be assured using dynamic IDs
     158  //CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
    154159};
    155160
  • src/unittests/bondgraphunittest.hpp

    rc39cc4 rbdb143  
    2222{
    2323    CPPUNIT_TEST_SUITE( BondGraphTest) ;
     24    CPPUNIT_TEST ( SetupTest );
    2425    CPPUNIT_TEST ( LoadTableTest );
    2526    CPPUNIT_TEST ( ConstructGraphFromTableTest );
     
    3031      void setUp();
    3132      void tearDown();
     33      void SetupTest();
    3234      void LoadTableTest();
    3335      void ConstructGraphFromTableTest();
     
    3739
    3840      molecule *TestMolecule;
    39       element *hydrogen;
    40       element *carbon;
    41       periodentafel *tafel;
     41      const element *hydrogen;
     42      const element *carbon;
    4243
    4344      BondGraph *BG;
  • src/unittests/listofbondsunittest.cpp

    rc39cc4 rbdb143  
    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. );
     
    7467
    7568  // check that TestMolecule was correctly constructed
    76   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    77 
     69  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    7870};
    7971
     
    8678  // are all cleaned when the world is destroyed
    8779  World::purgeInstance();
    88   MemoryUsageObserver::purgeInstance();
    8980  logger::purgeInstance();
    9081};
    9182
     83/** Tests whether setup worked correctly.
     84 *
     85 */
     86void ListOfBondsTest::SetupTest()
     87{
     88  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->empty() );
     89  CPPUNIT_ASSERT_EQUAL( (size_t)4, TestMolecule->size() );
     90};
     91
    9292/** Unit Test of molecule::AddBond()
    9393 *
     
    9696{
    9797  bond *Binder = NULL;
    98   atom *atom1 = TestMolecule->start->next;
    99   atom *atom2 = atom1->next;
    100   CPPUNIT_ASSERT( atom1 != NULL );
    101   CPPUNIT_ASSERT( atom2 != NULL );
    102 
    103   // add bond
    104   Binder = TestMolecule->AddBond(atom1, atom2, 1);
    105   CPPUNIT_ASSERT( Binder != NULL );
    106   bond *TestBond = TestMolecule->first->next;
    107   CPPUNIT_ASSERT_EQUAL ( TestBond, Binder );
     98  molecule::iterator iter = TestMolecule->begin();
     99  atom *atom1 = *iter;
     100  iter++;
     101  atom *atom2 = *iter;
     102  CPPUNIT_ASSERT( atom1 != NULL );
     103  CPPUNIT_ASSERT( atom2 != NULL );
     104
     105  // add bond
     106  Binder = TestMolecule->AddBond(atom1, atom2, 1);
     107  CPPUNIT_ASSERT( Binder != NULL );
     108  CPPUNIT_ASSERT_EQUAL ( true, TestMolecule->hasBondStructure() );
    108109
    109110  // check that bond contains the two atoms
     
    124125{
    125126  bond *Binder = NULL;
    126   atom *atom1 = TestMolecule->start->next;
    127   atom *atom2 = atom1->next;
     127  molecule::iterator iter = TestMolecule->begin();
     128  atom *atom1 = *iter;
     129  iter++;
     130  atom *atom2 = *iter;
    128131  CPPUNIT_ASSERT( atom1 != NULL );
    129132  CPPUNIT_ASSERT( atom2 != NULL );
     
    141144
    142145  // check if removed from molecule
    143   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
     146  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
    144147};
    145148
     
    150153{
    151154  bond *Binder = NULL;
    152   atom *atom1 = TestMolecule->start->next;
    153   atom *atom2 = atom1->next;
    154   atom *atom3 = atom2->next;
     155  molecule::iterator iter = TestMolecule->begin();
     156  atom *atom1 = *iter;
     157  iter++;
     158  atom *atom2 = *iter;
     159  iter++;
     160  atom *atom3 = *iter;
    155161  CPPUNIT_ASSERT( atom1 != NULL );
    156162  CPPUNIT_ASSERT( atom2 != NULL );
     
    179185
    180186  // check if removed from molecule
    181   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, Binder );
    182   CPPUNIT_ASSERT_EQUAL( Binder->next, TestMolecule->last );
     187  CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() );
     188  CPPUNIT_ASSERT_EQUAL( (unsigned int)1, TestMolecule->CountBonds() );
    183189};
    184190
     
    189195{
    190196  bond *Binder = NULL;
    191   atom *atom1 = TestMolecule->start->next;
    192   atom *atom2 = atom1->next;
     197  molecule::iterator iter = TestMolecule->begin();
     198  atom *atom1 = *iter;
     199  iter++;
     200  atom *atom2 = *iter;
    193201  CPPUNIT_ASSERT( atom1 != NULL );
    194202  CPPUNIT_ASSERT( atom2 != NULL );
     
    206214
    207215  // check if removed from molecule
    208   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
     216  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
    209217};
    210218
     
    215223{
    216224  bond *Binder = NULL;
    217   atom *atom1 = TestMolecule->start->next;
    218   atom *atom2 = atom1->next;
     225  molecule::iterator iter = TestMolecule->begin();
     226  atom *atom1 = *iter;
     227  iter++;
     228  atom *atom2 = *iter;
    219229  CPPUNIT_ASSERT( atom1 != NULL );
    220230  CPPUNIT_ASSERT( atom2 != NULL );
     
    231241
    232242  // check if removed from molecule
    233   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
     243  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
    234244};
    235245
     
    239249void ListOfBondsTest::DeleteAtomTest()
    240250{
    241   bond *Binder = NULL;
    242   atom *atom1 = TestMolecule->start->next;
    243   atom *atom2 = atom1->next;
    244   CPPUNIT_ASSERT( atom1 != NULL );
    245   CPPUNIT_ASSERT( atom2 != NULL );
    246 
    247   // add bond
    248   Binder = TestMolecule->AddBond(atom1, atom2, 1);
    249   CPPUNIT_ASSERT( Binder != NULL );
     251  atom *atom1 = NULL;
     252  atom *atom2 = NULL;
     253  bond *Binder = NULL;
     254  {
     255    molecule::iterator iter = TestMolecule->begin();
     256    atom1 = *iter;
     257    iter++;
     258    atom2 = *iter;
     259  }
     260  CPPUNIT_ASSERT( atom1 != NULL );
     261  CPPUNIT_ASSERT( atom2 != NULL );
     262
     263  // add bond
     264  Binder = TestMolecule->AddBond(atom1, atom2, 1);
     265  CPPUNIT_ASSERT( Binder != NULL );
     266
     267  CPPUNIT_ASSERT_EQUAL( (size_t) 1, atom1->ListOfBonds.size() );
     268  CPPUNIT_ASSERT_EQUAL( (size_t) 1, atom2->ListOfBonds.size() );
     269
     270  CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() );
    250271
    251272  // remove atom2
     
    256277
    257278  // check if removed from molecule
    258   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
    259 };
     279  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
     280};
  • src/unittests/listofbondsunittest.hpp

    rc39cc4 rbdb143  
    2020{
    2121    CPPUNIT_TEST_SUITE( ListOfBondsTest) ;
     22    CPPUNIT_TEST ( SetupTest );
    2223    CPPUNIT_TEST ( AddingBondTest );
    2324    CPPUNIT_TEST ( RemovingBondTest );
     
    3132      void setUp();
    3233      void tearDown();
     34      void SetupTest();
    3335      void AddingBondTest();
    3436      void RemovingBondTest();
     
    4143
    4244      molecule *TestMolecule;
    43       element *hydrogen;
    44       periodentafel *tafel;
     45      const element *hydrogen;
    4546};
    4647
  • src/unittests/manipulateAtomsTest.cpp

    rc39cc4 rbdb143  
    5555public:
    5656  countObserver() :
     57    Observer("countObserver"),
    5758    count(0)
    5859    {}
     
    8687static void operation(atom* _atom){
    8788  AtomStub *atom = dynamic_cast<AtomStub*>(_atom);
    88   assert(atom);
     89  CPPUNIT_ASSERT(atom);
    8990  atom->doSomething();
    9091}
     
    99100    AtomStub *atom;
    100101    atom = dynamic_cast<AtomStub*>(*iter);
    101     assert(atom);
     102    CPPUNIT_ASSERT(atom);
    102103    CPPUNIT_ASSERT(atom->manipulated);
    103104  }
     
    113114    AtomStub *atom;
    114115    atom = dynamic_cast<AtomStub*>(*iter);
    115     assert(atom);
     116    CPPUNIT_ASSERT(atom);
    116117    if(atom->getId()!=(int)ATOM_COUNT/2)
    117118      CPPUNIT_ASSERT(atom->manipulated);
  • src/unittests/memoryallocatorunittest.cpp

    rc39cc4 rbdb143  
    1212#include "memoryallocator.hpp"
    1313#include "memoryallocatorunittest.hpp"
     14#include "memoryusageobserver.hpp"
    1415#include "helpers.hpp"
    1516#include "log.hpp"
  • src/unittests/stackclassunittest.cpp

    rc39cc4 rbdb143  
    3737  Stack->ClearStack();
    3838  delete(Stack);
    39   MemoryUsageObserver::purgeInstance();
    4039  logger::purgeInstance();
    4140};
  • src/unittests/tesselation_boundarytriangleunittest.cpp

    rc39cc4 rbdb143  
    7070    delete tesselpoints[i];
    7171  }
    72   MemoryUsageObserver::purgeInstance();
    7372  logger::purgeInstance();
    7473  errorLogger::purgeInstance();
  • src/unittests/tesselation_insideoutsideunittest.cpp

    rc39cc4 rbdb143  
    134134  }
    135135  Corners.clear();
    136   MemoryUsageObserver::purgeInstance();
    137136  logger::purgeInstance();
    138137  errorLogger::purgeInstance();
  • src/unittests/tesselationunittest.cpp

    rc39cc4 rbdb143  
    106106  }
    107107  Corners.clear();
    108   MemoryUsageObserver::purgeInstance();
    109108  logger::purgeInstance();
    110109  errorLogger::purgeInstance();
  • src/unittests/vectorunittest.cpp

    rc39cc4 rbdb143  
    4949void VectorTest::tearDown()
    5050{
    51   MemoryUsageObserver::purgeInstance();
    5251  logger::purgeInstance();
    5352  errorLogger::purgeInstance();
  • src/valence.db

    rc39cc4 rbdb143  
     1#atomicnumber numberofvalenceorbitals
    121       0.10000000000000E+01
    232       0.20000000000000E+01
  • src/vector.cpp

    rc39cc4 rbdb143  
    55 */
    66
     7#include "Helpers/MemDebug.hpp"
    78
    89#include "vector.hpp"
     
    2324Vector::Vector()
    2425{
    25   x[0] = x[1] = x[2] = 0.;
     26  content = gsl_vector_calloc (NDIM);
    2627};
    2728
     
    3233Vector::Vector(const Vector& src)
    3334{
    34   x[0] = src[0];
    35   x[1] = src[1];
    36   x[2] = src[2];
     35  content = gsl_vector_alloc(NDIM);
     36  gsl_vector_set(content,0,src[0]);
     37  gsl_vector_set(content,1,src[1]);
     38  gsl_vector_set(content,2,src[2]);
    3739}
    3840
     
    4143Vector::Vector(const double x1, const double x2, const double x3)
    4244{
    43   x[0] = x1;
    44   x[1] = x2;
    45   x[2] = x3;
     45  content = gsl_vector_alloc(NDIM);
     46  gsl_vector_set(content,0,x1);
     47  gsl_vector_set(content,1,x2);
     48  gsl_vector_set(content,2,x3);
    4649};
    4750
     
    5255  // check for self assignment
    5356  if(&src!=this){
    54     x[0] = src[0];
    55     x[1] = src[1];
    56     x[2] = src[2];
     57    gsl_vector_set(content,0,src[0]);
     58    gsl_vector_set(content,1,src[1]);
     59    gsl_vector_set(content,2,src[2]);
    5760  }
    5861  return *this;
     
    6164/** Desctructor of class vector.
    6265 */
    63 Vector::~Vector() {};
     66Vector::~Vector() {
     67  gsl_vector_free(content);
     68};
    6469
    6570/** Calculates square of distance between this and another vector.
     
    7176  double res = 0.;
    7277  for (int i=NDIM;i--;)
    73     res += (x[i]-y[i])*(x[i]-y[i]);
     78    res += (at(i)-y[i])*(at(i)-y[i]);
    7479  return (res);
    7580};
     
    199204  double res = 0.;
    200205  for (int i=NDIM;i--;)
    201     res += x[i]*y[i];
     206    res += at(i)*y[i];
    202207  return (res);
    203208};
     
    213218{
    214219  Vector tmp;
    215   tmp[0] = x[1]* y[2] - x[2]* y[1];
    216   tmp[1] = x[2]* y[0] - x[0]* y[2];
    217   tmp[2] = x[0]* y[1] - x[1]* y[0];
     220  for(int i=NDIM;i--;)
     221    tmp[i] = at((i+1)%NDIM)*y[(i+2)%NDIM] - at((i+2)%NDIM)*y[(i+1)%NDIM];
    218222  (*this) = tmp;
    219223};
     
    308312bool Vector::IsZero() const
    309313{
    310   return (fabs(x[0])+fabs(x[1])+fabs(x[2]) < MYEPSILON);
     314  return (fabs(at(0))+fabs(at(1))+fabs(at(2)) < MYEPSILON);
    311315};
    312316
     
    337341  bool status = true;
    338342  for (int i=0;i<NDIM;i++) {
    339     if (fabs(x[i] - a[i]) > MYEPSILON)
     343    if (fabs(at(i) - a[i]) > MYEPSILON)
    340344      status = false;
    341345  }
     
    365369double& Vector::operator[](size_t i){
    366370  ASSERT(i<=NDIM && i>=0,"Vector Index out of Range");
    367   return x[i];
     371  return *gsl_vector_ptr (content, i);
    368372}
    369373
    370374const double& Vector::operator[](size_t i) const{
    371375  ASSERT(i<=NDIM && i>=0,"Vector Index out of Range");
    372   return x[i];
     376  return *gsl_vector_ptr (content, i);
    373377}
    374378
     
    381385}
    382386
    383 double* Vector::get(){
    384   return x;
     387gsl_vector* Vector::get(){
     388  return content;
    385389}
    386390
     
    497501{
    498502  for (int i=NDIM;i--;)
    499     x[i] *= factor[i];
     503    at(i) *= factor[i];
    500504};
    501505
     
    505509{
    506510  for (int i=NDIM;i--;)
    507     x[i] *= factor;
     511    at(i) *= factor;
    508512};
    509513
     
    517521  // truncate to [0,1] for each axis
    518522  for (int i=0;i<NDIM;i++) {
    519     x[i] += 0.5;  // set to center of box
    520     while (x[i] >= 1.)
    521       x[i] -= 1.;
    522     while (x[i] < 0.)
    523       x[i] += 1.;
     523    //at(i) += 0.5;  // set to center of box
     524    while (at(i) >= 1.)
     525      at(i) -= 1.;
     526    while (at(i) < 0.)
     527      at(i) += 1.;
    524528  }
    525529  MatrixMultiplication(M);
     
    548552void Vector::MatrixMultiplication(const double * const M)
    549553{
     554  Vector tmp;
    550555  // do the matrix multiplication
    551   at(0) = M[0]*x[0]+M[3]*x[1]+M[6]*x[2];
    552   at(1) = M[1]*x[0]+M[4]*x[1]+M[7]*x[2];
    553   at(2) = M[2]*x[0]+M[5]*x[1]+M[8]*x[2];
     556  for(int i=NDIM;i--;)
     557    tmp[i] = M[i]*at(0)+M[i+3]*at(1)+M[i+6]*at(2);
     558
     559  (*this) = tmp;
    554560};
    555561
     
    576582    B[8] =  detAReci*RDET2(A[0],A[1],A[3],A[4]);    // A_33
    577583
    578     // do the matrix multiplication
    579     at(0) = B[0]*x[0]+B[3]*x[1]+B[6]*x[2];
    580     at(1) = B[1]*x[0]+B[4]*x[1]+B[7]*x[2];
    581     at(2) = B[2]*x[0]+B[5]*x[1]+B[8]*x[2];
     584    MatrixMultiplication(B);
    582585
    583586    return true;
     
    615618  SubtractVector(x1);
    616619  for (int i=NDIM;i--;)
    617     result = result || (fabs(x[i]) > MYEPSILON);
     620    result = result || (fabs(at(i)) > MYEPSILON);
    618621
    619622  return result;
     
    677680{
    678681  for(int i=NDIM;i--;)
    679     x[i] += y[i];
     682    at(i) += y[i];
    680683}
    681684
     
    686689{
    687690  for(int i=NDIM;i--;)
    688     x[i] -= y[i];
     691    at(i) -= y[i];
    689692}
    690693
  • src/vector.hpp

    rc39cc4 rbdb143  
    3131 */
    3232class Vector : public Space{
    33 protected:
    34   // this struct is used to indicate calls to the Baseconstructor from inside vectors.
    35   struct Baseconstructor{};
    3633public:
    3734
     
    8279
    8380  // Access to internal structure
    84   double* get();
     81  gsl_vector* get();
    8582
    8683  // Methods that are derived directly from other methods
     
    107104
    108105private:
    109   double x[NDIM];
     106  gsl_vector *content;
    110107
    111108};
  • src/vector_ops.cpp

    rc39cc4 rbdb143  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "vector.hpp"
  • src/verbose.cpp

    rc39cc4 rbdb143  
    11using namespace std;
     2
     3#include "Helpers/MemDebug.hpp"
    24
    35#include "info.hpp"
  • tests/Makefile.am

    rc39cc4 rbdb143  
    1 AUTOM4TE = autom4te
    2 EXTRA_DIST = testsuite.at $(TESTSUITE) atlocal.in regression
    3 TESTSUITE = $(srcdir)/testsuite
     1SUBDIRS = regression Tesselations
    42
    5 SUBDIRS = Tesselations
    6 
    7 check-local: atconfig atlocal package.m4 $(TESTSUITE)
    8                 $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS)
    9 
    10 installcheck-local: atconfig atlocal $(TESTSUITE)
    11                 $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \
    12                 $(TESTSUITEFLAGS)
    13      
    14 clean-local:
    15                 test ! -f '$(TESTSUITE)' || \
    16                 $(SHELL) '$(TESTSUITE)' --clean
    17 
    18 AUTOTEST = $(AUTOM4TE) --language=autotest
    19 $(TESTSUITE): $(srcdir)/testsuite.at
    20                 $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
    21                 mv $@.tmp $@
    22 
    23 # The `:;' works around a Bash 3.2 bug when the output is not writeable.
    24 $(srcdir)/package.m4: $(top_srcdir)/configure.ac
    25                         :;{ \
    26                                         echo '# Signature of the current package.' && \
    27                                         echo 'm4_define([AT_PACKAGE_NAME],      [@PACKAGE_NAME@])' && \
    28                                         echo 'm4_define([AT_PACKAGE_TARNAME],   [@PACKAGE_TARNAME@])' && \
    29                                         echo 'm4_define([AT_PACKAGE_VERSION],   [@PACKAGE_VERSION@])' && \
    30                                         echo 'm4_define([AT_PACKAGE_STRING],    [@PACKAGE_STRING@])' && \
    31                                         echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
    32                                 } >'$(srcdir)/package.m4'
  • tests/Tesselations/defs.in

    rc39cc4 rbdb143  
    3030        CLEANUP="$CLEANUP; rm -rf $testdir"
    3131        cp -r @srcdir@/$testdir/* $testdir/
    32         cd $testdir
    3332        CLEANUP="rm -f stderr stdout diffstderr diffstdout; cd ..; $CLEANUP"
    3433        CLEANUP="rm -f *.conf*; rm -f NonConvexEnvelope*; rm -f ${testdir}.xyz; rm -f ${testdir}.dbond; $CLEANUP"
     
    5251        FILENAME="NonConvexEnvelope"
    5352        exitcode=0
    54         cd $RADIUS
     53        cd $testdir/$RADIUS
    5554        #echo "Current dir is `pwd`, calling $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N $RADIUS $FILENAME."
    5655        if [ -e $mol.dbond ]; then
    57                 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -A $mol.dbond -N $RADIUS $FILENAME 2>stderr >stdout || exitcode=$?
     56                $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -A $mol.dbond -N 0 --sphere-radius $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?
    5857        else
    59                 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N $RADIUS $FILENAME 2>stderr >stdout || exitcode=$?
     58                $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N 0 --sphere-radius $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?
    6059        fi
    6160        #echo "Molecuilder done with exitcode $exitcode."
    6261        #cat stderr
    6362        #cat stdout
    64         diff ${FILENAME}.dat ../@srcdir@/$mol/$2/${FILENAME}-$mol.dat 2>diffstderr >diffstdout || exitcode=$?
     63        grep -E "^[0-9]* [0-9]* [0-9]*$" ../../../../../molecuilder/tests/Tesselations/$mol/$2/${FILENAME}-$mol.dat | sort -n >reference-triangles.dat
     64        grep -E "^[0-9]* [0-9]* [0-9]*$" ${FILENAME}.dat | sort -n >new-triangles.dat
     65        diff reference-triangles.dat new-triangles.dat 2>diffstderr >diffstdout || exitcode=$?
    6566        #echo "Diff done with exitcode $exitcode."
    6667        #cat diffstderr
    6768        #cat diffstdout
    68         cd ..
     69        cd ../..
    6970        test $exitcode = $expected_exitcode || exit 1
    7071}
  • tests/Tesselations/heptan/1.5/NonConvexEnvelope-heptan.dat

    rc39cc4 rbdb143  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="heptan", N=23, E=64, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 -7.27e-07 -1.22006 0.930455 3
    5 -7.27e-07 -1.22006 -0.849545 3
    6 -1.2492 0.921941 0.930455 3
    7 -1.2492 0.921941 -0.849545 3
    8 1.2492 0.921941 -0.849545 3
    9 1.2492 0.921941 0.930455 3
    10 -2.4985 -1.22006 -0.849545 4
    11 -2.4985 -1.22006 0.930455 4
    12 2.4985 -1.22006 0.930455 4
    13 2.4985 -1.22006 -0.849545 4
    14 -4.6377 -0.336759 0.0404545 6
    15 -3.7477 0.921941 0.930455 5
    16 -3.7477 0.921941 -0.849545 5
    17 4.6377 -0.336759 0.0404545 4
    18 3.7477 0.921941 -0.849545 4
    19 3.7477 0.921941 0.930455 4
    20 -7.27e-07 -0.590759 0.0404545 6
    21 -1.2492 0.292641 0.0404545 6
    22 1.2492 0.292641 0.0404545 6
    23 -2.4985 -0.590759 0.0404545 6
    24 2.4985 -0.590759 0.0404545 6
    25 -3.7477 0.292641 0.0404545 12
    26 3.7477 0.292641 0.0404545 12
     4-7.27e-07 -1.22006 0.930455 18.7229
     5-7.27e-07 -1.22006 -0.849545 18.7229
     6-1.2492 0.921941 0.930455 18.7227
     7-1.2492 0.921941 -0.849545 18.7227
     81.2492 0.921941 -0.849545 18.7222
     91.2492 0.921941 0.930455 27.0641
     10-2.4985 -1.22006 -0.849545 19.9769
     11-2.4985 -1.22006 0.930455 27.4727
     122.4985 -1.22006 0.930455 19.9769
     132.4985 -1.22006 -0.849545 27.4727
     14-4.6377 -0.336759 0.0404545 21.541
     15-3.7477 0.921941 0.930455 18.8853
     16-3.7477 0.921941 -0.849545 18.8853
     174.6377 -0.336759 0.0404545 10.6618
     183.7477 0.921941 -0.849545 18.5406
     193.7477 0.921941 0.930455 12.1988
     20-7.27e-07 -0.590759 0.0404545 23.0174
     21-1.2492 0.292641 0.0404545 23.0167
     221.2492 0.292641 0.0404545 20.1632
     23-2.4985 -0.590759 0.0404545 18.9798
     242.4985 -0.590759 0.0404545 18.9798
     25-3.7477 0.292641 0.0404545 39.5267
     263.7477 0.292641 0.0404545 23.2512
    2727
    282814 15 23
     
    38385 18 19
    39394 5 18
     406 18 19
     413 6 18
    40423 4 18
    41433 4 18
    42 3 18 19
    43 3 6 19
    44444 18 22
    45454 13 22
     
    484812 13 22
    494912 13 22
    50 16 19 23
    51 6 16 19
    52 14 16 23
    53 14 16 23
    54 9 14 23
    55 9 16 23
     506 19 23
     516 16 23
    565211 13 22
    575311 13 22
     
    62588 11 22
    63598 12 22
     6014 16 23
     6114 16 23
     629 14 23
     639 16 23
     643 8 12
     651 3 8
     661 3 6
     671 6 9
     686 9 16
    64694 7 13
    65702 4 7
     
    67722 5 10
    68735 10 15
    69 3 8 12
    70 1 3 8
    71 1 3 6
    72 1 6 9
    73 6 9 16
    747410 14 21
    75759 10 21
     
    84842 17 20
    85852 7 20
    86 1 17 20
    87 1 8 20
    88867 8 20
    89877 8 20
    90887 11 20
    91898 11 20
     908 17 20
     911 8 17
  • tests/Tesselations/heptan/2.5/NonConvexEnvelope-heptan.dat

    rc39cc4 rbdb143  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 -7.27e-07 -1.22006 0.930455 0
    5 -7.27e-07 -1.22006 -0.849545 0
    6 -1.2492 0.921941 0.930455 0
    7 -1.2492 0.921941 -0.849545 0
    8 1.2492 0.921941 -0.849545 0
    9 1.2492 0.921941 0.930455 0
    10 -2.4985 -1.22006 -0.849545 0
    11 -2.4985 -1.22006 0.930455 0
    12 2.4985 -1.22006 0.930455 0
    13 2.4985 -1.22006 -0.849545 0
    14 -4.6377 -0.336759 0.0404545 0
    15 -3.7477 0.921941 0.930455 0
    16 -3.7477 0.921941 -0.849545 0
    17 4.6377 -0.336759 0.0404545 0
    18 3.7477 0.921941 -0.849545 0
    19 3.7477 0.921941 0.930455 0
     4-7.27e-07 -1.22006 0.930455 -17.4952
     5-7.27e-07 -1.22006 -0.849545 -17.4952
     6-1.2492 0.921941 0.930455 -19.6818
     7-1.2492 0.921941 -0.849545 -15.323
     81.2492 0.921941 -0.849545 -17.495
     91.2492 0.921941 0.930455 -17.4951
     10-2.4985 -1.22006 -0.849545 -13.1263
     11-2.4985 -1.22006 0.930455 -10.8961
     122.4985 -1.22006 0.930455 -13.1263
     132.4985 -1.22006 -0.849545 -10.8961
     14-4.6377 -0.336759 0.0404545 -9.35471
     15-3.7477 0.921941 0.930455 -9.24444
     16-3.7477 0.921941 -0.849545 -11.4805
     174.6377 -0.336759 0.0404545 -9.35473
     183.7477 0.921941 -0.849545 -11.4805
     193.7477 0.921941 0.930455 -9.24445
    2020
    212114 15 16
     
    27273 12 13
    282811 12 13
    29 8 11 12
    30 3 8 12
    31 1 3 8
    32 1 3 6
    33 1 6 9
    34 6 9 16
    35 9 14 16
     297 11 13
     304 7 13
     312 4 7
     322 4 5
     332 5 10
     345 10 15
     3510 14 15
    36369 10 14
    37372 9 10
     
    40401 7 8
    41417 8 11
    42 10 14 15
    43 5 10 15
    44 2 5 10
    45 2 4 5
    46 2 4 7
    47 4 7 13
    48 7 11 13
     429 14 16
     436 9 16
     441 6 9
     451 3 6
     461 3 8
     473 8 12
     488 11 12
  • tests/Tesselations/heptan/2/NonConvexEnvelope-heptan.dat

    rc39cc4 rbdb143  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 -7.27e-07 -1.22006 0.930455 0
    5 -7.27e-07 -1.22006 -0.849545 0
    6 -1.2492 0.921941 0.930455 0
    7 -1.2492 0.921941 -0.849545 0
    8 1.2492 0.921941 -0.849545 0
    9 1.2492 0.921941 0.930455 0
    10 -2.4985 -1.22006 -0.849545 0
    11 -2.4985 -1.22006 0.930455 0
    12 2.4985 -1.22006 0.930455 0
    13 2.4985 -1.22006 -0.849545 0
    14 -4.6377 -0.336759 0.0404545 0
    15 -3.7477 0.921941 0.930455 0
    16 -3.7477 0.921941 -0.849545 0
    17 4.6377 -0.336759 0.0404545 0
    18 3.7477 0.921941 -0.849545 0
    19 3.7477 0.921941 0.930455 0
     4-7.27e-07 -1.22006 0.930455 -17.4952
     5-7.27e-07 -1.22006 -0.849545 -17.4952
     6-1.2492 0.921941 0.930455 -19.6818
     7-1.2492 0.921941 -0.849545 -15.323
     81.2492 0.921941 -0.849545 -17.495
     91.2492 0.921941 0.930455 -17.4951
     10-2.4985 -1.22006 -0.849545 -13.1263
     11-2.4985 -1.22006 0.930455 -10.8961
     122.4985 -1.22006 0.930455 -13.1263
     132.4985 -1.22006 -0.849545 -10.8961
     14-4.6377 -0.336759 0.0404545 -9.35471
     15-3.7477 0.921941 0.930455 -9.24444
     16-3.7477 0.921941 -0.849545 -11.4805
     174.6377 -0.336759 0.0404545 -9.35473
     183.7477 0.921941 -0.849545 -11.4805
     193.7477 0.921941 0.930455 -9.24445
    2020
    212114 15 16
     
    27273 12 13
    282811 12 13
    29 8 11 12
    30 3 8 12
    31 1 3 8
    32 1 3 6
    33 1 6 9
    34 6 9 16
    35 9 14 16
     297 11 13
     304 7 13
     312 4 7
     322 4 5
     332 5 10
     345 10 15
     3510 14 15
    36369 10 14
    37372 9 10
     
    40401 7 8
    41417 8 11
    42 10 14 15
    43 5 10 15
    44 2 5 10
    45 2 4 5
    46 2 4 7
    47 4 7 13
    48 7 11 13
     429 14 16
     436 9 16
     441 6 9
     451 3 6
     461 3 8
     473 8 12
     488 11 12
  • tests/Tesselations/heptan/25/NonConvexEnvelope-heptan.dat

    rc39cc4 rbdb143  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 -7.27e-07 -1.22006 0.930455 0
    5 -7.27e-07 -1.22006 -0.849545 0
    6 -1.2492 0.921941 0.930455 0
    7 -1.2492 0.921941 -0.849545 0
    8 1.2492 0.921941 -0.849545 0
    9 1.2492 0.921941 0.930455 0
    10 -2.4985 -1.22006 -0.849545 0
    11 -2.4985 -1.22006 0.930455 0
    12 2.4985 -1.22006 0.930455 0
    13 2.4985 -1.22006 -0.849545 0
    14 -4.6377 -0.336759 0.0404545 0
    15 -3.7477 0.921941 0.930455 0
    16 -3.7477 0.921941 -0.849545 0
    17 4.6377 -0.336759 0.0404545 0
    18 3.7477 0.921941 -0.849545 0
    19 3.7477 0.921941 0.930455 0
     4-7.27e-07 -1.22006 0.930455 -17.4952
     5-7.27e-07 -1.22006 -0.849545 -17.4952
     6-1.2492 0.921941 0.930455 -19.6818
     7-1.2492 0.921941 -0.849545 -15.323
     81.2492 0.921941 -0.849545 -17.495
     91.2492 0.921941 0.930455 -17.4951
     10-2.4985 -1.22006 -0.849545 -13.1263
     11-2.4985 -1.22006 0.930455 -10.8961
     122.4985 -1.22006 0.930455 -13.1263
     132.4985 -1.22006 -0.849545 -10.8961
     14-4.6377 -0.336759 0.0404545 -9.35471
     15-3.7477 0.921941 0.930455 -9.24444
     16-3.7477 0.921941 -0.849545 -11.4805
     174.6377 -0.336759 0.0404545 -9.35473
     183.7477 0.921941 -0.849545 -11.4805
     193.7477 0.921941 0.930455 -9.24445
    2020
    212114 15 16
     
    27273 12 13
    282811 12 13
    29 8 11 12
    30 3 8 12
    31 1 3 8
    32 1 3 6
    33 1 6 9
    34 6 9 16
    35 9 14 16
     297 11 13
     304 7 13
     312 4 7
     322 4 5
     332 5 10
     345 10 15
     3510 14 15
    36369 10 14
    37372 9 10
     
    40401 7 8
    41417 8 11
    42 10 14 15
    43 5 10 15
    44 2 5 10
    45 2 4 5
    46 2 4 7
    47 4 7 13
    48 7 11 13
     429 14 16
     436 9 16
     441 6 9
     451 3 6
     461 3 8
     473 8 12
     488 11 12
  • tests/Tesselations/heptan/3.5/NonConvexEnvelope-heptan.dat

    rc39cc4 rbdb143  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 -7.27e-07 -1.22006 0.930455 0
    5 -7.27e-07 -1.22006 -0.849545 0
    6 -1.2492 0.921941 0.930455 0
    7 -1.2492 0.921941 -0.849545 0
    8 1.2492 0.921941 -0.849545 0
    9 1.2492 0.921941 0.930455 0
    10 -2.4985 -1.22006 -0.849545 0
    11 -2.4985 -1.22006 0.930455 0
    12 2.4985 -1.22006 0.930455 0
    13 2.4985 -1.22006 -0.849545 0
    14 -4.6377 -0.336759 0.0404545 0
    15 -3.7477 0.921941 0.930455 0
    16 -3.7477 0.921941 -0.849545 0
    17 4.6377 -0.336759 0.0404545 0
    18 3.7477 0.921941 -0.849545 0
    19 3.7477 0.921941 0.930455 0
     4-7.27e-07 -1.22006 0.930455 -17.4952
     5-7.27e-07 -1.22006 -0.849545 -17.4952
     6-1.2492 0.921941 0.930455 -19.6818
     7-1.2492 0.921941 -0.849545 -15.323
     81.2492 0.921941 -0.849545 -17.495
     91.2492 0.921941 0.930455 -17.4951
     10-2.4985 -1.22006 -0.849545 -13.1263
     11-2.4985 -1.22006 0.930455 -10.8961
     122.4985 -1.22006 0.930455 -13.1263
     132.4985 -1.22006 -0.849545 -10.8961
     14-4.6377 -0.336759 0.0404545 -9.35471
     15-3.7477 0.921941 0.930455 -9.24444
     16-3.7477 0.921941 -0.849545 -11.4805
     174.6377 -0.336759 0.0404545 -9.35473
     183.7477 0.921941 -0.849545 -11.4805
     193.7477 0.921941 0.930455 -9.24445
    2020
    212114 15 16
     
    27273 12 13
    282811 12 13
    29 8 11 12
    30 3 8 12
    31 1 3 8
    32 1 3 6
    33 1 6 9
    34 6 9 16
    35 9 14 16
     297 11 13
     304 7 13
     312 4 7
     322 4 5
     332 5 10
     345 10 15
     3510 14 15
    36369 10 14
    37372 9 10
     
    40401 7 8
    41417 8 11
    42 10 14 15
    43 5 10 15
    44 2 5 10
    45 2 4 5
    46 2 4 7
    47 4 7 13
    48 7 11 13
     429 14 16
     436 9 16
     441 6 9
     451 3 6
     461 3 8
     473 8 12
     488 11 12
  • tests/Tesselations/heptan/3/NonConvexEnvelope-heptan.dat

    rc39cc4 rbdb143  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 -7.27e-07 -1.22006 0.930455 0
    5 -7.27e-07 -1.22006 -0.849545 0
    6 -1.2492 0.921941 0.930455 0
    7 -1.2492 0.921941 -0.849545 0
    8 1.2492 0.921941 -0.849545 0
    9 1.2492 0.921941 0.930455 0
    10 -2.4985 -1.22006 -0.849545 0
    11 -2.4985 -1.22006 0.930455 0
    12 2.4985 -1.22006 0.930455 0
    13 2.4985 -1.22006 -0.849545 0
    14 -4.6377 -0.336759 0.0404545 0
    15 -3.7477 0.921941 0.930455 0
    16 -3.7477 0.921941 -0.849545 0
    17 4.6377 -0.336759 0.0404545 0
    18 3.7477 0.921941 -0.849545 0
    19 3.7477 0.921941 0.930455 0
     4-7.27e-07 -1.22006 0.930455 -17.4952
     5-7.27e-07 -1.22006 -0.849545 -17.4952
     6-1.2492 0.921941 0.930455 -19.6818
     7-1.2492 0.921941 -0.849545 -15.323
     81.2492 0.921941 -0.849545 -17.495
     91.2492 0.921941 0.930455 -17.4951
     10-2.4985 -1.22006 -0.849545 -13.1263
     11-2.4985 -1.22006 0.930455 -10.8961
     122.4985 -1.22006 0.930455 -13.1263
     132.4985 -1.22006 -0.849545 -10.8961
     14-4.6377 -0.336759 0.0404545 -9.35471
     15-3.7477 0.921941 0.930455 -9.24444
     16-3.7477 0.921941 -0.849545 -11.4805
     174.6377 -0.336759 0.0404545 -9.35473
     183.7477 0.921941 -0.849545 -11.4805
     193.7477 0.921941 0.930455 -9.24445
    2020
    212114 15 16
     
    27273 12 13
    282811 12 13
    29 8 11 12
    30 3 8 12
    31 1 3 8
    32 1 3 6
    33 1 6 9
    34 6 9 16
    35 9 14 16
     297 11 13
     304 7 13
     312 4 7
     322 4 5
     332 5 10
     345 10 15
     3510 14 15
    36369 10 14
    37372 9 10
     
    40401 7 8
    41417 8 11
    42 10 14 15
    43 5 10 15
    44 2 5 10
    45 2 4 5
    46 2 4 7
    47 4 7 13
    48 7 11 13
     429 14 16
     436 9 16
     441 6 9
     451 3 6
     461 3 8
     473 8 12
     488 11 12
  • tests/Tesselations/heptan/4/NonConvexEnvelope-heptan.dat

    rc39cc4 rbdb143  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 -7.27e-07 -1.22006 0.930455 0
    5 -7.27e-07 -1.22006 -0.849545 0
    6 -1.2492 0.921941 0.930455 0
    7 -1.2492 0.921941 -0.849545 0
    8 1.2492 0.921941 -0.849545 0
    9 1.2492 0.921941 0.930455 0
    10 -2.4985 -1.22006 -0.849545 0
    11 -2.4985 -1.22006 0.930455 0
    12 2.4985 -1.22006 0.930455 0
    13 2.4985 -1.22006 -0.849545 0
    14 -4.6377 -0.336759 0.0404545 0
    15 -3.7477 0.921941 0.930455 0
    16 -3.7477 0.921941 -0.849545 0
    17 4.6377 -0.336759 0.0404545 0
    18 3.7477 0.921941 -0.849545 0
    19 3.7477 0.921941 0.930455 0
     4-7.27e-07 -1.22006 0.930455 -17.4952
     5-7.27e-07 -1.22006 -0.849545 -17.4952
     6-1.2492 0.921941 0.930455 -19.6818
     7-1.2492 0.921941 -0.849545 -15.323
     81.2492 0.921941 -0.849545 -17.495
     91.2492 0.921941 0.930455 -17.4951
     10-2.4985 -1.22006 -0.849545 -13.1263
     11-2.4985 -1.22006 0.930455 -10.8961
     122.4985 -1.22006 0.930455 -13.1263
     132.4985 -1.22006 -0.849545 -10.8961
     14-4.6377 -0.336759 0.0404545 -9.35471
     15-3.7477 0.921941 0.930455 -9.24444
     16-3.7477 0.921941 -0.849545 -11.4805
     174.6377 -0.336759 0.0404545 -9.35473
     183.7477 0.921941 -0.849545 -11.4805
     193.7477 0.921941 0.930455 -9.24445
    2020
    212114 15 16
     
    27273 12 13
    282811 12 13
    29 8 11 12
    30 3 8 12
    31 1 3 8
    32 1 3 6
    33 1 6 9
    34 6 9 16
    35 9 14 16
     297 11 13
     304 7 13
     312 4 7
     322 4 5
     332 5 10
     345 10 15
     3510 14 15
    36369 10 14
    37372 9 10
     
    40401 7 8
    41417 8 11
    42 10 14 15
    43 5 10 15
    44 2 5 10
    45 2 4 5
    46 2 4 7
    47 4 7 13
    48 7 11 13
     429 14 16
     436 9 16
     441 6 9
     451 3 6
     461 3 8
     473 8 12
     488 11 12
  • tests/regression/Simple_configuration/2/post/test.conf

    rc39cc4 rbdb143  
    3535RelEpsTotalE    1e-07   # relative change in total energy
    3636RelEpsKineticE  1e-05   # relative change in kinetic energy
    37 MaxMinStopStep  0       # check every ..th steps
     37MaxMinStopStep  1       # check every ..th steps
    3838MaxMinGapStopStep       0       # check every ..th steps
    3939
     
    4242InitRelEpsTotalE        1e-05   # relative change in total energy
    4343InitRelEpsKineticE      0.0001  # relative change in kinetic energy
    44 InitMaxMinStopStep      0       # check every ..th steps
     44InitMaxMinStopStep      1       # check every ..th steps
    4545InitMaxMinGapStopStep   0       # check every ..th steps
    4646
     
    5454Level0Factor    2       # factor by which node number increases from S to 0 level
    5555RiemannTensor   0       # (Use metric)
    56 PsiType         0       # 0 - doubly occupied, 1 - SpinUp,SpinDown
     56PsiType         1       # 0 - doubly occupied, 1 - SpinUp,SpinDown
    5757MaxPsiDouble    0       # here: specifying both maximum number of SpinUp- and -Down-states
    5858PsiMaxNoUp      0       # here: specifying maximum number of SpinUp-states
    59 PsiMaxNoDown    0       # here: specifying maximum number of SpinDown-states
     59PsiMaxNoDown    1       # here: specifying maximum number of SpinDown-states
    6060AddPsis         0       # Additional unoccupied Psis for bandgap determination
    6161
  • tests/regression/Simple_configuration/2/post/test.conf.xyz

    rc39cc4 rbdb143  
    111
    22        Created by molecuilder on Tue Oct  6 18:34:23 2009
    3 H       10      10      10     
     3H       10      10      10
  • tests/regression/Simple_configuration/3/post/test.conf

    rc39cc4 rbdb143  
    3535RelEpsTotalE    1e-07   # relative change in total energy
    3636RelEpsKineticE  1e-05   # relative change in kinetic energy
    37 MaxMinStopStep  0       # check every ..th steps
     37MaxMinStopStep  1       # check every ..th steps
    3838MaxMinGapStopStep       0       # check every ..th steps
    3939
     
    4242InitRelEpsTotalE        1e-05   # relative change in total energy
    4343InitRelEpsKineticE      0.0001  # relative change in kinetic energy
    44 InitMaxMinStopStep      0       # check every ..th steps
     44InitMaxMinStopStep      1       # check every ..th steps
    4545InitMaxMinGapStopStep   0       # check every ..th steps
    4646
     
    5454Level0Factor    2       # factor by which node number increases from S to 0 level
    5555RiemannTensor   0       # (Use metric)
    56 PsiType         0       # 0 - doubly occupied, 1 - SpinUp,SpinDown
     56PsiType         1       # 0 - doubly occupied, 1 - SpinUp,SpinDown
    5757MaxPsiDouble    0       # here: specifying both maximum number of SpinUp- and -Down-states
    5858PsiMaxNoUp      0       # here: specifying maximum number of SpinUp-states
    59 PsiMaxNoDown    0       # here: specifying maximum number of SpinDown-states
     59PsiMaxNoDown    1       # here: specifying maximum number of SpinDown-states
    6060AddPsis         0       # Additional unoccupied Psis for bandgap determination
    6161
  • tests/regression/Simple_configuration/3/post/test.conf.xyz

    rc39cc4 rbdb143  
    111
    22        Created by molecuilder on Tue Oct  6 18:34:23 2009
    3 H       10      10      10     
     3H       10      10      10
  • tests/regression/Simple_configuration/4/post/test.conf

    rc39cc4 rbdb143  
    3535RelEpsTotalE    1e-07   # relative change in total energy
    3636RelEpsKineticE  1e-05   # relative change in kinetic energy
    37 MaxMinStopStep  0       # check every ..th steps
     37MaxMinStopStep  2       # check every ..th steps
    3838MaxMinGapStopStep       1       # check every ..th steps
    3939
     
    4242InitRelEpsTotalE        1e-05   # relative change in total energy
    4343InitRelEpsKineticE      0.0001  # relative change in kinetic energy
    44 InitMaxMinStopStep      0       # check every ..th steps
     44InitMaxMinStopStep      2       # check every ..th steps
    4545InitMaxMinGapStopStep   1       # check every ..th steps
    4646
     
    5555RiemannTensor   0       # (Use metric)
    5656PsiType         0       # 0 - doubly occupied, 1 - SpinUp,SpinDown
    57 MaxPsiDouble    0       # here: specifying both maximum number of SpinUp- and -Down-states
    58 PsiMaxNoUp      0       # here: specifying maximum number of SpinUp-states
    59 PsiMaxNoDown    0       # here: specifying maximum number of SpinDown-states
     57MaxPsiDouble    2       # here: specifying both maximum number of SpinUp- and -Down-states
     58PsiMaxNoUp      2       # here: specifying maximum number of SpinUp-states
     59PsiMaxNoDown    2       # here: specifying maximum number of SpinDown-states
    6060AddPsis         0       # Additional unoccupied Psis for bandgap determination
    6161
  • tests/regression/Simple_configuration/4/post/test.conf.xyz

    rc39cc4 rbdb143  
    111
    22        Created by molecuilder on Tue Oct  6 18:31:23 2009
    3 C       10      10      10     
     3C       10      10      10
  • tests/regression/Tesselation/1/post/NonConvexEnvelope.dat

    rc39cc4 rbdb143  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 9.78209 2.64589 2.64589 0
    5 9.78209 2.64589 4.42589 0
    6 10.672 3.90454 3.53589 0
    7 8.53279 4.78789 2.64589 0
    8 8.53279 4.78789 4.42589 0
    9 6.39363 3.90454 3.53589 0
    10 7.28359 2.64589 2.64589 0
    11 7.28359 2.64589 4.42589 0
     49.78209 2.64589 2.64589 -9.24443
     59.78209 2.64589 4.42589 -11.4804
     610.672 3.90454 3.53589 -9.35464
     78.53279 4.78789 2.64589 -9.11459
     88.53279 4.78789 4.42589 -9.11459
     96.39363 3.90454 3.53589 -9.35431
     107.28359 2.64589 2.64589 -11.4803
     117.28359 2.64589 4.42589 -9.24433
    1212
    13131 3 4
  • tests/regression/Tesselation/1/post/NonConvexEnvelope.r3d

    rc39cc4 rbdb143  
    33# All atoms as spheres
    442
    5   1.37419 -0.26503 -4.44089e-16         0.1     1. 1. 1.
     5  1.24926 -0.870237 -0.89       0.1     1. 1. 1.
    662
    7   0.12489 0.61837 -4.44089e-16  0.1     1. 1. 1.
     7  1.24926 -0.870237 0.89        0.1     1. 1. 1.
    882
    9   -1.12431 -0.26503 -4.44089e-16        0.1     1. 1. 1.
     9  2.13922 0.388414 0    0.1     1. 1. 1.
    10102
    11   1.37419 -0.89433 -0.89        0.1     1. 1. 1.
     11  -3.63639e-05 1.27176 -0.89    0.1     1. 1. 1.
    12122
    13   1.37419 -0.89433 0.89         0.1     1. 1. 1.
     13  -3.63639e-05 1.27176 0.89     0.1     1. 1. 1.
    14142
    15   2.26414 0.364321 -4.44089e-16         0.1     1. 1. 1.
     15  -2.13919 0.388414 0   0.1     1. 1. 1.
    16162
    17   0.12489 1.24767 -0.89         0.1     1. 1. 1.
     17  -1.24924 -0.870237 -0.89      0.1     1. 1. 1.
    18182
    19   0.12489 1.24767 0.89  0.1     1. 1. 1.
     19  -1.24924 -0.870237 0.89       0.1     1. 1. 1.
    20202
    21   -2.01426 0.364321 -4.44089e-16        0.1     1. 1. 1.
     21  1.24926 -0.240937 0   0.1     1. 1. 1.
    22222
    23   -1.12431 -0.89433 -0.89       0.1     1. 1. 1.
     23  -3.63639e-05 0.642463 0       0.1     1. 1. 1.
    24242
    25   -1.12431 -0.89433 0.89        0.1     1. 1. 1.
     25  -1.24924 -0.240937 0  0.1     1. 1. 1.
    2626# All tesselation triangles
    27278
     
    3030  BACKFACE  0.3 0.3 1.0   0 0
    31311
    32   1.37419 -0.89433 -0.89        2.26414 0.364321 -4.44089e-16   0.12489 1.24767 -0.89   1. 0. 0.
     32  1.24926 -0.870237 -0.89       2.13922 0.388414 0      -3.63639e-05 1.27176 -0.89      1. 0. 0.
    33331
    34   1.37419 -0.89433 -0.89        0.12489 1.24767 -0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
     34  1.24926 -0.870237 -0.89       -3.63639e-05 1.27176 -0.89      -1.24924 -0.870237 -0.89        1. 0. 0.
    35351
    36   0.12489 1.24767 -0.89         -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 -0.89         1. 0. 0.
     36  -3.63639e-05 1.27176 -0.89    -2.13919 0.388414 0     -1.24924 -0.870237 -0.89        1. 0. 0.
    37371
    38   2.26414 0.364321 -4.44089e-16         0.12489 1.24767 -0.89   0.12489 1.24767 0.89    1. 0. 0.
     38  2.13922 0.388414 0    -3.63639e-05 1.27176 -0.89      -3.63639e-05 1.27176 0.89       1. 0. 0.
    39391
    40   0.12489 1.24767 -0.89         0.12489 1.24767 0.89    -2.01426 0.364321 -4.44089e-16  1. 0. 0.
     40  -3.63639e-05 1.27176 -0.89    -3.63639e-05 1.27176 0.89       -2.13919 0.388414 0     1. 0. 0.
    41411
    42   1.37419 -0.89433 0.89         2.26414 0.364321 -4.44089e-16   0.12489 1.24767 0.89    1. 0. 0.
     42  1.24926 -0.870237 0.89        2.13922 0.388414 0      -3.63639e-05 1.27176 0.89       1. 0. 0.
    43431
    44   1.37419 -0.89433 0.89         0.12489 1.24767 0.89    -1.12431 -0.89433 0.89  1. 0. 0.
     44  1.24926 -0.870237 0.89        -3.63639e-05 1.27176 0.89       -1.24924 -0.870237 0.89         1. 0. 0.
    45451
    46   0.12489 1.24767 0.89  -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 0.89  1. 0. 0.
     46  -3.63639e-05 1.27176 0.89     -2.13919 0.388414 0     -1.24924 -0.870237 0.89         1. 0. 0.
    47471
    48   -2.01426 0.364321 -4.44089e-16        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     48  -2.13919 0.388414 0   -1.24924 -0.870237 -0.89        -1.24924 -0.870237 0.89         1. 0. 0.
    49491
    50   1.37419 -0.89433 0.89         -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     50  1.24926 -0.870237 0.89        -1.24924 -0.870237 -0.89        -1.24924 -0.870237 0.89         1. 0. 0.
    51511
    52   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
     52  1.24926 -0.870237 -0.89       1.24926 -0.870237 0.89  -1.24924 -0.870237 -0.89        1. 0. 0.
    53531
    54   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   2.26414 0.364321 -4.44089e-16   1. 0. 0.
     54  1.24926 -0.870237 -0.89       1.24926 -0.870237 0.89  2.13922 0.388414 0      1. 0. 0.
    55559
    5656#  terminating special property
     
    5959  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
    60602
    61   1.67084 -0.47478 -8.88178e-16 5       1 0 0
     61  1.54591 -0.450686 -4.44089e-16        5       1 0 0
    62629
    6363  terminating special property
  • tests/regression/Tesselation/2/post/ConvexEnvelope.dat

    rc39cc4 rbdb143  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 9.78209 2.64589 2.64589 0
    5 9.78209 2.64589 4.42589 0
    6 10.672 3.90454 3.53589 0
    7 8.53279 4.78789 2.64589 0
    8 8.53279 4.78789 4.42589 0
    9 6.39363 3.90454 3.53589 0
    10 7.28359 2.64589 2.64589 0
    11 7.28359 2.64589 4.42589 0
     49.78209 2.64589 2.64589 -9.24443
     59.78209 2.64589 4.42589 -11.4804
     610.672 3.90454 3.53589 -9.35464
     78.53279 4.78789 2.64589 -9.11459
     88.53279 4.78789 4.42589 -9.11459
     96.39363 3.90454 3.53589 -9.35431
     107.28359 2.64589 2.64589 -11.4803
     117.28359 2.64589 4.42589 -9.24433
    1212
    13131 3 4
  • tests/regression/Tesselation/2/post/ConvexEnvelope.r3d

    rc39cc4 rbdb143  
    33# All atoms as spheres
    442
    5   1.37419 -0.26503 -4.44089e-16         0.1     1. 1. 1.
     5  1.24926 -0.870237 -0.89       0.1     1. 1. 1.
    662
    7   0.12489 0.61837 -4.44089e-16  0.1     1. 1. 1.
     7  1.24926 -0.870237 0.89        0.1     1. 1. 1.
    882
    9   -1.12431 -0.26503 -4.44089e-16        0.1     1. 1. 1.
     9  2.13922 0.388414 0    0.1     1. 1. 1.
    10102
    11   1.37419 -0.89433 -0.89        0.1     1. 1. 1.
     11  -3.63639e-05 1.27176 -0.89    0.1     1. 1. 1.
    12122
    13   1.37419 -0.89433 0.89         0.1     1. 1. 1.
     13  -3.63639e-05 1.27176 0.89     0.1     1. 1. 1.
    14142
    15   2.26414 0.364321 -4.44089e-16         0.1     1. 1. 1.
     15  -2.13919 0.388414 0   0.1     1. 1. 1.
    16162
    17   0.12489 1.24767 -0.89         0.1     1. 1. 1.
     17  -1.24924 -0.870237 -0.89      0.1     1. 1. 1.
    18182
    19   0.12489 1.24767 0.89  0.1     1. 1. 1.
     19  -1.24924 -0.870237 0.89       0.1     1. 1. 1.
    20202
    21   -2.01426 0.364321 -4.44089e-16        0.1     1. 1. 1.
     21  1.24926 -0.240937 0   0.1     1. 1. 1.
    22222
    23   -1.12431 -0.89433 -0.89       0.1     1. 1. 1.
     23  -3.63639e-05 0.642463 0       0.1     1. 1. 1.
    24242
    25   -1.12431 -0.89433 0.89        0.1     1. 1. 1.
     25  -1.24924 -0.240937 0  0.1     1. 1. 1.
    2626# All tesselation triangles
    27278
     
    3030  BACKFACE  0.3 0.3 1.0   0 0
    31311
    32   1.37419 -0.89433 -0.89        2.26414 0.364321 -4.44089e-16   0.12489 1.24767 -0.89   1. 0. 0.
     32  1.24926 -0.870237 -0.89       2.13922 0.388414 0      -3.63639e-05 1.27176 -0.89      1. 0. 0.
    33331
    34   1.37419 -0.89433 -0.89        0.12489 1.24767 -0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
     34  1.24926 -0.870237 -0.89       -3.63639e-05 1.27176 -0.89      -1.24924 -0.870237 -0.89        1. 0. 0.
    35351
    36   0.12489 1.24767 -0.89         -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 -0.89         1. 0. 0.
     36  -3.63639e-05 1.27176 -0.89    -2.13919 0.388414 0     -1.24924 -0.870237 -0.89        1. 0. 0.
    37371
    38   2.26414 0.364321 -4.44089e-16         0.12489 1.24767 -0.89   0.12489 1.24767 0.89    1. 0. 0.
     38  2.13922 0.388414 0    -3.63639e-05 1.27176 -0.89      -3.63639e-05 1.27176 0.89       1. 0. 0.
    39391
    40   0.12489 1.24767 -0.89         0.12489 1.24767 0.89    -2.01426 0.364321 -4.44089e-16  1. 0. 0.
     40  -3.63639e-05 1.27176 -0.89    -3.63639e-05 1.27176 0.89       -2.13919 0.388414 0     1. 0. 0.
    41411
    42   1.37419 -0.89433 0.89         2.26414 0.364321 -4.44089e-16   0.12489 1.24767 0.89    1. 0. 0.
     42  1.24926 -0.870237 0.89        2.13922 0.388414 0      -3.63639e-05 1.27176 0.89       1. 0. 0.
    43431
    44   1.37419 -0.89433 0.89         0.12489 1.24767 0.89    -1.12431 -0.89433 0.89  1. 0. 0.
     44  1.24926 -0.870237 0.89        -3.63639e-05 1.27176 0.89       -1.24924 -0.870237 0.89         1. 0. 0.
    45451
    46   0.12489 1.24767 0.89  -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 0.89  1. 0. 0.
     46  -3.63639e-05 1.27176 0.89     -2.13919 0.388414 0     -1.24924 -0.870237 0.89         1. 0. 0.
    47471
    48   -2.01426 0.364321 -4.44089e-16        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     48  -2.13919 0.388414 0   -1.24924 -0.870237 -0.89        -1.24924 -0.870237 0.89         1. 0. 0.
    49491
    50   1.37419 -0.89433 0.89         -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     50  1.24926 -0.870237 0.89        -1.24924 -0.870237 -0.89        -1.24924 -0.870237 0.89         1. 0. 0.
    51511
    52   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
     52  1.24926 -0.870237 -0.89       1.24926 -0.870237 0.89  -1.24924 -0.870237 -0.89        1. 0. 0.
    53531
    54   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   2.26414 0.364321 -4.44089e-16   1. 0. 0.
     54  1.24926 -0.870237 -0.89       1.24926 -0.870237 0.89  2.13922 0.388414 0      1. 0. 0.
    55559
    5656#  terminating special property
     
    5959  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
    60602
    61   1.67084 -0.47478 -8.88178e-16 5       1 0 0
     61  1.54591 -0.450686 -4.44089e-16        5       1 0 0
    62629
    6363  terminating special property
  • tests/regression/Tesselation/2/post/NonConvexEnvelope.dat

    rc39cc4 rbdb143  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 9.78209 2.64589 2.64589 0
    5 9.78209 2.64589 4.42589 0
    6 10.672 3.90454 3.53589 0
    7 8.53279 4.78789 2.64589 0
    8 8.53279 4.78789 4.42589 0
    9 6.39363 3.90454 3.53589 0
    10 7.28359 2.64589 2.64589 0
    11 7.28359 2.64589 4.42589 0
     49.78209 2.64589 2.64589 -9.24443
     59.78209 2.64589 4.42589 -11.4804
     610.672 3.90454 3.53589 -9.35464
     78.53279 4.78789 2.64589 -9.11459
     88.53279 4.78789 4.42589 -9.11459
     96.39363 3.90454 3.53589 -9.35431
     107.28359 2.64589 2.64589 -11.4803
     117.28359 2.64589 4.42589 -9.24433
    1212
    13131 3 4
  • tests/regression/Tesselation/2/post/NonConvexEnvelope.r3d

    rc39cc4 rbdb143  
    33# All atoms as spheres
    442
    5   1.37419 -0.26503 -4.44089e-16         0.1     1. 1. 1.
     5  1.24926 -0.870237 -0.89       0.1     1. 1. 1.
    662
    7   0.12489 0.61837 -4.44089e-16  0.1     1. 1. 1.
     7  1.24926 -0.870237 0.89        0.1     1. 1. 1.
    882
    9   -1.12431 -0.26503 -4.44089e-16        0.1     1. 1. 1.
     9  2.13922 0.388414 0    0.1     1. 1. 1.
    10102
    11   1.37419 -0.89433 -0.89        0.1     1. 1. 1.
     11  -3.63639e-05 1.27176 -0.89    0.1     1. 1. 1.
    12122
    13   1.37419 -0.89433 0.89         0.1     1. 1. 1.
     13  -3.63639e-05 1.27176 0.89     0.1     1. 1. 1.
    14142
    15   2.26414 0.364321 -4.44089e-16         0.1     1. 1. 1.
     15  -2.13919 0.388414 0   0.1     1. 1. 1.
    16162
    17   0.12489 1.24767 -0.89         0.1     1. 1. 1.
     17  -1.24924 -0.870237 -0.89      0.1     1. 1. 1.
    18182
    19   0.12489 1.24767 0.89  0.1     1. 1. 1.
     19  -1.24924 -0.870237 0.89       0.1     1. 1. 1.
    20202
    21   -2.01426 0.364321 -4.44089e-16        0.1     1. 1. 1.
     21  1.24926 -0.240937 0   0.1     1. 1. 1.
    22222
    23   -1.12431 -0.89433 -0.89       0.1     1. 1. 1.
     23  -3.63639e-05 0.642463 0       0.1     1. 1. 1.
    24242
    25   -1.12431 -0.89433 0.89        0.1     1. 1. 1.
     25  -1.24924 -0.240937 0  0.1     1. 1. 1.
    2626# All tesselation triangles
    27278
     
    3030  BACKFACE  0.3 0.3 1.0   0 0
    31311
    32   1.37419 -0.89433 -0.89        2.26414 0.364321 -4.44089e-16   0.12489 1.24767 -0.89   1. 0. 0.
     32  1.24926 -0.870237 -0.89       2.13922 0.388414 0      -3.63639e-05 1.27176 -0.89      1. 0. 0.
    33331
    34   1.37419 -0.89433 -0.89        0.12489 1.24767 -0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
     34  1.24926 -0.870237 -0.89       -3.63639e-05 1.27176 -0.89      -1.24924 -0.870237 -0.89        1. 0. 0.
    35351
    36   0.12489 1.24767 -0.89         -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 -0.89         1. 0. 0.
     36  -3.63639e-05 1.27176 -0.89    -2.13919 0.388414 0     -1.24924 -0.870237 -0.89        1. 0. 0.
    37371
    38   2.26414 0.364321 -4.44089e-16         0.12489 1.24767 -0.89   0.12489 1.24767 0.89    1. 0. 0.
     38  2.13922 0.388414 0    -3.63639e-05 1.27176 -0.89      -3.63639e-05 1.27176 0.89       1. 0. 0.
    39391
    40   0.12489 1.24767 -0.89         0.12489 1.24767 0.89    -2.01426 0.364321 -4.44089e-16  1. 0. 0.
     40  -3.63639e-05 1.27176 -0.89    -3.63639e-05 1.27176 0.89       -2.13919 0.388414 0     1. 0. 0.
    41411
    42   1.37419 -0.89433 0.89         2.26414 0.364321 -4.44089e-16   0.12489 1.24767 0.89    1. 0. 0.
     42  1.24926 -0.870237 0.89        2.13922 0.388414 0      -3.63639e-05 1.27176 0.89       1. 0. 0.
    43431
    44   1.37419 -0.89433 0.89         0.12489 1.24767 0.89    -1.12431 -0.89433 0.89  1. 0. 0.
     44  1.24926 -0.870237 0.89        -3.63639e-05 1.27176 0.89       -1.24924 -0.870237 0.89         1. 0. 0.
    45451
    46   0.12489 1.24767 0.89  -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 0.89  1. 0. 0.
     46  -3.63639e-05 1.27176 0.89     -2.13919 0.388414 0     -1.24924 -0.870237 0.89         1. 0. 0.
    47471
    48   -2.01426 0.364321 -4.44089e-16        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     48  -2.13919 0.388414 0   -1.24924 -0.870237 -0.89        -1.24924 -0.870237 0.89         1. 0. 0.
    49491
    50   1.37419 -0.89433 0.89         -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     50  1.24926 -0.870237 0.89        -1.24924 -0.870237 -0.89        -1.24924 -0.870237 0.89         1. 0. 0.
    51511
    52   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
     52  1.24926 -0.870237 -0.89       1.24926 -0.870237 0.89  -1.24924 -0.870237 -0.89        1. 0. 0.
    53531
    54   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   2.26414 0.364321 -4.44089e-16   1. 0. 0.
     54  1.24926 -0.870237 -0.89       1.24926 -0.870237 0.89  2.13922 0.388414 0      1. 0. 0.
    55559
    5656#  terminating special property
     
    5959  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
    60602
    61   1.67084 -0.47478 -8.88178e-16 5       1 0 0
     61  1.54591 -0.450686 -4.44089e-16        5       1 0 0
    62629
    6363  terminating special property
  • tests/regression/Tesselation/3/post/NonConvexEnvelope.dat

    rc39cc4 rbdb143  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="test", N=44, E=86, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 6.9077 1.1106 0.1214 1
    5 0.3612 -3.628 1.323 1
    6 0.4884 -3.5983 -0.4521 3
    7 1.4985 -2.5112 0.5308 4
    8 -1.9534 -3.5752 0.5362 2
    9 -1.1883 -0.199 1.5176 3
    10 -0.7165 -1.6046 2.5129 1
    11 1.7627 -1.4479 -0.8349 4
    12 -1.003 -1.3584 -2.8848 2
    13 0.0217 -2.6629 -2.2008 1
    14 -2.8885 -1.5706 1.7543 2
    15 -2.0579 -3.6765 -1.7622 0
    16 -2.9259 -2.1146 -1.7672 1
    17 1.0353 0.1785 2.542 3
    18 1.6325 -1.3323 1.8306 2
    19 0.7271 1.177 0.3594 3
    20 1.3374 -0.2942 -2.961 2
    21 0.6036 1.0859 -2.1126 3
    22 -3.2034 -0.5041 -1.0881 3
    23 -5.1809 -1.8679 0.9687 1
    24 -4.6025 -2.4721 -0.6025 2
    25 -4.3385 -3.4329 0.8725 0
    26 3.191 1.3217 -2.8354 1
    27 -4.0905 0.6312 1.6028 3
    28 2.8131 1.4776 2.5103 0
    29 3.9137 2.2936 1.3739 0
    30 2.159 2.5738 1.2698 5
    31 3.6606 -0.4593 2.1396 2
    32 3.2007 -1.4419 0.7311 4
    33 -3.3002 2.3589 0.0094 8
    34 -4.377 1.6962 -1.2433 3
    35 5.2593 1.4547 -1.7445 0
    36 4.6863 2.7674 -0.6775 0
    37 5.746 -0.9031 1.204 0
    38 5.1212 -0.8867 -0.4582 4
    39 -5.2641 2.8314 1.4476 0
    40 5.2727 1.6068 1.2828 2
    41 -6.2394 4.6427 0.0632 0
    42 -4.4738 4.5591 -0.1458 3
    43 -5.5506 3.8964 -1.3985 0
    44 -6.7081 0.9923 0.6224 2
    45 -7.5442 2.5597 0.5118 0
    46 -6.8554 1.8134 -0.9499 1
    47 7.1391 2.0447 0.0264 0
     46.9077 1.1106 0.1214 -6.99715
     50.3612 -3.628 1.323 6.00416
     60.4884 -3.5983 -0.4521 11.8428
     71.4985 -2.5112 0.5308 6.07951
     8-1.9534 -3.5752 0.5362 -4.26914
     9-1.1883 -0.199 1.5176 14.2992
     10-0.7165 -1.6046 2.5129 6.2134
     111.7627 -1.4479 -0.8349 7.15053
     12-1.003 -1.3584 -2.8848 32.043
     130.0217 -2.6629 -2.2008 16.8009
     14-2.8885 -1.5706 1.7543 -1.77076
     15-2.0579 -3.6765 -1.7622 -7.05319
     16-2.9259 -2.1146 -1.7672 33.6663
     171.0353 0.1785 2.542 48.8869
     181.6325 -1.3323 1.8306 1.44108
     190.7271 1.177 0.3594 27.9872
     201.3374 -0.2942 -2.961 13.6459
     210.6036 1.0859 -2.1126 98.521
     22-3.2034 -0.5041 -1.0881 8.44805
     23-5.1809 -1.8679 0.9687 -6.07448
     24-4.6025 -2.4721 -0.6025 -6.52057
     25-4.3385 -3.4329 0.8725 -4.12716
     263.191 1.3217 -2.8354 -10.5968
     27-4.0905 0.6312 1.6028 21.8745
     282.8131 1.4776 2.5103 -0.774194
     293.9137 2.2936 1.3739 -2.51806
     302.159 2.5738 1.2698 151.494
     313.6606 -0.4593 2.1396 2.60004
     323.2007 -1.4419 0.7311 2.29272
     33-3.3002 2.3589 0.0094 461.065
     34-4.377 1.6962 -1.2433 43.4649
     355.2593 1.4547 -1.7445 -6.26082
     364.6863 2.7674 -0.6775 -8.55931
     375.746 -0.9031 1.204 -1.29544
     385.1212 -0.8867 -0.4582 31.5177
     39-5.2641 2.8314 1.4476 21.5516
     405.2727 1.6068 1.2828 -2.57271
     41-6.2394 4.6427 0.0632 -9.24392
     42-4.4738 4.5591 -0.1458 62.5211
     43-5.5506 3.8964 -1.3985 -10.3613
     44-6.7081 0.9923 0.6224 -7.08885
     45-7.5442 2.5597 0.5118 -11.4252
     46-6.8554 1.8134 -0.9499 3.80444
     477.1391 2.0447 0.0264 -7.88713
    4848
    49491 32 44
  • tests/regression/Tesselation/3/post/NonConvexEnvelope.r3d

    rc39cc4 rbdb143  
    33# All atoms as spheres
    442
    5   0.952534 -3.05798 0.420171    0.1     1. 1. 1.
    6 2
    7   -0.139866 -1.98848 0.359771   0.1     1. 1. 1.
    8 2
    9   0.0788342 -1.07508 -0.875229  0.1     1. 1. 1.
    10 2
    11   -1.49147 -2.63828 0.0780712   0.1     1. 1. 1.
    12 2
    13   -0.0588658 -1.09478 1.58347   0.1     1. 1. 1.
    14 2
    15   1.53473 -0.644479 -0.868129   0.1     1. 1. 1.
    16 2
    17   -0.333166 -2.00128 -2.02443   0.1     1. 1. 1.
    18 2
    19   -2.62147 -1.78218 0.653571    0.1     1. 1. 1.
    20 2
    21   -1.60077 -2.70398 -1.46563    0.1     1. 1. 1.
    22 2
    23   1.37913 -0.560579 1.65607     0.1     1. 1. 1.
    24 2
    25   1.75933 0.205421 0.395371     0.1     1. 1. 1.
    26 2
    27   1.79893 0.246421 -2.08883     0.1     1. 1. 1.
    28 2
    29   -2.64037 -0.423279 -0.0491288         0.1     1. 1. 1.
    30 2
    31   -3.96017 -2.48928 0.432671    0.1     1. 1. 1.
    32 2
    33   3.23013 0.593821 0.484471     0.1     1. 1. 1.
    34 2
    35   3.14803 0.889821 -1.96833     0.1     1. 1. 1.
    36 2
    37   -3.79507 0.418021 0.498371    0.1     1. 1. 1.
    38 2
    39   3.36023 1.76962 1.45487       0.1     1. 1. 1.
    40 2
    41   3.78273 1.01752 -0.849429     0.1     1. 1. 1.
    42 2
    43   4.07093 -0.563879 1.01767     0.1     1. 1. 1.
    44 2
    45   -3.81397 1.77692 -0.204329    0.1     1. 1. 1.
    46 2
    47   5.17783 1.62112 -0.842829     0.1     1. 1. 1.
    48 2
    49   5.49863 -0.464179 0.482071    0.1     1. 1. 1.
    50 2
    51   -4.96867 2.61822 0.343171     0.1     1. 1. 1.
    52 2
    53   5.93083 0.990421 0.337371     0.1     1. 1. 1.
    54 2
    55   -4.98757 3.97722 -0.359529    0.1     1. 1. 1.
    56 2
    57   -6.29237 1.89422 0.0890712    0.1     1. 1. 1.
    58 2
    59   7.33693 1.04442 0.0886712     0.1     1. 1. 1.
    60 2
    61   0.790434 -3.69418 1.29027     0.1     1. 1. 1.
    62 2
    63   0.917634 -3.66448 -0.484829   0.1     1. 1. 1.
    64 2
    65   1.92773 -2.57738 0.498071     0.1     1. 1. 1.
    66 2
    67   -0.574266 -0.203779 -0.824729         0.1     1. 1. 1.
    68 2
    69   -1.52417 -3.64138 0.503471    0.1     1. 1. 1.
    70 2
    71   -0.759066 -0.265179 1.48487   0.1     1. 1. 1.
    72 2
    73   -0.287266 -1.67078 2.48017    0.1     1. 1. 1.
    74 2
    75   2.19193 -1.51408 -0.867629    0.1     1. 1. 1.
    76 2
    77   -0.573766 -1.42458 -2.91753   0.1     1. 1. 1.
    78 2
    79   0.450934 -2.72908 -2.23353    0.1     1. 1. 1.
    80 2
    81   -2.45927 -1.63678 1.72157     0.1     1. 1. 1.
    82 2
    83   -1.62867 -3.74268 -1.79493    0.1     1. 1. 1.
    84 2
    85   -2.49667 -2.18078 -1.79993    0.1     1. 1. 1.
    86 2
    87   1.46453 0.112321 2.50927      0.1     1. 1. 1.
    88 2
    89   2.06173 -1.39848 1.79787      0.1     1. 1. 1.
    90 2
    91   1.15633 1.11082 0.326671      0.1     1. 1. 1.
    92 2
    93   1.76663 -0.360379 -2.99373    0.1     1. 1. 1.
    94 2
    95   1.03283 1.01972 -2.14533      0.1     1. 1. 1.
    96 2
    97   -1.69727 0.0925205 0.131971   0.1     1. 1. 1.
    98 2
    99   -2.77417 -0.570279 -1.12083   0.1     1. 1. 1.
    100 2
    101   -4.75167 -1.93408 0.935971    0.1     1. 1. 1.
    102 2
    103   -4.17327 -2.53828 -0.635229   0.1     1. 1. 1.
    104 2
    105   -3.90927 -3.49908 0.839771    0.1     1. 1. 1.
    106 2
    107   3.62023 1.25552 -2.86813      0.1     1. 1. 1.
    108 2
    109   -4.73807 -0.0977795 0.317371  0.1     1. 1. 1.
    110 2
    111   -3.66127 0.565021 1.57007     0.1     1. 1. 1.
    112 2
    113   3.24233 1.41142 2.47757       0.1     1. 1. 1.
    114 2
    115   4.34293 2.22742 1.34117       0.1     1. 1. 1.
    116 2
    117   2.58823 2.50762 1.23707       0.1     1. 1. 1.
    118 2
    119   4.08983 -0.525479 2.10687     0.1     1. 1. 1.
    120 2
    121   3.62993 -1.50808 0.698371     0.1     1. 1. 1.
    122 2
    123   -2.87097 2.29272 -0.0233288   0.1     1. 1. 1.
    124 2
    125   -3.94777 1.63002 -1.27603     0.1     1. 1. 1.
    126 2
    127   5.68853 1.38852 -1.77723      0.1     1. 1. 1.
    128 2
    129   5.11553 2.70122 -0.710229     0.1     1. 1. 1.
    130 2
    131   6.17523 -0.969279 1.17127     0.1     1. 1. 1.
    132 2
    133   5.55043 -0.952879 -0.490929   0.1     1. 1. 1.
    134 2
    135   -4.83487 2.76522 1.41487      0.1     1. 1. 1.
    136 2
    137   5.70193 1.54062 1.25007       0.1     1. 1. 1.
    138 2
    139   -5.81017 4.57652 0.0304712    0.1     1. 1. 1.
    140 2
    141   -4.04457 4.49292 -0.178529    0.1     1. 1. 1.
    142 2
    143   -5.12137 3.83022 -1.43123     0.1     1. 1. 1.
    144 2
    145   -6.27887 0.926121 0.589671    0.1     1. 1. 1.
    146 2
    147   -7.11497 2.49352 0.479071     0.1     1. 1. 1.
    148 2
    149   -6.42617 1.74722 -0.982629    0.1     1. 1. 1.
    150 2
    151   7.56833 1.97852 -0.00632877   0.1     1. 1. 1.
     5  0.939662 -3.01666 0.414493    0.1     1. 1. 1.
     62
     7  -0.152738 -1.94716 0.354093   0.1     1. 1. 1.
     82
     9  0.0659622 -1.03376 -0.880907  0.1     1. 1. 1.
     102
     11  -1.50434 -2.59696 0.0723932   0.1     1. 1. 1.
     122
     13  -0.0717378 -1.05346 1.57779   0.1     1. 1. 1.
     142
     15  1.52186 -0.603155 -0.873807   0.1     1. 1. 1.
     162
     17  -0.346038 -1.95996 -2.03011   0.1     1. 1. 1.
     182
     19  -2.63434 -1.74086 0.647893    0.1     1. 1. 1.
     202
     21  -1.61364 -2.66266 -1.47131    0.1     1. 1. 1.
     222
     23  1.36626 -0.519255 1.65039     0.1     1. 1. 1.
     242
     25  1.74646 0.246745 0.389693     0.1     1. 1. 1.
     262
     27  1.78606 0.287745 -2.09451     0.1     1. 1. 1.
     282
     29  -2.65324 -0.381955 -0.0548068         0.1     1. 1. 1.
     302
     31  -3.97304 -2.44796 0.426993    0.1     1. 1. 1.
     322
     33  3.21726 0.635145 0.478793     0.1     1. 1. 1.
     342
     35  3.13516 0.931145 -1.97401     0.1     1. 1. 1.
     362
     37  -3.80794 0.459345 0.492693    0.1     1. 1. 1.
     382
     39  3.34736 1.81094 1.44919       0.1     1. 1. 1.
     402
     41  3.76986 1.05884 -0.855107     0.1     1. 1. 1.
     422
     43  4.05806 -0.522555 1.01199     0.1     1. 1. 1.
     442
     45  -3.82684 1.81824 -0.210007    0.1     1. 1. 1.
     462
     47  5.16496 1.66244 -0.848507     0.1     1. 1. 1.
     482
     49  5.48576 -0.422855 0.476393    0.1     1. 1. 1.
     502
     51  -4.98154 2.65954 0.337493     0.1     1. 1. 1.
     522
     53  5.91796 1.03174 0.331693      0.1     1. 1. 1.
     542
     55  -5.00044 4.01854 -0.365207    0.1     1. 1. 1.
     562
     57  -6.30524 1.93554 0.0833932    0.1     1. 1. 1.
     582
     59  7.32406 1.08574 0.0829932     0.1     1. 1. 1.
     602
     61  0.777562 -3.65286 1.28459     0.1     1. 1. 1.
     622
     63  0.904762 -3.62316 -0.490507   0.1     1. 1. 1.
     642
     65  1.91486 -2.53606 0.492393     0.1     1. 1. 1.
     662
     67  -0.587138 -0.162455 -0.830407         0.1     1. 1. 1.
     682
     69  -1.53704 -3.60006 0.497793    0.1     1. 1. 1.
     702
     71  -0.771938 -0.223855 1.47919   0.1     1. 1. 1.
     722
     73  -0.300138 -1.62946 2.47449    0.1     1. 1. 1.
     742
     75  2.17906 -1.47276 -0.873307    0.1     1. 1. 1.
     762
     77  -0.586638 -1.38326 -2.92321   0.1     1. 1. 1.
     782
     79  0.438062 -2.68776 -2.23921    0.1     1. 1. 1.
     802
     81  -2.47214 -1.59546 1.71589     0.1     1. 1. 1.
     822
     83  -1.64154 -3.70136 -1.80061    0.1     1. 1. 1.
     842
     85  -2.50954 -2.13946 -1.80561    0.1     1. 1. 1.
     862
     87  1.45166 0.153645 2.50359      0.1     1. 1. 1.
     882
     89  2.04886 -1.35716 1.79219      0.1     1. 1. 1.
     902
     91  1.14346 1.15214 0.320993      0.1     1. 1. 1.
     922
     93  1.75376 -0.319055 -2.99941    0.1     1. 1. 1.
     942
     95  1.01996 1.06104 -2.15101      0.1     1. 1. 1.
     962
     97  -1.71014 0.133845 0.126293    0.1     1. 1. 1.
     982
     99  -2.78704 -0.528955 -1.12651   0.1     1. 1. 1.
     1002
     101  -4.76454 -1.89276 0.930293    0.1     1. 1. 1.
     1022
     103  -4.18614 -2.49696 -0.640907   0.1     1. 1. 1.
     1042
     105  -3.92214 -3.45776 0.834093    0.1     1. 1. 1.
     1062
     107  3.60736 1.29684 -2.87381      0.1     1. 1. 1.
     1082
     109  -4.75094 -0.0564554 0.311693  0.1     1. 1. 1.
     1102
     111  -3.67414 0.606345 1.56439     0.1     1. 1. 1.
     1122
     113  3.22946 1.45274 2.47189       0.1     1. 1. 1.
     1142
     115  4.33006 2.26874 1.33549       0.1     1. 1. 1.
     1162
     117  2.57536 2.54894 1.23139       0.1     1. 1. 1.
     1182
     119  4.07696 -0.484155 2.10119     0.1     1. 1. 1.
     1202
     121  3.61706 -1.46676 0.692693     0.1     1. 1. 1.
     1222
     123  -2.88384 2.33404 -0.0290068   0.1     1. 1. 1.
     1242
     125  -3.96064 1.67134 -1.28171     0.1     1. 1. 1.
     1262
     127  5.67566 1.42984 -1.78291      0.1     1. 1. 1.
     1282
     129  5.10266 2.74254 -0.715907     0.1     1. 1. 1.
     1302
     131  6.16236 -0.927955 1.16559     0.1     1. 1. 1.
     1322
     133  5.53756 -0.911555 -0.496607   0.1     1. 1. 1.
     1342
     135  -4.84774 2.80654 1.40919      0.1     1. 1. 1.
     1362
     137  5.68906 1.58194 1.24439       0.1     1. 1. 1.
     1382
     139  -5.82304 4.61784 0.0247932    0.1     1. 1. 1.
     1402
     141  -4.05744 4.53424 -0.184207    0.1     1. 1. 1.
     1422
     143  -5.13424 3.87154 -1.43691     0.1     1. 1. 1.
     1442
     145  -6.29174 0.967445 0.583993    0.1     1. 1. 1.
     1462
     147  -7.12784 2.53484 0.473393     0.1     1. 1. 1.
     1482
     149  -6.43904 1.78854 -0.988307    0.1     1. 1. 1.
     1502
     151  7.55546 2.01984 -0.0120068    0.1     1. 1. 1.
    152152# All tesselation triangles
    1531538
     
    156156  BACKFACE  0.3 0.3 1.0   0 0
    1571571
    158   7.33693 1.04442 0.0886712     5.68853 1.38852 -1.77723        7.56833 1.97852 -0.00632877     1. 0. 0.
    159 1
    160   7.33693 1.04442 0.0886712     5.68853 1.38852 -1.77723        5.55043 -0.952879 -0.490929     1. 0. 0.
    161 1
    162   7.33693 1.04442 0.0886712     6.17523 -0.969279 1.17127       5.55043 -0.952879 -0.490929     1. 0. 0.
    163 1
    164   3.62023 1.25552 -2.86813      5.68853 1.38852 -1.77723        5.55043 -0.952879 -0.490929     1. 0. 0.
    165 1
    166   1.76663 -0.360379 -2.99373    3.62023 1.25552 -2.86813        5.55043 -0.952879 -0.490929     1. 0. 0.
    167 1
    168   2.19193 -1.51408 -0.867629    1.76663 -0.360379 -2.99373      5.55043 -0.952879 -0.490929     1. 0. 0.
    169 1
    170   2.19193 -1.51408 -0.867629    0.450934 -2.72908 -2.23353      1.76663 -0.360379 -2.99373      1. 0. 0.
    171 1
    172   0.917634 -3.66448 -0.484829   2.19193 -1.51408 -0.867629      0.450934 -2.72908 -2.23353      1. 0. 0.
    173 1
    174   0.917634 -3.66448 -0.484829   2.19193 -1.51408 -0.867629      5.55043 -0.952879 -0.490929     1. 0. 0.
    175 1
    176   0.917634 -3.66448 -0.484829   1.92773 -2.57738 0.498071       5.55043 -0.952879 -0.490929     1. 0. 0.
    177 1
    178   1.92773 -2.57738 0.498071     3.62993 -1.50808 0.698371       5.55043 -0.952879 -0.490929     1. 0. 0.
    179 1
    180   3.62993 -1.50808 0.698371     6.17523 -0.969279 1.17127       5.55043 -0.952879 -0.490929     1. 0. 0.
    181 1
    182   0.790434 -3.69418 1.29027     0.917634 -3.66448 -0.484829     1.92773 -2.57738 0.498071       1. 0. 0.
    183 1
    184   0.790434 -3.69418 1.29027     1.92773 -2.57738 0.498071       3.62993 -1.50808 0.698371       1. 0. 0.
    185 1
    186   0.790434 -3.69418 1.29027     2.06173 -1.39848 1.79787        3.62993 -1.50808 0.698371       1. 0. 0.
    187 1
    188   2.06173 -1.39848 1.79787      4.08983 -0.525479 2.10687       3.62993 -1.50808 0.698371       1. 0. 0.
    189 1
    190   4.08983 -0.525479 2.10687     3.62993 -1.50808 0.698371       6.17523 -0.969279 1.17127       1. 0. 0.
    191 1
    192   0.790434 -3.69418 1.29027     -0.287266 -1.67078 2.48017      2.06173 -1.39848 1.79787        1. 0. 0.
    193 1
    194   -0.287266 -1.67078 2.48017    1.46453 0.112321 2.50927        2.06173 -1.39848 1.79787        1. 0. 0.
    195 1
    196   1.46453 0.112321 2.50927      2.06173 -1.39848 1.79787        4.08983 -0.525479 2.10687       1. 0. 0.
    197 1
    198   1.46453 0.112321 2.50927      3.24233 1.41142 2.47757         4.08983 -0.525479 2.10687       1. 0. 0.
    199 1
    200   3.24233 1.41142 2.47757       4.08983 -0.525479 2.10687       5.70193 1.54062 1.25007         1. 0. 0.
    201 1
    202   4.08983 -0.525479 2.10687     6.17523 -0.969279 1.17127       5.70193 1.54062 1.25007         1. 0. 0.
    203 1
    204   7.33693 1.04442 0.0886712     6.17523 -0.969279 1.17127       5.70193 1.54062 1.25007         1. 0. 0.
    205 1
    206   7.33693 1.04442 0.0886712     5.70193 1.54062 1.25007         7.56833 1.97852 -0.00632877     1. 0. 0.
    207 1
    208   3.24233 1.41142 2.47757       4.34293 2.22742 1.34117         5.70193 1.54062 1.25007         1. 0. 0.
    209 1
    210   3.24233 1.41142 2.47757       4.34293 2.22742 1.34117         2.58823 2.50762 1.23707         1. 0. 0.
    211 1
    212   4.34293 2.22742 1.34117       2.58823 2.50762 1.23707         5.11553 2.70122 -0.710229       1. 0. 0.
    213 1
    214   4.34293 2.22742 1.34117       5.11553 2.70122 -0.710229       7.56833 1.97852 -0.00632877     1. 0. 0.
    215 1
    216   4.34293 2.22742 1.34117       5.70193 1.54062 1.25007         7.56833 1.97852 -0.00632877     1. 0. 0.
    217 1
    218   1.46453 0.112321 2.50927      3.24233 1.41142 2.47757         2.58823 2.50762 1.23707         1. 0. 0.
    219 1
    220   1.46453 0.112321 2.50927      2.58823 2.50762 1.23707         -2.87097 2.29272 -0.0233288     1. 0. 0.
    221 1
    222   -0.759066 -0.265179 1.48487   1.46453 0.112321 2.50927        -2.87097 2.29272 -0.0233288     1. 0. 0.
    223 1
    224   -0.759066 -0.265179 1.48487   -3.66127 0.565021 1.57007       -2.87097 2.29272 -0.0233288     1. 0. 0.
    225 1
    226   -3.66127 0.565021 1.57007     -2.87097 2.29272 -0.0233288     -4.83487 2.76522 1.41487        1. 0. 0.
    227 1
    228   -2.87097 2.29272 -0.0233288   -4.83487 2.76522 1.41487        -4.04457 4.49292 -0.178529      1. 0. 0.
    229 1
    230   2.58823 2.50762 1.23707       -2.87097 2.29272 -0.0233288     -4.04457 4.49292 -0.178529      1. 0. 0.
    231 1
    232   2.58823 2.50762 1.23707       -2.87097 2.29272 -0.0233288     -4.04457 4.49292 -0.178529      1. 0. 0.
    233 1
    234   1.15633 1.11082 0.326671      2.58823 2.50762 1.23707         -2.87097 2.29272 -0.0233288     1. 0. 0.
    235 1
    236   1.15633 1.11082 0.326671      1.03283 1.01972 -2.14533        -2.87097 2.29272 -0.0233288     1. 0. 0.
    237 1
    238   1.15633 1.11082 0.326671      1.03283 1.01972 -2.14533        2.58823 2.50762 1.23707         1. 0. 0.
    239 1
    240   1.03283 1.01972 -2.14533      2.58823 2.50762 1.23707         5.11553 2.70122 -0.710229       1. 0. 0.
    241 1
    242   1.03283 1.01972 -2.14533      3.62023 1.25552 -2.86813        5.11553 2.70122 -0.710229       1. 0. 0.
    243 1
    244   -0.759066 -0.265179 1.48487   -0.287266 -1.67078 2.48017      -3.66127 0.565021 1.57007       1. 0. 0.
    245 1
    246   -0.759066 -0.265179 1.48487   -0.287266 -1.67078 2.48017      1.46453 0.112321 2.50927        1. 0. 0.
    247 1
    248   -0.287266 -1.67078 2.48017    -2.45927 -1.63678 1.72157       -3.66127 0.565021 1.57007       1. 0. 0.
    249 1
    250   -2.45927 -1.63678 1.72157     -4.75167 -1.93408 0.935971      -3.66127 0.565021 1.57007       1. 0. 0.
    251 1
    252   -4.75167 -1.93408 0.935971    -3.66127 0.565021 1.57007       -6.27887 0.926121 0.589671      1. 0. 0.
    253 1
    254   -3.66127 0.565021 1.57007     -4.83487 2.76522 1.41487        -6.27887 0.926121 0.589671      1. 0. 0.
    255 1
    256   -4.83487 2.76522 1.41487      -6.27887 0.926121 0.589671      -7.11497 2.49352 0.479071       1. 0. 0.
    257 1
    258   -2.45927 -1.63678 1.72157     -4.75167 -1.93408 0.935971      -3.90927 -3.49908 0.839771      1. 0. 0.
    259 1
    260   -1.52417 -3.64138 0.503471    -2.45927 -1.63678 1.72157       -3.90927 -3.49908 0.839771      1. 0. 0.
    261 1
    262   -1.52417 -3.64138 0.503471    -0.287266 -1.67078 2.48017      -2.45927 -1.63678 1.72157       1. 0. 0.
    263 1
    264   0.790434 -3.69418 1.29027     -1.52417 -3.64138 0.503471      -0.287266 -1.67078 2.48017      1. 0. 0.
    265 1
    266   -4.83487 2.76522 1.41487      -5.81017 4.57652 0.0304712      -4.04457 4.49292 -0.178529      1. 0. 0.
    267 1
    268   -4.83487 2.76522 1.41487      -5.81017 4.57652 0.0304712      -7.11497 2.49352 0.479071       1. 0. 0.
    269 1
    270   1.03283 1.01972 -2.14533      -2.87097 2.29272 -0.0233288     -3.94777 1.63002 -1.27603       1. 0. 0.
    271 1
    272   -2.87097 2.29272 -0.0233288   -3.94777 1.63002 -1.27603       -4.04457 4.49292 -0.178529      1. 0. 0.
    273 1
    274   -3.94777 1.63002 -1.27603     -4.04457 4.49292 -0.178529      -5.12137 3.83022 -1.43123       1. 0. 0.
    275 1
    276   -0.573766 -1.42458 -2.91753   1.03283 1.01972 -2.14533        -3.94777 1.63002 -1.27603       1. 0. 0.
    277 1
    278   -0.573766 -1.42458 -2.91753   1.76663 -0.360379 -2.99373      1.03283 1.01972 -2.14533        1. 0. 0.
    279 1
    280   1.76663 -0.360379 -2.99373    1.03283 1.01972 -2.14533        3.62023 1.25552 -2.86813        1. 0. 0.
    281 1
    282   -0.573766 -1.42458 -2.91753   -2.77417 -0.570279 -1.12083     -3.94777 1.63002 -1.27603       1. 0. 0.
    283 1
    284   -0.573766 -1.42458 -2.91753   -2.49667 -2.18078 -1.79993      -2.77417 -0.570279 -1.12083     1. 0. 0.
    285 1
    286   -2.49667 -2.18078 -1.79993    -2.77417 -0.570279 -1.12083     -3.94777 1.63002 -1.27603       1. 0. 0.
    287 1
    288   -2.49667 -2.18078 -1.79993    -4.17327 -2.53828 -0.635229     -3.94777 1.63002 -1.27603       1. 0. 0.
    289 1
    290   -4.17327 -2.53828 -0.635229   -3.94777 1.63002 -1.27603       -6.42617 1.74722 -0.982629      1. 0. 0.
    291 1
    292   -3.94777 1.63002 -1.27603     -5.12137 3.83022 -1.43123       -6.42617 1.74722 -0.982629      1. 0. 0.
    293 1
    294   -0.573766 -1.42458 -2.91753   -1.62867 -3.74268 -1.79493      -2.49667 -2.18078 -1.79993      1. 0. 0.
    295 1
    296   -0.573766 -1.42458 -2.91753   0.450934 -2.72908 -2.23353      -1.62867 -3.74268 -1.79493      1. 0. 0.
    297 1
    298   -0.573766 -1.42458 -2.91753   0.450934 -2.72908 -2.23353      1.76663 -0.360379 -2.99373      1. 0. 0.
    299 1
    300   -1.62867 -3.74268 -1.79493    -2.49667 -2.18078 -1.79993      -4.17327 -2.53828 -0.635229     1. 0. 0.
    301 1
    302   -1.62867 -3.74268 -1.79493    -4.17327 -2.53828 -0.635229     -3.90927 -3.49908 0.839771      1. 0. 0.
    303 1
    304   -1.52417 -3.64138 0.503471    -1.62867 -3.74268 -1.79493      -3.90927 -3.49908 0.839771      1. 0. 0.
    305 1
    306   0.917634 -3.66448 -0.484829   -1.52417 -3.64138 0.503471      -1.62867 -3.74268 -1.79493      1. 0. 0.
    307 1
    308   0.790434 -3.69418 1.29027     0.917634 -3.66448 -0.484829     -1.52417 -3.64138 0.503471      1. 0. 0.
    309 1
    310   0.917634 -3.66448 -0.484829   0.450934 -2.72908 -2.23353      -1.62867 -3.74268 -1.79493      1. 0. 0.
    311 1
    312   -4.75167 -1.93408 0.935971    -4.17327 -2.53828 -0.635229     -3.90927 -3.49908 0.839771      1. 0. 0.
    313 1
    314   -4.75167 -1.93408 0.935971    -4.17327 -2.53828 -0.635229     -6.27887 0.926121 0.589671      1. 0. 0.
    315 1
    316   -4.17327 -2.53828 -0.635229   -6.27887 0.926121 0.589671      -6.42617 1.74722 -0.982629      1. 0. 0.
    317 1
    318   -6.27887 0.926121 0.589671    -7.11497 2.49352 0.479071       -6.42617 1.74722 -0.982629      1. 0. 0.
    319 1
    320   3.62023 1.25552 -2.86813      5.68853 1.38852 -1.77723        5.11553 2.70122 -0.710229       1. 0. 0.
    321 1
    322   5.68853 1.38852 -1.77723      5.11553 2.70122 -0.710229       7.56833 1.97852 -0.00632877     1. 0. 0.
    323 1
    324   -5.12137 3.83022 -1.43123     -7.11497 2.49352 0.479071       -6.42617 1.74722 -0.982629      1. 0. 0.
    325 1
    326   -5.81017 4.57652 0.0304712    -5.12137 3.83022 -1.43123       -7.11497 2.49352 0.479071       1. 0. 0.
    327 1
    328   -5.81017 4.57652 0.0304712    -4.04457 4.49292 -0.178529      -5.12137 3.83022 -1.43123       1. 0. 0.
     158  7.32406 1.08574 0.0829932     5.67566 1.42984 -1.78291        7.55546 2.01984 -0.0120068      1. 0. 0.
     1591
     160  7.32406 1.08574 0.0829932     5.67566 1.42984 -1.78291        5.53756 -0.911555 -0.496607     1. 0. 0.
     1611
     162  7.32406 1.08574 0.0829932     6.16236 -0.927955 1.16559       5.53756 -0.911555 -0.496607     1. 0. 0.
     1631
     164  3.60736 1.29684 -2.87381      5.67566 1.42984 -1.78291        5.53756 -0.911555 -0.496607     1. 0. 0.
     1651
     166  1.75376 -0.319055 -2.99941    3.60736 1.29684 -2.87381        5.53756 -0.911555 -0.496607     1. 0. 0.
     1671
     168  2.17906 -1.47276 -0.873307    1.75376 -0.319055 -2.99941      5.53756 -0.911555 -0.496607     1. 0. 0.
     1691
     170  2.17906 -1.47276 -0.873307    0.438062 -2.68776 -2.23921      1.75376 -0.319055 -2.99941      1. 0. 0.
     1711
     172  0.904762 -3.62316 -0.490507   2.17906 -1.47276 -0.873307      0.438062 -2.68776 -2.23921      1. 0. 0.
     1731
     174  0.904762 -3.62316 -0.490507   2.17906 -1.47276 -0.873307      5.53756 -0.911555 -0.496607     1. 0. 0.
     1751
     176  0.904762 -3.62316 -0.490507   1.91486 -2.53606 0.492393       5.53756 -0.911555 -0.496607     1. 0. 0.
     1771
     178  1.91486 -2.53606 0.492393     3.61706 -1.46676 0.692693       5.53756 -0.911555 -0.496607     1. 0. 0.
     1791
     180  3.61706 -1.46676 0.692693     6.16236 -0.927955 1.16559       5.53756 -0.911555 -0.496607     1. 0. 0.
     1811
     182  0.777562 -3.65286 1.28459     0.904762 -3.62316 -0.490507     1.91486 -2.53606 0.492393       1. 0. 0.
     1831
     184  0.777562 -3.65286 1.28459     1.91486 -2.53606 0.492393       3.61706 -1.46676 0.692693       1. 0. 0.
     1851
     186  0.777562 -3.65286 1.28459     2.04886 -1.35716 1.79219        3.61706 -1.46676 0.692693       1. 0. 0.
     1871
     188  2.04886 -1.35716 1.79219      4.07696 -0.484155 2.10119       3.61706 -1.46676 0.692693       1. 0. 0.
     1891
     190  4.07696 -0.484155 2.10119     3.61706 -1.46676 0.692693       6.16236 -0.927955 1.16559       1. 0. 0.
     1911
     192  0.777562 -3.65286 1.28459     -0.300138 -1.62946 2.47449      2.04886 -1.35716 1.79219        1. 0. 0.
     1931
     194  -0.300138 -1.62946 2.47449    1.45166 0.153645 2.50359        2.04886 -1.35716 1.79219        1. 0. 0.
     1951
     196  1.45166 0.153645 2.50359      2.04886 -1.35716 1.79219        4.07696 -0.484155 2.10119       1. 0. 0.
     1971
     198  1.45166 0.153645 2.50359      3.22946 1.45274 2.47189         4.07696 -0.484155 2.10119       1. 0. 0.
     1991
     200  3.22946 1.45274 2.47189       4.07696 -0.484155 2.10119       5.68906 1.58194 1.24439         1. 0. 0.
     2011
     202  4.07696 -0.484155 2.10119     6.16236 -0.927955 1.16559       5.68906 1.58194 1.24439         1. 0. 0.
     2031
     204  7.32406 1.08574 0.0829932     6.16236 -0.927955 1.16559       5.68906 1.58194 1.24439         1. 0. 0.
     2051
     206  7.32406 1.08574 0.0829932     5.68906 1.58194 1.24439         7.55546 2.01984 -0.0120068      1. 0. 0.
     2071
     208  3.22946 1.45274 2.47189       4.33006 2.26874 1.33549         5.68906 1.58194 1.24439         1. 0. 0.
     2091
     210  3.22946 1.45274 2.47189       4.33006 2.26874 1.33549         2.57536 2.54894 1.23139         1. 0. 0.
     2111
     212  4.33006 2.26874 1.33549       2.57536 2.54894 1.23139         5.10266 2.74254 -0.715907       1. 0. 0.
     2131
     214  4.33006 2.26874 1.33549       5.10266 2.74254 -0.715907       7.55546 2.01984 -0.0120068      1. 0. 0.
     2151
     216  4.33006 2.26874 1.33549       5.68906 1.58194 1.24439         7.55546 2.01984 -0.0120068      1. 0. 0.
     2171
     218  1.45166 0.153645 2.50359      3.22946 1.45274 2.47189         2.57536 2.54894 1.23139         1. 0. 0.
     2191
     220  1.45166 0.153645 2.50359      2.57536 2.54894 1.23139         -2.88384 2.33404 -0.0290068     1. 0. 0.
     2211
     222  -0.771938 -0.223855 1.47919   1.45166 0.153645 2.50359        -2.88384 2.33404 -0.0290068     1. 0. 0.
     2231
     224  -0.771938 -0.223855 1.47919   -3.67414 0.606345 1.56439       -2.88384 2.33404 -0.0290068     1. 0. 0.
     2251
     226  -3.67414 0.606345 1.56439     -2.88384 2.33404 -0.0290068     -4.84774 2.80654 1.40919        1. 0. 0.
     2271
     228  -2.88384 2.33404 -0.0290068   -4.84774 2.80654 1.40919        -4.05744 4.53424 -0.184207      1. 0. 0.
     2291
     230  2.57536 2.54894 1.23139       -2.88384 2.33404 -0.0290068     -4.05744 4.53424 -0.184207      1. 0. 0.
     2311
     232  2.57536 2.54894 1.23139       -2.88384 2.33404 -0.0290068     -4.05744 4.53424 -0.184207      1. 0. 0.
     2331
     234  1.14346 1.15214 0.320993      2.57536 2.54894 1.23139         -2.88384 2.33404 -0.0290068     1. 0. 0.
     2351
     236  1.14346 1.15214 0.320993      1.01996 1.06104 -2.15101        -2.88384 2.33404 -0.0290068     1. 0. 0.
     2371
     238  1.14346 1.15214 0.320993      1.01996 1.06104 -2.15101        2.57536 2.54894 1.23139         1. 0. 0.
     2391
     240  1.01996 1.06104 -2.15101      2.57536 2.54894 1.23139         5.10266 2.74254 -0.715907       1. 0. 0.
     2411
     242  1.01996 1.06104 -2.15101      3.60736 1.29684 -2.87381        5.10266 2.74254 -0.715907       1. 0. 0.
     2431
     244  -0.771938 -0.223855 1.47919   -0.300138 -1.62946 2.47449      -3.67414 0.606345 1.56439       1. 0. 0.
     2451
     246  -0.771938 -0.223855 1.47919   -0.300138 -1.62946 2.47449      1.45166 0.153645 2.50359        1. 0. 0.
     2471
     248  -0.300138 -1.62946 2.47449    -2.47214 -1.59546 1.71589       -3.67414 0.606345 1.56439       1. 0. 0.
     2491
     250  -2.47214 -1.59546 1.71589     -4.76454 -1.89276 0.930293      -3.67414 0.606345 1.56439       1. 0. 0.
     2511
     252  -4.76454 -1.89276 0.930293    -3.67414 0.606345 1.56439       -6.29174 0.967445 0.583993      1. 0. 0.
     2531
     254  -3.67414 0.606345 1.56439     -4.84774 2.80654 1.40919        -6.29174 0.967445 0.583993      1. 0. 0.
     2551
     256  -4.84774 2.80654 1.40919      -6.29174 0.967445 0.583993      -7.12784 2.53484 0.473393       1. 0. 0.
     2571
     258  -2.47214 -1.59546 1.71589     -4.76454 -1.89276 0.930293      -3.92214 -3.45776 0.834093      1. 0. 0.
     2591
     260  -1.53704 -3.60006 0.497793    -2.47214 -1.59546 1.71589       -3.92214 -3.45776 0.834093      1. 0. 0.
     2611
     262  -1.53704 -3.60006 0.497793    -0.300138 -1.62946 2.47449      -2.47214 -1.59546 1.71589       1. 0. 0.
     2631
     264  0.777562 -3.65286 1.28459     -1.53704 -3.60006 0.497793      -0.300138 -1.62946 2.47449      1. 0. 0.
     2651
     266  -4.84774 2.80654 1.40919      -5.82304 4.61784 0.0247932      -4.05744 4.53424 -0.184207      1. 0. 0.
     2671
     268  -4.84774 2.80654 1.40919      -5.82304 4.61784 0.0247932      -7.12784 2.53484 0.473393       1. 0. 0.
     2691
     270  1.01996 1.06104 -2.15101      -2.88384 2.33404 -0.0290068     -3.96064 1.67134 -1.28171       1. 0. 0.
     2711
     272  -2.88384 2.33404 -0.0290068   -3.96064 1.67134 -1.28171       -4.05744 4.53424 -0.184207      1. 0. 0.
     2731
     274  -3.96064 1.67134 -1.28171     -4.05744 4.53424 -0.184207      -5.13424 3.87154 -1.43691       1. 0. 0.
     2751
     276  -0.586638 -1.38326 -2.92321   1.01996 1.06104 -2.15101        -3.96064 1.67134 -1.28171       1. 0. 0.
     2771
     278  -0.586638 -1.38326 -2.92321   1.75376 -0.319055 -2.99941      1.01996 1.06104 -2.15101        1. 0. 0.
     2791
     280  1.75376 -0.319055 -2.99941    1.01996 1.06104 -2.15101        3.60736 1.29684 -2.87381        1. 0. 0.
     2811
     282  -0.586638 -1.38326 -2.92321   -2.78704 -0.528955 -1.12651     -3.96064 1.67134 -1.28171       1. 0. 0.
     2831
     284  -0.586638 -1.38326 -2.92321   -2.50954 -2.13946 -1.80561      -2.78704 -0.528955 -1.12651     1. 0. 0.
     2851
     286  -2.50954 -2.13946 -1.80561    -2.78704 -0.528955 -1.12651     -3.96064 1.67134 -1.28171       1. 0. 0.
     2871
     288  -2.50954 -2.13946 -1.80561    -4.18614 -2.49696 -0.640907     -3.96064 1.67134 -1.28171       1. 0. 0.
     2891
     290  -4.18614 -2.49696 -0.640907   -3.96064 1.67134 -1.28171       -6.43904 1.78854 -0.988307      1. 0. 0.
     2911
     292  -3.96064 1.67134 -1.28171     -5.13424 3.87154 -1.43691       -6.43904 1.78854 -0.988307      1. 0. 0.
     2931
     294  -0.586638 -1.38326 -2.92321   -1.64154 -3.70136 -1.80061      -2.50954 -2.13946 -1.80561      1. 0. 0.
     2951
     296  -0.586638 -1.38326 -2.92321   0.438062 -2.68776 -2.23921      -1.64154 -3.70136 -1.80061      1. 0. 0.
     2971
     298  -0.586638 -1.38326 -2.92321   0.438062 -2.68776 -2.23921      1.75376 -0.319055 -2.99941      1. 0. 0.
     2991
     300  -1.64154 -3.70136 -1.80061    -2.50954 -2.13946 -1.80561      -4.18614 -2.49696 -0.640907     1. 0. 0.
     3011
     302  -1.64154 -3.70136 -1.80061    -4.18614 -2.49696 -0.640907     -3.92214 -3.45776 0.834093      1. 0. 0.
     3031
     304  -1.53704 -3.60006 0.497793    -1.64154 -3.70136 -1.80061      -3.92214 -3.45776 0.834093      1. 0. 0.
     3051
     306  0.904762 -3.62316 -0.490507   -1.53704 -3.60006 0.497793      -1.64154 -3.70136 -1.80061      1. 0. 0.
     3071
     308  0.777562 -3.65286 1.28459     0.904762 -3.62316 -0.490507     -1.53704 -3.60006 0.497793      1. 0. 0.
     3091
     310  0.904762 -3.62316 -0.490507   0.438062 -2.68776 -2.23921      -1.64154 -3.70136 -1.80061      1. 0. 0.
     3111
     312  -4.76454 -1.89276 0.930293    -4.18614 -2.49696 -0.640907     -3.92214 -3.45776 0.834093      1. 0. 0.
     3131
     314  -4.76454 -1.89276 0.930293    -4.18614 -2.49696 -0.640907     -6.29174 0.967445 0.583993      1. 0. 0.
     3151
     316  -4.18614 -2.49696 -0.640907   -6.29174 0.967445 0.583993      -6.43904 1.78854 -0.988307      1. 0. 0.
     3171
     318  -6.29174 0.967445 0.583993    -7.12784 2.53484 0.473393       -6.43904 1.78854 -0.988307      1. 0. 0.
     3191
     320  3.60736 1.29684 -2.87381      5.67566 1.42984 -1.78291        5.10266 2.74254 -0.715907       1. 0. 0.
     3211
     322  5.67566 1.42984 -1.78291      5.10266 2.74254 -0.715907       7.55546 2.01984 -0.0120068      1. 0. 0.
     3231
     324  -5.13424 3.87154 -1.43691     -7.12784 2.53484 0.473393       -6.43904 1.78854 -0.988307      1. 0. 0.
     3251
     326  -5.82304 4.61784 0.0247932    -5.13424 3.87154 -1.43691       -7.12784 2.53484 0.473393       1. 0. 0.
     3271
     328  -5.82304 4.61784 0.0247932    -4.05744 4.53424 -0.184207      -5.13424 3.87154 -1.43691       1. 0. 0.
    3293299
    330330#  terminating special property
     
    333333  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
    3343342
    335   -4.99203 4.29989 -0.526429    5       1 0 0
     335  -5.0049 4.34121 -0.532107     5       1 0 0
    3363369
    337337  terminating special property
Note: See TracChangeset for help on using the changeset viewer.