Changes in / [c39cc4:bdb143]
- Files:
-
- 255 added
- 51 deleted
- 167 edited
Legend:
- Unmodified
- Added
- Removed
-
configure.ac
rc39cc4 rbdb143 27 27 28 28 # Boost libraries 29 AX_BOOST_BASE([1. 33.1])30 #AX_BOOST_PROGRAM_OPTIONS29 AX_BOOST_BASE([1.40]) 30 AX_BOOST_PROGRAM_OPTIONS 31 31 #AX_BOOST_FOREACH 32 32 #AX_BOOST_FILESYSTEM 33 33 AX_BOOST_THREAD 34 #AX_BOOST_PROGRAM_OPTIONS35 34 #AX_BOOST_SERIALIZATION 35 36 #QT4 libraries 37 gw_CHECK_QT4 38 AX_CHECK_GLU 39 AC_MSG_NOTICE(["GLU_CFLAGS: $GLU_CFLAGS, GLU_CXXFLAGS: $GLU_CXXFLAGS, GLU_LDFLAGS: $GLU_LDFLAGS, GLU_LIBS: $GLU_LIBS"]) 40 36 41 37 42 # Checks for header files. … … 93 98 94 99 # 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]) 100 AC_CONFIG_TESTDIR(tests/regression) 101 AC_CONFIG_FILES([ 102 tests/Makefile 103 tests/regression/atlocal 104 tests/regression/Makefile]) 105 AC_CONFIG_FILES([tests/regression/molecuilder], [chmod +x tests/regression/molecuilder]) 106 AC_CONFIG_FILES([ 107 tests/Tesselations/Makefile 108 tests/Tesselations/defs]) 109 AC_CONFIG_FILES([ 110 doc/molecuilder.xml]) 111 AC_CONFIG_FILES([ 112 Makefile 113 doc/Makefile 114 src/Makefile 115 src/Actions/Makefile 116 src/UIElements/Makefile 117 src/unittests/Makefile]) 101 118 AC_OUTPUT -
doc/Doxyfile
rc39cc4 rbdb143 258 258 # Configuration::additions related to the search engine 259 259 #--------------------------------------------------------------------------- 260 SEARCHENGINE = NO260 SEARCHENGINE = YES -
doc/class structure.uxf
rc39cc4 rbdb143 21 21 22 22 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>2 94</y><w>147</w><h>70</h></coordinates><panel_attributes>AtomInfo23 // 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 24 24 -- 25 25 -x,v,F: Vector … … 28 28 #AtomInfo(); 29 29 #~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=<<<<-</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>Element30 </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=<<<<-</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 31 31 -- 32 32 mass: double … … 49 49 #~element(); 50 50 #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>BondedParticle51 #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 52 52 -- 53 53 -- … … 63 63 #OutputBondOfAtom() const 64 64 #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=<<-</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=<<-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=<<-</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>BondedParticleInfo65 #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=<<-</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=<<- 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=<<-</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 67 67 -- 68 68 AdaptiveOrder: unsigned char … … 71 71 #BondedParticleInfo() 72 72 #~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>ParticleInfo73 </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 74 74 -- 75 75 nr: int … … 79 79 #~ParticleInfo() 80 80 #ostream & operator << (ostream &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=<<<<-</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>BondList81 </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=<<<<-</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 82 82 {Some Properties} 83 83 -- … … 90 90 Responsibilities 91 91 -- 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>GraphNodeInfo92 *-- 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 93 93 -- 94 94 -- … … 102 102 #GraphNodeInfo() 103 103 #~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>GraphNode104 </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 105 105 -- 106 106 -- … … 109 109 #OutputGraphInfo() const 110 110 #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=<<-</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=<<-</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>Atom111 </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=<<-</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=<<-</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 112 112 -- 113 113 sort: int* … … 129 129 #DistanceToVector(const Vector &origin) const: double 130 130 #DistanceSquaredToVector(const Vector &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=<<<<-</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>TrajectoryParticle131 #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=<<<<-</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 132 132 -- 133 133 -- … … 147 147 #Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration) 148 148 #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=<<-</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=<<-</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>TrajectoryParticleInfo149 #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=<<-</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=<<-</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 150 150 -- 151 151 Trajectory: struct {vector<Vector> R,U,V} … … 153 153 -- 154 154 #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=<<-</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=<<-</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=<<-</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>TesselPoint155 #~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=<<-</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=<<-</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=<<-</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 156 156 -- 157 157 -id: Long … … 163 163 Responsibilities 164 164 -- 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=<<-</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=<<-</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=<<-</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=<<-</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>Bond165 *-- 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=<<-</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=<<-</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=<<-</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=<<-</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 166 166 -- 167 167 HydrogenBond: int … … 182 182 #bond() 183 183 #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=<<<<-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>8 96</y><w>132</w><h>49</h></coordinates><panel_attributes>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=<<<<-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>1 330</y><w>504</w><h>168</h></coordinates><panel_attributes>BondGraph184 #~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=<<<<- 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>812</y><w>132</w><h>49</h></coordinates><panel_attributes>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>658</y><w>111</w><h>167</h></coordinates><panel_attributes>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>1246</y><w>504</w><h>168</h></coordinates><panel_attributes>BondGraph 188 188 -- 189 189 max_distance: double … … 199 199 double &MinDistance, double &MaxDistance, bool IsAngstroem) 200 200 #CovalentMinMaxDistance(BondedParticle * const Walker, BondedParticle * const OtherWalker, 201 double &MinDistance, double &MaxDistance, bool IsAngstroem)</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1596</x><y>1 407</y><w>167</w><h>34</h></coordinates><panel_attributes>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>MatrixContainer201 double &MinDistance, double &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=<<<<-</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 202 202 -- 203 203 -id: Long … … 209 209 Responsibilities 210 210 -- 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>config211 *-- 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 212 212 -- 213 213 PsiType: int … … 297 297 #SetDefaultPath(const char * const path); 298 298 #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>1 428</y><w>636</w><h>34</h></coordinates><panel_attributes>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=<<<<-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><<Singleton>>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=<<<<-</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=<<<<- 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>896</y><w>224</w><h>140</h></coordinates><panel_attributes><<Singleton>> 301 301 errorLogger 302 302 -- … … 310 310 #static setVerbosity(int verbosityLevel); 311 311 #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>KeyCompare312 #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 313 313 -- 314 314 -- 315 315 #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>1 218</y><w>147</w><h>105</h></coordinates><panel_attributes>UniqueFragments316 </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 317 317 -- 318 318 ANOVAOrder: int … … 322 322 ShortestPathList: int * 323 323 UsedList: bool ** 324 BondsPerSPCount: int *</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>490</x><y>1 253</y><w>692</w><h>34</h></coordinates><panel_attributes>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=<<<<-</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>Graph324 BondsPerSPCount: 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=<<<<-</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=<<<<-</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 325 325 {map <KeySet, NumberValuePair, KeyCompare>} 326 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>861</x><y>1 134</y><w>321</w><h>153</h></coordinates><panel_attributes>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>KeySet327 {set<int>}</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>945</x><y>11 97</y><w>237</w><h>90</h></coordinates><panel_attributes>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=<<<<-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>2 282</y><w>147</w><h>42</h></coordinates><panel_attributes>LSQ_params326 </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=<<<<-</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<int>}</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=<<<<-</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=<<<<- 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>2198</y><w>147</w><h>42</h></coordinates><panel_attributes>LSQ_params 329 329 -- 330 330 vectors: const Vector ** 331 331 num: 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_params333 -- 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=<<<<-</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 -- 334 x: 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=<<<<-</panel_attributes><additional_attributes>21;21;105;21</additional_attributes></element></umlet_diagram> -
src/Actions/Action.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <string> … … 15 17 using namespace std; 16 18 19 Action::state_ptr getEmptyState() { 20 return Action::state_ptr(Memory::ignore(new ActionState())); 21 } 22 17 23 // 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()));24 Action::state_ptr Action::success = getEmptyState(); 25 Action::state_ptr Action::failure = getEmptyState(); 20 26 21 27 Action::Action(std::string _name,bool _doRegister) : -
src/Actions/ActionHistory.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "ActionHistory.hpp" -
src/Actions/ActionRegistry.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "Actions/ActionRegistry.hpp" … … 17 19 using namespace std; 18 20 21 /** Constructor for class ActionRegistry. 22 */ 19 23 ActionRegistry::ActionRegistry() 20 24 { 21 25 } 22 26 27 /** Destructor for class ActionRegistry. 28 */ 23 29 ActionRegistry::~ActionRegistry() 24 30 { … … 30 36 } 31 37 38 /** Returns pointer to an action named by \a name. 39 * \param name name of action 40 * \return pointer to Action 41 */ 32 42 Action* ActionRegistry::getActionByName(const std::string name){ 33 43 map<const string,Action*>::iterator iter; … … 37 47 } 38 48 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 */ 54 bool 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 */ 39 63 void ActionRegistry::registerAction(Action* action){ 40 64 pair<map<const string,Action*>::iterator,bool> ret; 65 //cout << "Trying to register action with name " << action->getName() << "." << endl; 41 66 ret = actionMap.insert(pair<const string,Action*>(action->getName(),action)); 42 67 ASSERT(ret.second,"Two actions with the same name added to registry"); 43 68 } 44 69 70 /** Unregisters an Action. 71 * \param *action pointer to Action. 72 */ 73 void 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 */ 81 std::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 */ 89 std::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 */ 97 std::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 */ 105 std::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 */ 115 ostream& 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 45 126 CONSTRUCT_SINGLETON(ActionRegistry) -
src/Actions/ActionRegistry.hpp
rc39cc4 rbdb143 9 9 #define ACTIONREGISTRY_HPP_ 10 10 11 #include <iostream> 11 12 #include <string> 12 13 #include <map> … … 21 22 public: 22 23 Action* getActionByName(const std::string); 24 bool isActionByNamePresent(const std::string name); 23 25 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; 24 32 25 33 private: … … 31 39 }; 32 40 41 std::ostream& operator<<(std::ostream& ost, const ActionRegistry& m); 42 33 43 #endif /* ACTIONREGISTRY_HPP_ */ -
src/Actions/ActionSequence.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "Actions/ActionSequence.hpp" -
src/Actions/ErrorAction.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <iostream> -
src/Actions/MakroAction.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <string> -
src/Actions/ManipulateAtomsProcess.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "ManipulateAtomsProcess.hpp" -
src/Actions/MethodAction.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <iostream> -
src/Actions/Process.cpp
rc39cc4 rbdb143 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "Process.hpp" 9 11 … … 12 14 Process::Process(int _maxSteps, std::string _name, bool _doRegister) : 13 15 Action(_name,_doRegister), 16 Observable("Process"), 14 17 maxSteps(_maxSteps), 15 18 active(false), … … 38 41 39 42 int Process::getCurrStep(){ 40 OBSERVE;41 43 return currStep; 42 44 } 43 45 44 46 void Process::setCurrStep(int _currStep){ 47 OBSERVE; 45 48 currStep = _currStep; 46 49 } … … 52 55 return 0; 53 56 } 54 55 57 int Process::getMaxSteps(){ 56 58 return maxSteps; -
src/Descriptors/AtomDescriptor.cpp
rc39cc4 rbdb143 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "Descriptors/AtomDescriptor.hpp" 9 11 #include "Descriptors/AtomDescriptor_impl.hpp" 10 12 11 13 #include "World.hpp" 12 13 14 #include "atom.hpp" 14 15 15 16 #include <boost/bind.hpp> 16 #include <cassert> 17 17 18 #include <iostream> 18 19 -
src/Descriptors/AtomIdDescriptor.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "AtomIdDescriptor.hpp" -
src/Descriptors/AtomTypeDescriptor.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "Descriptors/AtomTypeDescriptor.hpp" -
src/Descriptors/MoleculeDescriptor.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "Descriptors/MoleculeDescriptor.hpp" … … 14 16 15 17 #include <boost/bind.hpp> 16 #include <cassert>17 18 #include <iostream> 18 19 -
src/Descriptors/MoleculeIdDescriptor.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "MoleculeIdDescriptor.hpp" -
src/Exceptions/CustomException.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "CustomException.hpp" -
src/Exceptions/LinearDependenceException.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "LinearDependenceException.hpp" -
src/Exceptions/MathException.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "MathException.hpp" -
src/Exceptions/SkewException.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "SkewException.hpp" -
src/Exceptions/ZeroVectorException.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "ZeroVectorException.hpp" -
src/Hbondangle.db
rc39cc4 rbdb143 1 # atomicnumber angles for single, double and triple bond (-1 no angle) 1 2 1 180 -1 -1 2 3 5 180 131.0 109.2 -
src/Hbonddistance.db
rc39cc4 rbdb143 1 #atomic number bond distances for single, double and triple bond (-1 no bond) 1 2 1 0.74 -1 -1 2 3 2 0.77429209 -1 -1 -
src/Helpers/Assert.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "Helpers/Assert.hpp" … … 46 48 using namespace Assert; 47 49 50 #ifndef NDEBUG 51 48 52 Action _my_assert::defaultAction = Ask; 49 53 std::vector<Assert::hook_t> _my_assert::hooks; … … 52 56 const char* _wrapper::message_ptr = "source pointer did not point to object of desired type"; 53 57 const char* _wrapper::message_ref = "source reference did not contain object of desired type"; 54 55 58 56 59 … … 63 66 { 64 67 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; 66 69 cout << "Assertion Message: " << message << std::endl; 67 70 while(true){ … … 123 126 return ActionNames[defaultAction]; 124 127 } 128 129 #endif 130 -
src/Helpers/MemDebug.cpp
rc39cc4 rbdb143 6 6 */ 7 7 8 #ifndef NDEBUG 9 #ifndef NO_MEMDEBUG 10 8 11 #include <iostream> 9 12 #include <cstdlib> … … 11 14 #include <boost/thread.hpp> 12 15 16 #ifdef __GNUC__ 17 #include <execinfo.h> 18 #include <cxxabi.h> 19 #endif 20 13 21 using namespace std; 14 22 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 17 46 18 47 namespace Memory { … … 34 63 char file[length+1]; 35 64 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 36 70 size_t nbytes; 37 71 bool isUsed; … … 44 78 }; 45 79 46 boost::mutex memorylock; 80 81 mutex_t memorylock = mutex_init; 47 82 48 83 // start and end of the doubly-linked list … … 96 131 for(entry_t *pos=begin;pos;pos=pos->next){ 97 132 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 98 137 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; 100 171 } 101 172 … … 105 176 return; 106 177 178 mutex_lock(memorylock); 107 179 if(entry->prev){ 108 180 entry->prev->next = entry->next; … … 120 192 end = entry->prev; 121 193 } 194 Memory::state -= entry->info.nbytes; 195 mutex_unlock(memorylock); 122 196 entry->isIgnored = true; 123 Memory::state -= entry->info.nbytes; 197 124 198 } 125 199 … … 130 204 deleteEntry(entry); 131 205 } 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 291 void *operator new(size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc) { 138 292 139 293 // to avoid allocations of 0 bytes if someone screws up … … 153 307 } 154 308 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 337 void *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 } 161 354 162 355 // build the entry in front of the space … … 171 364 entry->info.location = (char*)res + entrySpace; 172 365 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); 185 369 186 370 // get the checksum... … … 196 380 } 197 381 382 #endif 383 198 384 void *operator new(size_t nbytes) throw(std::bad_alloc) { 199 385 // Just forward to the other operator, when we do not know from 200 386 // 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 201 404 return operator new(nbytes,"Unknown",0); 202 } 405 #endif 406 } 407 408 #ifdef __GNUC__ 409 410 void *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 203 416 204 417 void *operator new[] (size_t nbytes,const char* file, int line) throw(std::bad_alloc) { … … 207 420 } 208 421 422 #endif 423 209 424 void *operator new[] (size_t nbytes) throw(std::bad_alloc) { 210 425 // 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 211 443 return operator new[] (nbytes,"Unknown",0); 444 #endif 212 445 } 213 446 … … 217 450 return; 218 451 } 219 220 // we need to lock, so the linked list does not changed while we are in here221 boost::mutex::scoped_lock guard(Memory::memorylock);222 452 223 453 // get the size for the entry, including alignment -
src/Helpers/MemDebug.hpp
rc39cc4 rbdb143 28 28 #endif 29 29 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 30 41 namespace Memory { 31 42 … … 50 61 } 51 62 } 52 63 #ifdef __GNUC__ 64 void *operator new (size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc); 65 void *operator new[] (size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc); 66 #else 53 67 void *operator new (size_t nbytes,const char* file, int line) throw(std::bad_alloc); 54 68 void *operator new[] (size_t nbytes,const char* file, int line) throw(std::bad_alloc); 69 #endif 55 70 void operator delete (void *ptr,const char*, int) throw(); 56 71 void operator delete[] (void *ptr,const char*, int) throw(); 72 73 57 74 58 75 /** … … 60 77 * version that allows tracking. 61 78 */ 79 #ifdef __GNUC__ 80 #define new new(__FILE__,__LINE__,__PRETTY_FUNCTION__) 81 #else 62 82 #define new new(__FILE__,__LINE__) 83 #endif 63 84 64 85 #endif 65 86 #endif 66 87 88 89 #ifdef NDEBUG 90 #undef MEMDEBUG 91 #endif 67 92 68 93 #ifndef MEMDEBUG -
src/Legacy/oldmenu.cpp
rc39cc4 rbdb143 6 6 * 7 7 */ 8 9 #include "Helpers/MemDebug.hpp" 8 10 9 11 #include "Legacy/oldmenu.hpp" … … 37 39 #include "Menu/DisplayMenuItem.hpp" 38 40 #include "Menu/SubMenuItem.hpp" 41 #include "Actions/MapOfActions.hpp" 39 42 #include "Actions/MethodAction.hpp" 40 43 #include "Actions/ErrorAction.hpp" … … 85 88 Dialog *dialog = UIFactory::getInstance().makeDialog(); 86 89 first = World::getInstance().createAtom(); 90 std::vector<element *> elements; 87 91 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); 89 93 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 } 91 100 } 92 101 else{ … … 425 434 void oldmenu::RemoveAtoms(molecule *mol) 426 435 { 427 atom * first, *second;436 atom *second; 428 437 int axis; 429 438 double tmp1, tmp2; … … 448 457 break; 449 458 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 } 460 469 } 461 470 break; … … 467 476 Log() << Verbose(0) << "Upper boundary: "; 468 477 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)); 477 484 } 478 485 } … … 518 525 min[i] = 0.; 519 526 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; 524 529 tmp1 = 0.; 525 if (first != second) {526 x = first->x - second->x;530 if (first != (*iter)) { 531 x = first->x - (*iter)->x; 527 532 tmp1 = x.Norm(); 528 533 } 529 534 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; 531 536 } 532 537 for (int i=MAX_ELEMENTS;i--;) … … 619 624 { 620 625 int Order1; 626 std::string path; 621 627 clock_t start, end; 622 628 … … 624 630 Log() << Verbose(0) << "What's the desired bond order: "; 625 631 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()) { 627 635 start = clock(); 628 mol->FragmentMolecule(Order1, configuration);636 mol->FragmentMolecule(Order1, path); 629 637 end = clock(); 630 638 Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl; … … 770 778 Log() << Verbose(0) << "State the factor: "; 771 779 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 776 782 Elements = new const element *[count]; 777 783 vectors = new Vector *[count]; 778 784 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; 784 788 j++; 785 789 } … … 798 802 } 799 803 } 800 if (mol-> first->next != mol->last) // if connect matrix is present already, redo it804 if (mol->hasBondStructure()) 801 805 mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 802 806 // free memory … … 924 928 molecule *srcmol = NULL, *destmol = NULL; 925 929 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")); 928 932 if(dialog->display()) { 929 933 molecules->SimpleAdd(srcmol, destmol); … … 938 942 molecule *srcmol = NULL, *destmol = NULL; 939 943 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")); 942 946 if(dialog->display()) { 943 947 molecules->EmbedMerge(destmol, srcmol); … … 1040 1044 return; 1041 1045 } 1042 atom *Walker = mol->start;1043 1046 1044 1047 // generate some KeySets 1045 1048 Log() << Verbose(0) << "Generating KeySets." << endl; 1046 KeySet TestSets[mol-> AtomCount+1];1049 KeySet TestSets[mol->getAtomCount()+1]; 1047 1050 i=1; 1048 while (Walker->next != mol->end) { 1049 Walker = Walker->next; 1051 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1050 1052 for (int j=0;j<i;j++) { 1051 TestSets[j].insert( Walker->nr);1053 TestSets[j].insert((*iter)->nr); 1052 1054 } 1053 1055 i++; … … 1055 1057 Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl; 1056 1058 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 } 1060 1067 } 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 } 1065 1070 1066 1071 // constructing Graph structure … … 1070 1075 // insert KeySets into Subgraphs 1071 1076 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++) { 1073 1078 Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.))); 1074 1079 } 1075 1080 Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl; 1076 1081 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.))); 1078 1083 if (test2.second) { 1079 1084 Log() << Verbose(1) << "Insertion worked?!" << endl; -
src/Line.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #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 4 SUBDIRS = Actions UIElements 5 1 6 # this includes source files that need to be present at multiple points 2 HELPERSOURCE = Helpers/Assert.cpp \ 3 Helpers/MemDebug.cpp 7 HELPERSOURCE = \ 8 Helpers/Assert.cpp \ 9 Helpers/MemDebug.cpp 4 10 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 11 ATOMSOURCE = \ 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 21 ATOMHEADER = \ 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 32 LINALGSOURCE = \ 33 ${HELPERSOURCE} \ 34 gslmatrix.cpp \ 35 gslvector.cpp \ 36 linearsystemofequations.cpp \ 37 Space.cpp \ 38 vector.cpp 14 39 15 40 LINALGHEADER = gslmatrix.hpp \ 16 17 18 19 41 gslvector.hpp \ 42 linearsystemofequations.hpp \ 43 Space.hpp \ 44 vector.hpp 20 45 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 46 ANALYSISSOURCE = \ 47 analysis_bonds.cpp \ 48 analysis_correlation.cpp 49 ANALYSISHEADER = \ 50 analysis_bonds.hpp \ 51 analysis_correlation.hpp 52 53 ACTIONSSOURCE = \ 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 64 ACTIONSHEADER = \ 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 79 PARSERSOURCE = \ 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 88 PARSERHEADER = \ 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 97 PATTERNSOURCE = \ 98 Patterns/Observer.cpp 99 PATTERNHEADER = \ 100 Patterns/Cacheable.hpp \ 101 Patterns/Observer.hpp \ 102 Patterns/Singleton.hpp 103 104 QTUIMOC_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 112 QTUIMOC_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 71 119 72 120 DESCRIPTORSOURCE = 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 77 127 128 129 DESCRIPTORHEADER = 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 78 136 79 DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp \80 Descriptors/AtomIdDescriptor.hpp \81 Descriptors/AtomTypeDescriptor.hpp \82 Descriptors/MoleculeDescriptor.hpp \83 Descriptors/MoleculeIdDescriptor.hpp84 85 86 87 137 EXCEPTIONSOURCE = Exceptions/CustomException.cpp \ 88 138 Exceptions/LinearDependenceException.cpp \ … … 96 146 Exceptions/SkewException.hpp \ 97 147 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 149 QTUISOURCE = ${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 159 QTUIHEADER = ${QTUIMOC_HEADER} UIElements/QT4/QTUIFactory.hpp 160 161 QTUI_DEFS = 162 163 SOURCE = \ 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 140 209 141 210 HEADER = \ 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 180 257 181 258 BOOST_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 259 GUI_LIBS = ${QT_LDADD} ${QT_LIB_GUI} -lQtOpenGL ${GLU_LIBS} 260 INCLUDES = -I$(top_srcdir)/src/unittests -I$(top_srcdir)/src/Actions -I$(top_srcdir)/src/UIElements 261 262 noinst_LIBRARIES = libmolecuilder.a libgslwrapper.a libmenu.a libparser.a 263 bin_PROGRAMS = molecuilder molecuildergui joiner analyzer 264 186 265 molecuilderdir = ${bindir} 266 187 267 libmolecuilder_a_SOURCES = ${SOURCE} ${HEADER} 268 269 libmenu_a_SOURCES = ${UISOURCE} ${UIHEADER} 270 libparser_a_SOURCES = ${PARSERSOURCE} ${PARSERHEADER} 188 271 libgslwrapper_a_SOURCES = ${LINALGSOURCE} ${LINALGHEADER} 272 189 273 molecuilder_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 275 molecuilder_CXXFLAGS = $(BOOST_CPPFLAGS) 276 #molecuilder_CXXFLAGS += -DNO_CACHING 277 molecuilder_LDFLAGS = $(BOOST_LIB) 278 molecuilder_SOURCES = ${LEGACYSOURCE} builder.cpp 279 molecuilder_SOURCES += $(srcdir)/version.c 280 molecuilder_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 283 molecuildergui_SOURCES = ${QTUISOURCE} ${LEGACYSOURCE} builder.cpp 284 molecuildergui_SOURCES += $(srcdir)/version.c 285 molecuildergui_CXXFLAGS = ${QT_CXXFLAGS} ${GLU_CXXFLAGS} -DUSE_GUI_QT 286 molecuildergui_LDFLAGS = $(BOOST_LIB) ${QT_LDFLAGS} ${GLU_LDFLAGS} 287 molecuildergui_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 193 289 joiner_SOURCES = joiner.cpp datacreator.cpp parser.cpp datacreator.hpp helpers.hpp parser.hpp periodentafel.hpp 194 290 joiner_LDADD = libmolecuilder.a $(BOOST_LIB) ${BOOST_THREAD_LIB} 291 195 292 analyzer_SOURCES = analyzer.cpp datacreator.cpp parser.cpp helpers.hpp periodentafel.hpp parser.hpp datacreator.hpp 196 293 analyzer_LDADD = libmolecuilder.a $(BOOST_LIB) ${BOOST_THREAD_LIB} 197 294 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 307 MOSTLYCLEANFILES = ${QTUIMOC_TARGETS} 308 198 309 #EXTRA_DIST = ${molecuilder_DATA} 199 310 … … 212 323 echo "const char *ESPACKVersion = \"$(PACKAGE_NAME) -- git version: "`cat $(srcdir)/.git-version`"\";" > $@ 213 324 214 molecuilder_SOURCES += $(srcdir)/version.c 325 -
src/Patterns/Cacheable.hpp
rc39cc4 rbdb143 28 28 owner(_owner) 29 29 {} 30 virtual T getValue()=0;30 virtual T& getValue()=0; 31 31 virtual void invalidate()=0; 32 32 virtual bool isValid()=0; … … 35 35 return busy; 36 36 } 37 virtual std::string getName()=0; 37 38 protected: 38 39 bool busy; … … 46 47 {} 47 48 48 virtual T getValue(){49 virtual T& getValue(){ 49 50 // set the state to valid 50 51 State::owner->switchState(State::owner->validState); … … 64 65 // nothing to do when entering this 65 66 } 67 68 virtual std::string getName(){ 69 return "invalid"; 70 } 66 71 }; 67 72 … … 72 77 {} 73 78 74 virtual T getValue(){79 virtual T& getValue(){ 75 80 return content; 76 81 } … … 90 95 State::busy = false; 91 96 } 97 98 virtual std::string getName(){ 99 return "valid"; 100 } 92 101 private: 93 102 T content; … … 100 109 {} 101 110 102 virtual T getValue(){111 virtual T& getValue(){ 103 112 ASSERT(0,"Cannot get a value from a Cacheable after it's Observable has died"); 104 113 // we have to return a grossly invalid reference, because no value can be produced anymore … … 118 127 // nothing to do when entering this state 119 128 } 129 130 virtual std::string getName(){ 131 return "destroyed"; 132 } 120 133 }; 121 134 … … 124 137 125 138 public: 126 Cacheable(Observable *_owner, boost::function<T()> _recalcMethod );139 Cacheable(Observable *_owner, boost::function<T()> _recalcMethod, std::string name); 127 140 virtual ~Cacheable(); 128 141 … … 134 147 void subjectKilled(Observable *subject); 135 148 private: 136 137 149 void switchState(state_ptr newState); 138 150 … … 144 156 145 157 Observable *owner; 146 147 158 boost::function<T()> recalcMethod; 148 159 … … 153 164 154 165 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)"), 156 168 owner(_owner), 157 169 recalcMethod(_recalcMethod) … … 208 220 void Cacheable<T>::switchState(state_ptr newState){ 209 221 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 210 226 state = newState; 211 227 state->enter(); … … 217 233 { 218 234 public: 219 Cacheable(Observable *_owner, boost::function<T()> _recalcMethod );235 Cacheable(Observable *_owner, boost::function<T()> _recalcMethod,std::string name); 220 236 virtual ~Cacheable(); 221 237 … … 232 248 233 249 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), 235 252 recalcMethod(_recalcMethod) 236 253 {} -
src/Patterns/Observer.cpp
rc39cc4 rbdb143 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "Observer.hpp" 9 11 … … 12 14 13 15 #include "Helpers/Assert.hpp" 16 #include "Helpers/MemDebug.hpp" 14 17 15 18 using namespace std; … … 43 46 // if no entry for this observable is found, an new one is created 44 47 // 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 45 51 depth[publisher]++; 46 52 } … … 60 66 // if zero is reached all observed blocks are done and we can 61 67 // 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]){} 63 73 else{ 64 74 publisher->notifyAll(); … … 82 92 Observable::_Observable_protector::_Observable_protector(Observable *_protege) : 83 93 protege(_protege) 94 { 95 start_observer_internal(protege); 96 } 97 98 Observable::_Observable_protector::_Observable_protector(const _Observable_protector &dest) : 99 protege(dest.protege) 84 100 { 85 101 start_observer_internal(protege); … … 117 133 callees_t::iterator iter; 118 134 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 119 140 (*iter).second->update(this); 120 141 } … … 159 180 // we do not need to publish all the changes at each time we are called 160 181 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 161 186 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 162 193 } 163 194 } … … 171 202 void Observable::signOn(Observer *target,int priority) { 172 203 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 173 207 bool res = false; 174 208 callees_t &callees = callTable[this]; … … 188 222 void Observable::signOff(Observer *target) { 189 223 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 190 227 callees_t &callees = callTable[this]; 228 191 229 callees_t::iterator iter; 192 230 callees_t::iterator deliter; … … 231 269 /** Constructor for class Observable. 232 270 */ 233 Observable::Observable() 234 {} 271 Observable::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 } 235 279 236 280 /** Destructor for class Observable. … … 239 283 Observable::~Observable() 240 284 { 285 #ifdef LOG_OBSERVER 286 observerLog().addMessage() << "-- Destroying Observable " << observerLog().getName(this) << endl; 287 #endif 241 288 if(callTable.count(this)) { 242 289 // delete all entries for this observable … … 252 299 /** Constructor for class Observer. 253 300 */ 254 Observer::Observer() 255 {} 301 Observer::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 */ 314 Observer::Observer(Observer::BaseConstructor){ 315 #ifdef LOG_OBSERVER 316 observerLog().addObservable(this); 317 #endif 318 } 256 319 257 320 /** Destructor for class Observer. 258 321 */ 259 322 Observer::~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 } 261 330 262 331 /** … … 289 358 } 290 359 } 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 367 ObserverLog &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 375 ObserverLog::ObserverLog() : 376 count (0) 377 {} 378 379 ObserverLog::~ObserverLog(){} 380 381 string ObserverLog::getLog(){return log.str();} 382 383 std::string ObserverLog::getName(void* obj){ 384 return names[obj]; 385 } 386 387 bool ObserverLog::isObservable(void* obj){ 388 return observables.count(obj); 389 } 390 391 void ObserverLog::addName(void* obj , string name){ 392 stringstream sstr; 393 sstr << name << "_" << count++; 394 names[obj] = sstr.str(); 395 } 396 397 void ObserverLog::addObservable(void* obj){ 398 observables.insert(obj); 399 } 400 401 void ObserverLog::deleteName(void* obj){ 402 names.erase(obj); 403 } 404 405 void ObserverLog::deleteObservable(void* obj){ 406 observables.erase(obj); 407 } 408 409 stringstream &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 11 11 #include <map> 12 12 #include <set> 13 #include <string> 14 #include <sstream> 13 15 14 16 /** … … 28 30 */ 29 31 32 // Deactivate any logging when we are not in debug mode 33 #ifdef NDEBUG 34 #undef LOG_OBSERVER 35 #endif 36 30 37 class Observable; 31 38 class Notification; … … 35 42 // identification process 36 43 typedef Notification *const Notification_ptr; 44 45 template<class _Set> 46 class ObservedIterator; 37 47 38 48 /** … … 53 63 friend class Observable; 54 64 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 70 public: 71 Observer(BaseConstructor); 72 Observer(std::string); 57 73 virtual ~Observer(); 58 74 … … 86 102 class Observable : public Observer { 87 103 public: 88 Observable( );104 Observable(std::string _name); 89 105 virtual ~Observable(); 90 106 … … 152 168 static std::set<Observable*> busyObservables; 153 169 154 155 170 //! @cond 156 171 // Structure for RAII-Style notification … … 164 179 public: 165 180 _Observable_protector(Observable *); 181 _Observable_protector(const _Observable_protector&); 166 182 ~_Observable_protector(); 167 183 private: … … 187 203 }; 188 204 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 */ 212 class ObserverLog{ 213 friend class Observable; 214 friend class Observer; 215 template <typename> friend class Cacheable; 216 public: 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*); 222 private: 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 234 ObserverLog &observerLog(); 235 236 #endif 237 189 238 // extra macro is necessary to work with __LINE__ 190 239 #define PASTE(a,b) PASTE_HELPER(a,b) -
src/Patterns/Singleton.hpp
rc39cc4 rbdb143 9 9 #define SINGLETON_HPP_ 10 10 11 #include <cassert>12 11 #include <boost/thread.hpp> 13 12 13 #include "Helpers/Assert.hpp" 14 14 #include "defs.hpp" 15 15 … … 181 181 182 182 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"); 184 184 } 185 185 }; … … 191 191 struct creator_t<creator_T,false>{ 192 192 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; 194 195 } 195 196 inline static void set(ptr_t& dest,creator_T* src){ -
src/Patterns/Singleton_impl.hpp
rc39cc4 rbdb143 72 72 template <class T,bool _may_create> 73 73 void 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"); 75 75 boost::recursive_mutex::scoped_lock guard(instanceLock); 76 76 theInstance.reset(newInstance); … … 83 83 template <class T, bool _may_create> 84 84 Singleton<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"); 86 86 } 87 87 -
src/Plane.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "Plane.hpp" -
src/Space.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "Space.hpp" -
src/UIElements/Dialog.cpp
rc39cc4 rbdb143 6 6 */ 7 7 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" 12 15 #include "vector.hpp" 13 16 … … 31 34 32 35 bool Dialog::display(){ 36 if(checkAll()){ 37 setAll(); 38 return true; 39 } 40 else{ 41 return false; 42 } 43 } 44 45 bool Dialog::checkAll(){ 33 46 list<Query*>::iterator iter; 34 47 bool retval = true; … … 36 49 retval &= (*iter)->handle(); 37 50 // 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); 39 53 break; 40 }41 if (retval){42 // if all queries succeeded we can set the targets to appropriate values43 for(iter=queries.begin(); iter!=queries.end(); iter++) {44 (*iter)->setResult();45 54 } 46 55 } … … 48 57 } 49 58 59 void Dialog::setAll(){ 60 list<Query*>::iterator iter; 61 for(iter=queries.begin(); iter!=queries.end(); iter++) { 62 (*iter)->setResult(); 63 } 64 } 65 50 66 /****************** Query types Infrastructure **************************/ 51 67 52 68 // Base class 53 Dialog::Query::Query(string _title) : 54 title(_title) 69 Dialog::Query::Query(string _title, string _description) : 70 title(_title), 71 description(_description) 55 72 {} 56 73 … … 61 78 } 62 79 80 const std::string Dialog::Query::getDescription() const{ 81 return description; 82 } 83 // empty Queries 84 85 Dialog::EmptyQuery::EmptyQuery(string title, std::string description) : 86 Query(title, description) 87 {} 88 89 Dialog::EmptyQuery::~EmptyQuery() {} 90 91 void Dialog::EmptyQuery::setResult() { 92 } 93 63 94 // Int Queries 64 95 65 Dialog::IntQuery::IntQuery(string title,int *_target ) :66 Query(title ), target(_target)96 Dialog::IntQuery::IntQuery(string title,int *_target, std::string description) : 97 Query(title, description), target(_target) 67 98 {} 68 99 … … 73 104 } 74 105 106 // Int Queries 107 108 Dialog::BooleanQuery::BooleanQuery(string title,bool *_target, std::string description) : 109 Query(title, description), target(_target) 110 {} 111 112 Dialog::BooleanQuery::~BooleanQuery() {} 113 114 void Dialog::BooleanQuery::setResult() { 115 *target = tmp; 116 } 117 75 118 // String Queries 76 119 77 Dialog::StringQuery::StringQuery(string title,string *_target ) :78 Query(title ), target(_target)120 Dialog::StringQuery::StringQuery(string title,string *_target, std::string _description) : 121 Query(title, _description), target(_target) 79 122 {} 80 123 … … 87 130 // Double Queries 88 131 89 Dialog::DoubleQuery::DoubleQuery(string title,double *_target ) :90 Query(title ), target(_target)132 Dialog::DoubleQuery::DoubleQuery(string title,double *_target, std::string _description) : 133 Query(title, _description), target(_target) 91 134 {} 92 135 … … 98 141 99 142 143 // Atom Queries 144 145 Dialog::AtomQuery::AtomQuery(string title, atom **_target, std::string _description) : 146 Query(title, _description), 147 tmp(0), 148 target(_target) 149 150 {} 151 152 Dialog::AtomQuery::~AtomQuery() {} 153 154 void Dialog::AtomQuery::setResult() { 155 *target = tmp; 156 } 157 100 158 // Molecule Queries 101 159 102 Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target, MoleculeListClass *_molecules) :103 Query(title ),160 Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target, std::string _description) : 161 Query(title, _description), 104 162 tmp(0), 105 molecules(_molecules),106 163 target(_target) 107 164 … … 116 173 // Vector Queries 117 174 118 Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check ) :119 Query(title ),175 Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description) : 176 Query(title, _description), 120 177 cellSize(_cellSize), 121 178 check(_check), 122 179 target(_target) 123 180 { 124 tmp = new Vector();181 tmp = new Vector(); 125 182 } 126 183 … … 134 191 } 135 192 193 // Box Queries 194 195 Dialog::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 202 Dialog::BoxQuery::~BoxQuery() 203 { 204 delete[] tmp; 205 } 206 207 void Dialog::BoxQuery::setResult() { 208 for (int i=0;i<6;i++) { 209 (*target)[i] = tmp[i]; 210 } 211 } 212 136 213 // Element Queries 137 Dialog::ElementQuery::ElementQuery(std::string title, const element **_target) : 138 Query(title), 139 tmp(0), 214 Dialog::ElementQuery::ElementQuery(std::string title, std::vector<element *> *_target, std::string _description) : 215 Query(title, _description), 140 216 target(_target) 141 217 {} … … 144 220 145 221 void Dialog::ElementQuery::setResult(){ 146 *target= tmp;147 } 222 *target=elements; 223 } -
src/UIElements/Dialog.hpp
rc39cc4 rbdb143 11 11 #include<string> 12 12 #include<list> 13 #include<vector> 13 14 14 class MoleculeListClass; 15 class atom; 16 class element; 15 17 class molecule; 16 18 class Vector; 17 class element;18 19 19 20 class Dialog … … 23 24 virtual ~Dialog(); 24 25 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; 31 36 32 37 virtual bool display(); 38 39 virtual bool checkAll(); 40 virtual void setAll(); 33 41 34 42 protected: … … 45 53 //base class for all queries 46 54 class Query { 55 friend class Dialog; 47 56 public: 48 Query(std::string _title );57 Query(std::string _title, std::string _description = ""); 49 58 virtual ~Query(); 50 59 virtual bool handle()=0; … … 52 61 protected: 53 62 const std::string getTitle() const; 63 const std::string getDescription() const; 54 64 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(); 56 76 }; 57 77 58 78 //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 59 91 class IntQuery : public Query { 60 92 public: 61 IntQuery(std::string title,int *_target );93 IntQuery(std::string title,int *_target, std::string _description = ""); 62 94 virtual ~IntQuery(); 63 95 virtual bool handle()=0; … … 71 103 class DoubleQuery : public Query { 72 104 public: 73 DoubleQuery(std::string title,double *_target );105 DoubleQuery(std::string title,double *_target, std::string _description = ""); 74 106 virtual ~DoubleQuery(); 75 107 virtual bool handle()=0; … … 83 115 class StringQuery : public Query { 84 116 public: 85 StringQuery(std::string title,std::string *_target );117 StringQuery(std::string title,std::string *_target, std::string _description = ""); 86 118 virtual ~StringQuery(); 87 119 virtual bool handle()=0; … … 93 125 }; 94 126 95 96 127 class MoleculeQuery : public Query { 97 128 public: 98 MoleculeQuery(std::string title, molecule **_target, MoleculeListClass *_molecules);129 MoleculeQuery(std::string title, molecule **_target, std::string _description = ""); 99 130 virtual ~MoleculeQuery(); 100 131 virtual bool handle()=0; … … 102 133 protected: 103 134 molecule *tmp; 104 MoleculeListClass *molecules;105 135 private: 106 136 molecule **target; 107 137 }; 108 138 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 109 151 class VectorQuery : public Query { 110 152 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 = ""); 112 154 virtual ~VectorQuery(); 113 155 virtual bool handle()=0; … … 121 163 }; 122 164 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 123 177 class ElementQuery : public Query { 124 178 public: 125 ElementQuery(std::string title, const element**_target);179 ElementQuery(std::string title, std::vector<element *> *_target, std::string _description = ""); 126 180 virtual ~ElementQuery(); 127 181 virtual bool handle()=0; 128 182 virtual void setResult(); 129 183 protected: 130 const element *tmp;184 std::vector<element *> elements; 131 185 private: 132 const element **target;186 std::vector<element *> * const target; 133 187 }; 134 188 … … 140 194 }; 141 195 196 142 197 #endif /* DIALOG_HPP_ */ -
src/UIElements/MainWindow.cpp
rc39cc4 rbdb143 6 6 */ 7 7 8 #include "UIElements/MainWindow.hpp" 8 #include "Helpers/MemDebug.hpp" 9 10 #include "MainWindow.hpp" 9 11 10 12 MainWindow::MainWindow() 11 { 12 // TODO Auto-generated constructor stub 13 14 } 13 {} 15 14 16 15 MainWindow::~MainWindow() 17 { 18 // TODO Auto-generated destructor stub 19 } 16 {} -
src/UIElements/MainWindow.hpp
rc39cc4 rbdb143 25 25 }; 26 26 27 /**28 * The type of menuPopulators29 */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 called35 * by the UIFactory upon creation of the main menu. Thus the actuall construction36 * of the Menus can be kept independent of the concrete type of UI that is being37 * built.38 */39 struct menuPopulaters{40 MenuMaker MakeEditMoleculesMenu;41 };42 27 43 28 #endif /* MAINWINDOW_HPP_ */ -
src/UIElements/UIFactory.cpp
rc39cc4 rbdb143 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 8 9 9 #include < cassert>10 #include <utility> 10 11 #include "Patterns/Singleton_impl.hpp" 11 12 #include "UIElements/UIFactory.hpp" 13 #include "Helpers/Assert.hpp" 14 #include "Helpers/MemDebug.hpp" 12 15 13 // all factories that can be used: 14 #include "UIElements/TextUIFactory.hpp" 16 using namespace std; 17 18 std::map<std::string,boost::shared_ptr<UIFactory::factoryDescription> > UIFactory::factories; 15 19 16 20 UIFactory::UIFactory() 17 { 18 // TODO Auto-generated constructor stub 21 {} 19 22 23 UIFactory::~UIFactory() 24 {} 25 26 void 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()); 20 30 } 21 31 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 } 32 void 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))); 37 36 } 38 37 39 38 CONSTRUCT_SINGLETON(UIFactory) 39 40 UIFactory::factoryDescription::factoryDescription(string _name) : 41 name(_name) 42 {} 43 44 UIFactory::factoryDescription::~factoryDescription() 45 {} -
src/UIElements/UIFactory.hpp
rc39cc4 rbdb143 11 11 class MainWindow; 12 12 class Dialog; 13 14 class MoleculeListClass; 15 class config; 16 class periodentafel; 17 18 struct menuPopulaters; 13 class DialogDescription; 19 14 20 15 #include "Patterns/Singleton.hpp" 16 17 #include <string> 18 #include <map> 19 #include <boost/smart_ptr.hpp> 21 20 22 21 /** … … 29 28 class UIFactory : public Singleton<UIFactory,false> 30 29 { 31 30 friend class Singleton<UIFactory,false>; 32 31 public: 33 enum InterfaceTypes {Text};34 virtual ~UIFactory();35 32 36 33 /** 37 34 * Produce some kind of main window, of whichever type was chosen when the factory was created 38 35 */ 39 virtual MainWindow* makeMainWindow( menuPopulaters,MoleculeListClass *, config *, periodentafel *, char *)=0;36 virtual MainWindow* makeMainWindow()=0; 40 37 41 38 /** … … 47 44 protected: 48 45 UIFactory(); 46 virtual ~UIFactory(); 49 47 50 48 public: 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 }; 51 58 /** 52 59 * create a Factory of a certain type. From that moment on only those UIElements can be produced by the factory 53 60 */ 54 static void makeUserInterface(InterfaceTypes type); 55 61 static void makeUserInterface(std::string type); 62 static void registerFactory(factoryDescription *factoryDesc); 63 protected: 64 private: 65 static std::map<std::string,boost::shared_ptr<factoryDescription> > factories; 56 66 }; 57 67 -
src/World.cpp
rc39cc4 rbdb143 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "World.hpp" 9 11 10 12 #include "atom.hpp" 13 #include "config.hpp" 11 14 #include "molecule.hpp" 12 15 #include "periodentafel.hpp" 16 #include "ThermoStatContainer.hpp" 13 17 #include "Descriptors/AtomDescriptor.hpp" 14 18 #include "Descriptors/AtomDescriptor_impl.hpp" … … 17 21 #include "Descriptors/SelectiveIterator_impl.hpp" 18 22 #include "Actions/ManipulateAtomsProcess.hpp" 23 #include "Helpers/Assert.hpp" 19 24 20 25 #include "Patterns/Singleton_impl.hpp" … … 27 32 } 28 33 34 config *&World::getConfig(){ 35 return configuration; 36 } 37 29 38 // Atoms 30 39 … … 55 64 } 56 65 66 std::vector<molecule*> World::getAllMolecules(){ 67 return getAllMolecules(AllMolecules()); 68 } 69 57 70 int World::numMolecules(){ 58 71 return molecules_deprecated->ListOfMolecules.size(); … … 70 83 } 71 84 72 char *World::getDefaultName() {85 std::string World::getDefaultName() { 73 86 return defaultName; 74 87 } 75 88 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"); 89 void World::setDefaultName(std::string name) 90 { 91 defaultName = name; 85 92 }; 86 93 94 class ThermoStatContainer * World::getThermostats() 95 { 96 return Thermostats; 97 } 98 99 100 int World::getExitFlag() { 101 return ExitFlag; 102 } 103 104 void World::setExitFlag(int flag) { 105 if (ExitFlag < flag) 106 ExitFlag = flag; 107 } 87 108 88 109 /******************** Methods to change World state *********************/ … … 92 113 molecule *mol = NULL; 93 114 mol = NewMolecule(); 94 assert(!molecules.count(currMoleculeId));115 ASSERT(!molecules.count(currMoleculeId),"currMoleculeId did not specify an unused ID"); 95 116 mol->setId(currMoleculeId++); 96 117 // store the molecule by ID … … 108 129 OBSERVE; 109 130 molecule *mol = molecules[id]; 110 assert(mol);131 ASSERT(mol,"Molecule id that was meant to be destroyed did not exist"); 111 132 DeleteMolecule(mol); 112 133 molecules.erase(id); … … 114 135 115 136 double *World::cell_size = NULL; 116 char *World::defaultName = NULL;117 137 118 138 atom *World::createAtom(){ … … 145 165 OBSERVE; 146 166 atom *atom = atoms[id]; 147 assert(atom);167 ASSERT(atom,"Atom ID that was meant to be destroyed did not exist"); 148 168 DeleteAtom(atom); 149 169 atoms.erase(id); … … 157 177 if(!target){ 158 178 target = atoms[oldId]; 159 assert(target &&"Atom with that ID not found");179 ASSERT(target,"Atom with that ID not found"); 160 180 return target->changeId(newId); 161 181 } … … 266 286 267 287 World::World() : 288 Observable("World"), 268 289 periode(new periodentafel), 290 configuration(new config), 291 Thermostats(new ThermoStatContainer), 292 ExitFlag(0), 269 293 atoms(), 270 294 currAtomId(0), … … 280 304 cell_size[4] = 0.; 281 305 cell_size[5] = 20.; 282 defaultName = new char[MAXSTRINGSIZE]; 283 strcpy(defaultName, "none"); 306 defaultName = "none"; 284 307 molecules_deprecated->signOn(this); 285 308 } … … 289 312 molecules_deprecated->signOff(this); 290 313 delete[] cell_size; 291 delete[] defaultName;292 314 delete molecules_deprecated; 293 315 delete periode; 316 delete configuration; 317 delete Thermostats; 294 318 MoleculeSet::iterator molIter; 295 319 for(molIter=molecules.begin();molIter!=molecules.end();++molIter){ -
src/World.hpp
rc39cc4 rbdb143 30 30 31 31 // forward declarations 32 class periodentafel;33 class MoleculeListClass;34 32 class atom; 35 class molecule;36 33 class AtomDescriptor; 37 34 class AtomDescriptor_impl; 35 template<typename T> class AtomsCalculation; 36 class config; 37 class ManipulateAtomsProcess; 38 class molecule; 38 39 class MoleculeDescriptor; 39 40 class MoleculeDescriptor_impl; 40 class M anipulateAtomsProcess;41 template<typename T> 42 class AtomsCalculation;41 class MoleculeListClass; 42 class periodentafel; 43 class ThermoStatContainer; 43 44 44 45 /****************************************** forward declarations *****************************/ … … 75 76 76 77 /** 78 * returns the configuration for the world. 79 */ 80 config *&getConfig(); 81 82 /** 77 83 * returns the first atom that matches a given descriptor. 78 84 * Do not rely on ordering for descriptors that match more than one atom. … … 109 115 */ 110 116 std::vector<molecule*> getAllMolecules(MoleculeDescriptor descriptor); 117 std::vector<molecule*> getAllMolecules(); 111 118 112 119 /** … … 128 135 * get the default name 129 136 */ 130 char *getDefaultName();137 std::string getDefaultName(); 131 138 132 139 /** 133 140 * set the default name 134 141 */ 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); 136 158 137 159 /***** Methods to work with the World *****/ … … 234 256 235 257 periodentafel *periode; 258 config *configuration; 236 259 static double *cell_size; 237 static char *defaultName; 260 std::string defaultName; 261 class ThermoStatContainer *Thermostats; 262 int ExitFlag; 238 263 public: 239 264 AtomSet atoms; -
src/analysis_bonds.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "analysis_bonds.hpp" … … 26 28 Mean = 0.; 27 29 28 atom *Walker = mol->start;29 30 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(); 33 33 if (Max < count) 34 34 Max = count; … … 51 51 * \param &Max maximum distance on return, 0 if no bond between the two elements 52 52 */ 53 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, element *type1,element *type2, double &Min, double &Mean, double &Max)53 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, const element *type1, const element *type2, double &Min, double &Mean, double &Max) 54 54 { 55 55 Min = 2e+6; … … 58 58 59 59 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) { 66 64 const double distance = (*BondRunner)->GetDistanceSquared(); 67 65 if (Min > distance) … … 127 125 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, const element * InterfaceElement = NULL, const element * Interface2Element = NULL) 128 126 { 129 atom *Walker = NULL;130 atom *Runner = NULL;131 127 int count = 0; 132 128 int OtherHydrogens = 0; … … 135 131 bool Interface2Flag = false; 136 132 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)) { 146 140 // check distance 147 const double distance = Runner->x.DistanceSquared(Walker->x);141 const double distance = (*Runner)->x.DistanceSquared((*Walker)->x); 148 142 if ((distance > MYEPSILON) && (distance < HBRIDGEDISTANCE*HBRIDGEDISTANCE)) { // distance >0 means different atoms 149 143 // on other atom(Runner) we check for bond to interface element and … … 154 148 InterfaceFlag = (InterfaceElement == NULL); 155 149 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); 158 152 // if hydrogen, check angle to be greater(!) than 30 degrees 159 153 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); 161 155 OtherHydrogenFlag = OtherHydrogenFlag && (angle > M_PI*(30./180.) + MYEPSILON); 162 156 Otherangle += angle; … … 180 174 if (InterfaceFlag && Interface2Flag && OtherHydrogenFlag) { 181 175 // 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); 184 178 if (OtherAtom->type->Z == 1) { 185 179 // 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); 188 182 count++; 189 183 break; … … 209 203 int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second) 210 204 { 211 atom *Walker = NULL;212 205 int count = 0; 213 206 214 207 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 matches219 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)) { 222 215 count++; 223 216 DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl); … … 244 237 bool MatchFlag[2]; 245 238 bool result = false; 246 atom *Walker = NULL;247 239 const element * ElementArray[2]; 248 240 ElementArray[0] = first; … … 250 242 251 243 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 matches244 molecule::iterator Walker = (*MolWalker)->begin(); 245 for(;Walker!=(*MolWalker)->end();++Walker){ 246 atom *theAtom = *Walker; 247 if (theAtom->type == second) { // first element matches 256 248 for (int i=0;i<2;i++) 257 249 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); 260 252 for (int i=0;i<2;i++) 261 253 if ((!MatchFlag[i]) && (OtherAtom->type == ElementArray[i])) { -
src/analysis_bonds.hpp
rc39cc4 rbdb143 31 31 32 32 void 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);33 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, const element *type1, const element *type2, double &Min, double &Mean, double &Max); 34 34 35 35 int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, const element * InterfaceElement, const element * Interface2Element); -
src/analysis_correlation.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <iostream> … … 23 25 /** Calculates the pair correlation between given elements. 24 26 * 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 29 29 * \return Map of doubles with values the pair of the two atoms. 30 30 */ 31 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2)31 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements) 32 32 { 33 33 Info FunctionInfo(__func__); 34 34 PairCorrelationMap *outmap = NULL; 35 35 double distance = 0.; 36 double *domain = World::getInstance().getDomain(); 36 37 37 38 if (molecules->ListOfMolecules.empty()) { … … 39 40 return outmap; 40 41 } 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 41 62 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++){ 43 64 if ((*MolWalker)->ActiveFlag) { 44 65 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)) ) ); 62 80 } 63 81 } 82 } 64 83 } 65 84 } 66 85 } 67 86 } 68 87 } 69 88 return outmap; 70 89 }; … … 72 91 /** Calculates the pair correlation between given elements. 73 92 * 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 78 95 * \param ranges[NDIM] interval boundaries for the periodic images to scan also 79 96 * \return Map of doubles with values the pair of the two atoms. 80 97 */ 81 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2, const int ranges[NDIM] )98 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const int ranges[NDIM] ) 82 99 { 83 100 Info FunctionInfo(__func__); … … 95 112 return outmap; 96 113 } 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 97 134 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++){ 99 136 if ((*MolWalker)->ActiveFlag) { 100 137 double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 101 138 double * FullInverseMatrix = InverseMatrix(FullMatrix); 102 139 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; 126 160 periodicOtherX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 127 161 // go through every range in xyz and get distance … … 132 166 checkOtherX.MatrixMultiplication(FullMatrix); 133 167 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)) ) ); 136 170 } 137 171 } 172 } 138 173 } 174 } 139 175 } 140 176 } 141 142 }143 Free(&FullMatrix);144 Free(&FullInverseMatrix);145 177 } 178 delete[](FullMatrix); 179 delete[](FullInverseMatrix); 180 } 181 } 146 182 147 183 return outmap; … … 149 185 150 186 /** 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 154 189 * \param *point vector to the correlation point 155 190 * \return Map of dobules with values as pairs of atom and the vector 156 191 */ 157 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point )192 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point ) 158 193 { 159 194 Info FunctionInfo(__func__); 160 195 CorrelationToPointMap *outmap = NULL; 161 196 double distance = 0.; 197 double *cell_size = World::getInstance().getDomain(); 162 198 163 199 if (molecules->ListOfMolecules.empty()) { … … 165 201 return outmap; 166 202 } 203 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 204 (*MolWalker)->doCountAtoms(); 167 205 outmap = new CorrelationToPointMap; 168 206 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 169 207 if ((*MolWalker)->ActiveFlag) { 170 208 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 } 180 217 } 181 218 } … … 185 222 186 223 /** 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 190 226 * \param *point vector to the correlation point 191 227 * \param ranges[NDIM] interval boundaries for the periodic images to scan also 192 228 * \return Map of dobules with values as pairs of atom and the vector 193 229 */ 194 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] )230 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] ) 195 231 { 196 232 Info FunctionInfo(__func__); … … 205 241 return outmap; 206 242 } 243 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 244 (*MolWalker)->doCountAtoms(); 207 245 outmap = new CorrelationToPointMap; 208 246 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) … … 211 249 double * FullInverseMatrix = InverseMatrix(FullMatrix); 212 250 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); 234 271 } 235 272 … … 238 275 239 276 /** 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 243 279 * \param *Surface pointer to Tesselation class surface 244 280 * \param *LC LinkedCell structure to quickly find neighbouring atoms 245 281 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest 246 282 */ 247 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC )283 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC ) 248 284 { 249 285 Info FunctionInfo(__func__); … … 257 293 return outmap; 258 294 } 295 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 296 (*MolWalker)->doCountAtoms(); 259 297 outmap = new CorrelationToSurfaceMap; 260 298 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 261 299 if ((*MolWalker)->ActiveFlag) { 262 300 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 { 275 314 DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl); 315 } 276 316 277 317 return outmap; … … 283 323 * axis an integer from [ -ranges[i], ranges[i] ] onto it and multiply with the domain matrix to bring it back into 284 324 * 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 288 327 * \param *Surface pointer to Tesselation class surface 289 328 * \param *LC LinkedCell structure to quickly find neighbouring atoms … … 291 330 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest 292 331 */ 293 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )332 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ) 294 333 { 295 334 Info FunctionInfo(__func__); … … 306 345 return outmap; 307 346 } 347 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 348 (*MolWalker)->doCountAtoms(); 308 349 outmap = new CorrelationToSurfaceMap; 309 350 double ShortestDistance = 0.; … … 314 355 double * FullInverseMatrix = InverseMatrix(FullMatrix); 315 356 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)^3323 // go through every range in xyz and get distance324 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 } 336 377 } 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); 345 385 } 346 386 -
src/analysis_correlation.hpp
rc39cc4 rbdb143 45 45 /********************************************** declarations *******************************/ 46 46 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] );47 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements); 48 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point ); 49 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC ); 50 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const int ranges[NDIM] ); 51 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] ); 52 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ); 53 53 int GetBin ( const double value, const double BinWidth, const double BinStart ); 54 54 void OutputCorrelation( ofstream * const file, const BinPairMap * const map ); -
src/analyzer.cpp
rc39cc4 rbdb143 7 7 8 8 //============================ INCLUDES =========================== 9 10 #include "Helpers/MemDebug.hpp" 9 11 10 12 #include <cstring> … … 75 77 return 1; 76 78 } else { 77 dir = Malloc<char>(strlen(argv[2]) + 2, "main: *dir");79 dir = new char[strlen(argv[2]) + 2]; 78 80 strcpy(dir, "/"); 79 81 strcat(dir, argv[2]); … … 82 84 if (argc > 4) { 83 85 DoLog(0) && (Log() << Verbose(0) << "Loading periodentafel." << endl); 84 periode = Malloc<periodentafel>(1, "main - periode");86 periode = new periodentafel; 85 87 periode->LoadPeriodentafel(argv[4]); 86 88 } … … 558 560 // ++++++++++++++++ exit ++++++++++++++++++++++++++++++++++ 559 561 delete(periode); 560 Free(&dir);562 delete[](dir); 561 563 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 562 564 return 0; -
src/atom.cpp
rc39cc4 rbdb143 4 4 * 5 5 */ 6 7 #include "Helpers/MemDebug.hpp" 6 8 7 9 #include "atom.hpp" … … 14 16 #include "vector.hpp" 15 17 #include "World.hpp" 18 #include "molecule.hpp" 16 19 17 20 /************************************* Functions for class atom *************************************/ … … 21 24 */ 22 25 atom::atom() : 23 previous(NULL), next(NULL), father(this), sort(&nr)26 father(this), sort(&nr), mol(0) 24 27 { 25 28 node = &x; // TesselPoint::x can only be referenced from here … … 29 32 */ 30 33 atom::atom(atom *pointer) : 31 ParticleInfo(pointer), 32 previous(NULL), next(NULL), father(pointer), sort(&nr) 34 ParticleInfo(pointer),father(pointer), sort(&nr) 33 35 { 34 36 type = pointer->type; // copy element of atom … … 37 39 FixedIon = pointer->FixedIon; 38 40 node = &x; 41 mol = 0; 39 42 }; 40 43 41 44 atom *atom::clone(){ 42 45 atom *res = new atom(this); 43 res->previous=0;44 res->next=0;45 46 res->father = this; 46 47 res->sort = &res->nr; … … 50 51 res->FixedIon = FixedIon; 51 52 res->node = &x; 53 res->mol = 0; 52 54 World::getInstance().registerAtom(res); 53 55 return res; … … 59 61 atom::~atom() 60 62 { 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 } 62 69 }; 63 70 … … 152 159 * \return true - \a *out present, false - \a *out is NULL 153 160 */ 154 bool atom::OutputArrayIndexed(o fstream * const out, const int *ElementNo, int *AtomNo, const char *comment) const161 bool atom::OutputArrayIndexed(ostream * const out, const int *ElementNo, int *AtomNo, const char *comment) const 155 162 { 156 163 AtomNo[type->Z]++; // increment number … … 229 236 * \param *AtomNo pointer to atom counter that is increased by one 230 237 */ 231 void atom::OutputMPQCLine(o fstream * const out, const Vector *center, int *AtomNo = NULL) const238 void atom::OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo = NULL) const 232 239 { 233 240 *out << "\t\t" << type->symbol << " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl; … … 272 279 { 273 280 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]; 276 283 for (int i=ListOfBonds.size()+1;i--;) 277 284 ComponentNr[i] = -1; … … 308 315 } 309 316 310 atomId_t atom::getId() {317 atomId_t atom::getId() const { 311 318 return id; 312 319 } 320 321 void 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 330 void atom::removeFromMolecule(){ 331 if(mol){ 332 if(mol->containsAtom(this)){ 333 mol->erase(this); 334 } 335 mol=0; 336 } 337 } 338 313 339 314 340 atom* NewAtom(atomId_t _id){ -
src/atom.hpp
rc39cc4 rbdb143 34 34 class Vector; 35 35 class World; 36 class molecule; 36 37 37 38 /********************************************** declarations *******************************/ … … 44 45 friend void DeleteAtom(atom*); 45 46 public: 46 atom *previous; //!< previous atom in molecule list47 atom *next; //!< next atom in molecule list48 47 atom *father; //!< In many-body bond order fragmentations points to originating atom 49 48 int *sort; //!< sort criteria … … 52 51 53 52 bool OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment = NULL) const; 54 bool OutputArrayIndexed(o fstream * 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; 55 54 bool OutputXYZLine(ofstream *out) const; 56 55 bool OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const; 57 56 bool OutputTrajectoryXYZ(ofstream * const out, const int step) const; 58 void OutputMPQCLine(o fstream * const out, const Vector *center, int *AtomNo) const;57 void OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo) const; 59 58 60 59 void InitComponentNr(); … … 80 79 void setWorld(World*); 81 80 82 virtual atomId_t getId() ;81 virtual atomId_t getId() const; 83 82 virtual bool changeId(atomId_t newId); 84 83 … … 89 88 virtual void setId(atomId_t); 90 89 90 void setMolecule(molecule*); 91 void removeFromMolecule(); 92 91 93 protected: 94 92 95 /** 93 96 * Protected constructor to ensure construction of atoms through the world. … … 108 111 virtual ~atom(); 109 112 private: 113 molecule *mol; // !< the molecule this atom belongs to 110 114 World* world; 111 115 atomId_t id; -
src/atom_atominfo.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "periodentafel.hpp" -
src/atom_bondedparticle.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "atom.hpp" … … 74 76 *BondFile << nr << "\t" << (*Runner)->GetOtherAtom(this)->nr << "\n"; 75 77 }; 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 */ 85 void 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 } 76 94 77 95 /** Puts a given bond into atom::ListOfBonds. -
src/atom_bondedparticle.hpp
rc39cc4 rbdb143 37 37 virtual ~BondedParticle(); 38 38 39 void addBond(BondedParticle* Partner); 39 40 bool RegisterBond(bond *Binder); 40 41 bool UnregisterBond(bond *Binder); -
src/atom_bondedparticleinfo.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "atom_bondedparticleinfo.hpp" -
src/atom_graphnode.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "atom_graphnode.hpp" -
src/atom_graphnodeinfo.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "atom_graphnodeinfo.hpp" … … 17 19 GraphNodeInfo::~GraphNodeInfo() 18 20 { 19 Free<int>(&ComponentNr, "atom::~atom: *ComponentNr");21 delete[](ComponentNr); 20 22 }; -
src/atom_particleinfo.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "atom_particleinfo.hpp" -
src/atom_trajectoryparticle.cpp
rc39cc4 rbdb143 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "atom.hpp" 9 11 #include "atom_trajectoryparticle.hpp" 10 12 #include "config.hpp" 11 13 #include "element.hpp" 14 #include "info.hpp" 12 15 #include "log.hpp" 13 16 #include "parser.hpp" 17 #include "ThermoStatContainer.hpp" 14 18 #include "verbose.hpp" 15 19 … … 71 75 void TrajectoryParticle::ResizeTrajectory(int MaxSteps) 72 76 { 77 Info FunctionInfo(__func__); 73 78 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); 75 80 Trajectory.R.resize(MaxSteps+1); 76 81 Trajectory.U.resize(MaxSteps+1); … … 193 198 void TrajectoryParticle::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration) 194 199 { 195 double sigma = sqrt(configuration->T argetTemp/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) 196 201 Vector &U = Trajectory.U.at(Step); 197 202 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 198 203 // throw a dice to determine whether it gets hit by a heat bath particle 199 if (((((rand()/(double)RAND_MAX))*configuration->T empFrequency) < 1.)) {204 if (((((rand()/(double)RAND_MAX))*configuration->Thermostats->TempFrequency) < 1.)) { 200 205 DoLog(3) && (Log() << Verbose(3) << "Particle " << *this << " was hit (sigma " << sigma << "): " << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << " -> "); 201 206 // pick three random numbers from a Boltzmann distribution around the desired temperature T for each momenta axis … … 221 226 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 222 227 for (int d=0; d<NDIM; d++) { 223 U[d] *= sqrt(1+(configuration->Deltat/configuration->T empFrequency)*(ScaleTempFactor-1));228 U[d] *= sqrt(1+(configuration->Deltat/configuration->Thermostats->TempFrequency)*(ScaleTempFactor-1)); 224 229 *ekin += 0.5*type->mass * U[d]*U[d]; 225 230 } … … 251 256 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 252 257 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)); 254 259 *ekin += (0.5*type->mass) * U[d]*U[d]; 255 260 } -
src/atom_trajectoryparticleinfo.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "atom_trajectoryparticleinfo.hpp" -
src/atom_trajectoryparticleinfo.hpp
rc39cc4 rbdb143 21 21 22 22 #include "vector.hpp" 23 #include "VectorSet.hpp" 23 24 24 25 /********************************************** declarations *******************************/ … … 28 29 struct 29 30 { 30 vector<Vector> R; //!< position vector31 vector<Vector> U; //!< velocity vector32 vector<Vector> F; //!< last force vector31 VectorSet<vector<Vector> > R; //!< position vector 32 VectorSet<vector<Vector> > U; //!< velocity vector 33 VectorSet<vector<Vector> > F; //!< last force vector 33 34 } Trajectory; 34 35 int FixedIon; //!< config variable that states whether forces act on the ion or not -
src/bond.cpp
rc39cc4 rbdb143 4 4 * 5 5 */ 6 7 #include "Helpers/MemDebug.hpp" 6 8 7 9 #include "atom.hpp" … … 15 17 /** Empty Constructor for class bond. 16 18 */ 17 bond::bond() : leftatom(NULL), rightatom(NULL), previous(NULL), next(NULL), HydrogenBond(0), BondDegree(0), nr(-1), Cyclic(false), Type(Undetermined), Used(white) 19 bond::bond() 20 : leftatom(NULL), rightatom(NULL), previous(NULL), next(NULL), HydrogenBond(0), 21 BondDegree(0), nr(-1), Cyclic(false), Type(Undetermined), Used(white) 18 22 { 19 23 }; … … 25 29 * \param number increasing index 26 30 */ 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) 31 bond::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) 28 34 { 29 35 if ((left != NULL) && (right != NULL)) { -
src/bondgraph.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <iostream> … … 88 90 { 89 91 Info FunctionInfo(__func__); 90 bool status = true;92 bool status = true; 91 93 92 if (mol-> start->next == mol->end) // only construct if molecule is not empty94 if (mol->empty()) // only construct if molecule is not empty 93 95 return false; 94 96 … … 124 126 max_distance = 0.; 125 127 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; 131 131 } 132 132 max_distance *= 2.; -
src/bondgraph.hpp
rc39cc4 rbdb143 27 27 28 28 class molecule; 29 class periodentafel;29 class BondedParticle; 30 30 class MatrixContainer; 31 31 -
src/boundary.cpp
rc39cc4 rbdb143 3 3 * Implementations and super-function for envelopes 4 4 */ 5 6 #include "Helpers/MemDebug.hpp" 5 7 6 8 #include "World.hpp" … … 139 141 { 140 142 Info FunctionInfo(__func__); 141 atom *Walker = NULL;142 143 PointMap PointsOnBoundary; 143 144 LineMap LinesOnBoundary; … … 165 166 166 167 // 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); 171 170 ProjectedVector.ProjectOntoPlane(AxisVector); 172 171 … … 182 181 angle = 2. * M_PI - angle; 183 182 } 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)))); 186 185 if (!BoundaryTestPair.second) { // same point exists, check first r, then distance of original vectors to center of gravity 187 186 DoLog(2) && (Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl); 188 187 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); 190 189 const double ProjectedVectorNorm = ProjectedVector.NormSquared(); 191 190 if ((ProjectedVectorNorm - BoundaryTestPair.first->second.first) > MYEPSILON) { 192 191 BoundaryTestPair.first->second.first = ProjectedVectorNorm; 193 BoundaryTestPair.first->second.second = Walker;192 BoundaryTestPair.first->second.second = (*iter); 194 193 DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl); 195 194 } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) { 196 helper = Walker->x - (*MolCenter); 195 helper = (*iter)->x; 196 helper -= *MolCenter; 197 197 const double oldhelperNorm = helper.NormSquared(); 198 198 helper = BoundaryTestPair.first->second.second->x - (*MolCenter); 199 199 if (helper.NormSquared() < oldhelperNorm) { 200 BoundaryTestPair.first->second.second = Walker;200 BoundaryTestPair.first->second.second = (*iter); 201 201 DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl); 202 202 } else { … … 226 226 do { // do as long as we still throw one out per round 227 227 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++; 231 235 // set neighbours correctly 232 236 if (runner == BoundaryPoints[axis].begin()) { … … 236 240 } 237 241 left--; 238 right = runner;239 right++;240 242 if (right == BoundaryPoints[axis].end()) { 241 243 right = BoundaryPoints[axis].begin(); 244 LoopOnceDone = true; 242 245 } 243 246 // check distance … … 279 282 DoLog(1) && (Log() << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl); 280 283 BoundaryPoints[axis].erase(runner); 284 runner = right; 281 285 flag = true; 282 286 } … … 359 363 360 364 // 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"); 381 366 382 367 // 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 … … 397 382 TesselStruct->FlipBaseline(line); 398 383 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 399 385 } 400 386 } … … 409 395 410 396 // 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, ""); 430 398 431 399 // free reference lists … … 678 646 /** Creates multiples of the by \a *mol given cluster and suspends them in water with a given final density. 679 647 * We get cluster volume by VolumeOfConvexEnvelope() and its diameters by GetDiametersOfCluster() 648 * TODO: Here, we need a VolumeOfGeneralEnvelope (i.e. non-convex one) 680 649 * \param *out output stream for debugging 681 650 * \param *configuration needed for path to store convex envelope file … … 695 664 int repetition[NDIM] = { 1, 1, 1 }; 696 665 int TotalNoClusters = 1; 697 atom *Walker = NULL;698 666 double totalmass = 0.; 699 667 double clustervolume = 0.; … … 706 674 GreatestDiameter = GetDiametersOfCluster(BoundaryPoints, mol, TesselStruct, IsAngstroem); 707 675 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 710 680 711 681 // some preparations beforehand … … 719 689 720 690 // 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; 725 693 } 726 694 DoLog(0) && (Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl); … … 804 772 Vector Inserter; 805 773 double FillIt = false; 806 atom *Walker = NULL;807 774 bond *Binder = NULL; 808 775 double phi[NDIM]; … … 811 778 812 779 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) 813 if ((*ListRunner)-> AtomCount> 0) {780 if ((*ListRunner)->getAtomCount() > 0) { 814 781 DoLog(1) && (Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl); 815 782 LCList[(*ListRunner)] = new LinkedCell((*ListRunner), 10.); // get linked cell list … … 822 789 filler->CenterEdge(&Inserter); 823 790 filler->Center.Zero(); 791 const int FillerCount = filler->getAtomCount(); 824 792 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]; 833 799 834 800 // calculate filler grid in [0,1]^3 … … 855 821 856 822 // go through all atoms 857 for (int i=0;i< filler->AtomCount;i++)823 for (int i=0;i<FillerCount;i++) 858 824 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){ 862 826 863 827 // create atomic random translation vector ... … … 883 847 884 848 // ... and put at new position 885 Inserter = Walker->x;849 Inserter = (*iter)->x; 886 850 if (DoRandomRotation) 887 851 Inserter.MatrixMultiplication(Rotations); … … 907 871 DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is outer point." << endl); 908 872 // 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); 913 877 } else { 914 878 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; 916 880 continue; 917 881 } 918 882 } 919 883 // 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 } 928 893 } 929 Free(&M);930 Free(&MInverse);894 delete[](M); 895 delete[](MInverse); 931 896 932 897 return Filling; … … 952 917 bool TesselationFailFlag = false; 953 918 919 mol->getAtomCount(); 920 954 921 if (TesselStruct == NULL) { 955 922 DoLog(1) && (Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl); … … 1023 990 // // look whether all points are inside of the convex envelope, otherwise add them via degenerated triangles 1024 991 // //->InsertStraddlingPoints(mol, LCList); 1025 // mol->GoToFirst();992 // for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1026 993 // class TesselPoint *Runner = NULL; 1027 // while (!mol->IsEnd()) { 1028 // Runner = mol->GetPoint(); 994 // Runner = *iter; 1029 995 // Log() << Verbose(1) << "Checking on " << Runner->Name << " ... " << endl; 1030 996 // if (!->IsInnerPoint(Runner, LCList)) { … … 1034 1000 // Log() << Verbose(2) << Runner->Name << " is inside of or on envelope." << endl; 1035 1001 // } 1036 // mol->GoToNext();1037 1002 // } 1038 1003 … … 1043 1008 // status = CheckListOfBaselines(TesselStruct); 1044 1009 1010 cout << "before correction" << endl; 1011 1045 1012 // store before correction 1046 StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, "");1013 StoreTrianglesinFile(mol, TesselStruct, filename, ""); 1047 1014 1048 1015 // // correct degenerated polygons … … 1054 1021 // write final envelope 1055 1022 CalculateConcavityPerBoundaryPoint(TesselStruct); 1056 StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, ""); 1023 cout << "after correction" << endl; 1024 StoreTrianglesinFile(mol, TesselStruct, filename, ""); 1057 1025 1058 1026 if (freeLC) -
src/builder.cpp
rc39cc4 rbdb143 1 1 /** \file builder.cpp 2 2 * 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 8 5 * 9 6 */ 10 7 11 /*! \mainpage Mole cuilder - a molecular set builder8 /*! \mainpage MoleCuilder - a molecular set builder 12 9 * 13 * This introductory shall briefly make a quainted 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. 14 11 * 15 12 * \section about About the Program 16 13 * 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. 20 21 * 21 * A configuration file may be written that is compatible to the format used by PCP - a parallel Car-Parrinello22 * molecular dynamics implementation.23 22 * 24 23 * \section install Installation … … 32 31 * -# make clean uninstall: deletes .o-files and removes executable from the given binary directory\n 33 32 * -# 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. 34 35 * 35 36 * \section run Running … … 37 38 * The program can be executed by running: ./molecuilder 38 39 * 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. 42 47 * 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. 46 53 * 47 54 */ 48 55 56 #include "Helpers/MemDebug.hpp" 49 57 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"60 58 #include "bondgraph.hpp" 61 #include " boundary.hpp"59 #include "CommandLineParser.hpp" 62 60 #include "config.hpp" 63 #include "element.hpp"64 #include "ellipsoid.hpp"65 #include "helpers.hpp"66 #include "leastsquaremin.hpp"67 #include "linkedcell.hpp"68 61 #include "log.hpp" 69 62 #include "memoryusageobserver.hpp" … … 72 65 #include "tesselationhelpers.hpp" 73 66 #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 74 72 #include "UIElements/MainWindow.hpp" 75 73 #include "UIElements/Dialog.hpp" 76 74 #include "Menu/ActionMenuItem.hpp" 75 #include "verbose.hpp" 76 #include "World.hpp" 77 77 78 #include "Actions/ActionRegistry.hpp" 78 79 #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 82 91 #include "version.h" 83 #include "World.hpp"84 #include "Helpers/MemDebug.hpp"85 86 /********************************************* Subsubmenu routine ************************************/87 #if 088 /** Submenu for adding atoms to the molecule.89 * \param *periode periodentafel90 * \param *molecule molecules with atoms91 */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 volume97 double a,b,c;98 char choice; // menu choice char99 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 atom118 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 type122 mol->AddAtom(first); // add to molecule123 break;124 125 case 'b': // relative coordinates of atom wrt to reference point126 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 type138 mol->AddAtom(first); // add to molecule139 break;140 141 case 'c': // relative coordinates of atom wrt to already placed atom142 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 type154 mol->AddAtom(first); // add to molecule155 break;156 157 case 'd': // two atoms, two angles and a distance158 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 vector195 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 angle211 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 angle217 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 angle237 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 vectors244 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 type254 mol->AddAtom(first); // add to molecule255 break;256 257 case 'e': // least square distance position to a set of atoms258 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 type277 mol->AddAtom(first); // add to molecule278 } 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 atoms288 */289 static void CenterAtoms(molecule *mol)290 {291 Vector x, y, helper;292 char choice; // menu choice char293 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 positive323 mol->Center.AddVector(&y); // translate by boundary324 helper.CopyVector(&y);325 helper.Scale(2.);326 helper.AddVector(&x);327 mol->SetBoxDimension(&helper); // update Box of atoms by boundary328 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 boundary336 mol->SetBoxDimension(&x);337 // center338 mol->CenterInBox();339 break;340 }341 };342 343 /** Submenu for aligning the atoms in the molecule.344 * \param *periode periodentafel345 * \param *mol molecule with all the atoms346 */347 static void AlignAtoms(periodentafel *periode, molecule *mol)348 {349 atom *first, *second, *third;350 Vector x,n;351 char choice; // menu choice char352 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 plane366 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 plane373 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 plane378 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(¶m);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 atoms414 */415 static void MirrorAtoms(molecule *mol)416 {417 atom *first, *second, *third;418 Vector n;419 char choice; // menu choice char420 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 plane433 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 plane440 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 plane445 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 atoms461 */462 static void RemoveAtoms(molecule *mol)463 {464 atom *first, *second;465 int axis;466 double tmp1, tmp2;467 char choice; // menu choice char468 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 else484 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 periodentafel524 * \param *mol molecule with all the atoms525 */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 char533 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; // advance559 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 else606 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 else634 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 atoms644 * \param *configuration configuration structure for the to be written config files of all fragments645 */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 bonds655 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 } else660 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 periodentafel667 * \param *molecules list of molecules whose atoms are to be manipulated668 */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 volume674 double *factor; // unit factor if desired675 double bond, minBond;676 char choice; // menu choice char677 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 atom699 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 bond708 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 metric731 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 angles748 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 atom757 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 atom766 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 angle777 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 // rotate785 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 angle790 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 element799 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 periodentafel820 * \param *molecules list of molecule to manipulate821 */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 volume826 int j, axis, count, faktor;827 char choice; // menu choice char828 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 times855 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 atoms865 if (mol->AtomCount != 0) { // if there is more than none866 count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand867 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 element872 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 magnitude882 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times883 x.AddVector(&y); // per factor one cell width further884 for (int k=count;k--;) { // go through every atom of the original cell885 first = new atom(); // create a new body886 first->x.CopyVector(vectors[k]); // use coordinate of original atom887 first->x.AddVector(&x); // translate the coordinates888 first->type = Elements[k]; // insert original element889 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 it893 mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);894 // free memory895 delete[](Elements);896 delete[](vectors);897 // correct cell size898 if (axis < 0) { // if sign was negative, we have to translate everything899 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 atoms914 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 atoms923 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 axis932 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 matrix941 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 atoms956 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 all967 if (Subgraphs != NULL) { // free disconnected subgraph list of DFS analysis was performed968 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 periodentafel979 * \param *molecules list of molecules to add to980 */981 static void EditMolecules(periodentafel *periode, MoleculeListClass *molecules)982 {983 char choice; // menu choice char984 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 file1010 {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 dimensions1020 mol->CenterEdge(¢er);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 file1061 {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 periodentafel1096 * \param *molecules list of molecules to add to1097 */1098 static void MergeMolecules(periodentafel *periode, MoleculeListClass *molecules)1099 {1100 char choice; // menu choice char1101 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 else1163 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 else1189 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 molecules1276 */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 subgraph1281 int i, comp, counter=0;1282 1283 // create a clone1284 molecule *mol = NULL;1285 if (molecules->ListOfMolecules.size() != 0) // clone1286 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 KeySets1295 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 structure1317 DoLog(0) && (Log() << Verbose(0) << "Generating Subgraph class." << endl);1318 Graph Subgraphs;1319 1320 // insert KeySets into Subgraphs1321 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 graphs1335 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 else1345 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 #endif1356 1357 /** Tries given filename or standard on saving the config file.1358 * \param *ConfigFileName name of file1359 * \param *configuration pointer to configuration structure with all the values1360 * \param *periode pointer to periodentafel structure with all the elements1361 * \param *molecules list of molecules structure with all the atoms and coordinates1362 */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 data1376 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 else1384 DoLog(0) && (Log() << Verbose(0) << "failed." << endl);1385 1386 // then save as tremolo data file1387 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 else1395 DoLog(0) && (Log() << Verbose(0) << "failed." << endl);1396 1397 // translate each to its center and merge all molecules in MoleculeListClass into this molecule1398 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 back1409 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 orbitals1417 mol->CalculateOrbitals(*configuration);1418 configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble;1419 if (ConfigFileName != NULL) { // test the file name1420 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 else1435 DoLog(0) && (Log() << Verbose(0) << "failed." << endl);1436 1437 // and save to xyz file1438 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 else1453 DoLog(0) && (Log() << Verbose(0) << "failed." << endl);1454 } else {1455 if (mol->OutputTrajectoriesXYZ(&output))1456 DoLog(0) && (Log() << Verbose(0) << "successful." << endl);1457 else1458 DoLog(0) && (Log() << Verbose(0) << "failed." << endl);1459 }1460 output.close();1461 output.clear();1462 1463 // and save as MPQC configuration1464 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 else1472 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 count1483 * \param **argv arguments array1484 * \param *molecules list of molecules structure1485 * \param *periode elements structure1486 * \param configuration config file structure1487 * \param *ConfigFileName pointer to config file name in **argv1488 * \param *PathToDatabases pointer to db's path in **argv1489 * \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 volume1495 double *factor; // unit factor if desired1496 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 option1514 // 1. : Parse options that just set variables or print help1515 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 on1627 argptr++;1628 break;1629 }1630 } else1631 argptr++;1632 } while (argptr < argc);1633 1634 // 3a. Parse the element database1635 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 BondGraphFileName1643 if (argv[1][0] != '-') {1644 // simply create a new molecule, wherein the config file is loaded and the manipulation takes place1645 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 } else1680 configPresent = absent;1681 // set mol to first active molecule1682 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 presence1706 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 molecule1747 if ((configPresent == empty) && (mol->AtomCount != 0))1748 configPresent = present;1749 } else1750 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 analysis1776 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 ListOfLocalAtoms1787 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 afterwards1807 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 else1864 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 else1895 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 else1927 LCWidth = 2.*radius;1928 }1929 1930 // get the boundary1931 class molecule *Boundary = NULL;1932 class Tesselation *TesselStruct = NULL;1933 const LinkedCell *LCList = NULL;1934 // find biggest molecule1935 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 else1955 surfacemap = CorrelationToSurface( molecules, elemental, TesselStruct, LCList);1956 OutputCorrelationToSurface(&output, surfacemap);1957 // check whether radius was appropriate1958 {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 surface2008 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 molecule2019 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 routine2042 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 molecule2114 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 else2154 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 else2174 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 else2190 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 // center2292 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 // center2311 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 positive2326 mol->CenterEdge(&x);2327 // update Box of atoms by boundary2328 mol->SetBoxDimension(&x);2329 // translate each coordinate by boundary2330 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 } else2395 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 ConvexEnvelope2456 }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 atoms2477 if (mol->AtomCount != 0) { // if there is more than none2478 count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand2479 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 element2484 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 magnitude2494 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times2495 x += y; // per factor one cell width further2496 for (int k=count;k--;) { // go through every atom of the original cell2497 first = World::getInstance().createAtom(); // create a new body2498 first->x = (*vectors[k]) + x;2499 first->type = Elements[k]; // insert original element2500 mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)2501 }2502 }2503 // free memory2504 delete[](Elements);2505 delete[](vectors);2506 // correct cell size2507 if (axis < 0) { // if sign was negative, we have to translate everything2508 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 on2517 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 db2527 if (periode->LoadPeriodentafel(configuration.databasepath))2528 DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);2529 else2530 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 EditMoleculesMenu2540 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 }2559 92 2560 93 2561 94 /********************************************** Main routine **************************************/ 2562 95 2563 void cleanUp(config *configuration){ 2564 UIFactory::purgeInstance(); 96 void cleanUp(){ 97 FormatParserStorage::purgeInstance(); 98 ChangeTracker::purgeInstance(); 2565 99 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();2572 100 logger::purgeInstance(); 2573 101 errorLogger::purgeInstance(); 102 UIFactory::purgeInstance(); 103 MapOfActions::purgeInstance(); 104 CommandLineParser::purgeInstance(); 2574 105 ActionRegistry::purgeInstance(); 2575 106 ActionHistory::purgeInstance(); 107 #ifdef LOG_OBSERVER 108 cout << observerLog().getLog(); 109 #endif 2576 110 Memory::getState(); 2577 111 } … … 2579 113 int main(int argc, char **argv) 2580 114 { 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(); 2589 126 2590 cout << ESPACKVersion << endl; 127 // print version check whether arguments are present at all 128 cout << ESPACKVersion << endl; 2591 129 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 } 2605 151 } 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 2618 171 } 172 } 2619 173 2620 { 2621 cout << ESPACKVersion << endl; 174 { 175 MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow(); 176 mainWindow->display(); 177 delete mainWindow; 178 } 2622 179 2623 setVerbosity(0); 180 FormatParserStorage::getInstance().SaveAll(); 181 ChangeTracker::getInstance().saveStatus(); 2624 182 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); 2627 190 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); 2643 193 } 2644 194 -
src/config.cpp
rc39cc4 rbdb143 5 5 */ 6 6 7 #include "Helpers/MemDebug.hpp" 8 7 9 #include <stdio.h> 8 10 #include <cstring> 9 11 10 #include "World.hpp"11 12 #include "atom.hpp" 12 13 #include "bond.hpp" 14 #include "bondgraph.hpp" 13 15 #include "config.hpp" 16 #include "ConfigFileBuffer.hpp" 14 17 #include "element.hpp" 15 18 #include "helpers.hpp" 19 #include "info.hpp" 16 20 #include "lists.hpp" 17 21 #include "log.hpp" … … 20 24 #include "molecule.hpp" 21 25 #include "periodentafel.hpp" 26 #include "ThermoStatContainer.hpp" 22 27 #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 number37 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 number41 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 number49 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 number54 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 name68 */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 lines75 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 one81 long file_position = file->tellg(); // mark current position82 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 dimension91 if (buffer != NULL) {92 DoeLog(1) && (eLog()<< Verbose(1) << "FileBuffer->buffer is not NULL!" << endl);93 return;94 } else95 buffer = Malloc<char*>(NoLines, "ConfigFileBuffer::ConfigFileBuffer: **buffer");96 97 // scan each line and put into buffer98 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 exit111 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 the138 * lines in \a *FileBuffer in a sorted manner of the Ion_Type?_? keywords. We assume that ConfigFileBuffer::CurrentLine139 * points to first Ion_Type entry.140 * \param *FileBuffer pointer to buffer structure141 * \param NoAtoms of subsequent lines to look at142 */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 map153 for (int i=0; i<NoAtoms; ++i) {154 IonTypeLineMap.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i));155 }156 157 // fill map158 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 }168 28 169 29 /************************************* Functions for class config ***************************/ … … 171 31 /** Constructor for config file class. 172 32 */ 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), 33 config::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), 176 35 DoOutVis(0), DoOutMes(1), DoOutNICS(0), DoOutOrbitals(0), DoOutCurrent(0), DoFullCurrent(0), DoPerturbation(0), DoWannier(0), CommonWannier(0), SawtoothStart(0.01), 177 36 VectorPlane(0), VectorCut(0.), UseAddGramSch(1), Seed(1), OutVisStep(10), OutSrcStep(5), MaxPsiStep(0), EpsWannier(1e-7), MaxMinStep(100), RelEpsTotalEnergy(1e-7), … … 179 38 MaxLevel(5), RiemannTensor(0), LevRFactor(0), RiemannLevel(0), Lev0Factor(2), RTActualUse(0), AddPsis(0), RCut(20.), StructOpt(0), IsAngstroem(1), RelativeCoord(0), 180 39 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 config path = 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(); 187 46 strcpy(mainname,"pcp"); 188 47 strcpy(defaultpath,"not specified"); 189 48 strcpy(pseudopotpath,"not specified"); 190 configpath[0]='\0';191 49 configname[0]='\0'; 192 50 basis = "3-21G"; 193 194 InitThermostats();195 51 }; 196 52 … … 199 55 config::~config() 200 56 { 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); 211 64 212 65 if (BG != NULL) 213 66 delete(BG); 214 67 }; 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 file241 */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 parameters248 if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {249 if (strcmp(thermo, ThermostatNames[0]) == 0) { // None250 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) { // Woodcock257 if (ThermostatImplemented[1] == 1) {258 Thermostat = Woodcock;259 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read scaling frequency260 } 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) { // Gaussian265 if (ThermostatImplemented[2] == 1) {266 Thermostat = Gaussian;267 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read collision rate268 } 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) { // Langevin273 if (ThermostatImplemented[3] == 1) {274 Thermostat = Langevin;275 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read gamma276 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) { // Berendsen286 if (ThermostatImplemented[4] == 1) {287 Thermostat = Berendsen;288 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read \tau_T289 } 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-Hoover294 if (ThermostatImplemented[5] == 1) {295 Thermostat = NoseHoover;296 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &HooverMass, 1, critical); // read Hoovermass297 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 314 68 315 69 /** Displays menu for editing each entry of the config file. … … 626 380 }; 627 381 628 /** Retrieves the path in the given config file name.629 * \param filename config file string630 */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 file657 * \param *FileBuffer pointer to FileBuffer on return, should point to NULL658 */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 670 382 /** Loads a molecule from a ConfigFileBuffer. 671 383 * \param *mol molecule to load … … 861 573 file->close(); 862 574 delete(file); 863 RetrieveConfigPathAndName(filename);864 575 865 576 // ParseParameterFile 866 struct ConfigFileBuffer *FileBuffer = NULL; 867 PrepareFileBuffer(filename,FileBuffer); 577 class ConfigFileBuffer *FileBuffer = new ConfigFileBuffer(filename); 868 578 869 579 /* Oeffne Hauptparameterdatei */ … … 874 584 int verbose = 0; 875 585 586 //TODO: This is actually sensible?: if (MaxOuterStep > 0) 876 587 ParseThermostats(FileBuffer); 877 588 … … 938 649 ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 939 650 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); 941 652 //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional); 942 653 if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional)) … … 1098 809 return; 1099 810 } 1100 RetrieveConfigPathAndName(filename);1101 811 // ParseParameters 1102 812 … … 1147 857 ParseForParameter(verbose,file,"VisOuterStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 1148 858 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); 1151 861 config::EpsWannier = 1e-8; 1152 862 … … 1336 1046 *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl; 1337 1047 *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" << Thermostat Names[Thermostat] << "\t";1339 switch(Thermostat ) {1048 *output << "Thermostat\t" << Thermostats->ThermostatNames[Thermostats->Thermostat] << "\t"; 1049 switch(Thermostats->Thermostat) { 1340 1050 default: 1341 1051 case None: 1342 1052 break; 1343 1053 case Woodcock: 1344 *output << ScaleTempStep;1054 *output << Thermostats->ScaleTempStep; 1345 1055 break; 1346 1056 case Gaussian: 1347 *output << ScaleTempStep;1057 *output << Thermostats->ScaleTempStep; 1348 1058 break; 1349 1059 case Langevin: 1350 *output << T empFrequency << "\t" <<alpha;1060 *output << Thermostats->TempFrequency << "\t" << Thermostats->alpha; 1351 1061 break; 1352 1062 case Berendsen: 1353 *output << T empFrequency;1063 *output << Thermostats->TempFrequency; 1354 1064 break; 1355 1065 case NoseHoover: 1356 *output << HooverMass;1066 *output << Thermostats->HooverMass; 1357 1067 break; 1358 1068 }; … … 1369 1079 *output << "OutVisStep\t" << config::OutVisStep << "\t# Output visual data every ...th step" << endl; 1370 1080 *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; 1372 1082 *output << "MaxPsiStep\t" << config::MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl; 1373 1083 *output << "EpsWannier\t" << config::EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl; … … 1480 1190 // output of atoms 1481 1191 AtomNo = 0; 1482 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );1192 mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo ); 1483 1193 delete(center); 1484 1194 *output << "\t}" << endl; … … 1522 1232 // output of atoms 1523 1233 AtomNo = 0; 1524 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );1234 mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo ); 1525 1235 delete(center); 1526 1236 *output << "\t}" << endl; … … 1547 1257 int AtomNo = -1; 1548 1258 int MolNo = 0; 1549 atom *Walker = NULL;1550 1259 FILE *f = NULL; 1551 1260 … … 1560 1269 fprintf(f, "# Created by MoleCuilder\n"); 1561 1270 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; 1565 1275 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 1570 1279 fprintf(f, 1571 1280 "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 */ 1573 1282 name, /* atom name */ 1574 (* Runner)->name, /* residue name */1283 (*MolRunner)->name, /* residue name */ 1575 1284 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1576 1285 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 */ 1582 1291 "0", /* segment identifier */ 1583 Walker->type->symbol, /* element symbol */1292 (*iter)->type->symbol, /* element symbol */ 1584 1293 "0"); /* charge */ 1585 1294 AtomNo++; 1586 1295 } 1587 Free(&elementNo);1296 delete[](elementNo); 1588 1297 MolNo++; 1589 1298 } … … 1601 1310 { 1602 1311 int AtomNo = -1; 1603 atom *Walker = NULL;1604 1312 FILE *f = NULL; 1605 1313 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; 1607 1317 char name[MAXSTRINGSIZE]; 1608 1318 strncpy(name, filename, MAXSTRINGSIZE-1); … … 1611 1321 if (f == NULL) { 1612 1322 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl); 1613 Free(&elementNo);1323 delete[](elementNo); 1614 1324 return false; 1615 1325 } 1616 1326 fprintf(f, "# Created by MoleCuilder\n"); 1617 1327 1618 Walker = mol->start;1619 1328 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 1624 1332 fprintf(f, 1625 1333 "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 */ 1627 1335 name, /* atom name */ 1628 1336 mol->name, /* residue name */ 1629 1337 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1630 1338 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 */ 1636 1344 "0", /* segment identifier */ 1637 Walker->type->symbol, /* element symbol */1345 (*iter)->type->symbol, /* element symbol */ 1638 1346 "0"); /* charge */ 1639 1347 AtomNo++; 1640 1348 } 1641 1349 fclose(f); 1642 Free(&elementNo);1350 delete[](elementNo); 1643 1351 1644 1352 return true; … … 1653 1361 bool config::SaveTREMOLO(const char * const filename, const molecule * const mol) const 1654 1362 { 1655 atom *Walker = NULL;1656 1363 ofstream *output = NULL; 1657 1364 stringstream * const fname = new stringstream; … … 1666 1373 1667 1374 // scan maximum number of neighbours 1668 Walker = mol->start;1669 1375 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(); 1673 1378 if (MaxNeighbours < count) 1674 1379 MaxNeighbours = count; 1675 1380 } 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"; 1683 1386 *output << mol->name << "\t"; 1684 1387 *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++) 1691 1394 *output << "-\t"; 1692 1395 *output << endl; … … 1708 1411 bool config::SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const 1709 1412 { 1710 atom *Walker = NULL;1413 Info FunctionInfo(__func__); 1711 1414 ofstream *output = NULL; 1712 1415 stringstream * const fname = new stringstream; … … 1723 1426 int MaxNeighbours = 0; 1724 1427 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(); 1729 1430 if (MaxNeighbours < count) 1730 1431 MaxNeighbours = count; 1731 1432 } 1732 1433 } 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; 1734 1435 1735 1436 // create global to local id map 1736 int **LocalNotoGlobalNoMap = Calloc<int *>(MolList->ListOfMolecules.size(), "config::SaveTREMOLO - **LocalNotoGlobalNoMap");1437 map<int, int> LocalNotoGlobalNoMap; 1737 1438 { 1738 int MolCounter = 0;1739 int AtomNo = 0;1439 unsigned int MolCounter = 0; 1440 int AtomNo = 1; 1740 1441 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 } 1745 1445 MolCounter++; 1746 1446 } 1447 ASSERT(MolCounter == MolList->ListOfMolecules.size(), "SaveTREMOLO: LocalNotoGlobalNoMap[] has not been correctly initialized for each molecule"); 1747 1448 } 1748 1449 … … 1752 1453 int AtomNo = 0; 1753 1454 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"; 1759 1458 *output << (*MolWalker)->name << "\t"; 1760 1459 *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++) 1767 1466 *output << "-\t"; 1768 1467 *output << endl; … … 1778 1477 delete(output); 1779 1478 delete(fname); 1780 for(size_t i=0;i<MolList->ListOfMolecules.size(); i++)1781 Free(&LocalNotoGlobalNoMap[i]);1782 Free(&LocalNotoGlobalNoMap);1783 1479 1784 1480 return true; … … 1795 1491 char filename[MAXSTRINGSIZE]; 1796 1492 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; 1804 1494 1805 1495 // first save as PDB data … … 1808 1498 if (output == NULL) 1809 1499 strcpy(filename,"main_pcp_linux"); 1810 Log() << Verbose(0) << "Saving as pdb input ";1500 Log() << Verbose(0) << "Saving as pdb input ... " << endl; 1811 1501 if (SavePDB(filename, molecules)) 1812 Log() << Verbose(0) << " done." << endl;1502 Log() << Verbose(0) << "\t... done." << endl; 1813 1503 else 1814 Log() << Verbose(0) << " failed." << endl;1504 Log() << Verbose(0) << "\t... failed." << endl; 1815 1505 1816 1506 // then save as tremolo data file … … 1819 1509 if (output == NULL) 1820 1510 strcpy(filename,"main_pcp_linux"); 1821 Log() << Verbose(0) << "Saving as tremolo data input ";1511 Log() << Verbose(0) << "Saving as tremolo data input ... " << endl; 1822 1512 if (SaveTREMOLO(filename, molecules)) 1823 Log() << Verbose(0) << " done." << endl;1513 Log() << Verbose(0) << "\t... done." << endl; 1824 1514 else 1825 Log() << Verbose(0) << " failed." << endl;1515 Log() << Verbose(0) << "\t... failed." << endl; 1826 1516 1827 1517 // translate each to its center and merge all molecules in MoleculeListClass into this molecule 1828 1518 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 } 1843 1541 } 1844 1542 1845 1543 Log() << Verbose(0) << "Storing configuration ... " << endl; 1846 1544 // get correct valence orbitals 1847 mol->CalculateOrbitals(*this);1848 InitMaxMinStopStep = MaxMinStopStep = MaxPsiDouble;1849 1545 if (ConfigFileName != NULL) { // test the file name 1850 1546 strcpy(filename, ConfigFileName); … … 1859 1555 output.close(); 1860 1556 output.clear(); 1861 Log() << Verbose(0) << "Saving of config file ";1557 Log() << Verbose(0) << "Saving of config file ... " << endl; 1862 1558 if (Save(filename, periode, mol)) 1863 Log() << Verbose(0) << " successful." << endl;1559 Log() << Verbose(0) << "\t... successful." << endl; 1864 1560 else 1865 Log() << Verbose(0) << " failed." << endl;1561 Log() << Verbose(0) << "\t... failed." << endl; 1866 1562 1867 1563 // and save to xyz file … … 1876 1572 output.open(filename, ios::trunc); 1877 1573 } 1878 Log() << Verbose(0) << "Saving of XYZ file ";1574 Log() << Verbose(0) << "Saving of XYZ file ... " << endl; 1879 1575 if (mol->MDSteps <= 1) { 1880 1576 if (mol->OutputXYZ(&output)) 1881 Log() << Verbose(0) << " successful." << endl;1577 Log() << Verbose(0) << "\t... successful." << endl; 1882 1578 else 1883 Log() << Verbose(0) << " failed." << endl;1579 Log() << Verbose(0) << "\t... failed." << endl; 1884 1580 } else { 1885 1581 if (mol->OutputTrajectoriesXYZ(&output)) 1886 Log() << Verbose(0) << " successful." << endl;1582 Log() << Verbose(0) << "\t... successful." << endl; 1887 1583 else 1888 Log() << Verbose(0) << " failed." << endl;1584 Log() << Verbose(0) << "\t... failed." << endl; 1889 1585 } 1890 1586 output.close(); … … 1896 1592 if (output == NULL) 1897 1593 strcpy(filename,"main_pcp_linux"); 1898 Log() << Verbose(0) << "Saving as mpqc input ";1594 Log() << Verbose(0) << "Saving as mpqc input .. " << endl; 1899 1595 if (SaveMPQC(filename, mol)) 1900 Log() << Verbose(0) << " done." << endl;1596 Log() << Verbose(0) << "\t... done." << endl; 1901 1597 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); 1909 1602 }; 1910 1603 … … 1938 1631 char *dummy1 = NULL; 1939 1632 char *dummy = NULL; 1940 char * const free_dummy = Malloc<char>(256, "config::ParseForParameter: *free_dummy"); // pointers in the line that is read in per step1633 char free_dummy[MAXSTRINGSIZE]; // pointers in the line that is read in per step 1941 1634 dummy1 = free_dummy; 1942 1635 … … 1954 1647 if (file->eof()) { 1955 1648 if ((critical) && (found == 0)) { 1956 Free(free_dummy);1957 1649 //Error(InitReading, name); 1958 1650 fprintf(stderr,"Error:InitReading, critical %s not found\n", name); … … 1962 1654 file->clear(); 1963 1655 file->seekg(file_position, ios::beg); // rewind to start position 1964 Free(free_dummy);1965 1656 return 0; 1966 1657 } … … 1993 1684 dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword) 1994 1685 //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name); 1995 //Free((void **)&free_dummy);1996 1686 //Error(FileOpenParams, NULL); 1997 1687 } else { … … 2014 1704 if (file->eof()) { 2015 1705 if ((critical) && (found == 0)) { 2016 Free(free_dummy);2017 1706 //Error(InitReading, name); 2018 1707 fprintf(stderr,"Error:InitReading, critical %s not found\n", name); … … 2022 1711 file->clear(); 2023 1712 file->seekg(file_position, ios::beg); // rewind to start position 2024 Free(free_dummy);2025 1713 return 0; 2026 1714 } … … 2063 1751 if (critical) { 2064 1752 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);2066 1753 //return 0; 2067 1754 exit(255); … … 2071 1758 file->clear(); 2072 1759 file->seekg(file_position, ios::beg); // rewind to start position 2073 Free(free_dummy);2074 1760 return 0; 2075 1761 } … … 2084 1770 file->seekg(file_position, ios::beg); // rewind to start position 2085 1771 } 2086 Free(free_dummy);2087 1772 return 0; 2088 1773 } … … 2140 1825 if ((type >= row_int) && (verbose)) 2141 1826 fprintf(stderr,"\n"); 2142 Free(free_dummy);2143 1827 if (!sequential) { 2144 1828 file->clear(); … … 2221 1905 dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword) 2222 1906 //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name); 2223 //Free(&free_dummy);2224 1907 //Error(FileOpenParams, NULL); 2225 1908 } else { … … 2361 2044 return (found); // true if found, false if not 2362 2045 } 2046 2047 /** Reading of Thermostat related values from parameter file. 2048 * \param *fb file buffer containing the config file 2049 */ 2050 void 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 20 20 #include <string> 21 21 22 #include "bondgraph.hpp"23 24 22 /****************************************** forward declarations *****************************/ 25 23 24 class BondGraph; 25 class ConfigFileBuffer; 26 26 class molecule; 27 27 class MoleculeListClass; 28 28 class periodentafel; 29 class ThermoStatContainer; 29 30 30 31 /********************************************** 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 };46 32 47 33 /** The config file. … … 51 37 public: 52 38 class BondGraph *BG; 39 class ThermoStatContainer *Thermostats; 53 40 54 41 int PsiType; … … 60 47 int ProcPEGamma; 61 48 int ProcPEPsi; 62 char *configpath;63 49 char *configname; 64 50 bool FastParsing; … … 70 56 int DoConstrainedMD; 71 57 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;80 58 81 59 private: … … 138 116 void Load(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList); 139 117 void LoadOld(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList); 140 void RetrieveConfigPathAndName(const string filename);141 118 bool Save(const char * const filename, const periodentafel * const periode, molecule * const mol) const; 142 119 bool SaveMPQC(const char * const filename, const molecule * const mol) const; … … 152 129 char *GetDefaultPath() const; 153 130 void SetDefaultPath(const char * const path); 154 void InitThermostats();155 131 void ParseThermostats(class ConfigFileBuffer * const fb); 156 132 }; -
src/datacreator.cpp
rc39cc4 rbdb143 6 6 7 7 //============================ INCLUDES =========================== 8 9 #include "Helpers/MemDebug.hpp" 8 10 9 11 #include "datacreator.hpp" -
src/defs.hpp
rc39cc4 rbdb143 82 82 #define STD_SEPERATOR_SPACER '-' 83 83 84 #define MOLECUILDER_NAME "Molecuilder" 85 84 86 #endif /*DEFS_HPP_*/ -
src/element.cpp
rc39cc4 rbdb143 4 4 * 5 5 */ 6 7 #include "Helpers/MemDebug.hpp" 6 8 7 9 #include <iomanip> -
src/elements.db
-
Property mode
changed from
100755
to100644
rc39cc4 rbdb143 2 2 #Element Name Symbol Period Group Block Atomic Number AtomicWeight Covalent Radius vdW Radius 3 3 Hydrogen H 1 1 s 1 1.008 0.23 1.09 4 Helium He 1 18 p 2 4.003 1.5 0 1.404 Helium He 1 18 p 2 4.003 1.5 1.4 5 5 Lithium Li 2 1 s 3 6.941 0.68 1.82 6 Beryllium Be 2 2 s 4 9.012 0.35 2 .007 Boron B 2 13 p 5 10.811 0.83 2 .008 Carbon C 2 14 p 6 12.011 0.68 1.7 06 Beryllium Be 2 2 s 4 9.012 0.35 2 7 Boron B 2 13 p 5 10.811 0.83 2 8 Carbon C 2 14 p 6 12.011 0.68 1.7 9 9 Nitrogen N 2 15 p 7 14.007 0.68 1.55 10 10 Oxygen O 2 16 p 8 15.999 0.68 1.52 11 11 Fluorine F 2 17 p 9 18.998 0.64 1.47 12 Neon Ne 2 18 p 10 20.18 0 1.501.5412 Neon Ne 2 18 p 10 20.18 1.5 1.54 13 13 Sodium Na 3 1 s 11 22.991 0.97 2.27 14 Magnesium Mg 3 2 s 12 24.305 1.1 01.7315 Aluminium Al 3 13 p 13 26.982 1.35 2 .0016 Silicon Si 3 14 p 14 28.086 1.2 0 2.1017 Phosphorus P 3 15 p 15 30.974 1.05 1.8 018 Sulphur S 3 16 p 16 32.066 1.02 1.8 014 Magnesium Mg 3 2 s 12 24.305 1.1 1.73 15 Aluminium Al 3 13 p 13 26.982 1.35 2 16 Silicon Si 3 14 p 14 28.086 1.2 2.1 17 Phosphorus P 3 15 p 15 30.974 1.05 1.8 18 Sulphur S 3 16 p 16 32.066 1.02 1.8 19 19 Chlorine Cl 3 17 p 17 35.453 0.99 1.75 20 20 Argon Ar 3 18 p 18 39.948 1.51 1.88 21 21 Potassium K 4 1 s 19 39.098 1.33 2.75 22 Calcium Ca 4 2 s 20 40.078 0.99 2 .0023 Scandium Sc 4 3 d 21 44.956 1.44 2 .0024 Titanium Ti 4 4 d 22 47.867 1.47 2 .0025 Vanadium V 4 5 d 23 50.942 1.33 2 .0026 Chromium Cr 4 6 d 24 51.996 1.35 2 .0027 Manganese Mn 4 7 d 25 54.938 1.35 2 .0028 Iron Fe 4 8 d 26 55.845 1.34 2 .0029 Cobalt Co 4 9 d 27 58.933 1.33 2 .0030 Nickel Ni 4 10 d 28 58.693 1.5 01.6331 Copper Cu 4 11 d 29 63.546 1.52 1.4 032 Zinc Zn 4 12 d 30 65.39 01.45 1.3922 Calcium Ca 4 2 s 20 40.078 0.99 2 23 Scandium Sc 4 3 d 21 44.956 1.44 2 24 Titanium Ti 4 4 d 22 47.867 1.47 2 25 Vanadium V 4 5 d 23 50.942 1.33 2 26 Chromium Cr 4 6 d 24 51.996 1.35 2 27 Manganese Mn 4 7 d 25 54.938 1.35 2 28 Iron Fe 4 8 d 26 55.845 1.34 2 29 Cobalt Co 4 9 d 27 58.933 1.33 2 30 Nickel Ni 4 10 d 28 58.693 1.5 1.63 31 Copper Cu 4 11 d 29 63.546 1.52 1.4 32 Zinc Zn 4 12 d 30 65.39 1.45 1.39 33 33 Gallium Ga 4 13 p 31 69.723 1.22 1.87 34 Germanium Ge 4 14 p 32 72.61 0 1.17 2.0034 Germanium Ge 4 14 p 32 72.61 1.17 2 35 35 Arsenic As 4 15 p 33 74.922 1.21 1.85 36 Selenium Se 4 16 p 34 78.96 0 1.22 1.9036 Selenium Se 4 16 p 34 78.96 1.22 1.9 37 37 Bromine Br 4 17 p 35 79.904 1.21 1.85 38 Krypton Kr 4 18 p 36 83.8 00 1.502.0239 Rubidium Rb 5 1 s 37 85.468 1.47 2 .0040 Strontium Sr 5 2 s 38 87.62 0 1.12 2.0041 Yttrium Y 5 3 d 39 88.906 1.78 2 .0042 Zirconium Zr 5 4 d 40 91.224 1.56 2 .0043 Niobium Nb 5 5 d 41 92.906 1.48 2 .0044 Molybdenum Mo 5 6 d 42 95.94 0 1.47 2.0045 Technetium Tc 5 7 d 43 98 1.35 2 .0046 Ruthenium Ru 5 8 d 44 101.07 0 1.40 2.0047 Rhodium Rh 5 9 d 45 102.906 1.45 2 .0048 Palladium Pd 5 10 d 46 106.42 0 1.501.6338 Krypton Kr 4 18 p 36 83.8 1.5 2.02 39 Rubidium Rb 5 1 s 37 85.468 1.47 2 40 Strontium Sr 5 2 s 38 87.62 1.12 2 41 Yttrium Y 5 3 d 39 88.906 1.78 2 42 Zirconium Zr 5 4 d 40 91.224 1.56 2 43 Niobium Nb 5 5 d 41 92.906 1.48 2 44 Molybdenum Mo 5 6 d 42 95.94 1.47 2 45 Technetium Tc 5 7 d 43 98 1.35 2 46 Ruthenium Ru 5 8 d 44 101.07 1.4 2 47 Rhodium Rh 5 9 d 45 102.906 1.45 2 48 Palladium Pd 5 10 d 46 106.42 1.5 1.63 49 49 Silver Ag 5 11 d 47 107.868 1.59 1.72 50 50 Cadmium Cd 5 12 d 48 112.411 1.69 1.58 51 51 Indium In 5 13 p 49 114.818 1.63 1.93 52 52 Tin 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 53 Antimony Sb 5 15 p 51 121.76 1.46 2 54 Tellurium Te 5 16 p 52 127.6 1.47 2.06 55 Iodine I 5 17 p 53 126.904 1.4 1.98 56 Xenon Xe 5 18 p 54 131.29 1.5 2.16 57 Caesium Cs 6 1 s 55 132.905 1.67 2 58 Barium Ba 6 2 s 56 137.327 1.34 2 59 Lanthanum La 6Lan 19 f 57 138.906 1.87 2 60 Cerium Ce 6Lan 19 f 58 140.116 1.83 2 61 Praseodymium Pr 6Lan 19 f 59 140.908 1.82 2 62 Neodymium Nd 6Lan 19 f 60 144.24 1.81 2 63 Promethium Pm 6Lan 19 f 61 145 1.8 2 64 Samarium Sm 6Lan 19 f 62 150.36 1.8 2 65 Europium Eu 6Lan 19 f 63 151.964 1.99 2 66 Gadolinium Gd 6Lan 19 f 64 157.25 1.79 2 67 Terbium Tb 6Lan 19 f 65 158.925 1.76 2 68 Dysprosium Dy 6Lan 19 f 66 162.5 1.75 2 69 Holmium Ho 6Lan 19 f 67 164.93 1.74 2 70 Erbium Er 6Lan 19 f 68 167.26 1.73 2 71 Thulium Tm 6Lan 19 f 69 168.934 1.72 2 72 Ytterbium Yb 6Lan 19 f 70 173.04 1.94 2 73 Lutetium Lu 6 3 d 71 174.967 1.72 2 74 Hafnium Hf 6 4 d 72 178.49 1.57 2 75 Tantalum Ta 6 5 d 73 180.948 1.43 2 76 Tungsten W 6 6 d 74 183.84 1.37 2 77 Rhenium Re 6 7 d 75 186.207 1.35 2 78 Osmium Os 6 8 d 76 190.23 1.37 2 79 Iridium Ir 6 9 d 77 192.217 1.32 2 80 Platinum Pt 6 10 d 78 195.078 1.5 1.72 81 Gold Au 6 11 d 79 196.967 1.5 1.66 82 Mercury Hg 6 12 d 80 200.59 1.7 1.55 69 83 Thallium 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 84 Lead Pb 6 14 p 82 207.2 1.54 2.02 85 Bismuth Bi 6 15 p 83 208.98 1.54 2 86 Polonium Po 6 16 p 84 210 1.68 2 87 Astatine At 6 17 p 85 210 1.21 2 88 Radon Rn 6 18 p 86 222 1.5 2 89 Francium Fr 7 1 s 87 223 1.5 2 90 Radium Ra 7 2 s 88 226 1.9 2 91 Actinium Ac 7Act 20 f 89 227 1.88 2 92 Thorium Th 7Act 20 f 90 232.038 1.79 2 93 Protactinium Pa 7Act 20 f 91 231.036 1.61 2 112 94 Uranium U 7Act 20 f 92 238.029 1.58 1.86 95 Neptunium Np 7Act 20 f 93 237 1.55 2 96 Plutonium Pu 7Act 20 f 94 244 1.53 2 97 Americium Am 7Act 20 f 95 243 1.51 2 98 Curium Cm 7Act 20 f 96 247 0.99 2 99 Berkelium Bk 7Act 20 f 97 247 1.54 2 100 Californium Cf 7Act 20 f 98 251 1.83 2 101 Einsteinium Es 7Act 20 f 99 252 1.5 2 102 Fermium Fm 7Act 20 f 100 257 1.5 2 103 Mendelevium Md 7Act 20 f 101 258 1.5 2 104 Nobelium No 7Act 20 f 102 259 1.5 2 105 Lawrencium Lr 7 3 d 103 262 1.5 2 106 Rutherfordium Rf 7 4 d 104 261 1.5 2 107 Dubnium Db 7 5 d 105 262 1.5 2 108 Seaborgium Sg 7 6 d 106 266 1.5 2 109 Bohrium Bh 7 7 d 107 264 1.5 2 110 Hassium Hs 7 8 d 108 269 1.5 2 111 Meitnerium Mt 7 9 d 109 268 1.5 2 112 Darmstadtium Ds 7 10 d 110 271 1.5 2 -
Property mode
changed from
-
src/ellipsoid.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <gsl/gsl_multimin.h> -
src/errorlogger.cpp
rc39cc4 rbdb143 5 5 * Author: metzler 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <fstream> -
src/graph.cpp
rc39cc4 rbdb143 4 4 * 5 5 */ 6 7 #include "Helpers/MemDebug.hpp" 6 8 7 9 using namespace std; -
src/gslmatrix.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 using namespace std; -
src/gslvector.cpp
rc39cc4 rbdb143 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include <cassert> 9 11 #include <cmath> … … 11 13 #include "gslvector.hpp" 12 14 #include "defs.hpp" 15 #include "vector.hpp" 13 16 14 17 /** Constructor of class GSLVector. … … 59 62 gsl_vector_memcpy (vector, &m.vector); 60 63 }; 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 */ 70 void GSLVector::SetFromVector(Vector &v){ 71 gsl_vector_memcpy (vector, v.get()); 72 } 61 73 62 74 /** This function returns the i-th element of a vector. -
src/gslvector.hpp
rc39cc4 rbdb143 24 24 25 25 class GSLVector; 26 class Vector; 26 27 27 28 /********************************************** declarations *******************************/ … … 38 39 // Accessing 39 40 void SetFromDoubleArray(double *x); 41 void SetFromVector(Vector &v); 40 42 double Get(size_t m) const; 41 43 void Set(size_t m, double x); -
src/helpers.cpp
rc39cc4 rbdb143 4 4 */ 5 5 6 #include "Helpers/MemDebug.hpp" 6 7 7 8 #include "helpers.hpp" … … 58 59 int CountLinesinFile(ifstream &InputFile) 59 60 { 60 char *buffer = Malloc<char>(MAXSTRINGSIZE, "CountLinesinFile: *buffer");61 char *buffer = new char[MAXSTRINGSIZE]; 61 62 int lines=0; 62 63 … … 70 71 } 71 72 InputFile.seekg(PositionMarker, ios::beg); 72 Free(&buffer);73 delete[](buffer); 73 74 return lines; 74 75 }; … … 90 91 } 91 92 // allocate string 92 returnstring = Malloc<char>(order + 2, "FixedDigitNumber: *returnstring");93 returnstring = new char[order + 2]; 93 94 // terminate and fill string array from end backward 94 95 returnstring[order] = '\0'; … … 122 123 double * ReturnFullMatrixforSymmetric(const double * const symm) 123 124 { 124 double *matrix = Malloc<double>(NDIM * NDIM, "molecule::ReturnFullMatrixforSymmetric: *matrix");125 double *matrix = new double[NDIM * NDIM]; 125 126 matrix[0] = symm[0]; 126 127 matrix[1] = symm[1]; … … 140 141 double * InverseMatrix( const double * const A) 141 142 { 142 double *B = Malloc<double>(NDIM * NDIM, "Vector::InverseMatrix: *B");143 double *B = new double[NDIM * NDIM]; 143 144 double detA = RDET3(A); 144 145 double detAReci; … … 180 181 181 182 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 allocate186 * \param failure message which is printed if the allocation fails187 * \return pointer to the allocated memory range, will be NULL if a failure occurred188 */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 207 183 /** 208 * Frees all memory registered by the memory observer and calls exit(225) afterwards.184 * Calls exit(255). 209 185 */ 210 186 void 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 216 187 exit(255); 217 188 } -
src/helpers.hpp
rc39cc4 rbdb143 97 97 98 98 if (LookupTable != NULL) { 99 Do Log(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); 100 100 return false; 101 101 } … … 110 110 } 111 111 if (count <= 0) { 112 Do Log(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); 113 113 return false; 114 114 } 115 115 116 116 // allocate and fill 117 LookupTable = Calloc<T*>(count, "CreateFatherLookupTable - **LookupTable");117 LookupTable = new T*[count]; 118 118 if (LookupTable == NULL) { 119 119 DoeLog(0) && (eLog()<< Verbose(0) << "LookupTable memory allocation failed!" << endl); … … 129 129 LookupTable[AtomNo] = Walker; 130 130 } else { 131 Do Log(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); 132 132 status = false; 133 133 break; … … 138 138 return status; 139 139 }; 140 140 141 141 142 /** Frees a two-dimensional array. -
src/info.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "info.hpp" -
src/joiner.cpp
rc39cc4 rbdb143 7 7 8 8 //============================ INCLUDES =========================== 9 10 #include "Helpers/MemDebug.hpp" 9 11 10 12 #include <cstring> … … 58 60 return 1; 59 61 } else { 60 dir = Malloc<char>(strlen(argv[2]) + 2, "main: *dir");62 dir = new char[strlen(argv[2]) + 2]; 61 63 strcpy(dir, "/"); 62 64 strcat(dir, argv[2]); … … 243 245 // exit 244 246 delete(periode); 245 Free(&dir);247 delete[](dir); 246 248 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 247 249 return 0; -
src/leastsquaremin.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <iostream> -
src/linearsystemofequations.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "defs.hpp" … … 54 56 { 55 57 assert ( columns == NDIM && "Vector class is always three-dimensional, unlike this LEqS!"); 56 b->SetFrom DoubleArray(x->get());58 b->SetFromVector(*x); 57 59 }; 58 60 -
src/linkedcell.cpp
rc39cc4 rbdb143 5 5 */ 6 6 7 #include "Helpers/MemDebug.hpp" 7 8 8 9 #include "atom.hpp" -
src/lists.hpp
rc39cc4 rbdb143 134 134 }; 135 135 136 /** Returns the first marker in a chain list.137 * \param *me one arbitrary item in chain list138 * \return poiner to first marker139 */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 list150 * \return poiner to last marker151 */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 160 136 #endif /* LISTS_HPP_ */ -
src/log.cpp
rc39cc4 rbdb143 5 5 * Author: metzler 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "logger.hpp" -
src/logger.cpp
rc39cc4 rbdb143 5 5 * Author: metzler 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <fstream> -
src/memoryusageobserver.cpp
rc39cc4 rbdb143 4 4 * This class represents a Singleton for observing memory usage. 5 5 */ 6 7 #include "Helpers/MemDebug.hpp" 6 8 7 9 #include <cstdlib> -
src/molecule.cpp
rc39cc4 rbdb143 4 4 * 5 5 */ 6 7 #include "Helpers/MemDebug.hpp" 6 8 7 9 #include <cstring> … … 35 37 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero. 36 38 */ 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); 39 molecule::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 { 52 46 53 47 // other stuff 54 48 for(int i=MAX_ELEMENTS;i--;) 55 49 ElementsInMolecule[i] = 0; 56 strcpy(name,World::getInstance().getDefaultName() );50 strcpy(name,World::getInstance().getDefaultName().c_str()); 57 51 }; 58 52 … … 67 61 { 68 62 CleanupMolecule(); 69 delete(first);70 delete(last);71 end->getWorld()->destroyAtom(end);72 start->getWorld()->destroyAtom(start);73 63 }; 74 64 … … 83 73 } 84 74 75 int molecule::getAtomCount() const{ 76 return *AtomCount; 77 } 78 85 79 void molecule::setName(const std::string _name){ 86 80 OBSERVE; 81 cout << "Set name of molecule " << getId() << " to " << _name << endl; 87 82 strncpy(name,_name.c_str(),MAXSTRINGSIZE); 88 83 } … … 104 99 stringstream sstr; 105 100 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()]++; 108 103 } 109 104 std::map<atomicNumber_t,unsigned int>::reverse_iterator iter; … … 115 110 } 116 111 112 /************************** Access to the List of Atoms ****************/ 113 114 115 molecule::iterator molecule::begin(){ 116 return molecule::iterator(atoms.begin(),this); 117 } 118 119 molecule::const_iterator molecule::begin() const{ 120 return atoms.begin(); 121 } 122 123 molecule::iterator molecule::end(){ 124 return molecule::iterator(atoms.end(),this); 125 } 126 127 molecule::const_iterator molecule::end() const{ 128 return atoms.end(); 129 } 130 131 bool molecule::empty() const 132 { 133 return (begin() == end()); 134 } 135 136 size_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 144 molecule::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 155 molecule::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 166 molecule::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 176 pair<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 187 bool molecule::containsAtom(atom* key){ 188 return (find(key) != end()); 189 } 117 190 118 191 /** Adds given atom \a *pointer from molecule list. … … 123 196 bool molecule::AddAtom(atom *pointer) 124 197 { 125 bool retval = false;126 198 OBSERVE; 127 199 if (pointer != NULL) { 128 200 pointer->sort = &pointer->nr; 129 pointer->nr = last_atom++; // increase number within molecule130 AtomCount++;131 201 if (pointer->type != NULL) { 132 202 if (ElementsInMolecule[pointer->type->Z] == 0) … … 141 211 } 142 212 } 143 retval = add(pointer, end); 144 } 145 return retval; 213 insert(pointer); 214 pointer->setMolecule(this); 215 } 216 return true; 146 217 }; 147 218 … … 157 228 if (pointer != NULL) { 158 229 atom *walker = pointer->clone(); 159 stringstream sstr; 160 sstr << pointer->getName(); 161 walker->setName(sstr.str()); 230 walker->setName(pointer->getName()); 162 231 walker->nr = last_atom++; // increase number within molecule 163 add(walker, end);232 insert(walker); 164 233 if ((pointer->type != NULL) && (pointer->type->Z != 1)) 165 234 NoNonHydrogen++; 166 AtomCount++;167 235 retval=walker; 168 236 } … … 242 310 Orthovector1.MatrixMultiplication(matrix); 243 311 InBondvector -= Orthovector1; // subtract just the additional translation 244 Free(&matrix);312 delete[](matrix); 245 313 bondlength = InBondvector.Norm(); 246 314 // Log() << Verbose(4) << "Corrected InBondvector is now: "; … … 251 319 InBondvector.Normalize(); 252 320 // get typical bond length and store as scale factor for later 321 ASSERT(TopOrigin->type != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given."); 253 322 BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1]; 254 323 if (BondRescale == -1) { … … 472 541 break; 473 542 } 474 Free(&matrix);543 delete[](matrix); 475 544 476 545 // Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl; … … 555 624 556 625 // copy all bonds 557 bond *Binder = first;626 bond *Binder = NULL; 558 627 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 } 572 643 // correct fathers 573 644 ActOnAllAtoms( &atom::CorrectFather ); 574 645 575 646 // copy values 576 copy->CountAtoms();577 647 copy->CountElements(); 578 if ( first->next != last) { // if adjaceny list is present648 if (hasBondStructure()) { // if adjaceny list is present 579 649 copy->BondDistance = BondDistance; 580 650 } … … 608 678 bond * molecule::AddBond(atom *atom1, atom *atom2, int degree) 609 679 { 680 OBSERVE; 610 681 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 621 695 return Binder; 622 696 }; … … 630 704 { 631 705 //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); 635 707 return true; 636 708 }; … … 668 740 else 669 741 length = strlen(molname) - strlen(endname); 742 cout << "Set name of molecule " << getId() << " to " << molname << endl; 670 743 strncpy(name, molname, length); 671 744 name[length]='\0'; … … 692 765 bool molecule::RemoveAtom(atom *pointer) 693 766 { 767 ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom()."); 768 OBSERVE; 694 769 if (ElementsInMolecule[pointer->type->Z] != 0) { // this would indicate an error 695 770 ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element 696 AtomCount--;697 771 } else 698 772 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); … … 700 774 ElementCount--; 701 775 RemoveBonds(pointer); 702 return remove(pointer, start, end); 776 erase(pointer); 777 return true; 703 778 }; 704 779 … … 717 792 if (ElementsInMolecule[pointer->type->Z] == 0) // was last atom of this element? 718 793 ElementCount--; 719 unlink(pointer);794 erase(pointer); 720 795 return true; 721 796 }; … … 726 801 bool molecule::CleanupMolecule() 727 802 { 728 return (cleanup(first,last) && cleanup(start,end)); 803 for (molecule::iterator iter = begin(); !empty(); iter = begin()) 804 erase(iter); 805 return empty(); 729 806 }; 730 807 … … 733 810 * \return pointer to atom or NULL 734 811 */ 735 atom * molecule::FindAtom(int Nr) const{ 736 atom * walker = find(&Nr, start,end); 737 if (walker != NULL) { 812 atom * 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()) { 738 819 //Log() << Verbose(0) << "Found Atom Nr. " << walker->nr << endl; 739 return walker;820 return (*iter); 740 821 } else { 741 822 DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl); … … 801 882 ElementNo[i] = current++; 802 883 } 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 ); 804 885 return true; 805 886 } … … 867 948 now = time((time_t *)NULL); // Get the system time and put it into 'now' as 'calender time' 868 949 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); 870 951 ActOnAllAtoms( &atom::OutputTrajectoryXYZ, output, step ); 871 952 } … … 884 965 if (output != NULL) { 885 966 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); 887 968 ActOnAllAtoms( &atom::OutputXYZLine, output ); 888 969 return true; … … 894 975 * \param *out output stream for debugging 895 976 */ 896 void molecule::CountAtoms() 897 { 977 int molecule::doCountAtoms() 978 { 979 int res = size(); 898 980 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); 902 990 i++; 903 991 } 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; 927 993 }; 928 994 … … 939 1005 for(int i=MAX_ELEMENTS;i--;) 940 1006 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 everything946 */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;968 1007 }; 969 1008 … … 986 1025 /// first count both their atoms and elements and update lists thereby ... 987 1026 //Log() << Verbose(0) << "Counting atoms, updating list" << endl; 988 CountAtoms();989 OtherMolecule->CountAtoms();990 1027 CountElements(); 991 1028 OtherMolecule->CountElements(); … … 994 1031 /// -# AtomCount 995 1032 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); 998 1035 result = false; 999 } else Log() << Verbose(4) << "AtomCounts match: " << AtomCount << " == " << OtherMolecule->AtomCount<< endl;1036 } else Log() << Verbose(4) << "AtomCounts match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl; 1000 1037 } 1001 1038 /// -# ElementCount … … 1034 1071 if (result) { 1035 1072 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()]; 1038 1075 SetIndexedArrayForEachAtomTo ( Distances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity); 1039 1076 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 } 1040 1081 1041 1082 /// ... sort each list (using heapsort (o(N log N)) from GSL) 1042 1083 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; 1048 1095 DoLog(5) && (Log() << Verbose(5) << "Combining Permutation Maps" << endl); 1049 for(int i= AtomCount;i--;)1096 for(int i=getAtomCount();i--;) 1050 1097 PermutationMap[PermMap[i]] = (int) OtherPermMap[i]; 1051 1098 … … 1053 1100 DoLog(4) && (Log() << Verbose(4) << "Comparing distances" << endl); 1054 1101 flag = 0; 1055 for (int i=0;i< AtomCount;i++) {1102 for (int i=0;i<getAtomCount();i++) { 1056 1103 DoLog(5) && (Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " << threshold << endl); 1057 1104 if (fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) > threshold*threshold) … … 1060 1107 1061 1108 // 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); 1066 1113 if (flag) { // if not equal 1067 Free(&PermutationMap);1114 delete[](PermutationMap); 1068 1115 result = false; 1069 1116 } … … 1089 1136 int * molecule::GetFatherSonAtomicMap(molecule *OtherMolecule) 1090 1137 { 1091 atom *Walker = NULL, *OtherWalker = NULL;1092 1138 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--;) 1095 1141 AtomicMap[i] = -1; 1096 1142 if (OtherMolecule == this) { // same molecule 1097 for (int i= AtomCount;i--;) // no need as -1 means already that there is trivial correspondence1143 for (int i=getAtomCount();i--;) // no need as -1 means already that there is trivial correspondence 1098 1144 AtomicMap[i] = i; 1099 1145 DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl); 1100 1146 } else { 1101 1147 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; 1107 1151 } 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) { 1111 1153 //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; 1116 1158 } 1117 1159 } 1118 DoLog(0) && (Log() << Verbose(0) << AtomicMap[ Walker->nr] << "\t");1160 DoLog(0) && (Log() << Verbose(0) << AtomicMap[(*iter)->nr] << "\t"); 1119 1161 } 1120 1162 DoLog(0) && (Log() << Verbose(0) << endl); … … 1150 1192 void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index) const 1151 1193 { 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); 1156 1196 } 1157 1197 }; -
src/molecule.hpp
rc39cc4 rbdb143 29 29 #include <string> 30 30 31 #include " defs.hpp"31 #include "types.hpp" 32 32 #include "graph.hpp" 33 33 #include "stackclass.hpp" 34 34 #include "tesselation.hpp" 35 35 #include "Patterns/Observer.hpp" 36 #include "Patterns/ObservedIterator.hpp" 36 37 #include "Patterns/Cacheable.hpp" 38 39 #include "Descriptors/MoleculeDescriptor_impl.hpp" 37 40 38 41 /****************************************** forward declarations *****************************/ … … 78 81 }; 79 82 80 #define MaxThermostats 6 //!< maximum number of thermostat entries in Ions#ThermostatNames and Ions#ThermostatImplemented81 enum thermostats { None, Woodcock, Gaussian, Langevin, Berendsen, NoseHoover }; //!< Thermostat names for output82 83 84 83 /** The complete molecule. 85 84 * Class incorporates number of types … … 88 87 friend molecule *NewMolecule(); 89 88 friend void DeleteMolecule(molecule *); 89 90 90 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 91 96 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 96 102 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() 98 104 int BondCount; //!< number of atoms, brought up-to-date by CountBonds() 99 105 int ElementCount; //!< how many unique elements are therein … … 110 116 private: 111 117 Cacheable<string> formula; 118 Cacheable<int> AtomCount; 112 119 moleculeId_t id; 120 atomSet atoms; //<!list of atoms 121 atomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms 113 122 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 114 131 molecule(const periodentafel * const teil); 115 132 virtual ~molecule(); … … 119 136 //getter and setter 120 137 const std::string getName(); 138 int getAtomCount() const; 139 int doCountAtoms(); 121 140 moleculeId_t getId(); 122 141 void setId(moleculeId_t); … … 125 144 std::string calcFormula(); 126 145 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 127 158 128 159 // re-definition of virtual functions from PointCloud … … 130 161 Vector *GetCenter() const ; 131 162 TesselPoint *GetPoint() const ; 132 TesselPoint *GetTerminalPoint() const ;133 163 int GetMaxId() const; 134 164 void GoToNext() const ; 135 void GoToPrevious() const ;136 165 void GoToFirst() const ; 137 void GoToLast() const ;138 166 bool IsEmpty() const ; 139 167 bool IsEnd() const ; … … 224 252 bool RemoveBond(bond *pointer); 225 253 bool RemoveBonds(atom *BondPartner); 254 bool hasBondStructure(); 255 unsigned int CountBonds() const; 226 256 227 257 /// Find atoms. … … 230 260 231 261 /// Count and change present atoms' coordination. 232 void CountAtoms();233 262 void CountElements(); 234 void CalculateOrbitals(class config &configuration);235 263 bool CenterInBox(); 236 264 bool BoundInBox(); … … 247 275 Vector * DetermineCenterOfGravity(); 248 276 Vector * DetermineCenterOfAll() const; 277 Vector * DetermineCenterOfBox() const; 249 278 void SetNameFromFilename(const char *filename); 250 279 void SetBoxDimension(Vector *dim); … … 258 287 double MinimiseConstrainedPotential(atom **&permutation, int startstep, int endstep, bool IsAngstroem); 259 288 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); 261 290 262 291 bool CheckBounds(const Vector *x) const; … … 290 319 291 320 /// 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); 300 329 bool CreateMappingLabelsToConfigSequence(int *&SortIndex); 330 bool CreateFatherLookupTable(atom **&LookupTable, int count = 0); 301 331 void BreadthFirstSearchAdd(molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem); 302 332 /// -# BOSSANOVA … … 327 357 private: 328 358 int last_atom; //!< number given to last atom 329 mutable atom *InternalPointer; //!< internal pointer for PointCloud359 mutable internal_iterator InternalPointer; //!< internal pointer for PointCloud 330 360 }; 331 361 … … 345 375 ~MoleculeListClass(); 346 376 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); 349 379 void insert(molecule *mol); 380 void erase(molecule *mol); 350 381 molecule * ReturnIndex(int index); 351 bool OutputConfigForListOfFragments( config *configuration, int *SortIndex);382 bool OutputConfigForListOfFragments(std::string &prefix, int *SortIndex); 352 383 int NumberOfActiveMolecules(); 353 384 void Enumerate(ostream *out); -
src/molecule_dynamics.cpp
rc39cc4 rbdb143 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "World.hpp" 9 11 #include "atom.hpp" 10 12 #include "config.hpp" 11 13 #include "element.hpp" 14 #include "info.hpp" 12 15 #include "log.hpp" 13 16 #include "memoryallocator.hpp" … … 15 18 #include "parser.hpp" 16 19 #include "Plane.hpp" 20 #include "ThermoStatContainer.hpp" 17 21 18 22 /************************************* Functions for class molecule *********************************/ … … 28 32 gsl_matrix *A = gsl_matrix_alloc(NDIM,NDIM); 29 33 gsl_vector *x = gsl_vector_alloc(NDIM); 30 atom * Runner = mol->start;31 34 atom *Sprinter = NULL; 32 35 Vector trajectory1, trajectory2, normal, TestVector; 33 36 double Norm1, Norm2, tmp, result = 0.; 34 37 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++) 38 40 break; 39 41 // determine normalized trajectories direction vector (n1, n2) … … 42 44 trajectory1.Normalize(); 43 45 Norm1 = trajectory1.Norm(); 44 Sprinter = Params.PermutationMap[ Runner->nr]; // find second target point45 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); 46 48 trajectory2.Normalize(); 47 49 Norm2 = trajectory1.Norm(); 48 50 // check whether either is zero() 49 51 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)); 51 53 } else if (Norm1 < MYEPSILON) { 52 54 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); 54 56 trajectory2 *= trajectory1.ScalarProduct(trajectory2); // trajectory2 is scaled to unity, hence we don't need to divide by anything 55 57 trajectory1 -= trajectory2; // project the part in norm direction away 56 58 tmp = trajectory1.Norm(); // remaining norm is distance 57 59 } else if (Norm2 < MYEPSILON) { 58 Sprinter = Params.PermutationMap[ Runner->nr]; // find second target point60 Sprinter = Params.PermutationMap[(*iter)->nr]; // find second target point 59 61 trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Walker->Trajectory.R.at(Params.startstep); // copy second offset 60 62 trajectory1 *= trajectory2.ScalarProduct(trajectory1); // trajectory1 is scaled to unity, hence we don't need to divide by anything … … 66 68 // Log() << Verbose(0) << " and "; 67 69 // 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)); 69 71 // Log() << Verbose(0) << " with distance " << tmp << "." << endl; 70 72 } 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 "; 72 74 // Log() << Verbose(0) << endl; 73 75 // Log() << Verbose(0) << "First Trajectory: "; … … 85 87 gsl_matrix_set(A, 1, i, trajectory2[i]); 86 88 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])); 88 90 } 89 91 // solve the linear system by Householder transformations … … 96 98 trajectory2.Scale(gsl_vector_get(x,1)); 97 99 normal.Scale(gsl_vector_get(x,2)); 98 TestVector = Runner->Trajectory.R.at(Params.startstep) + trajectory2 + normal100 TestVector = (*iter)->Trajectory.R.at(Params.startstep) + trajectory2 + normal 99 101 - (Walker->Trajectory.R.at(Params.startstep) + trajectory1); 100 102 if (TestVector.Norm() < MYEPSILON) { … … 125 127 { 126 128 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)) { 131 131 // 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 "; 133 133 // Log() << Verbose(0) << Sprinter->Trajectory.R.at(endstep); 134 134 // Log() << Verbose(0) << ", penalting." << endl; … … 161 161 // go through every atom 162 162 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) { 166 164 // first term: distance to target 167 Runner = Params.PermutationMap[ Walker->nr]; // find target point168 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))); 169 167 tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem; 170 168 result += Params.PenaltyConstants[0] * tmp; … … 172 170 173 171 // second term: sum of distances to other trajectories 174 result += SumDistanceOfTrajectories( Walker, this, Params);172 result += SumDistanceOfTrajectories((*iter), this, Params); 175 173 176 174 // third term: penalty for equal targets 177 result += PenalizeEqualTargets( Walker, this, Params);175 result += PenalizeEqualTargets((*iter), this, Params); 178 176 } 179 177 … … 189 187 { 190 188 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; 192 192 int doubles = 0; 193 193 zeile1 << "PermutationMap: "; … … 203 203 if (doubles >0) 204 204 DoLog(2) && (Log() << Verbose(2) << "Found " << doubles << " Doubles." << endl); 205 Free(&DoubleList);205 delete[](DoubleList); 206 206 // Log() << Verbose(2) << zeile1.str() << endl << zeile2.str() << endl; 207 207 }; … … 213 213 void FillDistanceList(molecule *mol, struct EvaluatePotential &Params) 214 214 { 215 for (int i=mol-> AtomCount; i--;) {215 for (int i=mol->getAtomCount(); i--;) { 216 216 Params.DistanceList[i] = new DistanceMap; // is the distance sorted target list per atom 217 217 Params.DistanceList[i]->clear(); 218 218 } 219 219 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)) ); 228 223 } 229 224 } … … 237 232 void CreateInitialLists(molecule *mol, struct EvaluatePotential &Params) 238 233 { 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); 247 240 } 248 241 }; … … 285 278 void MakeInjectivePermutation(molecule *mol, struct EvaluatePotential &Params) 286 279 { 287 atom *Walker = mol->start;280 molecule::const_iterator iter = mol->begin(); 288 281 DistanceMap::iterator NewBase; 289 282 double Potential = fabs(mol->ConstrainedPotential(Params)); 290 283 284 if (mol->empty()) { 285 eLog() << Verbose(1) << "Molecule is empty." << endl; 286 return; 287 } 291 288 while ((Potential) > Params.PenaltyConstants[2]) { 292 PrintPermutationMap(mol-> AtomCount, Params);293 Walker = Walker->next;294 if ( Walker == mol->end) // round-robin at the end295 Walker = mol->start->next;296 if (Params.DoubleList[Params.DistanceIterators[ Walker->nr]->second->nr] <= 1) // no need to make those injective that aren't289 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 297 294 continue; 298 295 // 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 <=1296 Potential = TryNextNearestNeighbourForInjectivePermutation(mol, (*iter), Potential, Params); 297 } 298 for (int i=mol->getAtomCount(); i--;) // now each single entry in the DoubleList should be <=1 302 299 if (Params.DoubleList[i] > 1) { 303 300 DoeLog(0) && (eLog()<< Verbose(0) << "Failed to create an injective PermutationMap!" << endl); … … 338 335 double Potential, OldPotential, OlderPotential; 339 336 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()]; 345 342 int round; 346 atom * Walker = NULL, *Runner = NULL, *Sprinter = NULL;343 atom *Sprinter = NULL; 347 344 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 } 348 351 349 352 /// Minimise the potential … … 362 365 DoLog(1) && (Log() << Verbose(1) << "Making the PermutationMap injective ... " << endl); 363 366 MakeInjectivePermutation(this, Params); 364 Free(&Params.DoubleList);367 delete[](Params.DoubleList); 365 368 366 369 // argument minimise the constrained potential in this injective PermutationMap … … 371 374 DoLog(2) && (Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl); 372 375 OlderPotential = OldPotential; 376 molecule::const_iterator iter; 373 377 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(); 383 386 break; 384 387 } 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; 386 389 // 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; 391 394 break; 392 395 } 393 Runner = Runner->next;394 396 } 395 if ( Runner != end) { // we found the other source397 if (runner != end()) { // we found the other source 396 398 // 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++) 399 401 if (Rider->second == Sprinter) 400 402 break; 401 if (Rider != Params.DistanceList[ Runner->nr]->end()) { // if we have found one402 //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; 403 405 // exchange both 404 Params.PermutationMap[ Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // put next farther distance into PermutationMap405 Params.PermutationMap[ Runner->nr] = Sprinter; // and hand the old target to its respective owner406 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); 407 409 // calculate the new potential 408 410 //Log() << Verbose(2) << "Checking new potential ..." << endl; … … 410 412 if (Potential > OldPotential) { // we made everything worse! Undo ... 411 413 //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; 413 415 // 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; 415 417 // Undo for Walker 416 Params.DistanceIterators[ Walker->nr] = Strider; // take next farther distance target417 //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; 419 421 } else { 420 Params.DistanceIterators[ Runner->nr] = Rider; // if successful also move the pointer in the iterator list422 Params.DistanceIterators[(*runner)->nr] = Rider; // if successful also move the pointer in the iterator list 421 423 DoLog(3) && (Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl); 422 424 OldPotential = Potential; … … 428 430 //Log() << Verbose(0) << endl; 429 431 } 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); 431 433 exit(255); 432 434 } 433 435 } 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! 435 437 } 436 Params.StepList[ Walker->nr]++; // take next farther distance target438 Params.StepList[(*iter)->nr]++; // take next farther distance target 437 439 } 438 } while ( Walker->next != end);440 } while (++iter != end()); 439 441 } while ((OlderPotential - OldPotential) > 1e-3); 440 442 DoLog(1) && (Log() << Verbose(1) << "done." << endl); … … 442 444 443 445 /// free memory and return with evaluated potential 444 for (int i= AtomCount; i--;)446 for (int i=getAtomCount(); i--;) 445 447 Params.DistanceList[i]->clear(); 446 Free(&Params.DistanceList);447 Free(&Params.DistanceIterators);448 delete[](Params.DistanceList); 449 delete[](Params.DistanceIterators); 448 450 return ConstrainedPotential(Params); 449 451 }; … … 471 473 * \param startstep stating initial configuration in molecule::Trajectories 472 474 * \param endstep stating final configuration in molecule::Trajectories 475 * \param &prefix path and prefix 473 476 * \param &config configuration structure 474 477 * \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() 475 478 * \return true - success in writing step files, false - error writing files or only one step in molecule::Trajectories 476 479 */ 477 bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, const char *prefix, config &configuration, bool MapByIdentity)480 bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string &prefix, config &configuration, bool MapByIdentity) 478 481 { 479 482 molecule *mol = NULL; … … 483 486 // Get the Permutation Map by MinimiseConstrainedPotential 484 487 atom **PermutationMap = NULL; 485 atom * Walker = NULL, *Sprinter = NULL;488 atom *Sprinter = NULL; 486 489 if (!MapByIdentity) 487 490 MinimiseConstrainedPotential(PermutationMap, startstep, endstep, configuration.GetIsAngstroem()); 488 491 else { 489 PermutationMap = Malloc<atom *>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: **PermutationMap");492 PermutationMap = new atom *[getAtomCount()]; 490 493 SetIndexedArrayForEachAtomTo( PermutationMap, &atom::nr ); 491 494 } … … 502 505 mol = World::getInstance().createMolecule(); 503 506 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) { 507 508 // add to molecule list 508 Sprinter = mol->AddCopyAtom( Walker);509 Sprinter = mol->AddCopyAtom((*iter)); 509 510 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); 511 512 // add to Trajectories 512 513 //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl; 513 514 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.; 517 518 } 518 519 } … … 522 523 523 524 // 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--; ) 526 527 SortIndex[i] = i; 527 status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex); 528 529 status = MoleculePerStep->OutputConfigForListOfFragments(prefix, SortIndex); 530 delete[](SortIndex); 528 531 529 532 // free and return 530 Free(&PermutationMap);533 delete[](PermutationMap); 531 534 delete(MoleculePerStep); 532 535 return status; … … 548 551 bool molecule::VerletForceIntegration(char *file, config &configuration) 549 552 { 553 Info FunctionInfo(__func__); 550 554 ifstream input(file); 551 555 string token; … … 567 571 return false; 568 572 } 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); 571 575 performCriticalExit(); 572 576 return false; … … 574 578 // correct Forces 575 579 Velocity.Zero(); 576 for(int i=0;i< AtomCount;i++)580 for(int i=0;i<getAtomCount();i++) 577 581 for(int d=0;d<NDIM;d++) { 578 582 Velocity[d] += Force.Matrix[0][i][d+5]; 579 583 } 580 for(int i=0;i< AtomCount;i++)584 for(int i=0;i<getAtomCount();i++) 581 585 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()); 583 587 } 584 588 // solve a constrained potential if we are meant to … … 588 592 ConstrainedPotentialEnergy = MinimiseConstrainedPotential(PermutationMap,configuration.DoConstrainedMD, 0, configuration.GetIsAngstroem()); 589 593 EvaluateConstrainedForces(configuration.DoConstrainedMD, 0, PermutationMap, &Force); 590 Free(&PermutationMap);594 delete[](PermutationMap); 591 595 } 592 596 593 597 // and perform Verlet integration for each atom with position, velocity and force vector 594 598 // 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); 598 602 } 599 603 // correct velocities (rather momenta) so that center of mass remains motionless 600 604 Velocity.Zero(); 601 605 IonMass = 0.; 602 ActOnAllAtoms ( &atom::SumUpKineticEnergy, MDSteps , &IonMass, &Velocity );606 ActOnAllAtoms ( &atom::SumUpKineticEnergy, MDSteps+1, &IonMass, &Velocity ); 603 607 604 608 // correct velocities (rather momenta) so that center of mass remains motionless 605 609 Velocity.Scale(1./IonMass); 606 610 ActualTemp = 0.; 607 ActOnAllAtoms ( &atom::CorrectVelocity, &ActualTemp, MDSteps , &Velocity );611 ActOnAllAtoms ( &atom::CorrectVelocity, &ActualTemp, MDSteps+1, &Velocity ); 608 612 Thermostats(configuration, ActualTemp, Berendsen); 609 613 MDSteps++; … … 642 646 643 647 // calculate scale configuration 644 ScaleTempFactor = configuration.T argetTemp/ActualTemp;648 ScaleTempFactor = configuration.Thermostats->TargetTemp/ActualTemp; 645 649 646 650 // differentating between the various thermostats … … 650 654 break; 651 655 case Woodcock: 652 if ((configuration. ScaleTempStep > 0) && ((MDSteps-1) % configuration.ScaleTempStep == 0)) {656 if ((configuration.Thermostats->ScaleTempStep > 0) && ((MDSteps-1) % configuration.Thermostats->ScaleTempStep == 0)) { 653 657 DoLog(2) && (Log() << Verbose(2) << "Applying Woodcock thermostat..." << endl); 654 658 ActOnAllAtoms( &atom::Thermostat_Woodcock, sqrt(ScaleTempFactor), MDSteps, &ekin ); … … 683 687 delta_alpha = 0.; 684 688 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); 688 692 // apply updated alpha as additional force 689 693 ActOnAllAtoms( &atom::Thermostat_NoseHoover_scale, MDSteps, &ekin, &configuration ); -
src/molecule_fragmentation.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <cstring> … … 39 41 int FragmentCount; 40 42 // 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; 45 45 } 46 46 FragmentCount = NoNonHydrogen*(1 << (c*order)); … … 82 82 * -# Scans TEFactors file and sets the TEFactor of each key set in the temporary graph accordingly 83 83 * 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 86 85 * \param *FragmentList empty, filled on return 87 86 * \return true - parsing successfully, false - failure on parsing (FragmentList will be NULL) 88 87 */ 89 bool ParseKeySetFile( char *path, Graph *&FragmentList)88 bool ParseKeySetFile(std::string &path, Graph *&FragmentList) 90 89 { 91 90 bool status = true; … … 94 93 GraphTestPair testGraphInsert; 95 94 int NumberOfFragments = 0; 96 char *filename = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseKeySetFile - filename");95 string filename; 97 96 98 97 if (FragmentList == NULL) { // check list pointer … … 102 101 // 1st pass: open file and read 103 102 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()) { 107 106 // each line represents a new fragment 108 char *buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseKeySetFile - *buffer");107 char buffer[MAXSTRINGSIZE]; 109 108 // 1. parse keysets and insert into temp. graph 110 109 while (!InputFile.eof()) { … … 122 121 InputFile.close(); 123 122 InputFile.clear(); 124 Free(&buffer); 125 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 123 DoLog(1) && (Log() << Verbose(1) << "\t ... done." << endl); 126 124 } else { 127 DoLog(1) && (Log() << Verbose(1) << " File " << filename << " not found." << endl);125 DoLog(1) && (Log() << Verbose(1) << "\t ... File " << filename << " not found." << endl); 128 126 status = false; 129 127 } 130 128 131 Free(&filename);132 129 return status; 133 130 }; … … 148 145 int NumberOfFragments = 0; 149 146 double TEFactor; 150 char *filename = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseTEFactorsFile - filename");147 char filename[MAXSTRINGSIZE]; 151 148 152 149 if (FragmentList == NULL) { // check list pointer … … 179 176 } 180 177 181 // free memory182 Free(&filename);183 184 178 return status; 185 179 }; 186 180 187 181 /** Stores key sets to file. 188 * \param *out output stream for debugging189 182 * \param KeySetList Graph with Keysets 190 * \param *path path to file183 * \param &path path to file 191 184 * \return true - file written successfully, false - writing failed 192 185 */ 193 bool StoreKeySetFile(Graph &KeySetList, char *path) 194 { 195 ofstream output; 186 bool StoreKeySetFile(Graph &KeySetList, std::string &path) 187 { 196 188 bool status = true; 197 string line; 189 string line = path + KEYSETFILE; 190 ofstream output(line.c_str()); 198 191 199 192 // open KeySet file 200 line = path;201 line.append("/");202 line += FRAGMENTPREFIX;203 line += KEYSETFILE;204 output.open(line.c_str(), ios::out);205 193 DoLog(1) && (Log() << Verbose(1) << "Saving key sets of the total graph ... "); 206 if(output != NULL) {194 if(output.good()) { 207 195 for(Graph::iterator runner = KeySetList.begin(); runner != KeySetList.end(); runner++) { 208 196 for (KeySet::iterator sprinter = (*runner).first.begin();sprinter != (*runner).first.end(); sprinter++) { … … 307 295 308 296 /** 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) 311 298 * \param &IndexedKeySetList list to find key set for a given index \a No 312 299 * \return adaptive criteria list from file 313 300 */ 314 map<int, pair<double,int> > * ScanAdaptiveFileIntoMap( char *path, map<int,KeySet> &IndexKeySetList)301 map<int, pair<double,int> > * ScanAdaptiveFileIntoMap(std::string &path, map<int,KeySet> &IndexKeySetList) 315 302 { 316 303 map<int, pair<double,int> > *AdaptiveCriteriaList = new map<int, pair<double,int> >; 317 304 int No = 0, FragOrder = 0; 318 305 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 } 322 314 323 315 if (CountLinesinFile(InputFile) > 0) { … … 345 337 InputFile.clear(); 346 338 } 347 Free(&buffer);348 339 349 340 return AdaptiveCriteriaList; … … 359 350 map<double, pair<int,int> > * ReMapAdaptiveCriteriaListToValue(map<int, pair<double,int> > *AdaptiveCriteriaList, molecule *mol) 360 351 { 361 atom *Walker = mol->start;352 atom *Walker = NULL; 362 353 map<double, pair<int,int> > *FinalRootCandidates = new map<double, pair<int,int> > ; 363 354 DoLog(1) && (Log() << Verbose(1) << "Root candidate list is: " << endl); … … 391 382 bool MarkUpdateCandidates(bool *AtomMask, map<double, pair<int,int> > &FinalRootCandidates, int Order, molecule *mol) 392 383 { 393 atom *Walker = mol->start;384 atom *Walker = NULL; 394 385 int No = -1; 395 386 bool status = false; … … 425 416 426 417 /** Checks whether the OrderAtSite is still below \a Order at some site. 427 * \param *out output stream for debugging428 418 * \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 429 419 * \param *GlobalKeySetList list of keysets with global ids (valid in "this" molecule) needed for adaptive increase 430 420 * \param Order desired Order if positive, desired exponent in threshold criteria if negative (0 is single-step) 431 421 * \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) 433 423 * \return true - needs further fragmentation, false - does not need fragmentation 434 424 */ 435 bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path) 436 { 437 atom *Walker = start; 425 bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, std::string path) 426 { 438 427 bool status = false; 439 428 440 429 // initialize mask list 441 for(int i= AtomCount;i--;)430 for(int i=getAtomCount();i--;) 442 431 AtomMask[i] = false; 443 432 444 433 if (Order < 0) { // adaptive increase of BondOrder per site 445 if (AtomMask[ AtomCount] == true) // break after one step434 if (AtomMask[getAtomCount()] == true) // break after one step 446 435 return false; 447 436 … … 457 446 if (AdaptiveCriteriaList->empty()) { 458 447 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) { 461 449 #ifdef ADDHYDROGEN 462 if ( Walker->type->Z != 1) // skip hydrogen450 if ((*iter)->type->Z != 1) // skip hydrogen 463 451 #endif 464 452 { 465 AtomMask[ Walker->nr] = true; // include all (non-hydrogen) atoms453 AtomMask[(*iter)->nr] = true; // include all (non-hydrogen) atoms 466 454 status = true; 467 455 } … … 474 462 MarkUpdateCandidates(AtomMask, *FinalRootCandidates, Order, this); 475 463 476 Free(&IndexKeySetList);477 Free(&AdaptiveCriteriaList);478 Free(&FinalRootCandidates);464 delete[](IndexKeySetList); 465 delete[](AdaptiveCriteriaList); 466 delete[](FinalRootCandidates); 479 467 } 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) { 482 469 #ifdef ADDHYDROGEN 483 if ( Walker->type->Z != 1) // skip hydrogen470 if ((*iter)->type->Z != 1) // skip hydrogen 484 471 #endif 485 472 { 486 AtomMask[ Walker->nr] = true; // include all (non-hydrogen) atoms487 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])) 488 475 status = true; 489 476 } 490 477 } 491 if (( Order == 0) && (AtomMask[AtomCount] == false)) // single stepping, just check478 if ((!Order) && (!AtomMask[getAtomCount()])) // single stepping, just check 492 479 status = true; 493 480 … … 500 487 } 501 488 502 PrintAtomMask(AtomMask, AtomCount); // for debugging489 PrintAtomMask(AtomMask, getAtomCount()); // for debugging 503 490 504 491 return status; … … 516 503 return false; 517 504 } 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--;) 520 507 SortIndex[i] = -1; 521 508 … … 524 511 525 512 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 */ 524 bool 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; 526 568 }; 527 569 … … 539 581 * of vertex indices: Global always means the index in "this" molecule, whereas local refers to the molecule or 540 582 * subgraph in the MoleculeListClass. 541 * \param *out output stream for debugging542 583 * \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 fragment584 * \param &prefix path and prefix of the bond order configs to be written 544 585 * \return 1 - continue, 2 - stop (no fragmentation occured) 545 586 */ 546 int molecule::FragmentMolecule(int Order, config *configuration)587 int molecule::FragmentMolecule(int Order, std::string &prefix) 547 588 { 548 589 MoleculeListClass *BondFragments = NULL; 549 int *SortIndex = NULL; 550 int *MinimumRingSize = new int[AtomCount]; 590 int *MinimumRingSize = new int[getAtomCount()]; 551 591 int FragmentCounter; 552 592 MoleculeLeafClass *MolecularWalker = NULL; … … 576 616 577 617 // create lookup table for Atom::nr 578 FragmentationToDo = FragmentationToDo && CreateFatherLookupTable( start, end, ListOfAtoms, AtomCount);618 FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(ListOfAtoms, getAtomCount()); 579 619 580 620 // === compare it with adjacency file === 581 FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule( configuration->configpath, ListOfAtoms);582 Free(&ListOfAtoms);621 FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(prefix, ListOfAtoms); 622 delete[](ListOfAtoms); 583 623 584 624 // ===== 2. perform a DFS analysis to gather info on cyclic structure and a list of disconnected subgraphs ===== … … 586 626 587 627 // 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(); 590 630 MolecularWalker = Subgraphs; 591 631 FragmentCounter = 0; … … 598 638 // // check the list of local atoms for debugging 599 639 // 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++) 601 641 // if (ListOfLocalAtoms[FragmentCounter][i] == NULL) 602 642 // Log() << Verbose(0) << "\tNULL"; … … 613 653 614 654 // ===== 3. if structure still valid, parse key set file and others ===== 615 FragmentationToDo = FragmentationToDo && ParseKeySetFile( configuration->configpath, ParsedFragmentList);655 FragmentationToDo = FragmentationToDo && ParseKeySetFile(prefix, ParsedFragmentList); 616 656 617 657 // ===== 4. check globally whether there's something to do actually (first adaptivity check) 618 FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile( configuration->configpath);658 FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(prefix); 619 659 620 660 // =================================== Begin of FRAGMENTATION =============================== … … 624 664 // ===== 6b. prepare and go into the adaptive (Order<0), single-step (Order==0) or incremental (Order>0) cycle 625 665 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; 628 668 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))) { 630 670 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() 632 672 // ===== 6b. fill RootStack for each subgraph (second adaptivity check) ===== 633 673 Subgraphs->next->FillRootStackForSubgraphs(RootStack, AtomMask, (FragmentCounter = 0)); … … 640 680 DoLog(1) && (Log() << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl); 641 681 //MolecularWalker->Leaf->OutputListOfBonds(out); // output atom::ListOfBonds for debugging 642 if (MolecularWalker->Leaf-> first->next != MolecularWalker->Leaf->last) {682 if (MolecularWalker->Leaf->hasBondStructure()) { 643 683 // call BOSSANOVA method 644 684 DoLog(0) && (Log() << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl); … … 672 712 delete(Subgraphs); 673 713 } 674 Free(&FragmentList);714 delete[](FragmentList); 675 715 676 716 // ===== 8b. gather keyset lists (graphs) from all subgraphs and transform into MoleculeListClass ===== … … 682 722 KeySet test = (*runner).first; 683 723 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())); 685 725 k++; 686 726 } … … 690 730 if (BondFragments->ListOfMolecules.size() != 0) { 691 731 // create the SortIndex from BFS labels to order in the config file 732 int *SortIndex = NULL; 692 733 CreateMappingLabelsToConfigSequence(SortIndex); 693 734 694 735 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)) 696 737 DoLog(1) && (Log() << Verbose(1) << "All configs written." << endl); 697 738 else … … 699 740 700 741 // store force index reference file 701 BondFragments->StoreForcesFile( configuration->configpath, SortIndex);742 BondFragments->StoreForcesFile(prefix, SortIndex); 702 743 703 744 // 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 } 712 752 713 753 // store Hydrogen saturation correction file 714 BondFragments->AddHydrogenCorrection( configuration->configpath);754 BondFragments->AddHydrogenCorrection(prefix); 715 755 716 756 // store adaptive orders into file 717 StoreOrderAtSiteFile( configuration->configpath);757 StoreOrderAtSiteFile(prefix); 718 758 719 759 // restore orbital and Stop values 720 CalculateOrbitals(*configuration);760 //CalculateOrbitals(*configuration); 721 761 722 762 // free memory for bond part 723 763 DoLog(1) && (Log() << Verbose(1) << "Freeing bond memory" << endl); 724 Free(&FragmentList); // remove bond molecule from memory 725 Free(&SortIndex); 764 delete[](SortIndex); 726 765 } else { 727 766 DoLog(1) && (Log() << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl); … … 736 775 /** Stores pairs (Atom::nr, Atom::AdaptiveOrder) into file. 737 776 * 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 740 778 * \return true - file writable, false - not writable 741 779 */ 742 bool molecule::StoreOrderAtSiteFile( char *path)743 { 744 string streamline;780 bool molecule::StoreOrderAtSiteFile(std::string &path) 781 { 782 string line; 745 783 ofstream file; 746 784 747 line << path << "/" << FRAGMENTPREFIX <<ORDERATSITEFILE;748 file.open(line. str().c_str());785 line = path + ORDERATSITEFILE; 786 file.open(line.c_str()); 749 787 DoLog(1) && (Log() << Verbose(1) << "Writing OrderAtSite " << ORDERATSITEFILE << " ... " << endl); 750 if (file != NULL) {788 if (file.good()) { 751 789 ActOnAllAtoms( &atom::OutputOrder, &file ); 752 790 file.close(); … … 754 792 return true; 755 793 } 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); 757 795 return false; 758 796 } … … 761 799 /** Parses pairs(Atom::nr, Atom::AdaptiveOrder) from file and stores in molecule's Atom's. 762 800 * 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 765 802 * \return true - file found and scanned, false - file not found 766 803 * \sa ParseKeySetFile() and CheckAdjacencyFileAgainstMolecule() as this is meant to be used in conjunction with the two 767 804 */ 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");805 bool molecule::ParseOrderAtSiteFromFile(std::string &path) 806 { 807 unsigned char *OrderArray = new unsigned char[getAtomCount()]; 808 bool *MaxArray = new bool[getAtomCount()]; 772 809 bool status; 773 810 int AtomNr, value; 774 string streamline;811 string line; 775 812 ifstream file; 776 813 814 for(int i=0;i<getAtomCount();i++) { 815 OrderArray[i] = 0; 816 MaxArray[i] = false; 817 } 818 777 819 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()) { 781 823 while (!file.eof()) { // parse from file 782 824 AtomNr = -1; … … 796 838 SetAtomValueToIndexedArray( MaxArray, &atom::nr, &atom::MaxOrder ); 797 839 798 DoLog(1) && (Log() << Verbose(1) << " done." << endl);840 DoLog(1) && (Log() << Verbose(1) << "\t ... done." << endl); 799 841 status = true; 800 842 } 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); 802 844 status = false; 803 845 } 804 Free(&OrderArray);805 Free(&MaxArray);846 delete[](OrderArray); 847 delete[](MaxArray); 806 848 807 849 DoLog(1) && (Log() << Verbose(1) << "End of ParseOrderAtSiteFromFile" << endl); … … 872 914 atom *OtherFather = NULL; 873 915 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();) { 879 922 LonelyFlag = true; 880 FatherOfRunner = Runner->father; 923 FatherOfRunner = (*iter)->father; 924 ASSERT(FatherOfRunner,"Atom without father found"); 881 925 if (SonList[FatherOfRunner->nr] != NULL) { // check if this, our father, is present in list 882 926 // create all bonds … … 889 933 // Log() << Verbose(3) << "Adding Bond: "; 890 934 // Log() << Verbose(0) << 891 Leaf->AddBond( Runner, SonList[OtherFather->nr], (*BondRunner)->BondDegree);935 Leaf->AddBond((*iter), SonList[OtherFather->nr], (*BondRunner)->BondDegree); 892 936 // Log() << Verbose(0) << "." << endl; 893 //NumBonds[ Runner->nr]++;937 //NumBonds[(*iter)->nr]++; 894 938 } else { 895 939 // Log() << Verbose(3) << "Not adding bond, labels in wrong order." << endl; … … 899 943 // Log() << Verbose(0) << ", who has no son in this fragment molecule." << endl; 900 944 #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)) 903 947 exit(1); 904 948 #endif 905 //NumBonds[ Runner->nr] += Binder->BondDegree;949 //NumBonds[(*iter)->nr] += Binder->BondDegree; 906 950 } 907 951 } 908 952 } 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; 914 959 #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 } 917 963 #endif 918 964 } … … 929 975 molecule * molecule::StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem) 930 976 { 931 atom **SonList = Calloc<atom*>(AtomCount, "molecule::StoreFragmentFromStack: **SonList");977 atom **SonList = new atom*[getAtomCount()]; 932 978 molecule *Leaf = World::getInstance().createMolecule(); 979 980 for(int i=0;i<getAtomCount();i++) 981 SonList[i] = NULL; 933 982 934 983 // Log() << Verbose(1) << "Begin of StoreFragmentFromKeyset." << endl; … … 939 988 940 989 //Leaflet->Leaf->ScanForPeriodicCorrection(out); 941 Free(&SonList);990 delete[](SonList); 942 991 // Log() << Verbose(1) << "End of StoreFragmentFromKeyset." << endl; 943 992 return Leaf; … … 1084 1133 int bits, TouchedIndex, SubSetDimension, SP, Added; 1085 1134 int SpaceLeft; 1086 int *TouchedList = Malloc<int>(SubOrder + 1, "molecule::SPFragmentGenerator: *TouchedList"); 1087 bond **BondsList = NULL; 1135 int *TouchedList = new int[SubOrder + 1]; 1088 1136 KeySetTestPair TestKeySetInsert; 1089 1137 … … 1124 1172 1125 1173 // then allocate and fill the list 1126 BondsList = Malloc<bond*>(SubSetDimension, "molecule::SPFragmentGenerator: **BondsList");1174 bond *BondsList[SubSetDimension]; 1127 1175 SubSetDimension = FillBondsList(BondsList, FragmentSearch->BondsPerSPList[2*SP], FragmentSearch->BondsPerSPList[2*SP+1], TouchedList, TouchedIndex); 1128 1176 … … 1130 1178 Log() << Verbose(2+verbosity) << "Calling subset generator " << SP << " away from root " << *FragmentSearch->Root << " with sub set dimension " << SubSetDimension << "." << endl; 1131 1179 SPFragmentGenerator(FragmentSearch, SP, BondsList, SubSetDimension, SubOrder-bits); 1132 1133 Free(&BondsList);1134 1180 } 1135 1181 } else { … … 1153 1199 } 1154 1200 } 1155 Free(&TouchedList);1201 delete[](TouchedList); 1156 1202 Log() << Verbose(1+verbosity) << "End of SPFragmentGenerator, " << RootDistance << " away from Root " << *FragmentSearch->Root << " and SubOrder is " << SubOrder << "." << endl; 1157 1203 }; … … 1165 1211 void InitialiseSPList(int Order, struct UniqueFragments &FragmentSearch) 1166 1212 { 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]; 1169 1215 for (int i=Order;i--;) { 1170 1216 FragmentSearch.BondsPerSPList[2*i] = new bond(); // start node … … 1184 1230 void FreeSPList(int Order, struct UniqueFragments &FragmentSearch) 1185 1231 { 1186 Free(&FragmentSearch.BondsPerSPCount);1232 delete[](FragmentSearch.BondsPerSPCount); 1187 1233 for (int i=Order;i--;) { 1188 1234 delete(FragmentSearch.BondsPerSPList[2*i]); 1189 1235 delete(FragmentSearch.BondsPerSPList[2*i+1]); 1190 1236 } 1191 Free(&FragmentSearch.BondsPerSPList);1237 delete[](FragmentSearch.BondsPerSPList); 1192 1238 }; 1193 1239 … … 1370 1416 int molecule::PowerSetGenerator(int Order, struct UniqueFragments &FragmentSearch, KeySet RestrictedKeySet) 1371 1417 { 1372 bond **BondsList = NULL;1373 1418 int Counter = FragmentSearch.FragmentCounter; // mark current value of counter 1374 1419 … … 1394 1439 1395 1440 // 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; 1397 1444 BondsList[0] = FragmentSearch.BondsPerSPList[0]->next; // on SP level 0 there's only the root bond 1398 1445 1399 1446 SPFragmentGenerator(&FragmentSearch, 0, BondsList, FragmentSearch.BondsPerSPCount[0], Order); 1400 1401 Free(&BondsList);1402 1447 } else { 1403 1448 DoLog(0) && (Log() << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl); … … 1507 1552 } 1508 1553 } 1509 Free(&FragmentLowerOrdersList[RootNr]);1554 delete[](FragmentLowerOrdersList[RootNr]); 1510 1555 RootNr++; 1511 1556 } 1512 Free(&FragmentLowerOrdersList);1557 delete[](FragmentLowerOrdersList); 1513 1558 }; 1514 1559 … … 1549 1594 // FragmentLowerOrdersList is a 2D-array of pointer to MoleculeListClass objects, one dimension represents the ANOVA expansion of a single order (i.e. 5) 1550 1595 // 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 } 1553 1603 1554 1604 // initialise the fragments structure … … 1556 1606 FragmentSearch.FragmentSet = new KeySet; 1557 1607 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--;) { 1560 1610 FragmentSearch.ShortestPathList[i] = -1; 1561 1611 } 1562 1612 1563 1613 // Construct the complete KeySet which we need for topmost level only (but for all Roots) 1564 atom *Walker = start;1565 1614 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); 1569 1617 } 1570 1618 … … 1577 1625 RootKeyNr = RootStack.front(); 1578 1626 RootStack.pop_front(); 1579 Walker = FindAtom(RootKeyNr);1627 atom *Walker = FindAtom(RootKeyNr); 1580 1628 // check cyclic lengths 1581 1629 //if ((MinimumRingSize[Walker->GetTrueFather()->nr] != -1) && (Walker->GetTrueFather()->AdaptiveOrder+1 > MinimumRingSize[Walker->GetTrueFather()->nr])) { … … 1592 1640 // allocate memory for all lower level orders in this 1D-array of ptrs 1593 1641 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; 1595 1645 1596 1646 // create top order where nothing is reduced … … 1628 1678 1629 1679 // cleanup FragmentSearch structure 1630 Free(&FragmentSearch.ShortestPathList);1680 delete[](FragmentSearch.ShortestPathList); 1631 1681 delete(FragmentSearch.FragmentSet); 1632 1682 … … 1641 1691 CombineAllOrderListIntoOne(FragmentList, FragmentLowerOrdersList, RootStack, this); 1642 1692 FreeAllOrdersList(FragmentLowerOrdersList, RootStack, this); 1643 Free(&NumMoleculesOfOrder);1693 delete[](NumMoleculesOfOrder); 1644 1694 1645 1695 DoLog(0) && (Log() << Verbose(0) << "End of FragmentBOSSANOVA." << endl); … … 1664 1714 Vector Translationvector; 1665 1715 //class StackClass<atom *> *CompStack = NULL; 1666 class StackClass<atom *> *AtomStack = new StackClass<atom *>( AtomCount);1716 class StackClass<atom *> *AtomStack = new StackClass<atom *>(getAtomCount()); 1667 1717 bool flag = true; 1668 1718 1669 1719 DoLog(2) && (Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl); 1670 1720 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; 1672 1724 while (flag) { 1673 1725 // remove bonds that are beyond bonddistance 1674 1726 Translationvector.Zero(); 1675 1727 // scan all bonds 1676 Binder = first;1677 1728 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 } 1689 1742 } 1690 1743 } 1691 }1692 1744 if (flag) { 1693 1745 // create translation vector from their periodically modified distance … … 1701 1753 Log() << Verbose(0) << Translationvector << endl; 1702 1754 // apply to all atoms of first component via BFS 1703 for (int i= AtomCount;i--;)1755 for (int i=getAtomCount();i--;) 1704 1756 ColorList[i] = white; 1705 1757 AtomStack->Push(Binder->leftatom); … … 1727 1779 // free allocated space from ReturnFullMatrixforSymmetric() 1728 1780 delete(AtomStack); 1729 Free(&ColorList);1730 Free(&matrix);1781 delete[](ColorList); 1782 delete[](matrix); 1731 1783 DoLog(2) && (Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl); 1732 1784 }; -
src/molecule_geometry.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "atom.hpp" … … 17 19 #include "World.hpp" 18 20 #include "Plane.hpp" 21 #include <boost/foreach.hpp> 22 19 23 20 24 /************************************* Functions for class molecule *********************************/ … … 28 32 bool status = true; 29 33 const Vector *Center = DetermineCenterOfAll(); 34 const Vector *CenterBox = DetermineCenterOfBox(); 30 35 double * const cell_size = World::getInstance().getDomain(); 31 36 double *M = ReturnFullMatrixforSymmetric(cell_size); … … 34 39 // go through all atoms 35 40 ActOnAllVectors( &Vector::SubtractVector, *Center); 41 ActOnAllVectors( &Vector::SubtractVector, *CenterBox); 36 42 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 37 43 38 Free(&M);39 Free(&Minv);44 delete[](M); 45 delete[](Minv); 40 46 delete(Center); 41 47 return status; … … 56 62 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 57 63 58 Free(&M);59 Free(&Minv);64 delete[](M); 65 delete[](Minv); 60 66 return status; 61 67 }; … … 70 76 71 77 // Log() << Verbose(3) << "Begin of CenterEdge." << endl; 72 atom *ptr = start->next; // start at first in list73 if ( ptr != end) {//list not empty?78 molecule::const_iterator iter = begin(); // start at first in list 79 if (iter != end()) { //list not empty? 74 80 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); 81 86 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); 84 89 } 85 90 } … … 105 110 { 106 111 int Num = 0; 107 atom *ptr = start; // start at first in list112 molecule::const_iterator iter = begin(); // start at first in list 108 113 109 114 Center.Zero(); 110 115 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 114 118 Num++; 115 Center += ptr->x;119 Center += (*iter)->x; 116 120 } 117 121 Center.Scale(-1./Num); // divide through total number (and sign for direction) … … 126 130 Vector * molecule::DetermineCenterOfAll() const 127 131 { 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 */ 151 Vector * 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 */ 167 Vector * molecule::DetermineCenterOfGravity() 168 { 169 molecule::const_iterator iter = begin(); // start at first in list 129 170 Vector *a = new Vector(); 130 171 Vector tmp; … … 133 174 a->Zero(); 134 175 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; 140 180 (*a) += tmp; 141 181 } 142 182 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 debugging149 * \return pointer to center of gravity vector150 */151 Vector * molecule::DetermineCenterOfGravity()152 {153 atom *ptr = start->next; // start at first in list154 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 present162 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)168 183 } 169 184 // Log() << Verbose(1) << "Resulting center of gravity: "; … … 203 218 void molecule::Scale(const double ** const factor) 204 219 { 205 atom *ptr = start; 206 207 while (ptr->next != end) { 208 ptr = ptr->next; 220 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 209 221 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); 212 224 } 213 225 }; … … 218 230 void molecule::Translate(const Vector *trans) 219 231 { 220 atom *ptr = start; 221 222 while (ptr->next != end) { 223 ptr = ptr->next; 232 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 224 233 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); 227 236 } 228 237 }; … … 239 248 240 249 // go through all atoms 241 ActOnAllVectors( &Vector:: SubtractVector, *trans);250 ActOnAllVectors( &Vector::AddVector, *trans); 242 251 ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv); 243 252 244 Free(&M);245 Free(&Minv);253 delete[](M); 254 delete[](Minv); 246 255 }; 247 256 … … 252 261 void molecule::Mirror(const Vector *n) 253 262 { 263 OBSERVE; 254 264 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); 261 267 } 262 268 }; … … 267 273 void molecule::DeterminePeriodicCenter(Vector ¢er) 268 274 { 269 atom *Walker = start;270 275 double * const cell_size = World::getInstance().getDomain(); 271 276 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 272 double *inversematrix = InverseMatrix( cell_size);277 double *inversematrix = InverseMatrix(matrix); 273 278 double tmp; 274 279 bool flag; … … 278 283 Center.Zero(); 279 284 flag = true; 280 while (Walker->next != end) { 281 Walker = Walker->next; 285 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 282 286 #ifdef ADDHYDROGEN 283 if ( Walker->type->Z != 1) {287 if ((*iter)->type->Z != 1) { 284 288 #endif 285 Testvector = Walker->x;289 Testvector = (*iter)->x; 286 290 Testvector.MatrixMultiplication(inversematrix); 287 291 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 nothing292 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 290 294 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]; 292 296 if ((fabs(tmp)) > BondDistance) { 293 297 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); 295 299 if (tmp > 0) 296 300 Translationvector[j] -= 1.; … … 306 310 #ifdef ADDHYDROGEN 307 311 // 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; 311 315 Testvector.MatrixMultiplication(inversematrix); 312 316 Testvector += Translationvector; … … 320 324 } 321 325 } 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())); 326 330 }; 327 331 … … 333 337 void molecule::PrincipalAxisSystem(bool DoRotate) 334 338 { 335 atom *ptr = start; // start at first in list336 339 double InertiaTensor[NDIM*NDIM]; 337 340 Vector *CenterOfGravity = DetermineCenterOfGravity(); … … 344 347 345 348 // 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; 349 351 //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]); 359 361 } 360 362 // print InertiaTensor for debugging … … 394 396 395 397 // 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]); 410 409 } 411 410 // print InertiaTensor for debugging … … 431 430 void molecule::Align(Vector *n) 432 431 { 433 atom *ptr = start;434 432 double alpha, tmp; 435 433 Vector z_axis; … … 442 440 alpha = atan(-n->at(0)/n->at(2)); 443 441 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]; 449 446 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]; 453 450 } 454 451 } … … 460 457 461 458 // rotate on z-y plane 462 ptr = start;463 459 alpha = atan(-n->at(1)/n->at(2)); 464 460 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]; 470 465 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]; 474 469 } 475 470 } … … 495 490 Vector a,b,c,d; 496 491 struct lsq_params *par = (struct lsq_params *)params; 497 atom *ptr = par->mol->start;498 492 499 493 // initialize vectors … … 505 499 b[2] = gsl_vector_get(x,5); 506 500 // 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; 511 504 t = c.ScalarProduct(b); // get direction parameter 512 505 d = t*b; // and create vector -
src/molecule_graph.cpp
rc39cc4 rbdb143 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "atom.hpp" 9 11 #include "bond.hpp" 10 12 #include "bondgraph.hpp" 11 13 #include "config.hpp" 14 #include "defs.hpp" 12 15 #include "element.hpp" 13 16 #include "helpers.hpp" 17 #include "info.hpp" 14 18 #include "linkedcell.hpp" 15 19 #include "lists.hpp" … … 19 23 #include "World.hpp" 20 24 #include "Helpers/fast_functions.hpp" 25 #include "Helpers/Assert.hpp" 26 21 27 22 28 struct BFSAccounting … … 54 60 void molecule::CreateAdjacencyListFromDbondFile(ifstream *input) 55 61 { 56 62 Info FunctionInfo(__func__); 57 63 // 1 We will parse bonds out of the dbond file created by tremolo. 58 64 int atom1, atom2; 59 65 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(); 63 71 }; 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"); 68 77 while (!input->eof()) // Check whether we read everything already 69 78 { 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); 73 85 if (atom2 < atom1) //Sort indices of atoms in order 74 86 flip(atom1, atom2); 75 87 Walker = FindAtom(atom1); 88 ASSERT(Walker,"Could not find an atom with the ID given in dbond file"); 76 89 OtherWalker = FindAtom(atom2); 90 ASSERT(OtherWalker,"Could not find an atom with the ID given in dbond file"); 77 91 AddBond(Walker, OtherWalker); //Add the bond between the two atoms with respective indices. 78 92 } … … 103 117 atom *Walker = NULL; 104 118 atom *OtherWalker = NULL; 105 atom **AtomMap = NULL;106 119 int n[NDIM]; 107 120 double MinDistance, MaxDistance; … … 118 131 DoLog(0) && (Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl); 119 132 // 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)); 127 137 BondCount = 0; 128 138 129 139 // 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.)) { 134 143 DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl); 135 144 LC = new LinkedCell(this, bonddistance); … … 137 146 // create a list to map Tesselpoint::nr to atom * 138 147 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++; 144 153 } 145 154 … … 153 162 if (List != NULL) { 154 163 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; 157 167 // 3c. check for possible bond between each atom in this and every one in the 27 cells 158 168 for (n[0] = -1; n[0] <= 1; n[0]++) … … 164 174 for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) { 165 175 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; 170 179 (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 180 const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x,cell_size); 171 181 const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance); 172 182 // Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl; … … 188 198 } 189 199 } 190 Free(&AtomMap);191 200 delete (LC); 192 201 DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl); … … 199 208 ActOnAllAtoms( &atom::OutputBondOfAtom ); 200 209 } 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); 202 211 DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl); 203 212 if (free_BG) … … 206 215 ; 207 216 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 */ 221 bool 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 */ 232 unsigned 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 208 242 /** Prints a list of all bonds to \a *out. 209 243 * \param output stream … … 212 246 { 213 247 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 } 219 253 DoLog(0) && (Log() << Verbose(0) << endl); 220 254 } … … 241 275 DoLog(0) && (Log() << Verbose(0) << " done." << endl); 242 276 } 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); 244 278 } 245 279 DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl); … … 260 294 MoleculeLeafClass *Subgraphs = NULL; 261 295 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++; 278 313 delete (BackEdgeStack); 279 314 return NoCyclicBonds; … … 461 496 void DepthFirstSearchAnalysis_Init(struct DFSAccounting &DFS, const molecule * const mol) 462 497 { 463 DFS.AtomStack = new StackClass<atom *> (mol-> AtomCount);498 DFS.AtomStack = new StackClass<atom *> (mol->getAtomCount()); 464 499 DFS.CurrentGraphNr = 0; 465 500 DFS.ComponentNumber = 0; … … 502 537 bond *Binder = NULL; 503 538 504 if ( AtomCount== 0)539 if (getAtomCount() == 0) 505 540 return SubGraphs; 506 541 DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl); 507 542 DepthFirstSearchAnalysis_Init(DFS, this); 508 543 509 DFS.Root = start->next;510 while (DFS.Root != end) { // if there any atoms at all544 for (molecule::const_iterator iter = begin(); iter != end();) { 545 DFS.Root = *iter; 511 546 // (1) mark all edges unused, empty stack, set atom->GraphNr = -1 for all 512 547 DFS.AtomStack->ClearStack(); … … 548 583 549 584 // 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 on553 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++; 554 589 } 555 590 } … … 573 608 { 574 609 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 } 583 617 } 584 618 ; … … 599 633 void molecule::OutputGraphInfoPerBond() const 600 634 { 635 bond *Binder = NULL; 601 636 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 } 615 651 } 616 652 ; … … 624 660 { 625 661 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]; 629 665 BFS.BFSStack = new StackClass<atom *> (AtomCount); 630 666 631 for (int i = AtomCount; i--;) 667 for (int i = AtomCount; i--;) { 632 668 BFS.ShortestPathList[i] = -1; 669 BFS.PredecessorList[i] = 0; 670 } 633 671 }; 634 672 … … 639 677 void FinalizeBFSAccounting(struct BFSAccounting &BFS) 640 678 { 641 Free(&BFS.PredecessorList);642 Free(&BFS.ShortestPathList);643 Free(&BFS.ColorList);679 delete[](BFS.PredecessorList); 680 delete[](BFS.ShortestPathList); 681 delete[](BFS.ColorList); 644 682 delete (BFS.BFSStack); 645 683 BFS.AtomCount = 0; … … 854 892 if (MinRingSize != -1) { // if rings are present 855 893 // 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 861 898 Walker = Root; 862 899 863 900 //Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl; 864 CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol-> AtomCount);901 CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol->getAtomCount()); 865 902 866 903 } … … 892 929 int MinRingSize = -1; 893 930 894 InitializeBFSAccounting(BFS, AtomCount);931 InitializeBFSAccounting(BFS, getAtomCount()); 895 932 896 933 //Log() << Verbose(1) << "Back edge list - "; … … 966 1003 void molecule::ResetAllBondsToUnused() const 967 1004 { 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(); 973 1009 } 974 1010 ; … … 989 1025 /** Storing the bond structure of a molecule to file. 990 1026 * Simply stores Atom::nr and then the Atom::nr of all bond partners per line. 991 * \param *path path tofile992 * \param *filename name of file1027 * \param &filename name of file 1028 * \param path path to file, defaults to empty 993 1029 * \return true - file written successfully, false - writing failed 994 1030 */ 995 bool molecule::StoreAdjacencyToFile( char *path, char *filename)1031 bool molecule::StoreAdjacencyToFile(std::string &filename, std::string path) 996 1032 { 997 1033 ofstream AdjacencyFile; 998 string streamline;1034 string line; 999 1035 bool status = true; 1000 1036 1001 if (path != NULL)1002 line << path << "/" <<filename;1037 if (path != "") 1038 line = path + "/" + filename; 1003 1039 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()) { 1008 1044 AdjacencyFile << "m\tn" << endl; 1009 1045 ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile); 1010 1046 AdjacencyFile.close(); 1011 DoLog(1) && (Log() << Verbose(1) << " done." << endl);1047 DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl); 1012 1048 } 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); 1014 1050 status = false; 1015 1051 } … … 1021 1057 /** Storing the bond structure of a molecule to file. 1022 1058 * Simply stores Atom::nr and then the Atom::nr of all bond partners, one per line. 1023 * \param *path path tofile1024 * \param *filename name of file1059 * \param &filename name of file 1060 * \param path path to file, defaults to empty 1025 1061 * \return true - file written successfully, false - writing failed 1026 1062 */ 1027 bool molecule::StoreBondsToFile( char *path, char *filename)1063 bool molecule::StoreBondsToFile(std::string &filename, std::string path) 1028 1064 { 1029 1065 ofstream BondFile; 1030 string streamline;1066 string line; 1031 1067 bool status = true; 1032 1068 1033 if (path != NULL)1034 line << path << "/" <<filename;1069 if (path != "") 1070 line = path + "/" + filename; 1035 1071 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()) { 1040 1076 BondFile << "m\tn" << endl; 1041 1077 ActOnAllAtoms(&atom::OutputBonds, &BondFile); 1042 1078 BondFile.close(); 1043 DoLog(1) && (Log() << Verbose(1) << " done." << endl);1079 DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl); 1044 1080 } 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); 1046 1082 status = false; 1047 1083 } … … 1051 1087 ; 1052 1088 1053 bool CheckAdjacencyFileAgainstMolecule_Init( char *path, ifstream &File, int *&CurrentBonds)1054 { 1055 string streamfilename;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)1089 bool 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()) 1060 1096 return false; 1061 1097 1062 1098 // 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; 1064 1102 return true; 1065 1103 } … … 1070 1108 File.close(); 1071 1109 File.clear(); 1072 Free(&CurrentBonds);1110 delete[](CurrentBonds); 1073 1111 } 1074 1112 ; … … 1090 1128 NonMatchNumber++; 1091 1129 status = false; 1130 DoeLog(2) && (eLog() << Verbose(2) << id << " can not be found in list." << endl); 1131 } else { 1092 1132 //Log() << Verbose(0) << "[" << id << "]\t"; 1093 } else {1094 //Log() << Verbose(0) << id << "\t";1095 1133 } 1096 1134 } … … 1109 1147 * \return true - structure is equal, false - not equivalence 1110 1148 */ 1111 bool molecule::CheckAdjacencyFileAgainstMolecule( char *path, atom **ListOfAtoms)1149 bool molecule::CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms) 1112 1150 { 1113 1151 ifstream File; 1114 1152 bool status = true; 1115 1153 atom *Walker = NULL; 1116 char *buffer = NULL;1117 1154 int *CurrentBonds = NULL; 1118 1155 int NonMatchNumber = 0; // will number of atoms with differing bond structure 1119 1156 size_t CurrentBondsOfAtom = -1; 1157 const int AtomCount = getAtomCount(); 1120 1158 1121 1159 if (!CheckAdjacencyFileAgainstMolecule_Init(path, File, CurrentBonds)) { … … 1124 1162 } 1125 1163 1126 buffer = Malloc<char> (MAXSTRINGSIZE, "molecule::CheckAdjacencyFileAgainstMolecule: *buffer");1164 char buffer[MAXSTRINGSIZE]; 1127 1165 // Parse the file line by line and count the bonds 1128 1166 while (!File.eof()) { … … 1140 1178 // compare against present bonds 1141 1179 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 } 1145 1185 CheckAdjacencyFileAgainstMolecule_Finalize(File, CurrentBonds); 1146 1186 … … 1196 1236 BFS.AtomCount = AtomCount; 1197 1237 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]; 1201 1241 BFS.BFSStack = new StackClass<atom *> (AtomCount); 1202 1242 … … 1207 1247 // initialise each vertex as white with no predecessor, empty queue, color Root lightgray 1208 1248 for (int i = AtomCount; i--;) { 1249 BFS.PredecessorList[i] = NULL; 1209 1250 BFS.ShortestPathList[i] = -1; 1210 1251 if ((AddedAtomList != NULL) && (AddedAtomList[i] != NULL)) // mark already present atoms (i.e. Root and maybe others) as visited … … 1213 1254 BFS.ColorList[i] = white; 1214 1255 } 1215 //BFS.ShortestPathList[Root->nr] = 0; // is set due to Calloc()1256 //BFS.ShortestPathList[Root->nr] = 0; // done by Calloc 1216 1257 } 1217 1258 ; … … 1219 1260 void BreadthFirstSearchAdd_Free(struct BFSAccounting &BFS) 1220 1261 { 1221 Free(&BFS.PredecessorList);1222 Free(&BFS.ShortestPathList);1223 Free(&BFS.ColorList);1262 delete[](BFS.PredecessorList); 1263 delete[](BFS.ShortestPathList); 1264 delete[](BFS.ColorList); 1224 1265 delete (BFS.BFSStack); 1225 1266 BFS.AtomCount = 0; … … 1313 1354 AddedAtomList[Root->nr] = Mol->AddCopyAtom(Root); 1314 1355 1315 BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, AtomCount, AddedAtomList);1356 BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, getAtomCount(), AddedAtomList); 1316 1357 1317 1358 // and go on ... Queue always contains all lightgray vertices … … 1360 1401 { 1361 1402 // 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; 1363 1406 DoLog(3) && (Log() << Verbose(3) << "Resetting ParentList." << endl); 1364 1407 } … … 1369 1412 // fill parent list with sons 1370 1413 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); 1375 1416 // 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 }; 1381 1420 1382 1421 void BuildInducedSubgraph_Finalize(atom **&ParentList) 1383 1422 { 1384 Free(&ParentList);1423 delete[](ParentList); 1385 1424 } 1386 1425 ; … … 1389 1428 { 1390 1429 bool status = true; 1391 atom *Walker = NULL;1392 1430 atom *OtherAtom = NULL; 1393 1431 // check each entry of parent list and if ok (one-to-and-onto matching) create bonds 1394 1432 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)) { 1400 1436 status = false; 1401 1437 } 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)); 1404 1440 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); 1407 1443 } 1408 1444 } … … 1427 1463 bool status = true; 1428 1464 atom **ParentList = NULL; 1429 1430 1465 DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl); 1431 BuildInducedSubgraph_Init(ParentList, Father-> AtomCount);1466 BuildInducedSubgraph_Init(ParentList, Father->getAtomCount()); 1432 1467 BuildInducedSubgraph_FillParentList(this, Father, ParentList); 1433 1468 status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList); -
src/molecule_pointcloud.cpp
rc39cc4 rbdb143 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "atom.hpp" 9 11 #include "config.hpp" 12 #include "info.hpp" 10 13 #include "memoryallocator.hpp" 11 14 #include "molecule.hpp" … … 31 34 }; 32 35 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. 35 39 */ 36 TesselPoint *molecule::GetPoint() const40 TesselPoint* molecule::GetPoint() const 37 41 { 38 if ((InternalPointer != start) && (InternalPointer != end)) 39 return InternalPointer; 40 else 41 return NULL; 42 return (*InternalPointer); 42 43 }; 43 44 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. 62 47 */ 63 48 void molecule::GoToNext() const 64 49 { 65 if (InternalPointer != end)66 InternalPointer = InternalPointer->next;50 if (InternalPointer != atoms.end()) 51 InternalPointer++; 67 52 }; 68 53 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. 79 56 */ 80 57 void molecule::GoToFirst() const 81 58 { 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)); 83 65 }; 84 66 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. 94 69 */ 95 70 bool molecule::IsEmpty() const 96 71 { 97 return ( start->next == end);72 return (empty()); 98 73 }; 99 74 100 /** Checks whether we are at the last atom101 * \return true - current atom is last one, false - is not last one75 /** PointCloud implementation of IsLast. 76 * Uses atoms and STL stuff. 102 77 */ 103 78 bool molecule::IsEnd() const 104 79 { 105 return (InternalPointer == end);80 return (InternalPointer == atoms.end()); 106 81 }; 82 83 int molecule::GetMaxId() const { 84 return getAtomCount(); 85 } -
src/molecule_template.hpp
rc39cc4 rbdb143 24 24 template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const 25 25 { 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)(); 30 28 } 31 29 }; 32 30 template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const ) const 33 31 { 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)(); 38 34 } 39 35 }; … … 41 37 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const 42 38 { 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); 47 41 } 48 42 }; 49 43 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const 50 44 { 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); 55 47 } 56 48 }; 57 49 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&), T &t ) const 58 50 { 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); 63 53 } 64 54 }; 65 55 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&) const, T &t ) const 66 56 { 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); 71 59 } 72 60 }; … … 74 62 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const 75 63 { 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); 80 66 } 81 67 }; 82 68 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const 83 69 { 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); 88 72 } 89 73 }; … … 91 75 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const 92 76 { 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); 97 79 } 98 80 }; 99 81 template <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 100 82 { 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); 105 85 } 106 86 }; … … 112 92 { 113 93 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)(); 118 96 } 119 97 return result; … … 122 100 { 123 101 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)(); 128 104 } 129 105 return result; … … 133 109 { 134 110 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); 139 113 } 140 114 return result; … … 143 117 { 144 118 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); 149 121 } 150 122 return result; … … 157 129 template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const 158 130 { 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)); 163 133 } 164 134 }; 165 135 template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const 166 136 { 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)); 171 139 } 172 140 }; … … 177 145 template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const 178 146 { 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)); 183 149 } 184 150 }; 185 151 template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const 186 152 { 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)); 191 155 } 192 156 }; … … 197 161 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const 198 162 { 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)); 204 166 } 205 167 }; 206 168 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const 207 169 { 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)); 213 173 } 214 174 }; 215 175 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const 216 176 { 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)); 222 180 } 223 181 }; 224 182 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) () const ) const 225 183 { 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)); 231 187 } 232 188 }; … … 234 190 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const 235 191 { 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)); 241 195 } 242 196 }; 243 197 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const 244 198 { 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)); 250 202 } 251 203 }; 252 204 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T), T t ) const 253 205 { 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)); 259 209 } 260 210 }; 261 211 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T) const, T t ) const 262 212 { 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)); 268 216 } 269 217 }; … … 271 219 template <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 272 220 { 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)); 278 224 } 279 225 }; 280 226 template <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 281 227 { 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)); 287 231 } 288 232 }; 289 233 template <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 290 234 { 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)); 296 238 } 297 239 }; 298 240 template <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 299 241 { 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)); 305 245 } 306 246 }; … … 308 248 template <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 309 249 { 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)); 315 253 } 316 254 }; 317 255 template <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 318 256 { 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)); 324 260 } 325 261 }; 326 262 template <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 327 263 { 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)); 333 267 } 334 268 }; 335 269 template <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 336 270 { 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)); 342 274 } 343 275 }; … … 348 280 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const 349 281 { 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)(); 354 284 } 355 285 }; 356 286 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const 357 287 { 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)(); 362 290 } 363 291 }; … … 365 293 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const 366 294 { 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); 371 297 } 372 298 }; 373 299 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const 374 300 { 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); 379 303 } 380 304 }; … … 382 306 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const 383 307 { 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); 388 310 } 389 311 }; 390 312 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const 391 313 { 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); 396 316 } 397 317 }; … … 399 319 template <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 400 320 { 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); 405 323 } 406 324 }; 407 325 template <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 408 326 { 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); 413 329 } 414 330 }; … … 416 332 template <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 417 333 { 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); 422 336 } 423 337 }; 424 338 template <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 425 339 { 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); 430 342 } 431 343 }; … … 436 348 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) const 437 349 { 438 atom *Walker = start;439 350 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); 443 353 } 444 354 }; 445 355 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) const 446 356 { 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); 451 359 } 452 360 }; 453 361 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) const 454 362 { 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); 459 365 } 460 366 }; … … 462 368 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) const 463 369 { 464 atom *Walker = start;465 370 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); 469 373 } 470 374 }; 471 375 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) const 472 376 { 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); 477 379 } 478 380 }; 479 381 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) const 480 382 { 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); 485 385 } 486 386 }; … … 488 388 template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value ) const 489 389 { 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); 494 392 } 495 393 }; 496 394 template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value ) const 497 395 { 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); 502 398 } 503 399 }; 504 400 template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const 505 401 { 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); 510 404 } 511 405 }; 512 406 template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const 513 407 { 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); 518 410 } 519 411 }; 520 412 template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const 521 413 { 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; 527 417 } 528 418 }; … … 530 420 template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) const 531 421 { 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; 537 425 } 538 426 }; -
src/moleculelist.cpp
rc39cc4 rbdb143 5 5 */ 6 6 7 #include "Helpers/MemDebug.hpp" 8 7 9 #include <cstring> 8 10 … … 10 12 #include "atom.hpp" 11 13 #include "bond.hpp" 14 #include "bondgraph.hpp" 12 15 #include "boundary.hpp" 13 16 #include "config.hpp" … … 20 23 #include "memoryallocator.hpp" 21 24 #include "periodentafel.hpp" 22 #include "World.hpp" 25 #include "Helpers/Assert.hpp" 26 27 #include "Helpers/Assert.hpp" 23 28 24 29 /*********************************** Functions for class MoleculeListClass *************************/ … … 27 32 */ 28 33 MoleculeListClass::MoleculeListClass(World *_world) : 34 Observable("MoleculeListClass"), 29 35 world(_world) 30 36 { … … 38 44 MoleculeListClass::~MoleculeListClass() 39 45 { 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); 46 49 ListOfMolecules.clear(); // empty list 47 50 }; … … 49 52 /** Insert a new molecule into the list and set its number. 50 53 * \param *mol molecule to add to list. 51 * \return true - add successful52 54 */ 53 55 void MoleculeListClass::insert(molecule *mol) … … 59 61 }; 60 62 63 /** Erases a molecule from the list. 64 * \param *mol molecule to add to list. 65 */ 66 void MoleculeListClass::erase(molecule *mol) 67 { 68 OBSERVE; 69 mol->signOff(this); 70 ListOfMolecules.remove(mol); 71 }; 72 61 73 /** Compare whether two molecules are equal. 62 74 * \param *a molecule one … … 69 81 int Count, Counter, aCounter, bCounter; 70 82 int flag; 71 atom *aWalker = NULL;72 atom *bWalker = NULL;73 83 74 84 // sort each atom list and put the numbers into a list, then go through 75 85 //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()) { 77 92 return -1; 78 93 } else { 79 if ( (**(molecule **) a).AtomCount > (**(molecule **) b).AtomCount)94 if (mol1->getAtomCount() > mol2->getAtomCount()) 80 95 return +1; 81 96 else { 82 Count = (**(molecule **) a).AtomCount;97 Count = mol1->getAtomCount(); 83 98 aList = new int[Count]; 84 99 bList = new int[Count]; 85 100 86 101 // fill the lists 87 aWalker = (**(molecule **) a).start;88 bWalker = (**(molecule **) b).start;89 102 Counter = 0; 90 103 aCounter = 0; 91 104 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) 96 110 aList[Counter] = Count + (aCounter++); 97 111 else 98 aList[Counter] = aWalker->GetTrueFather()->nr;99 if ( bWalker->GetTrueFather() == NULL)112 aList[Counter] = (*aiter)->GetTrueFather()->nr; 113 if ((*biter)->GetTrueFather() == NULL) 100 114 bList[Counter] = Count + (bCounter++); 101 115 else 102 bList[Counter] = bWalker->GetTrueFather()->nr;116 bList[Counter] = (*biter)->GetTrueFather()->nr; 103 117 Counter++; 104 118 } 105 119 // check if AtomCount was for real 106 120 flag = 0; 107 if ((a Walker->next == (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {121 if ((aiter == mol1->end()) && (biter != mol2->end())) { 108 122 flag = -1; 109 123 } else { 110 if ((a Walker->next != (**(molecule **) a).end) && (bWalker->next == (**(molecule **) b).end))124 if ((aiter != mol1->end()) && (biter == mol2->end())) 111 125 flag = 1; 112 126 } … … 142 156 void MoleculeListClass::Enumerate(ostream *out) 143 157 { 144 atom *Walker = NULL;145 158 periodentafel *periode = World::getInstance().getPeriode(); 146 159 std::map<atomicNumber_t,unsigned int> counts; … … 158 171 // count atoms per element and determine size of bounding sphere 159 172 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); 166 177 } 167 178 // 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"; 169 180 170 181 std::map<atomicNumber_t,unsigned int>::reverse_iterator iter; … … 202 213 203 214 // 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; 209 217 srcmol->UnlinkAtom(Walker); 210 218 mol->AddAtom(Walker); … … 228 236 229 237 // 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)); 236 241 Walker->father = Walker; 237 242 } … … 254 259 status = status && SimpleMerge(mol, srcmol); 255 260 } 261 insert(mol); 256 262 return status; 257 263 }; … … 330 336 331 337 // 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++) 335 340 CopyAtoms[i] = NULL; 336 341 337 342 // for each of the source atoms check whether we are in- or outside and add copy atom 338 atom *Walker = srcmol->start;339 343 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]); 346 349 nr++; 347 350 } else { … … 349 352 } 350 353 } 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."); 352 355 353 356 // 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 } 360 363 delete(LCList); 361 364 return true; … … 377 380 * bonded to the same atom, then we add for this pair a correction term constructed from a Morse 378 381 * 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 */ 384 bool MoleculeListClass::AddHydrogenCorrection(std::string &path) 385 { 386 386 bond *Binder = NULL; 387 387 double ***FitConstant = NULL, **correction = NULL; … … 400 400 // 0a. find dimension of matrices with constants 401 401 line = path; 402 line.append("/");403 line += FRAGMENTPREFIX;404 402 line += "1"; 405 403 line += FITCONSTANTSUFFIX; 406 404 input.open(line.c_str()); 407 if (input == NULL) {405 if (input.fail()) { 408 406 DoLog(1) && (Log() << Verbose(1) << endl << "Unable to open " << line << ", is the directory correct?" << endl); 409 407 return false; … … 427 425 428 426 // 0b. allocate memory for constants 429 FitConstant = Calloc<double**>(3, "MoleculeListClass::AddHydrogenCorrection: ***FitConstant");427 FitConstant = new double**[3]; 430 428 for (int k = 0; k < 3; k++) { 431 FitConstant[k] = Calloc<double*>(a, "MoleculeListClass::AddHydrogenCorrection: **FitConstant[]");429 FitConstant[k] = new double*[a]; 432 430 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 } 434 435 } 435 436 } … … 477 478 478 479 // 0d. allocate final correction matrix 479 correction = Calloc<double*>(a, "MoleculeListClass::AddHydrogenCorrection: **correction");480 correction = new double*[a]; 480 481 for (int i = a; i--;) 481 correction[i] = Calloc<double>(b, "MoleculeListClass::AddHydrogenCorrection: *correction[]");482 correction[i] = new double[b]; 482 483 483 484 // 1a. go through every molecule in the list … … 488 489 correction[k][j] = 0.; 489 490 // 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; 500 497 // 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!) 503 500 // 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; 506 503 for (int k = 0; k < a; k++) { 507 504 for (int j = 0; j < b; j++) { … … 531 528 FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), (*ListRunner)->IndexNr); 532 529 line += FragmentNumber; 533 delete (FragmentNumber);530 delete[] (FragmentNumber); 534 531 line += HCORRECTIONSUFFIX; 535 532 output.open(line.c_str()); … … 542 539 output.close(); 543 540 } 541 for (int i = a; i--;) 542 delete[](correction[i]); 543 delete[](correction); 544 544 545 line = path; 545 546 line.append("/"); … … 556 557 for (int k = 0; k < 3; k++) { 557 558 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); 563 564 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 564 565 return true; … … 566 567 567 568 /** 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 570 570 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config 571 571 * \return true - file written successfully, false - writing failed 572 572 */ 573 bool MoleculeListClass::StoreForcesFile(char *path, 574 int *SortIndex) 573 bool MoleculeListClass::StoreForcesFile(std::string &path, int *SortIndex) 575 574 { 576 575 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()); 580 579 periodentafel *periode=World::getInstance().getPeriode(); 581 580 582 581 // open file for the force factors 583 582 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()) { 587 584 //Log() << Verbose(1) << "Final AtomicForcesList: "; 588 585 //output << prefix << "Forces" << endl; … … 590 587 periodentafel::const_iterator elemIter; 591 588 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 598 593 //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"; 600 595 } else 601 596 // otherwise a -1 to indicate an added saturation hydrogen … … 611 606 } else { 612 607 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); 614 609 } 615 610 ForcesFile.close(); … … 620 615 /** Writes a config file for each molecule in the given \a **FragmentList. 621 616 * \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 623 618 * \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't625 * \param DoCentering true - call molecule::CenterEdge(), false - don't626 619 * \return true - success (each file was written), false - something went wrong. 627 620 */ 628 bool MoleculeListClass::OutputConfigForListOfFragments( config *configuration, int *SortIndex)621 bool MoleculeListClass::OutputConfigForListOfFragments(std::string &prefix, int *SortIndex) 629 622 { 630 623 ofstream outputFragment; 631 char FragmentName[MAXSTRINGSIZE];624 std::string FragmentName; 632 625 char PathBackup[MAXSTRINGSIZE]; 633 626 bool result = true; 634 627 bool intermediateResult = true; 635 atom *Walker = NULL;636 628 Vector BoxDimension; 637 629 char *FragmentNumber = NULL; … … 648 640 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) { 649 641 // save default path as it is changed for each fragment 650 path = configuration->GetDefaultPath();642 path = World::getInstance().getConfig()->GetDefaultPath(); 651 643 if (path != NULL) 652 644 strcpy(PathBackup, path); … … 661 653 // output xyz file 662 654 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); 665 657 DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as XYZ ..."); 666 658 if ((intermediateResult = (*ListRunner)->OutputXYZ(&outputFragment))) … … 674 666 // list atoms in fragment for debugging 675 667 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() << " "); 680 670 } 681 671 DoLog(0) && (Log() << Verbose(0) << endl); … … 687 677 for (int k = 0; k < NDIM; k++) { 688 678 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); 690 680 cell_size[j] = BoxDimension[k] * 2.; 691 681 } … … 694 684 // also calculate necessary orbitals 695 685 (*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); 697 687 698 688 // 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()); 702 695 703 696 // and save as config 704 sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);697 FragmentName = prefix + FragmentNumber + ".conf"; 705 698 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)))) 707 700 DoLog(0) && (Log() << Verbose(0) << " done." << endl); 708 701 else … … 711 704 712 705 // restore old config 713 configuration->SetDefaultPath(PathBackup);706 World::getInstance().getConfig()->SetDefaultPath(PathBackup); 714 707 715 708 // and save as mpqc input file 716 sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);709 FragmentName = prefix + FragmentNumber + ".conf"; 717 710 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)))) 719 712 DoLog(2) && (Log() << Verbose(2) << " done." << endl); 720 713 else … … 724 717 //outputFragment.close(); 725 718 //outputFragment.clear(); 726 Free(&FragmentNumber);719 delete[](FragmentNumber); 727 720 } 728 721 DoLog(0) && (Log() << Verbose(0) << " done." << endl); … … 756 749 void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration) 757 750 { 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 758 758 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); 785 764 } 786 765 787 766 // 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); 791 775 return; 792 776 } … … 810 794 const int MolCount = Subgraphs->next->Count(); 811 795 char number[MAXSTRINGSIZE]; 812 molecule **molecules = Malloc<molecule *>(MolCount, "config::Load() - **molecules"); 796 molecule **molecules = new molecule *[MolCount]; 797 MoleculeLeafClass *MolecularWalker = Subgraphs; 813 798 for (int i=0;i<MolCount;i++) { 799 MolecularWalker = MolecularWalker->next; 814 800 molecules[i] = World::getInstance().createMolecule(); 815 801 molecules[i]->ActiveFlag = true; … … 819 805 strncat(molecules[i]->name, number, MAXSTRINGSIZE - strlen(mol->name) - 1); 820 806 } 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 } 822 811 insert(molecules[i]); 823 812 } … … 825 814 // 4b. create and fill map of which atom is associated to which connected molecule (note, counting starts at 1) 826 815 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; 830 818 while (MolecularWalker->next != NULL) { 831 819 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 836 825 } 837 826 FragmentCounter++; 838 827 } 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 858 830 // 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 866 832 // 4e. free Leafs 867 833 MolecularWalker = Subgraphs; … … 871 837 } 872 838 delete(MolecularWalker); 873 Free(&MolMap); 874 Free(&molecules); 839 delete[](molecules); 875 840 DoLog(1) && (Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl); 876 841 }; … … 882 847 int MoleculeListClass::CountAllAtoms() const 883 848 { 884 atom *Walker = NULL;885 849 int AtomNo = 0; 886 850 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(); 892 852 } 893 853 return AtomNo; … … 1064 1024 bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList) 1065 1025 { 1066 atom *Walker = NULL;1067 1026 atom *OtherWalker = NULL; 1068 1027 atom *Father = NULL; … … 1072 1031 DoLog(1) && (Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl); 1073 1032 // fill ListOfLocalAtoms if NULL was given 1074 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference-> AtomCount, FreeList)) {1033 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) { 1075 1034 DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl); 1076 1035 return false; … … 1080 1039 DoLog(1) && (Log() << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl); 1081 1040 // 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(); 1094 1048 AtomNo = Father->nr; // global id of the current walker 1095 1049 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 walker1050 OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker 1097 1051 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); 1100 1054 } 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); 1102 1056 status = false; 1103 1057 } … … 1108 1062 if ((FreeList) && (ListOfLocalAtoms != NULL)) { 1109 1063 // free the index lookup list 1110 Free(&ListOfLocalAtoms[FragmentCounter]);1064 delete[](ListOfLocalAtoms[FragmentCounter]); 1111 1065 if (FragmentCounter == 0) // first fragments frees the initial pointer to list 1112 Free(&ListOfLocalAtoms);1066 delete[](ListOfLocalAtoms); 1113 1067 } 1114 1068 DoLog(1) && (Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl); … … 1126 1080 bool MoleculeLeafClass::FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter) 1127 1081 { 1128 atom * Walker = NULL, *Father = NULL;1082 atom *Father = NULL; 1129 1083 1130 1084 if (RootStack != NULL) { … … 1132 1086 if (&(RootStack[FragmentCounter]) != NULL) { 1133 1087 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(); 1138 1090 if (AtomMask[Father->nr]) // apply mask 1139 1091 #ifdef ADDHYDROGEN 1140 if ( Walker->type->Z != 1) // skip hydrogen1092 if ((*iter)->type->Z != 1) // skip hydrogen 1141 1093 #endif 1142 RootStack[FragmentCounter].push_front( Walker->nr);1094 RootStack[FragmentCounter].push_front((*iter)->nr); 1143 1095 } 1144 1096 if (next != NULL) … … 1171 1123 // allocate and set each field to NULL 1172 1124 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]; 1174 1127 if (ListOfLocalAtoms == NULL) { 1175 1128 FreeList = FreeList && false; 1176 1129 status = false; 1177 1130 } 1131 for (int i=0;i<Counter;i++) 1132 ListOfLocalAtoms[i] = NULL; 1178 1133 } 1179 1134 1180 1135 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); 1182 1137 FreeList = FreeList && true; 1183 1138 } … … 1203 1158 DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl); 1204 1159 // fill ListOfLocalAtoms if NULL was given 1205 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference-> AtomCount, FreeList)) {1160 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) { 1206 1161 DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl); 1207 1162 return false; … … 1211 1166 if (FragmentList == NULL) { 1212 1167 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; 1214 1171 KeySetCounter = 0; 1215 1172 } … … 1245 1202 if ((FreeList) && (ListOfLocalAtoms != NULL)) { 1246 1203 // free the index lookup list 1247 Free(&ListOfLocalAtoms[FragmentCounter]);1204 delete[](ListOfLocalAtoms[FragmentCounter]); 1248 1205 if (FragmentCounter == 0) // first fragments frees the initial pointer to list 1249 Free(&ListOfLocalAtoms);1206 delete[](ListOfLocalAtoms); 1250 1207 } 1251 1208 DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl); -
src/orbitals.db
rc39cc4 rbdb143 1 # atomicnumber numberoforbitals 1 2 1 1 2 3 2 0 -
src/parser.cpp
rc39cc4 rbdb143 6 6 7 7 // ======================================= INCLUDES ========================================== 8 9 #include "Helpers/MemDebug.hpp" 8 10 9 11 #include <cstring> … … 59 61 MatrixContainer::MatrixContainer() { 60 62 Indices = NULL; 61 Header = Malloc<char*>(1, "MatrixContainer::MatrixContainer: **Header");62 Matrix = Malloc<double**>(1, "MatrixContainer::MatrixContainer: ***Matrix"); // one more each for the total molecule63 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]; 65 67 Header[0] = NULL; 66 68 Matrix[0] = NULL; … … 77 79 if ((ColumnCounter != NULL) && (RowCounter != NULL)) { 78 80 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]); 81 83 } 82 84 } 83 85 if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL)) 84 86 for(int j=RowCounter[MatrixCounter]+1;j--;) 85 Free(&Matrix[MatrixCounter][j]);87 delete[](Matrix[MatrixCounter][j]); 86 88 if (MatrixCounter != 0) 87 Free(&Matrix[MatrixCounter]);88 Free(&Matrix);89 delete[](Matrix[MatrixCounter]); 90 delete[](Matrix); 89 91 } 90 92 if (Indices != NULL) 91 93 for(int i=MatrixCounter+1;i--;) { 92 Free(&Indices[i]);93 } 94 Free(&Indices);94 delete[](Indices[i]); 95 } 96 delete[](Indices); 95 97 96 98 if (Header != NULL) 97 99 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); 102 104 }; 103 105 … … 112 114 if (Matrix == NULL) { 113 115 DoLog(0) && (Log() << Verbose(0) << " with trivial mapping." << endl); 114 Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices");116 Indices = new int*[MatrixCounter + 1]; 115 117 for(int i=MatrixCounter+1;i--;) { 116 Indices[i] = Malloc<int>(RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");118 Indices[i] = new int[RowCounter[i]]; 117 119 for(int j=RowCounter[i];j--;) 118 120 Indices[i][j] = j; … … 122 124 if (MatrixCounter != Matrix->MatrixCounter) 123 125 return false; 124 Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices");126 Indices = new int*[MatrixCounter + 1]; 125 127 for(int i=MatrixCounter+1;i--;) { 126 128 if (RowCounter[i] != Matrix->RowCounter[i]) 127 129 return false; 128 Indices[i] = Malloc<int>(Matrix->RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");130 Indices[i] = new int[Matrix->RowCounter[i]]; 129 131 for(int j=Matrix->RowCounter[i];j--;) { 130 132 Indices[i][j] = Matrix->Indices[i][j]; … … 166 168 167 169 // parse header 168 Header[MatrixNr] = Malloc<char>(1024, "MatrixContainer::ParseMatrix: *Header[]");170 Header[MatrixNr] = new char[1024]; 169 171 for (int m=skiplines+1;m--;) 170 172 input.getline(Header[MatrixNr], 1023); … … 205 207 // allocate matrix if it's not zero dimension in one direction 206 208 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]; 208 210 209 211 // parse in each entry for this matrix … … 217 219 strncpy(Header[MatrixNr], line.str().c_str(), 1023); 218 220 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]]; 220 222 input.getline(filename, 1023); 221 223 stringstream lines(filename); … … 227 229 //Log() << Verbose(1) << " " << setprecision(2) << Matrix[MatrixNr][j][k] << endl; 228 230 } 229 Matrix[MatrixNr][ RowCounter[MatrixNr] ] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[RowCounter[MatrixNr]][]");231 Matrix[MatrixNr][ RowCounter[MatrixNr] ] = new double[ColumnCounter[MatrixNr]]; 230 232 for(int j=ColumnCounter[MatrixNr];j--;) 231 233 Matrix[MatrixNr][ RowCounter[MatrixNr] ][j] = 0.; … … 281 283 282 284 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]; 287 293 for(int i=MatrixCounter+1;i--;) { 288 294 Matrix[i] = NULL; … … 298 304 if (!ParseMatrix(file.str().c_str(), skiplines, skipcolumns, i)) 299 305 return false; 300 Free(&FragmentNumber);306 delete[](FragmentNumber); 301 307 } 302 308 return true; … … 313 319 { 314 320 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 molecule317 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]; 319 325 for(int i=MatrixCounter+1;i--;) { 320 Header[i] = Malloc<char>(1024, "MatrixContainer::AllocateMatrix: *Header[i]");326 Header[i] = new char[1024]; 321 327 strncpy(Header[i], GivenHeader[i], 1023); 322 328 RowCounter[i] = RCounter[i]; 323 329 ColumnCounter[i] = CCounter[i]; 324 Matrix[i] = Malloc<double*>(RowCounter[i] + 1, "MatrixContainer::AllocateMatrix: **Matrix[]");330 Matrix[i] = new double*[RowCounter[i] + 1]; 325 331 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]]; 327 333 for(int k=ColumnCounter[i];k--;) 328 334 Matrix[i][j][k] = 0.; … … 474 480 FragmentNumber = FixedDigitNumber(MatrixCounter, i); 475 481 line << name << FRAGMENTPREFIX << FragmentNumber << "/" << prefix; 476 Free(&FragmentNumber);482 delete[](FragmentNumber); 477 483 output.open(line.str().c_str(), ios::out); 478 484 if (output == NULL) { … … 530 536 { 531 537 DoLog(0) && (Log() << Verbose(0) << "Parsing energy indices." << endl); 532 Indices = Malloc<int*>(MatrixCounter + 1, "EnergyMatrix::ParseIndices: **Indices");538 Indices = new int*[MatrixCounter + 1]; 533 539 for(int i=MatrixCounter+1;i--;) { 534 Indices[i] = Malloc<int>(RowCounter[i], "EnergyMatrix::ParseIndices: *Indices[]");540 Indices[i] = new int[RowCounter[i]]; 535 541 for(int j=RowCounter[i];j--;) 536 542 Indices[i][j] = j; … … 589 595 // allocate last plus one matrix 590 596 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]; 592 598 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]]; 594 600 595 601 // try independently to parse global energysuffix file if present … … 616 622 617 623 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]; 619 625 line << name << FRAGMENTPREFIX << FORCESFILE; 620 626 input.open(line.str().c_str(), ios::in); … … 629 635 line.str(filename); 630 636 // parse the values 631 Indices[i] = Malloc<int>(RowCounter[i], "ForceMatrix::ParseIndices: *Indices[]");637 Indices[i] = new int[RowCounter[i]]; 632 638 FragmentNumber = FixedDigitNumber(MatrixCounter, i); 633 639 //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:"; 634 Free(&FragmentNumber);640 delete[](FragmentNumber); 635 641 for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) { 636 642 line >> Indices[i][j]; … … 639 645 //Log() << Verbose(0) << endl; 640 646 } 641 Indices[MatrixCounter] = Malloc<int>(RowCounter[MatrixCounter], "ForceMatrix::ParseIndices: *Indices[]");647 Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]]; 642 648 for(int j=RowCounter[MatrixCounter];j--;) { 643 649 Indices[MatrixCounter][j] = j; … … 725 731 // allocate last plus one matrix 726 732 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]; 728 734 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]]; 730 736 731 737 // try independently to parse global forcesuffix file if present … … 754 760 755 761 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]; 757 763 line << name << FRAGMENTPREFIX << FORCESFILE; 758 764 input.open(line.str().c_str(), ios::in); … … 767 773 line.str(filename); 768 774 // parse the values 769 Indices[i] = Malloc<int>(RowCounter[i], "HessianMatrix::ParseIndices: *Indices[]");775 Indices[i] = new int[RowCounter[i]]; 770 776 FragmentNumber = FixedDigitNumber(MatrixCounter, i); 771 777 //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:"; 772 Free(&FragmentNumber);778 delete[](FragmentNumber); 773 779 for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) { 774 780 line >> Indices[i][j]; … … 777 783 //Log() << Verbose(0) << endl; 778 784 } 779 Indices[MatrixCounter] = Malloc<int>(RowCounter[MatrixCounter], "HessianMatrix::ParseIndices: *Indices[]");785 Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]]; 780 786 for(int j=RowCounter[MatrixCounter];j--;) { 781 787 Indices[MatrixCounter][j] = j; … … 953 959 // allocate last plus one matrix 954 960 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]; 956 962 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]]; 958 964 959 965 // try independently to parse global forcesuffix file if present … … 985 991 KeySetsContainer::~KeySetsContainer() { 986 992 for(int i=FragmentCounter;i--;) 987 Free(&KeySets[i]);993 delete[](KeySets[i]); 988 994 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); 994 1000 }; 995 1001 … … 1008 1014 FragmentCounter = FCounter; 1009 1015 DoLog(0) && (Log() << Verbose(0) << "Parsing key sets." << endl); 1010 KeySets = Malloc<int*>(FragmentCounter, "KeySetsContainer::ParseKeySets: **KeySets");1016 KeySets = new int*[FragmentCounter]; 1011 1017 for(int i=FragmentCounter;i--;) 1012 1018 KeySets[i] = NULL; … … 1018 1024 } 1019 1025 1020 AtomCounter = Malloc<int>(FragmentCounter, "KeySetsContainer::ParseKeySets: *RowCounter");1026 AtomCounter = new int[FragmentCounter]; 1021 1027 for(int i=0;(i<FragmentCounter) && (!input.eof());i++) { 1022 1028 stringstream line; 1023 1029 AtomCounter[i] = ACounter[i]; 1024 1030 // parse the values 1025 KeySets[i] = Malloc<int>(AtomCounter[i], "KeySetsContainer::ParseKeySets: *KeySets[]");1031 KeySets[i] = new int[AtomCounter[i]]; 1026 1032 for(int j=AtomCounter[i];j--;) 1027 1033 KeySets[i][j] = -1; 1028 1034 FragmentNumber = FixedDigitNumber(FragmentCounter, i); 1029 1035 //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << AtomCounter[i] << "]:"; 1030 Free(&FragmentNumber);1036 delete[](FragmentNumber); 1031 1037 input.getline(filename, 1023); 1032 1038 line.str(filename); … … 1062 1068 1063 1069 // scan through all to determine fragments per order 1064 FragmentsPerOrder = Malloc<int>(Order, "KeySetsContainer::ParseManyBodyTerms: *FragmentsPerOrder");1070 FragmentsPerOrder = new int[Order]; 1065 1071 for(int i=Order;i--;) 1066 1072 FragmentsPerOrder[i] = 0; … … 1076 1082 1077 1083 // scan through all to gather indices to each order set 1078 OrderSet = Malloc<int*>(Order, "KeySetsContainer::ParseManyBodyTerms: **OrderSet");1084 OrderSet = new int*[Order]; 1079 1085 for(int i=Order;i--;) 1080 OrderSet[i] = Malloc<int>(FragmentsPerOrder[i], "KeySetsContainer::ParseManyBodyTermsKeySetsContainer::ParseManyBodyTerms: *OrderSet[]");1086 OrderSet[i] = new int[FragmentsPerOrder[i]]; 1081 1087 for(int i=Order;i--;) 1082 1088 FragmentsPerOrder[i] = 0; -
src/periodentafel.cpp
rc39cc4 rbdb143 5 5 */ 6 6 7 #include "Helpers/MemDebug.hpp" 8 7 9 using namespace std; 8 10 9 11 #include <iomanip> 12 #include <iostream> 10 13 #include <fstream> 11 14 #include <cstring> 12 #include <cassert> 13 15 16 #include "Helpers/Assert.hpp" 14 17 #include "element.hpp" 18 #include "elements_db.hpp" 15 19 #include "helpers.hpp" 16 20 #include "lists.hpp" … … 27 31 */ 28 32 periodentafel::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 }; 30 60 31 61 /** destructor for class periodentafel 32 62 * Removes every element and afterwards deletes start and end of list. 63 * TODO: Handle when elements have changed and store databases then 33 64 */ 34 65 periodentafel::~periodentafel() … … 39 70 /** Adds element to period table list 40 71 * \param *pointer element to be added 41 * \return true - succeeded, false - does not occur72 * \return iterator to added element 42 73 */ 43 74 periodentafel::iterator periodentafel::AddElement(element * const pointer) 44 75 { 45 76 atomicNumber_t Z = pointer->getNumber(); 46 assert(!elements.count(Z));77 ASSERT(!elements.count(Z), "Element is already present."); 47 78 pointer->sort = &pointer->Z; 48 79 if (pointer->getNumber() < 1 && pointer->getNumber() >= MAX_ELEMENTS) … … 54 85 /** Removes element from list. 55 86 * \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 */ 88 size_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 */ 96 size_t periodentafel::RemoveElement(atomicNumber_t Z) 97 { 98 return elements.erase(Z); 62 99 }; 63 100 64 101 /** Removes every element from the period table. 65 * \return true - succeeded, false - does not occur66 102 */ 67 103 void periodentafel::CleanupPeriodtable() … … 78 114 * \return pointer to element or NULL if not found 79 115 */ 80 const element *periodentafel::FindElement(atomicNumber_t Z) const116 element * const periodentafel::FindElement(atomicNumber_t Z) const 81 117 { 82 118 const_iterator res = elements.find(Z); … … 89 125 * \return pointer to element 90 126 */ 91 const element *periodentafel::FindElement(const char * const shorthand) const127 element * const periodentafel::FindElement(const char * const shorthand) const 92 128 { 93 129 element *res = 0; … … 102 138 103 139 /** 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 */ 142 element * const periodentafel::AskElement() const 143 { 144 element * walker = NULL; 108 145 int Z; 109 146 do { … … 118 155 * \return pointer to either present or newly created element 119 156 */ 120 const element * periodentafel::EnterElement() 121 { 122 const element *res = NULL; 157 element * const periodentafel::EnterElement() 158 { 123 159 atomicNumber_t Z = 0; 124 160 DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl); 125 161 cin >> Z; 126 res = FindElement(Z);162 element * const res = FindElement(Z); 127 163 if (!res) { 128 164 // TODO: make this using the constructor 129 element *tmp;130 165 DoLog(0) && (Log() << Verbose(0) << "Element not found in database, please enter." << endl); 131 tmp = new element;166 element *tmp = new element; 132 167 tmp->Z = Z; 133 168 DoLog(0) && (Log() << Verbose(0) << "Mass: " << endl); … … 138 173 cin >> tmp->symbol; 139 174 AddElement(tmp); 140 re s =tmp;175 return tmp; 141 176 } 142 177 return res; … … 204 239 bool periodentafel::LoadPeriodentafel(const char *path) 205 240 { 206 ifstream infile; 207 element *ptr; 208 map<atomicNumber_t,element*> parsedElems; 241 ifstream input; 209 242 bool status = true; 210 243 bool otherstatus = true; … … 212 245 213 246 // 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 */ 312 bool 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 219 320 DoLog(0) && (Log() << Verbose(0) << "Parsed elements:"); 220 while (! infile.eof()) {321 while (!(*input).eof()) { 221 322 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; 242 342 //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) << " <?>"); 248 360 delete(neues); 249 361 } 250 362 } 251 363 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); 255 366 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 */ 379 bool periodentafel::LoadValenceDatabase(istream *input) 380 { 381 char dummy[MAXSTRINGSIZE]; 382 if (!(*input).fail()) { 383 (*input).getline(dummy, MAXSTRINGSIZE); 384 while (!(*input).eof()) { 262 385 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 */ 402 bool periodentafel::LoadOrbitalsDatabase(istream *input) 403 { 404 char dummy[MAXSTRINGSIZE]; 405 if (!(*input).fail()) { 406 (*input).getline(dummy, MAXSTRINGSIZE); 407 while (!(*input).eof()) { 279 408 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 */ 425 bool periodentafel::LoadHBondAngleDatabase(istream *input) 426 { 427 char dummy[MAXSTRINGSIZE]; 428 if (!(*input).fail()) { 429 (*input).getline(dummy, MAXSTRINGSIZE); 430 while (!(*input).eof()) { 296 431 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 */ 450 bool 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; 304 464 //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl; 305 465 } 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 } 346 470 347 471 /** Stores element list to file. … … 353 477 char filename[MAXSTRINGSIZE]; 354 478 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)); 356 482 f.open(filename); 357 483 if (f != NULL) { … … 362 488 } 363 489 f.close(); 364 } else365 result = false;366 return result;367 }; 490 return true; 491 } else 492 return result; 493 }; -
src/periodentafel.hpp
rc39cc4 rbdb143 13 13 #include <iterator> 14 14 15 #include "unittests/periodentafelTest.hpp" 15 16 #include "defs.hpp" 16 17 #include "types.hpp" … … 27 28 class periodentafel { 28 29 /******* Types *********/ 30 friend class periodentafelTest; 29 31 private: 30 32 typedef std::map<atomicNumber_t,element*> elementSet; … … 42 44 43 45 iterator AddElement(element * const pointer); 44 void RemoveElement(element * const pointer); 46 size_t RemoveElement(element * const pointer); 47 size_t RemoveElement(atomicNumber_t); 45 48 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(); 50 53 51 54 const_iterator begin(); … … 59 62 60 63 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 61 71 elementSet elements; 62 72 }; -
src/stackclass.hpp
rc39cc4 rbdb143 50 50 template <typename T> StackClass<T>::StackClass(int dimension) : StackList(NULL), EntryCount(dimension), CurrentLastEntry(0), CurrentFirstEntry(0), NextFreeField(0) 51 51 { 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; 53 55 }; 54 56 … … 57 59 template <typename T> StackClass<T>::~StackClass() 58 60 { 59 Free(&StackList);61 delete[](StackList); 60 62 }; 61 63 -
src/tesselation.cpp
rc39cc4 rbdb143 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include <fstream> 9 #include <assert.h>10 11 11 12 #include "helpers.hpp" … … 387 388 // get ascending order of endpoints 388 389 PointMap OrderMap; 389 for (int i = 0; i < 3; i++) 390 for (int i = 0; i < 3; i++) { 390 391 // for all three lines 391 392 for (int j = 0; j < 2; j++) { // for both endpoints … … 393 394 // and we don't care whether insertion fails 394 395 } 396 } 395 397 // set endpoints 396 398 int Counter = 0; … … 401 403 Counter++; 402 404 } 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 409 408 410 409 /** Destructor of BoundaryTriangleSet. … … 1272 1271 ; 1273 1272 1274 /** PointCloud implementation of GetTerminalPoint.1275 * Uses PointsOnBoundary and STL stuff.1276 */1277 TesselPoint * Tesselation::GetTerminalPoint() const1278 {1279 Info FunctionInfo(__func__);1280 PointMap::const_iterator Runner = PointsOnBoundary.end();1281 Runner--;1282 return (Runner->second->node);1283 }1284 ;1285 1286 1273 /** PointCloud implementation of GoToNext. 1287 1274 * Uses PointsOnBoundary and STL stuff. … … 1295 1282 ; 1296 1283 1297 /** PointCloud implementation of GoToPrevious.1298 * Uses PointsOnBoundary and STL stuff.1299 */1300 void Tesselation::GoToPrevious() const1301 {1302 Info FunctionInfo(__func__);1303 if (InternalPointer != PointsOnBoundary.begin())1304 InternalPointer--;1305 }1306 ;1307 1308 1284 /** PointCloud implementation of GoToFirst. 1309 1285 * Uses PointsOnBoundary and STL stuff. … … 1313 1289 Info FunctionInfo(__func__); 1314 1290 InternalPointer = PointsOnBoundary.begin(); 1315 }1316 ;1317 1318 /** PointCloud implementation of GoToLast.1319 * Uses PointsOnBoundary and STL stuff.1320 */1321 void Tesselation::GoToLast() const1322 {1323 Info FunctionInfo(__func__);1324 InternalPointer = PointsOnBoundary.end();1325 InternalPointer--;1326 1291 } 1327 1292 ; … … 1996 1961 RemoveTesselationLine(triangle->lines[i]); 1997 1962 } 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); 1999 1964 OpenLines.insert(pair<BoundaryLineSet *, CandidateForTesselation *> (triangle->lines[i], NULL)); 2000 1965 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"); 2002 1967 DoLog(0) && (Log() << Verbose(0) << endl); 2003 1968 // for (int j=0;j<2;j++) { … … 2606 2571 baseline = Runner->second; 2607 2572 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"); 2609 2574 T = (((baseline->BaseLine->triangles.begin()))->second); 2610 2575 DoLog(1) && (Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl); … … 2633 2598 // fill the set of neighbours 2634 2599 TesselPointSet SetOfNeighbours; 2600 2635 2601 SetOfNeighbours.insert(CandidateLine.BaseLine->endpoints[1]->node); 2636 2602 for (TesselPointList::iterator Runner = CandidateLine.pointlist.begin(); Runner != CandidateLine.pointlist.end(); Runner++) … … 3052 3018 OldBaseLineNr = Base->Nr; 3053 3019 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); 3058 3030 } 3059 3031 -
src/tesselation.hpp
rc39cc4 rbdb143 247 247 virtual Vector *GetCenter() const { return NULL; }; 248 248 virtual TesselPoint *GetPoint() const { return NULL; }; 249 virtual TesselPoint *GetTerminalPoint() const { return NULL; };250 249 virtual int GetMaxId() const { return 0; }; 251 250 virtual void GoToNext() const {}; 252 virtual void GoToPrevious() const {};253 251 virtual void GoToFirst() const {}; 254 virtual void GoToLast() const {};255 252 virtual bool IsEmpty() const { return true; }; 256 253 virtual bool IsEnd() const { return true; }; … … 366 363 virtual Vector *GetCenter(ofstream *out) const; 367 364 virtual TesselPoint *GetPoint() const; 368 virtual TesselPoint *GetTerminalPoint() const;369 365 virtual void GoToNext() const; 370 virtual void GoToPrevious() const;371 366 virtual void GoToFirst() const; 372 virtual void GoToLast() const;373 367 virtual bool IsEmpty() const; 374 368 virtual bool IsEnd() const; -
src/tesselationhelpers.cpp
rc39cc4 rbdb143 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include <fstream> … … 844 846 Walker = cloud->GetPoint(); 845 847 *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 } 848 852 *rasterfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour 849 853 cloud->GoToNext(); … … 855 859 *rasterfile << "1" << endl << " "; // 1 is triangle type 856 860 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 } 859 865 *rasterfile << "\t"; 860 866 } … … 895 901 } 896 902 *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++){ 900 906 LookupList[i] = -1; 907 } 901 908 902 909 // print atom coordinates 903 910 int Counter = 1; 904 911 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) { 906 913 Walker = target->second->node; 907 914 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; 909 920 } 910 921 *tecplot << endl; -
src/triangleintersectionlist.cpp
rc39cc4 rbdb143 8 8 * Author: heber 9 9 */ 10 11 #include "Helpers/MemDebug.hpp" 10 12 11 13 #include "triangleintersectionlist.hpp" -
src/unittests/ActOnAllUnitTest.cpp
rc39cc4 rbdb143 46 46 // Ref was copy constructed, hence has to be cleaned, too! 47 47 Ref.EmptyList(); 48 MemoryUsageObserver::purgeInstance();49 48 }; 50 49 … … 77 76 78 77 // 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]; 81 80 for (int i=0;i<NDIM;++i) { 82 81 factors[i] = 2.; … … 88 87 VL.ActOnAll<Vector,void,const double*>(&Vector::ScaleAll, inverses ); 89 88 CPPUNIT_ASSERT_EQUAL( VL == Ref , true ); 90 Free(factors);91 Free(inverses);89 delete[](factors); 90 delete[](inverses); 92 91 }; 93 92 -
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
rc39cc4 rbdb143 17 17 #include "AnalysisCorrelationToPointUnitTest.hpp" 18 18 19 #include "World.hpp"20 19 #include "atom.hpp" 21 #include "boundary.hpp"22 20 #include "element.hpp" 23 21 #include "molecule.hpp" 24 22 #include "linkedcell.hpp" 25 23 #include "periodentafel.hpp" 26 #include "tesselation.hpp"27 24 #include "World.hpp" 28 25 … … 43 40 TestList = NULL; 44 41 TestMolecule = NULL; 45 hydrogen = NULL;46 tafel = NULL;47 42 pointmap = NULL; 48 43 binmap = NULL; 49 44 point = NULL; 50 45 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); 62 51 // construct molecule (tetraeder of hydrogens) 63 52 TestMolecule = World::getInstance().createMolecule(); … … 80 69 81 70 // check that TestMolecule was correctly constructed 82 CPPUNIT_ASSERT_EQUAL( TestMolecule-> AtomCount, 4 );71 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 83 72 84 73 TestList = World::getInstance().getMolecules(); … … 90 79 91 80 // 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 ); 93 82 binmap = NULL; 94 83 … … 105 94 delete(point); 106 95 World::purgeInstance(); 107 MemoryUsageObserver::purgeInstance();108 96 logger::purgeInstance(); 109 97 }; -
src/unittests/AnalysisCorrelationToPointUnitTest.hpp
rc39cc4 rbdb143 12 12 13 13 class element; 14 class LinkedCell;15 14 class molecule; 16 15 class MoleculeListClass; 17 class periodentafel;18 class Tesselation;19 16 class Vector; 20 17 … … 41 38 molecule *TestMolecule; 42 39 element *hydrogen; 43 periodentafel *tafel;44 40 45 41 CorrelationToPointMap *pointmap; -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
rc39cc4 rbdb143 17 17 #include "AnalysisCorrelationToSurfaceUnitTest.hpp" 18 18 19 #include "World.hpp"20 19 #include "atom.hpp" 21 20 #include "boundary.hpp" … … 26 25 #include "tesselation.hpp" 27 26 #include "World.hpp" 27 #include "Helpers/Assert.hpp" 28 28 29 29 #include "Helpers/Assert.hpp" … … 40 40 void AnalysisCorrelationToSurfaceUnitTest::setUp() 41 41 { 42 //ASSERT_DO(Assert::Throw);42 ASSERT_DO(Assert::Throw); 43 43 44 44 atom *Walker = NULL; … … 47 47 TestList = NULL; 48 48 TestSurfaceMolecule = NULL; 49 hydrogen = NULL;50 tafel = NULL;51 49 surfacemap = NULL; 52 50 binmap = NULL; … … 54 52 LC = NULL; 55 53 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(); 70 58 71 59 // construct molecule (tetraeder of hydrogens) base 72 60 TestSurfaceMolecule = World::getInstance().createMolecule(); 61 73 62 Walker = World::getInstance().createAtom(); 74 63 Walker->type = hydrogen; 75 64 *Walker->node = Vector(1., 0., 1. ); 76 77 TestSurfaceMolecule->AddAtom(Walker); 65 TestSurfaceMolecule->AddAtom(Walker); 66 78 67 Walker = World::getInstance().createAtom(); 79 68 Walker->type = hydrogen; 80 69 *Walker->node = Vector(0., 1., 1. ); 81 70 TestSurfaceMolecule->AddAtom(Walker); 71 82 72 Walker = World::getInstance().createAtom(); 83 73 Walker->type = hydrogen; 84 74 *Walker->node = Vector(1., 1., 0. ); 85 75 TestSurfaceMolecule->AddAtom(Walker); 76 86 77 Walker = World::getInstance().createAtom(); 87 78 Walker->type = hydrogen; … … 90 81 91 82 // check that TestMolecule was correctly constructed 92 CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule-> AtomCount, 4 );83 CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->getAtomCount(), 4 ); 93 84 94 85 TestList = World::getInstance().getMolecules(); … … 102 93 103 94 // add outer atoms 95 carbon = World::getInstance().getPeriode()->FindElement(6); 104 96 TestSurfaceMolecule = World::getInstance().createMolecule(); 105 97 Walker = World::getInstance().createAtom(); … … 107 99 *Walker->node = Vector(4., 0., 4. ); 108 100 TestSurfaceMolecule->AddAtom(Walker); 101 109 102 Walker = World::getInstance().createAtom(); 110 103 Walker->type = carbon; 111 104 *Walker->node = Vector(0., 4., 4. ); 112 105 TestSurfaceMolecule->AddAtom(Walker); 106 113 107 Walker = World::getInstance().createAtom(); 114 108 Walker->type = carbon; 115 109 *Walker->node = Vector(4., 4., 0. ); 116 110 TestSurfaceMolecule->AddAtom(Walker); 111 117 112 // add inner atoms 118 113 Walker = World::getInstance().createAtom(); … … 120 115 *Walker->node = Vector(0.5, 0.5, 0.5 ); 121 116 TestSurfaceMolecule->AddAtom(Walker); 117 122 118 TestSurfaceMolecule->ActiveFlag = true; 123 119 TestList->insert(TestSurfaceMolecule); … … 141 137 delete(LC); 142 138 World::purgeInstance(); 143 MemoryUsageObserver::purgeInstance();144 139 logger::purgeInstance(); 145 140 }; … … 150 145 void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest() 151 146 { 152 CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule-> AtomCount);147 CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->getAtomCount() ); 153 148 CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() ); 154 149 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() ); … … 160 155 { 161 156 // do the pair correlation 162 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 157 elements.push_back(hydrogen); 158 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC ); 163 159 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 164 160 CPPUNIT_ASSERT( surfacemap != NULL ); … … 169 165 { 170 166 BinPairMap::iterator tester; 171 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 167 elements.push_back(hydrogen); 168 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC ); 172 169 // put pair correlation into bins and check with no range 173 170 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); … … 184 181 { 185 182 BinPairMap::iterator tester; 186 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 183 elements.push_back(hydrogen); 184 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC ); 187 185 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 188 186 // ... and check with [0., 2.] range … … 202 200 { 203 201 BinPairMap::iterator tester; 204 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC ); 202 elements.push_back(carbon); 203 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC ); 205 204 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 206 205 // put pair correlation into bins and check with no range … … 221 220 { 222 221 BinPairMap::iterator tester; 223 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC ); 222 elements.push_back(carbon); 223 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC ); 224 224 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 225 225 // ... and check with [0., 2.] range -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp
rc39cc4 rbdb143 47 47 element *hydrogen; 48 48 element *carbon; 49 periodentafel *tafel;49 std::vector<element *> elements; 50 50 51 51 CorrelationToSurfaceMap *surfacemap; -
src/unittests/AnalysisPairCorrelationUnitTest.cpp
rc39cc4 rbdb143 44 44 TestList = NULL; 45 45 TestMolecule = NULL; 46 hydrogen = NULL;47 tafel = NULL;48 46 correlationmap = NULL; 49 47 binmap = NULL; 50 48 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); 60 55 61 56 // construct molecule (tetraeder of hydrogens) … … 79 74 80 75 // check that TestMolecule was correctly constructed 81 CPPUNIT_ASSERT_EQUAL( TestMolecule-> AtomCount, 4 );76 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 82 77 83 78 TestList = World::getInstance().getMolecules(); … … 86 81 87 82 // init maps 88 correlationmap = PairCorrelation( TestList, hydrogen, hydrogen);83 correlationmap = PairCorrelation( TestList, elements); 89 84 binmap = NULL; 90 85 … … 101 96 // note that all the atoms are cleaned by TestMolecule 102 97 World::purgeInstance(); 103 MemoryUsageObserver::purgeInstance();104 98 logger::purgeInstance(); 105 99 errorLogger::purgeInstance(); -
src/unittests/AnalysisPairCorrelationUnitTest.hpp
rc39cc4 rbdb143 12 12 13 13 class element; 14 class LinkedCell;15 14 class molecule; 16 15 class MoleculeListClass; 17 class periodentafel;18 class Tesselation;19 16 class Vector; 20 17 … … 41 38 molecule *TestMolecule; 42 39 element *hydrogen; 43 periodentafel *tafel;44 40 45 41 PairCorrelationMap *correlationmap; -
src/unittests/CacheableTest.cpp
rc39cc4 rbdb143 55 55 56 56 threeNumbers(int _x,int _y, int _z) : 57 Observable("threeNumbers"), 57 58 x(_x),y(_y),z(_z), 58 sum(this,boost::bind(&threeNumbers::calcSum,this) ),59 sum(this,boost::bind(&threeNumbers::calcSum,this),"sum"), 59 60 hasRecalced(false) 60 61 {} … … 81 82 CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum)); 82 83 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 83 91 } -
src/unittests/CountBondsUnitTest.cpp
rc39cc4 rbdb143 16 16 #include <stdio.h> 17 17 #include <cstring> 18 19 #include "Helpers/Assert.hpp" 18 20 19 21 #include "analysis_bonds.hpp" … … 40 42 { 41 43 atom *Walker = NULL; 42 BG = NULL;43 filename = NULL;44 45 // init private all pointers to zero46 molecules = NULL;47 TestMolecule1 = NULL;48 TestMolecule2 = NULL;49 hydrogen = NULL;50 oxygen = NULL;51 tafel = NULL;52 44 53 45 // 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"); 69 50 70 51 // construct molecule (water molecule) 71 52 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"); 73 56 Walker->type = hydrogen; 74 57 *Walker->node = Vector(-0.2418, 0.9350, 0. ); 75 58 TestMolecule1->AddAtom(Walker); 76 59 Walker = World::getInstance().createAtom(); 60 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 77 61 Walker->type = hydrogen; 78 62 *Walker->node = Vector(0.9658, 0., 0. ); 79 63 TestMolecule1->AddAtom(Walker); 80 64 Walker = World::getInstance().createAtom(); 65 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 81 66 Walker->type = oxygen; 82 67 *Walker->node = Vector(0., 0., 0. ); … … 84 69 85 70 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"); 87 74 Walker->type = hydrogen; 88 75 *Walker->node = Vector(-0.2418, 0.9350, 0. ); 89 76 TestMolecule2->AddAtom(Walker); 90 77 Walker = World::getInstance().createAtom(); 78 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 91 79 Walker->type = hydrogen; 92 80 *Walker->node = Vector(0.9658, 0., 0. ); 93 81 TestMolecule2->AddAtom(Walker); 94 82 Walker = World::getInstance().createAtom(); 83 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 95 84 Walker->type = oxygen; 96 85 *Walker->node = Vector(0., 0., 0. ); … … 98 87 99 88 molecules = World::getInstance().getMolecules(); 89 CPPUNIT_ASSERT(molecules != NULL && "could not obtain list of molecules"); 100 90 molecules->insert(TestMolecule1); 101 91 molecules->insert(TestMolecule2); 102 92 103 93 // 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 ); 110 96 111 97 // create a small file with table 112 98 BG = new BondGraph(true); 99 CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph"); 113 100 114 101 // construct bond graphs … … 126 113 127 114 World::purgeInstance(); 128 MemoryUsageObserver::purgeInstance();129 115 }; 130 116 … … 158 144 { 159 145 double *mirror = new double[3]; 146 CPPUNIT_ASSERT(mirror != NULL && "could not create array of doubles"); 160 147 for (int i=0;i<3;i++) 161 148 mirror[i] = -1.; -
src/unittests/CountBondsUnitTest.hpp
rc39cc4 rbdb143 39 39 molecule *TestMolecule1; 40 40 molecule *TestMolecule2; 41 element *hydrogen; 42 element *oxygen; 43 periodentafel *tafel; 41 const element *hydrogen; 42 const element *oxygen; 44 43 45 44 BondGraph *BG; -
src/unittests/LinkedCellUnitTest.cpp
rc39cc4 rbdb143 38 38 atom *Walker = NULL; 39 39 40 // init private all pointers to zero41 TestMolecule = NULL;42 hydrogen = NULL;43 tafel = NULL;44 45 40 // 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"); 55 43 56 44 // construct molecule (water molecule) 57 45 TestMolecule = World::getInstance().createMolecule(); 46 CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule"); 58 47 for (double x=0.5;x<3;x+=1.) 59 48 for (double y=0.5;y<3;y+=1.) 60 49 for (double z=0.5;z<3;z+=1.) { 61 50 Walker = World::getInstance().createAtom(); 51 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 62 52 Walker->type = hydrogen; 63 53 *Walker->node = Vector(x, y, z ); … … 67 57 // construct linked cell 68 58 LC = new LinkedCell (TestMolecule, 1.); 59 CPPUNIT_ASSERT(LC != NULL && "could not create LinkedCell"); 69 60 70 61 // 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 ); 74 63 }; 75 64 … … 79 68 delete(LC); 80 69 World::purgeInstance(); 81 MemoryUsageObserver::purgeInstance();82 70 }; 83 71 … … 197 185 { 198 186 // 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) ); 203 189 } 204 190 205 191 // 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); 211 197 212 198 // 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); 218 204 }; 219 205 … … 278 264 Vector tester; 279 265 LinkedCell::LinkedNodes *ListOfPoints = NULL; 280 atom *Walker = NULL;281 266 size_t size = 0; 282 267 … … 287 272 size = ListOfPoints->size(); 288 273 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)); 294 277 size--; 295 278 CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); … … 306 289 size=ListOfPoints->size(); 307 290 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); 313 294 size--; 314 295 CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); … … 326 307 size=ListOfPoints->size(); 327 308 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); 332 311 size--; 333 312 CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); … … 346 325 Vector tester; 347 326 LinkedCell::LinkedNodes *ListOfPoints = NULL; 348 atom *Walker = NULL;349 327 size_t size = 0; 350 328 … … 355 333 size = ListOfPoints->size(); 356 334 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); 362 338 size--; 363 339 CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() ); -
src/unittests/LinkedCellUnitTest.hpp
rc39cc4 rbdb143 48 48 49 49 molecule *TestMolecule; 50 element *hydrogen; 51 periodentafel *tafel; 50 const element *hydrogen; 52 51 LinkedCell *LC; 53 52 }; -
src/unittests/Makefile.am
rc39cc4 rbdb143 1 # PLEASE adhere to the alphabetical ordering in this Makefile! 2 # Also indentation by a single tab 3 1 4 INCLUDES = -I$(top_srcdir)/src 2 5 … … 31 34 MemoryAllocatorUnitTest \ 32 35 MoleculeDescriptorTest \ 36 ObserverTest \ 37 ParserUnitTest \ 38 periodentafelTest \ 33 39 PlaneUnittest \ 34 ObserverTest \35 40 SingletonTest \ 36 41 StackClassUnitTest \ … … 47 52 GSLLIBS = ../libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} 48 53 ALLLIBS = ../libmolecuilder.a ${GSLLIBS} 54 PARSERLIBS = ../libparser.a ${ALLLIBS} 49 55 50 56 TESTSOURCES = \ … … 73 79 memoryusageobserverunittest.cpp \ 74 80 MoleculeDescriptorTest.cpp \ 81 ObserverTest.cpp \ 82 ParserUnitTest.cpp \ 83 periodentafelTest.cpp \ 75 84 PlaneUnittest.cpp \ 76 ObserverTest.cpp \77 85 SingletonTest.cpp \ 78 86 stackclassunittest.cpp \ … … 107 115 memoryusageobserverunittest.hpp \ 108 116 MoleculeDescriptorTest.hpp \ 117 periodentafelTest.hpp \ 109 118 PlaneUnittest.hpp \ 110 119 ObserverTest.hpp \ … … 117 126 118 127 128 ActionSequenceTest_SOURCES = UnitTestMain.cpp ../../../TestRunnerClient.hpp ActionSequenceTest.cpp ActionSequenceTest.hpp 129 ActionSequenceTest_LDADD = ${ALLLIBS} 130 119 131 ActOnAllUnitTest_SOURCES = UnitTestMain.cpp ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp 120 132 ActOnAllUnitTest_LDADD = ${ALLLIBS} … … 135 147 atomsCalculationTest_LDADD = ${ALLLIBS} 136 148 149 AtomDescriptorTest_SOURCES = UnitTestMain.cpp AtomDescriptorTest.cpp AtomDescriptorTest.hpp 150 AtomDescriptorTest_LDADD = ${ALLLIBS} 151 137 152 BondGraphUnitTest_SOURCES = UnitTestMain.cpp bondgraphunittest.cpp bondgraphunittest.hpp 138 153 BondGraphUnitTest_LDADD = ${ALLLIBS} 139 154 155 CacheableTest_SOURCES = UnitTestMain.cpp CacheableTest.cpp CacheableTest.hpp 156 CacheableTest_LDADD = ${ALLLIBS} 157 140 158 CountBondsUnitTest_SOURCES = UnitTestMain.cpp CountBondsUnitTest.cpp CountBondsUnitTest.hpp 141 159 CountBondsUnitTest_LDADD = ${ALLLIBS} … … 168 186 LogUnitTest_LDADD = ${ALLLIBS} 169 187 170 MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp 188 manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp 189 manipulateAtomsTest_LDADD = ${ALLLIBS} 190 191 MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp 171 192 MemoryAllocatorUnitTest_LDADD = ${ALLLIBS} 172 193 173 MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp194 MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp 174 195 MemoryUsageObserverUnitTest_LDADD = ${ALLLIBS} 175 196 … … 177 198 MoleculeDescriptorTest_LDADD = ${ALLLIBS} 178 199 200 ObserverTest_SOURCES = UnitTestMain.cpp ObserverTest.cpp ObserverTest.hpp 201 ObserverTest_LDADD = ${ALLLIBS} 202 203 ParserUnitTest_SOURCES = UnitTestMain.cpp ParserUnitTest.cpp ParserUnitTest.hpp 204 ParserUnitTest_LDADD = ${PARSERLIBS} 205 206 periodentafelTest_SOURCES = UnitTestMain.cpp periodentafelTest.cpp periodentafelTest.hpp 207 periodentafelTest_LDADD = ${ALLLIBS} 208 179 209 PlaneUnittest_SOURCES = UnitTestMain.cpp PlaneUnittest.cpp PlaneUnittest.hpp 180 210 PlaneUnittest_LDADD = ${ALLLIBS} 181 211 182 212 SingletonTest_SOURCES = UnitTestMain.cpp SingletonTest.cpp SingletonTest.hpp 183 SingletonTest_LDADD = $ (BOOST_LIB) ${BOOST_THREAD_LIB}213 SingletonTest_LDADD = ${ALLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB} 184 214 185 215 StackClassUnitTest_SOURCES = UnitTestMain.cpp stackclassunittest.cpp stackclassunittest.hpp … … 195 225 Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS} 196 226 227 TestRunner_SOURCES = TestRunnerMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp $(TESTSOURCES) $(TESTHEADERS) 228 TestRunner_LDADD = ${ALLLIBS} 229 197 230 VectorUnitTest_SOURCES = UnitTestMain.cpp vectorunittest.cpp vectorunittest.hpp 198 231 VectorUnitTest_LDADD = ${ALLLIBS} 199 232 200 ActionSequenceTest_SOURCES = UnitTestMain.cpp ../../../TestRunnerClient.hpp ActionSequenceTest.cpp ActionSequenceTest.hpp201 ActionSequenceTest_LDADD = ${ALLLIBS}202 203 ObserverTest_SOURCES = UnitTestMain.cpp ObserverTest.cpp ObserverTest.hpp204 ObserverTest_LDADD = ${ALLLIBS}205 206 CacheableTest_SOURCES = UnitTestMain.cpp CacheableTest.cpp CacheableTest.hpp207 CacheableTest_LDADD = ${ALLLIBS}208 209 AtomDescriptorTest_SOURCES = UnitTestMain.cpp AtomDescriptorTest.cpp AtomDescriptorTest.hpp210 AtomDescriptorTest_LDADD = ${ALLLIBS}211 212 manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp213 manipulateAtomsTest_LDADD = ${ALLLIBS}214 215 TestRunner_SOURCES = UnitTestMain.cpp $(TESTSOURCES) $(TESTHEADERS)216 TestRunner_LDADD = ${ALLLIBS}217 218 233 #AUTOMAKE_OPTIONS = parallel-tests 219 -
src/unittests/ObserverTest.cpp
rc39cc4 rbdb143 11 11 #include <cppunit/extensions/TestFactoryRegistry.h> 12 12 #include <cppunit/ui/text/TestRunner.h> 13 #include <set> 13 14 14 15 #include "Patterns/Observer.hpp" 16 #include "Patterns/ObservedIterator.hpp" 15 17 #include "Helpers/Assert.hpp" 16 18 … … 31 33 public: 32 34 UpdateCountObserver() : 35 Observer("UpdateCountObserver"), 33 36 updates(0) 34 37 {}; … … 43 46 class SimpleObservable : public Observable { 44 47 public: 48 SimpleObservable() : 49 Observable("SimpleObservable") 50 {} 51 45 52 void changeMethod() { 46 53 OBSERVE; … … 52 59 class CallObservable : public Observable { 53 60 public: 61 CallObservable() : 62 Observable("CallObservable") 63 {} 64 54 65 void changeMethod1() { 55 66 OBSERVE; … … 68 79 class BlockObservable : public Observable { 69 80 public: 81 BlockObservable() : 82 Observable("BlockObservable") 83 {} 84 70 85 void changeMethod1(){ 71 86 OBSERVE; … … 102 117 class SuperObservable : public Observable { 103 118 public: 104 SuperObservable(){ 119 SuperObservable(): 120 Observable("SuperObservable") 121 { 105 122 subObservable = new SimpleObservable(); 106 123 subObservable->signOn(this); … … 121 138 public: 122 139 NotificationObservable() : 123 notification1(new Notification(this)), 124 notification2(new Notification(this)) 140 Observable("NotificationObservable"), 141 notification1(new Notification(this)), 142 notification2(new Notification(this)) 125 143 {} 126 144 … … 147 165 public: 148 166 NotificationObserver(Notification_ptr notification) : 167 Observer("NotificationObserver"), 149 168 requestedNotification(notification), 150 169 wasNotified(false) … … 162 181 bool wasNotified; 163 182 }; 183 184 class ObservableCollection : public Observable { 185 public: 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 218 private: 219 set theSet; 220 }; 221 164 222 165 223 /******************* actuall tests ***************/ … … 173 231 blockObservable = new BlockObservable(); 174 232 notificationObservable = new NotificationObservable(); 233 collection = new ObservableCollection(5); 175 234 176 235 observer1 = new UpdateCountObserver(); … … 181 240 notificationObserver1 = new NotificationObserver(notificationObservable->notification1); 182 241 notificationObserver2 = new NotificationObserver(notificationObservable->notification2); 183 184 242 } 185 243 … … 191 249 delete blockObservable; 192 250 delete notificationObservable; 251 delete collection; 193 252 194 253 delete observer1; … … 279 338 } 280 339 340 void 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 281 374 void ObserverTest::CircleDetectionTest() { 282 375 cout << endl << "Warning: the next test involved methods that can produce infinite loops." << endl; … … 289 382 // make this Observable its own subject. NEVER DO THIS IN ACTUAL CODE 290 383 simpleObservable1->signOn(simpleObservable1); 384 #ifndef NDEBUG 291 385 CPPUNIT_ASSERT_THROW(simpleObservable1->changeMethod(),Assert::AssertionFailure); 386 #else 387 simpleObservable1->changeMethod(); 388 #endif 292 389 293 390 // more complex test … … 295 392 simpleObservable1->signOn(simpleObservable2); 296 393 simpleObservable2->signOn(simpleObservable1); 394 #ifndef NDEBUG 297 395 CPPUNIT_ASSERT_THROW(simpleObservable1->changeMethod(),Assert::AssertionFailure); 396 #else 397 simpleObservable1->changeMethod(); 398 #endif 399 400 298 401 simpleObservable1->signOff(simpleObservable2); 299 402 simpleObservable2->signOff(simpleObservable1); -
src/unittests/ObserverTest.hpp
rc39cc4 rbdb143 17 17 class CallObservable; 18 18 class SuperObservable; 19 class ObservableCollection; 19 20 class BlockObservable; 20 21 class NotificationObservable; 21 22 22 23 23 class ObserverTest : public CppUnit::TestFixture … … 29 29 CPPUNIT_TEST ( doesNotifyTest ); 30 30 CPPUNIT_TEST ( doesReportTest ); 31 CPPUNIT_TEST ( iteratorTest ); 31 32 CPPUNIT_TEST ( CircleDetectionTest ); 32 33 CPPUNIT_TEST_SUITE_END(); … … 41 42 void doesNotifyTest(); 42 43 void doesReportTest(); 44 void iteratorTest(); 43 45 void CircleDetectionTest(); 44 46 … … 58 60 SuperObservable *superObservable; 59 61 NotificationObservable *notificationObservable; 62 ObservableCollection *collection; 63 60 64 }; 61 65 -
src/unittests/SingletonTest.cpp
rc39cc4 rbdb143 52 52 count1++; 53 53 } 54 // explicit copy constructor to catch if th siis ever called54 // explicit copy constructor to catch if this is ever called 55 55 SingletonStub2(const SingletonStub2&){ 56 56 CPPUNIT_FAIL ( "Copy constructor of Singleton called" ); -
src/unittests/TestRunnerMain.cpp
rc39cc4 rbdb143 14 14 // give the main function its correct name 15 15 #define CPPUNIT_MAIN main 16 17 16 // include the TestRunnerClient file containing the main class 18 17 #include "../../../TestRunnerClient.h" -
src/unittests/analysisbondsunittest.cpp
rc39cc4 rbdb143 25 25 #include "molecule.hpp" 26 26 #include "periodentafel.hpp" 27 #include "World.hpp" 27 28 28 29 #ifdef HAVE_TESTRUNNER … … 40 41 atom *Walker = NULL; 41 42 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"); 66 48 67 49 // construct molecule (tetraeder of hydrogens) 68 50 TestMolecule = World::getInstance().createMolecule(); 51 CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule"); 69 52 Walker = World::getInstance().createAtom(); 53 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 70 54 Walker->type = hydrogen; 71 55 *Walker->node = Vector(1.5, 0., 1.5 ); 72 56 TestMolecule->AddAtom(Walker); 73 57 Walker = World::getInstance().createAtom(); 58 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 74 59 Walker->type = hydrogen; 75 60 *Walker->node = Vector(0., 1.5, 1.5 ); 76 61 TestMolecule->AddAtom(Walker); 77 62 Walker = World::getInstance().createAtom(); 63 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 78 64 Walker->type = hydrogen; 79 65 *Walker->node = Vector(1.5, 1.5, 0. ); 80 66 TestMolecule->AddAtom(Walker); 81 67 Walker = World::getInstance().createAtom(); 68 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 82 69 Walker->type = hydrogen; 83 70 *Walker->node = Vector(0., 0., 0. ); 84 71 TestMolecule->AddAtom(Walker); 85 72 Walker = World::getInstance().createAtom(); 73 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 86 74 Walker->type = carbon; 87 75 *Walker->node = Vector(0.5, 0.5, 0.5 ); … … 89 77 90 78 // check that TestMolecule was correctly constructed 91 CPPUNIT_ASSERT_EQUAL( TestMolecule-> AtomCount, 5 );79 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 5 ); 92 80 93 81 // create a small file with table 94 82 filename = new string("test.dat"); 83 CPPUNIT_ASSERT(filename != NULL && "could not create string"); 95 84 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"; 99 92 test.close(); 100 93 BG = new BondGraph(true); 94 CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph"); 101 95 102 96 CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) ); 103 97 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) ); 106 100 107 101 BG->ConstructBondGraph(TestMolecule); -
src/unittests/analysisbondsunittest.hpp
rc39cc4 rbdb143 34 34 35 35 molecule *TestMolecule; 36 element *hydrogen; 37 element *carbon; 38 periodentafel *tafel; 36 const element *hydrogen; 37 const element *carbon; 39 38 40 39 BondGraph *BG; -
src/unittests/bondgraphunittest.cpp
rc39cc4 rbdb143 15 15 #include <stdio.h> 16 16 #include <cstring> 17 18 #include "Helpers/Assert.hpp" 17 19 18 20 #include "World.hpp" … … 41 43 atom *Walker = NULL; 42 44 43 // init private all pointers to zero44 TestMolecule = NULL;45 hydrogen = NULL;46 tafel = NULL;47 48 45 // 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"); 67 50 68 51 // construct molecule (tetraeder of hydrogens) 69 52 TestMolecule = World::getInstance().createMolecule(); 53 CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule"); 70 54 Walker = World::getInstance().createAtom(); 55 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 71 56 Walker->type = carbon; 72 57 *Walker->node = Vector(1., 0., 1. ); … … 74 59 75 60 Walker = World::getInstance().createAtom(); 61 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 76 62 Walker->type = carbon; 77 63 *Walker->node = Vector(0., 1., 1. ); … … 79 65 80 66 Walker = World::getInstance().createAtom(); 67 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 81 68 Walker->type = carbon; 82 69 *Walker->node = Vector(1., 1., 0. ); … … 84 71 85 72 Walker = World::getInstance().createAtom(); 73 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 86 74 Walker->type = carbon; 87 75 *Walker->node = Vector(0., 0., 0. ); … … 89 77 90 78 // check that TestMolecule was correctly constructed 91 CPPUNIT_ASSERT_EQUAL( TestMolecule-> AtomCount, 4 );79 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 92 80 93 81 // create a small file with table 94 82 dummyname = new string("dummy.dat"); 83 CPPUNIT_ASSERT(dummyname != NULL && "could not create string"); 95 84 filename = new string("test.dat"); 85 CPPUNIT_ASSERT(filename != NULL && "could not create string"); 96 86 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"; 100 94 test.close(); 101 95 BG = new BondGraph(true); 96 CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph"); 102 97 }; 103 98 … … 116 111 // are all cleaned when the world is destroyed 117 112 World::purgeInstance(); 118 MemoryUsageObserver::purgeInstance();119 113 logger::purgeInstance(); 114 }; 115 116 /** Tests whether setup worked. 117 */ 118 void BondGraphTest::SetupTest() 119 { 120 CPPUNIT_ASSERT_EQUAL (false, TestMolecule->empty()); 121 CPPUNIT_ASSERT_EQUAL ((size_t)4, TestMolecule->size()); 120 122 }; 121 123 … … 126 128 CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) ); 127 129 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) ); 130 132 }; 131 133 … … 134 136 void BondGraphTest::ConstructGraphFromTableTest() 135 137 { 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++; 139 141 CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) ); 140 142 CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) ); 141 CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );143 CPPUNIT_ASSERT_EQUAL( true , (*Walker)->IsBondedTo((*Runner)) ); 142 144 }; 143 145 … … 146 148 void BondGraphTest::ConstructGraphFromCovalentRadiiTest() 147 149 { 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 ); 151 154 CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(*dummyname) ); 152 155 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) ); 154 159 }; 155 160 -
src/unittests/bondgraphunittest.hpp
rc39cc4 rbdb143 22 22 { 23 23 CPPUNIT_TEST_SUITE( BondGraphTest) ; 24 CPPUNIT_TEST ( SetupTest ); 24 25 CPPUNIT_TEST ( LoadTableTest ); 25 26 CPPUNIT_TEST ( ConstructGraphFromTableTest ); … … 30 31 void setUp(); 31 32 void tearDown(); 33 void SetupTest(); 32 34 void LoadTableTest(); 33 35 void ConstructGraphFromTableTest(); … … 37 39 38 40 molecule *TestMolecule; 39 element *hydrogen; 40 element *carbon; 41 periodentafel *tafel; 41 const element *hydrogen; 42 const element *carbon; 42 43 43 44 BondGraph *BG; -
src/unittests/listofbondsunittest.cpp
rc39cc4 rbdb143 38 38 atom *Walker = NULL; 39 39 40 // init private all pointers to zero41 TestMolecule = NULL;42 hydrogen = NULL;43 tafel = NULL;44 45 40 // 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"); 55 43 56 44 // construct molecule (tetraeder of hydrogens) 57 45 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"); 59 49 Walker->type = hydrogen; 60 50 *Walker->node = Vector(1., 0., 1. ); 61 51 TestMolecule->AddAtom(Walker); 62 52 Walker = World::getInstance().createAtom(); 53 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 63 54 Walker->type = hydrogen; 64 55 *Walker->node = Vector(0., 1., 1. ); 65 56 TestMolecule->AddAtom(Walker); 66 57 Walker = World::getInstance().createAtom(); 58 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 67 59 Walker->type = hydrogen; 68 60 *Walker->node = Vector(1., 1., 0. ); 69 61 TestMolecule->AddAtom(Walker); 70 62 Walker = World::getInstance().createAtom(); 63 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 71 64 Walker->type = hydrogen; 72 65 *Walker->node = Vector(0., 0., 0. ); … … 74 67 75 68 // check that TestMolecule was correctly constructed 76 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 ); 77 69 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 78 70 }; 79 71 … … 86 78 // are all cleaned when the world is destroyed 87 79 World::purgeInstance(); 88 MemoryUsageObserver::purgeInstance();89 80 logger::purgeInstance(); 90 81 }; 91 82 83 /** Tests whether setup worked correctly. 84 * 85 */ 86 void ListOfBondsTest::SetupTest() 87 { 88 CPPUNIT_ASSERT_EQUAL( false, TestMolecule->empty() ); 89 CPPUNIT_ASSERT_EQUAL( (size_t)4, TestMolecule->size() ); 90 }; 91 92 92 /** Unit Test of molecule::AddBond() 93 93 * … … 96 96 { 97 97 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() ); 108 109 109 110 // check that bond contains the two atoms … … 124 125 { 125 126 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; 128 131 CPPUNIT_ASSERT( atom1 != NULL ); 129 132 CPPUNIT_ASSERT( atom2 != NULL ); … … 141 144 142 145 // check if removed from molecule 143 CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last);146 CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() ); 144 147 }; 145 148 … … 150 153 { 151 154 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; 155 161 CPPUNIT_ASSERT( atom1 != NULL ); 156 162 CPPUNIT_ASSERT( atom2 != NULL ); … … 179 185 180 186 // 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() ); 183 189 }; 184 190 … … 189 195 { 190 196 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; 193 201 CPPUNIT_ASSERT( atom1 != NULL ); 194 202 CPPUNIT_ASSERT( atom2 != NULL ); … … 206 214 207 215 // check if removed from molecule 208 CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last);216 CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() ); 209 217 }; 210 218 … … 215 223 { 216 224 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; 219 229 CPPUNIT_ASSERT( atom1 != NULL ); 220 230 CPPUNIT_ASSERT( atom2 != NULL ); … … 231 241 232 242 // check if removed from molecule 233 CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last);243 CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() ); 234 244 }; 235 245 … … 239 249 void ListOfBondsTest::DeleteAtomTest() 240 250 { 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() ); 250 271 251 272 // remove atom2 … … 256 277 257 278 // 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 20 20 { 21 21 CPPUNIT_TEST_SUITE( ListOfBondsTest) ; 22 CPPUNIT_TEST ( SetupTest ); 22 23 CPPUNIT_TEST ( AddingBondTest ); 23 24 CPPUNIT_TEST ( RemovingBondTest ); … … 31 32 void setUp(); 32 33 void tearDown(); 34 void SetupTest(); 33 35 void AddingBondTest(); 34 36 void RemovingBondTest(); … … 41 43 42 44 molecule *TestMolecule; 43 element *hydrogen; 44 periodentafel *tafel; 45 const element *hydrogen; 45 46 }; 46 47 -
src/unittests/manipulateAtomsTest.cpp
rc39cc4 rbdb143 55 55 public: 56 56 countObserver() : 57 Observer("countObserver"), 57 58 count(0) 58 59 {} … … 86 87 static void operation(atom* _atom){ 87 88 AtomStub *atom = dynamic_cast<AtomStub*>(_atom); 88 assert(atom);89 CPPUNIT_ASSERT(atom); 89 90 atom->doSomething(); 90 91 } … … 99 100 AtomStub *atom; 100 101 atom = dynamic_cast<AtomStub*>(*iter); 101 assert(atom);102 CPPUNIT_ASSERT(atom); 102 103 CPPUNIT_ASSERT(atom->manipulated); 103 104 } … … 113 114 AtomStub *atom; 114 115 atom = dynamic_cast<AtomStub*>(*iter); 115 assert(atom);116 CPPUNIT_ASSERT(atom); 116 117 if(atom->getId()!=(int)ATOM_COUNT/2) 117 118 CPPUNIT_ASSERT(atom->manipulated); -
src/unittests/memoryallocatorunittest.cpp
rc39cc4 rbdb143 12 12 #include "memoryallocator.hpp" 13 13 #include "memoryallocatorunittest.hpp" 14 #include "memoryusageobserver.hpp" 14 15 #include "helpers.hpp" 15 16 #include "log.hpp" -
src/unittests/stackclassunittest.cpp
rc39cc4 rbdb143 37 37 Stack->ClearStack(); 38 38 delete(Stack); 39 MemoryUsageObserver::purgeInstance();40 39 logger::purgeInstance(); 41 40 }; -
src/unittests/tesselation_boundarytriangleunittest.cpp
rc39cc4 rbdb143 70 70 delete tesselpoints[i]; 71 71 } 72 MemoryUsageObserver::purgeInstance();73 72 logger::purgeInstance(); 74 73 errorLogger::purgeInstance(); -
src/unittests/tesselation_insideoutsideunittest.cpp
rc39cc4 rbdb143 134 134 } 135 135 Corners.clear(); 136 MemoryUsageObserver::purgeInstance();137 136 logger::purgeInstance(); 138 137 errorLogger::purgeInstance(); -
src/unittests/tesselationunittest.cpp
rc39cc4 rbdb143 106 106 } 107 107 Corners.clear(); 108 MemoryUsageObserver::purgeInstance();109 108 logger::purgeInstance(); 110 109 errorLogger::purgeInstance(); -
src/unittests/vectorunittest.cpp
rc39cc4 rbdb143 49 49 void VectorTest::tearDown() 50 50 { 51 MemoryUsageObserver::purgeInstance();52 51 logger::purgeInstance(); 53 52 errorLogger::purgeInstance(); -
src/valence.db
rc39cc4 rbdb143 1 #atomicnumber numberofvalenceorbitals 1 2 1 0.10000000000000E+01 2 3 2 0.20000000000000E+01 -
src/vector.cpp
rc39cc4 rbdb143 5 5 */ 6 6 7 #include "Helpers/MemDebug.hpp" 7 8 8 9 #include "vector.hpp" … … 23 24 Vector::Vector() 24 25 { 25 x[0] = x[1] = x[2] = 0.;26 content = gsl_vector_calloc (NDIM); 26 27 }; 27 28 … … 32 33 Vector::Vector(const Vector& src) 33 34 { 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]); 37 39 } 38 40 … … 41 43 Vector::Vector(const double x1, const double x2, const double x3) 42 44 { 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); 46 49 }; 47 50 … … 52 55 // check for self assignment 53 56 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]); 57 60 } 58 61 return *this; … … 61 64 /** Desctructor of class vector. 62 65 */ 63 Vector::~Vector() {}; 66 Vector::~Vector() { 67 gsl_vector_free(content); 68 }; 64 69 65 70 /** Calculates square of distance between this and another vector. … … 71 76 double res = 0.; 72 77 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]); 74 79 return (res); 75 80 }; … … 199 204 double res = 0.; 200 205 for (int i=NDIM;i--;) 201 res += x[i]*y[i];206 res += at(i)*y[i]; 202 207 return (res); 203 208 }; … … 213 218 { 214 219 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]; 218 222 (*this) = tmp; 219 223 }; … … 308 312 bool Vector::IsZero() const 309 313 { 310 return (fabs( x[0])+fabs(x[1])+fabs(x[2]) < MYEPSILON);314 return (fabs(at(0))+fabs(at(1))+fabs(at(2)) < MYEPSILON); 311 315 }; 312 316 … … 337 341 bool status = true; 338 342 for (int i=0;i<NDIM;i++) { 339 if (fabs( x[i]- a[i]) > MYEPSILON)343 if (fabs(at(i) - a[i]) > MYEPSILON) 340 344 status = false; 341 345 } … … 365 369 double& Vector::operator[](size_t i){ 366 370 ASSERT(i<=NDIM && i>=0,"Vector Index out of Range"); 367 return x[i];371 return *gsl_vector_ptr (content, i); 368 372 } 369 373 370 374 const double& Vector::operator[](size_t i) const{ 371 375 ASSERT(i<=NDIM && i>=0,"Vector Index out of Range"); 372 return x[i];376 return *gsl_vector_ptr (content, i); 373 377 } 374 378 … … 381 385 } 382 386 383 double* Vector::get(){384 return x;387 gsl_vector* Vector::get(){ 388 return content; 385 389 } 386 390 … … 497 501 { 498 502 for (int i=NDIM;i--;) 499 x[i]*= factor[i];503 at(i) *= factor[i]; 500 504 }; 501 505 … … 505 509 { 506 510 for (int i=NDIM;i--;) 507 x[i]*= factor;511 at(i) *= factor; 508 512 }; 509 513 … … 517 521 // truncate to [0,1] for each axis 518 522 for (int i=0;i<NDIM;i++) { 519 x[i]+= 0.5; // set to center of box520 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.; 524 528 } 525 529 MatrixMultiplication(M); … … 548 552 void Vector::MatrixMultiplication(const double * const M) 549 553 { 554 Vector tmp; 550 555 // 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; 554 560 }; 555 561 … … 576 582 B[8] = detAReci*RDET2(A[0],A[1],A[3],A[4]); // A_33 577 583 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); 582 585 583 586 return true; … … 615 618 SubtractVector(x1); 616 619 for (int i=NDIM;i--;) 617 result = result || (fabs( x[i]) > MYEPSILON);620 result = result || (fabs(at(i)) > MYEPSILON); 618 621 619 622 return result; … … 677 680 { 678 681 for(int i=NDIM;i--;) 679 x[i]+= y[i];682 at(i) += y[i]; 680 683 } 681 684 … … 686 689 { 687 690 for(int i=NDIM;i--;) 688 x[i]-= y[i];691 at(i) -= y[i]; 689 692 } 690 693 -
src/vector.hpp
rc39cc4 rbdb143 31 31 */ 32 32 class Vector : public Space{ 33 protected:34 // this struct is used to indicate calls to the Baseconstructor from inside vectors.35 struct Baseconstructor{};36 33 public: 37 34 … … 82 79 83 80 // Access to internal structure 84 double* get();81 gsl_vector* get(); 85 82 86 83 // Methods that are derived directly from other methods … … 107 104 108 105 private: 109 double x[NDIM];106 gsl_vector *content; 110 107 111 108 }; -
src/vector_ops.cpp
rc39cc4 rbdb143 5 5 * Author: crueger 6 6 */ 7 8 #include "Helpers/MemDebug.hpp" 7 9 8 10 #include "vector.hpp" -
src/verbose.cpp
rc39cc4 rbdb143 1 1 using namespace std; 2 3 #include "Helpers/MemDebug.hpp" 2 4 3 5 #include "info.hpp" -
tests/Makefile.am
rc39cc4 rbdb143 1 AUTOM4TE = autom4te 2 EXTRA_DIST = testsuite.at $(TESTSUITE) atlocal.in regression 3 TESTSUITE = $(srcdir)/testsuite 1 SUBDIRS = regression Tesselations 4 2 5 SUBDIRS = Tesselations6 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)' --clean17 18 AUTOTEST = $(AUTOM4TE) --language=autotest19 $(TESTSUITE): $(srcdir)/testsuite.at20 $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at21 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.ac25 :;{ \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 30 30 CLEANUP="$CLEANUP; rm -rf $testdir" 31 31 cp -r @srcdir@/$testdir/* $testdir/ 32 cd $testdir33 32 CLEANUP="rm -f stderr stdout diffstderr diffstdout; cd ..; $CLEANUP" 34 33 CLEANUP="rm -f *.conf*; rm -f NonConvexEnvelope*; rm -f ${testdir}.xyz; rm -f ${testdir}.dbond; $CLEANUP" … … 52 51 FILENAME="NonConvexEnvelope" 53 52 exitcode=0 54 cd $ RADIUS53 cd $testdir/$RADIUS 55 54 #echo "Current dir is `pwd`, calling $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N $RADIUS $FILENAME." 56 55 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=$? 58 57 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=$? 60 59 fi 61 60 #echo "Molecuilder done with exitcode $exitcode." 62 61 #cat stderr 63 62 #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=$? 65 66 #echo "Diff done with exitcode $exitcode." 66 67 #cat diffstderr 67 68 #cat diffstdout 68 cd .. 69 cd ../.. 69 70 test $exitcode = $expected_exitcode || exit 1 70 71 } -
tests/Tesselations/heptan/1.5/NonConvexEnvelope-heptan.dat
rc39cc4 rbdb143 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="heptan", N=23, E=64, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 -7.27e-07 -1.22006 0.930455 35 -7.27e-07 -1.22006 -0.849545 36 -1.2492 0.921941 0.930455 37 -1.2492 0.921941 -0.849545 38 1.2492 0.921941 -0.849545 39 1.2492 0.921941 0.930455 310 -2.4985 -1.22006 -0.849545 411 -2.4985 -1.22006 0.930455 412 2.4985 -1.22006 0.930455 413 2.4985 -1.22006 -0.849545 414 -4.6377 -0.336759 0.0404545 615 -3.7477 0.921941 0.930455 516 -3.7477 0.921941 -0.849545 517 4.6377 -0.336759 0.0404545 418 3.7477 0.921941 -0.849545 419 3.7477 0.921941 0.930455 420 -7.27e-07 -0.590759 0.0404545 621 -1.2492 0.292641 0.0404545 622 1.2492 0.292641 0.0404545 623 -2.4985 -0.590759 0.0404545 624 2.4985 -0.590759 0.0404545 625 -3.7477 0.292641 0.0404545 1226 3.7477 0.292641 0.0404545 124 -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 8 1.2492 0.921941 -0.849545 18.7222 9 1.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 12 2.4985 -1.22006 0.930455 19.9769 13 2.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 17 4.6377 -0.336759 0.0404545 10.6618 18 3.7477 0.921941 -0.849545 18.5406 19 3.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 22 1.2492 0.292641 0.0404545 20.1632 23 -2.4985 -0.590759 0.0404545 18.9798 24 2.4985 -0.590759 0.0404545 18.9798 25 -3.7477 0.292641 0.0404545 39.5267 26 3.7477 0.292641 0.0404545 23.2512 27 27 28 28 14 15 23 … … 38 38 5 18 19 39 39 4 5 18 40 6 18 19 41 3 6 18 40 42 3 4 18 41 43 3 4 18 42 3 18 1943 3 6 1944 44 4 18 22 45 45 4 13 22 … … 48 48 12 13 22 49 49 12 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 50 6 19 23 51 6 16 23 56 52 11 13 22 57 53 11 13 22 … … 62 58 8 11 22 63 59 8 12 22 60 14 16 23 61 14 16 23 62 9 14 23 63 9 16 23 64 3 8 12 65 1 3 8 66 1 3 6 67 1 6 9 68 6 9 16 64 69 4 7 13 65 70 2 4 7 … … 67 72 2 5 10 68 73 5 10 15 69 3 8 1270 1 3 871 1 3 672 1 6 973 6 9 1674 74 10 14 21 75 75 9 10 21 … … 84 84 2 17 20 85 85 2 7 20 86 1 17 2087 1 8 2088 86 7 8 20 89 87 7 8 20 90 88 7 11 20 91 89 8 11 20 90 8 17 20 91 1 8 17 -
tests/Tesselations/heptan/2.5/NonConvexEnvelope-heptan.dat
rc39cc4 rbdb143 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 -7.27e-07 -1.22006 0.930455 05 -7.27e-07 -1.22006 -0.849545 06 -1.2492 0.921941 0.930455 07 -1.2492 0.921941 -0.849545 08 1.2492 0.921941 -0.849545 09 1.2492 0.921941 0.930455 010 -2.4985 -1.22006 -0.849545 011 -2.4985 -1.22006 0.930455 012 2.4985 -1.22006 0.930455 013 2.4985 -1.22006 -0.849545 014 -4.6377 -0.336759 0.0404545 015 -3.7477 0.921941 0.930455 016 -3.7477 0.921941 -0.849545 017 4.6377 -0.336759 0.0404545 018 3.7477 0.921941 -0.849545 019 3.7477 0.921941 0.930455 04 -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 8 1.2492 0.921941 -0.849545 -17.495 9 1.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 12 2.4985 -1.22006 0.930455 -13.1263 13 2.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 17 4.6377 -0.336759 0.0404545 -9.35473 18 3.7477 0.921941 -0.849545 -11.4805 19 3.7477 0.921941 0.930455 -9.24445 20 20 21 21 14 15 16 … … 27 27 3 12 13 28 28 11 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 29 7 11 13 30 4 7 13 31 2 4 7 32 2 4 5 33 2 5 10 34 5 10 15 35 10 14 15 36 36 9 10 14 37 37 2 9 10 … … 40 40 1 7 8 41 41 7 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 42 9 14 16 43 6 9 16 44 1 6 9 45 1 3 6 46 1 3 8 47 3 8 12 48 8 11 12 -
tests/Tesselations/heptan/2/NonConvexEnvelope-heptan.dat
rc39cc4 rbdb143 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 -7.27e-07 -1.22006 0.930455 05 -7.27e-07 -1.22006 -0.849545 06 -1.2492 0.921941 0.930455 07 -1.2492 0.921941 -0.849545 08 1.2492 0.921941 -0.849545 09 1.2492 0.921941 0.930455 010 -2.4985 -1.22006 -0.849545 011 -2.4985 -1.22006 0.930455 012 2.4985 -1.22006 0.930455 013 2.4985 -1.22006 -0.849545 014 -4.6377 -0.336759 0.0404545 015 -3.7477 0.921941 0.930455 016 -3.7477 0.921941 -0.849545 017 4.6377 -0.336759 0.0404545 018 3.7477 0.921941 -0.849545 019 3.7477 0.921941 0.930455 04 -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 8 1.2492 0.921941 -0.849545 -17.495 9 1.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 12 2.4985 -1.22006 0.930455 -13.1263 13 2.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 17 4.6377 -0.336759 0.0404545 -9.35473 18 3.7477 0.921941 -0.849545 -11.4805 19 3.7477 0.921941 0.930455 -9.24445 20 20 21 21 14 15 16 … … 27 27 3 12 13 28 28 11 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 29 7 11 13 30 4 7 13 31 2 4 7 32 2 4 5 33 2 5 10 34 5 10 15 35 10 14 15 36 36 9 10 14 37 37 2 9 10 … … 40 40 1 7 8 41 41 7 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 42 9 14 16 43 6 9 16 44 1 6 9 45 1 3 6 46 1 3 8 47 3 8 12 48 8 11 12 -
tests/Tesselations/heptan/25/NonConvexEnvelope-heptan.dat
rc39cc4 rbdb143 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 -7.27e-07 -1.22006 0.930455 05 -7.27e-07 -1.22006 -0.849545 06 -1.2492 0.921941 0.930455 07 -1.2492 0.921941 -0.849545 08 1.2492 0.921941 -0.849545 09 1.2492 0.921941 0.930455 010 -2.4985 -1.22006 -0.849545 011 -2.4985 -1.22006 0.930455 012 2.4985 -1.22006 0.930455 013 2.4985 -1.22006 -0.849545 014 -4.6377 -0.336759 0.0404545 015 -3.7477 0.921941 0.930455 016 -3.7477 0.921941 -0.849545 017 4.6377 -0.336759 0.0404545 018 3.7477 0.921941 -0.849545 019 3.7477 0.921941 0.930455 04 -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 8 1.2492 0.921941 -0.849545 -17.495 9 1.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 12 2.4985 -1.22006 0.930455 -13.1263 13 2.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 17 4.6377 -0.336759 0.0404545 -9.35473 18 3.7477 0.921941 -0.849545 -11.4805 19 3.7477 0.921941 0.930455 -9.24445 20 20 21 21 14 15 16 … … 27 27 3 12 13 28 28 11 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 29 7 11 13 30 4 7 13 31 2 4 7 32 2 4 5 33 2 5 10 34 5 10 15 35 10 14 15 36 36 9 10 14 37 37 2 9 10 … … 40 40 1 7 8 41 41 7 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 42 9 14 16 43 6 9 16 44 1 6 9 45 1 3 6 46 1 3 8 47 3 8 12 48 8 11 12 -
tests/Tesselations/heptan/3.5/NonConvexEnvelope-heptan.dat
rc39cc4 rbdb143 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 -7.27e-07 -1.22006 0.930455 05 -7.27e-07 -1.22006 -0.849545 06 -1.2492 0.921941 0.930455 07 -1.2492 0.921941 -0.849545 08 1.2492 0.921941 -0.849545 09 1.2492 0.921941 0.930455 010 -2.4985 -1.22006 -0.849545 011 -2.4985 -1.22006 0.930455 012 2.4985 -1.22006 0.930455 013 2.4985 -1.22006 -0.849545 014 -4.6377 -0.336759 0.0404545 015 -3.7477 0.921941 0.930455 016 -3.7477 0.921941 -0.849545 017 4.6377 -0.336759 0.0404545 018 3.7477 0.921941 -0.849545 019 3.7477 0.921941 0.930455 04 -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 8 1.2492 0.921941 -0.849545 -17.495 9 1.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 12 2.4985 -1.22006 0.930455 -13.1263 13 2.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 17 4.6377 -0.336759 0.0404545 -9.35473 18 3.7477 0.921941 -0.849545 -11.4805 19 3.7477 0.921941 0.930455 -9.24445 20 20 21 21 14 15 16 … … 27 27 3 12 13 28 28 11 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 29 7 11 13 30 4 7 13 31 2 4 7 32 2 4 5 33 2 5 10 34 5 10 15 35 10 14 15 36 36 9 10 14 37 37 2 9 10 … … 40 40 1 7 8 41 41 7 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 42 9 14 16 43 6 9 16 44 1 6 9 45 1 3 6 46 1 3 8 47 3 8 12 48 8 11 12 -
tests/Tesselations/heptan/3/NonConvexEnvelope-heptan.dat
rc39cc4 rbdb143 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 -7.27e-07 -1.22006 0.930455 05 -7.27e-07 -1.22006 -0.849545 06 -1.2492 0.921941 0.930455 07 -1.2492 0.921941 -0.849545 08 1.2492 0.921941 -0.849545 09 1.2492 0.921941 0.930455 010 -2.4985 -1.22006 -0.849545 011 -2.4985 -1.22006 0.930455 012 2.4985 -1.22006 0.930455 013 2.4985 -1.22006 -0.849545 014 -4.6377 -0.336759 0.0404545 015 -3.7477 0.921941 0.930455 016 -3.7477 0.921941 -0.849545 017 4.6377 -0.336759 0.0404545 018 3.7477 0.921941 -0.849545 019 3.7477 0.921941 0.930455 04 -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 8 1.2492 0.921941 -0.849545 -17.495 9 1.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 12 2.4985 -1.22006 0.930455 -13.1263 13 2.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 17 4.6377 -0.336759 0.0404545 -9.35473 18 3.7477 0.921941 -0.849545 -11.4805 19 3.7477 0.921941 0.930455 -9.24445 20 20 21 21 14 15 16 … … 27 27 3 12 13 28 28 11 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 29 7 11 13 30 4 7 13 31 2 4 7 32 2 4 5 33 2 5 10 34 5 10 15 35 10 14 15 36 36 9 10 14 37 37 2 9 10 … … 40 40 1 7 8 41 41 7 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 42 9 14 16 43 6 9 16 44 1 6 9 45 1 3 6 46 1 3 8 47 3 8 12 48 8 11 12 -
tests/Tesselations/heptan/4/NonConvexEnvelope-heptan.dat
rc39cc4 rbdb143 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 -7.27e-07 -1.22006 0.930455 05 -7.27e-07 -1.22006 -0.849545 06 -1.2492 0.921941 0.930455 07 -1.2492 0.921941 -0.849545 08 1.2492 0.921941 -0.849545 09 1.2492 0.921941 0.930455 010 -2.4985 -1.22006 -0.849545 011 -2.4985 -1.22006 0.930455 012 2.4985 -1.22006 0.930455 013 2.4985 -1.22006 -0.849545 014 -4.6377 -0.336759 0.0404545 015 -3.7477 0.921941 0.930455 016 -3.7477 0.921941 -0.849545 017 4.6377 -0.336759 0.0404545 018 3.7477 0.921941 -0.849545 019 3.7477 0.921941 0.930455 04 -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 8 1.2492 0.921941 -0.849545 -17.495 9 1.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 12 2.4985 -1.22006 0.930455 -13.1263 13 2.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 17 4.6377 -0.336759 0.0404545 -9.35473 18 3.7477 0.921941 -0.849545 -11.4805 19 3.7477 0.921941 0.930455 -9.24445 20 20 21 21 14 15 16 … … 27 27 3 12 13 28 28 11 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 29 7 11 13 30 4 7 13 31 2 4 7 32 2 4 5 33 2 5 10 34 5 10 15 35 10 14 15 36 36 9 10 14 37 37 2 9 10 … … 40 40 1 7 8 41 41 7 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 42 9 14 16 43 6 9 16 44 1 6 9 45 1 3 6 46 1 3 8 47 3 8 12 48 8 11 12 -
tests/regression/Simple_configuration/2/post/test.conf
rc39cc4 rbdb143 35 35 RelEpsTotalE 1e-07 # relative change in total energy 36 36 RelEpsKineticE 1e-05 # relative change in kinetic energy 37 MaxMinStopStep 0# check every ..th steps37 MaxMinStopStep 1 # check every ..th steps 38 38 MaxMinGapStopStep 0 # check every ..th steps 39 39 … … 42 42 InitRelEpsTotalE 1e-05 # relative change in total energy 43 43 InitRelEpsKineticE 0.0001 # relative change in kinetic energy 44 InitMaxMinStopStep 0# check every ..th steps44 InitMaxMinStopStep 1 # check every ..th steps 45 45 InitMaxMinGapStopStep 0 # check every ..th steps 46 46 … … 54 54 Level0Factor 2 # factor by which node number increases from S to 0 level 55 55 RiemannTensor 0 # (Use metric) 56 PsiType 0# 0 - doubly occupied, 1 - SpinUp,SpinDown56 PsiType 1 # 0 - doubly occupied, 1 - SpinUp,SpinDown 57 57 MaxPsiDouble 0 # here: specifying both maximum number of SpinUp- and -Down-states 58 58 PsiMaxNoUp 0 # here: specifying maximum number of SpinUp-states 59 PsiMaxNoDown 0# here: specifying maximum number of SpinDown-states59 PsiMaxNoDown 1 # here: specifying maximum number of SpinDown-states 60 60 AddPsis 0 # Additional unoccupied Psis for bandgap determination 61 61 -
tests/regression/Simple_configuration/2/post/test.conf.xyz
rc39cc4 rbdb143 1 1 1 2 2 Created by molecuilder on Tue Oct 6 18:34:23 2009 3 H 10 10 10 3 H 10 10 10 -
tests/regression/Simple_configuration/3/post/test.conf
rc39cc4 rbdb143 35 35 RelEpsTotalE 1e-07 # relative change in total energy 36 36 RelEpsKineticE 1e-05 # relative change in kinetic energy 37 MaxMinStopStep 0# check every ..th steps37 MaxMinStopStep 1 # check every ..th steps 38 38 MaxMinGapStopStep 0 # check every ..th steps 39 39 … … 42 42 InitRelEpsTotalE 1e-05 # relative change in total energy 43 43 InitRelEpsKineticE 0.0001 # relative change in kinetic energy 44 InitMaxMinStopStep 0# check every ..th steps44 InitMaxMinStopStep 1 # check every ..th steps 45 45 InitMaxMinGapStopStep 0 # check every ..th steps 46 46 … … 54 54 Level0Factor 2 # factor by which node number increases from S to 0 level 55 55 RiemannTensor 0 # (Use metric) 56 PsiType 0# 0 - doubly occupied, 1 - SpinUp,SpinDown56 PsiType 1 # 0 - doubly occupied, 1 - SpinUp,SpinDown 57 57 MaxPsiDouble 0 # here: specifying both maximum number of SpinUp- and -Down-states 58 58 PsiMaxNoUp 0 # here: specifying maximum number of SpinUp-states 59 PsiMaxNoDown 0# here: specifying maximum number of SpinDown-states59 PsiMaxNoDown 1 # here: specifying maximum number of SpinDown-states 60 60 AddPsis 0 # Additional unoccupied Psis for bandgap determination 61 61 -
tests/regression/Simple_configuration/3/post/test.conf.xyz
rc39cc4 rbdb143 1 1 1 2 2 Created by molecuilder on Tue Oct 6 18:34:23 2009 3 H 10 10 10 3 H 10 10 10 -
tests/regression/Simple_configuration/4/post/test.conf
rc39cc4 rbdb143 35 35 RelEpsTotalE 1e-07 # relative change in total energy 36 36 RelEpsKineticE 1e-05 # relative change in kinetic energy 37 MaxMinStopStep 0# check every ..th steps37 MaxMinStopStep 2 # check every ..th steps 38 38 MaxMinGapStopStep 1 # check every ..th steps 39 39 … … 42 42 InitRelEpsTotalE 1e-05 # relative change in total energy 43 43 InitRelEpsKineticE 0.0001 # relative change in kinetic energy 44 InitMaxMinStopStep 0# check every ..th steps44 InitMaxMinStopStep 2 # check every ..th steps 45 45 InitMaxMinGapStopStep 1 # check every ..th steps 46 46 … … 55 55 RiemannTensor 0 # (Use metric) 56 56 PsiType 0 # 0 - doubly occupied, 1 - SpinUp,SpinDown 57 MaxPsiDouble 0# here: specifying both maximum number of SpinUp- and -Down-states58 PsiMaxNoUp 0# here: specifying maximum number of SpinUp-states59 PsiMaxNoDown 0# here: specifying maximum number of SpinDown-states57 MaxPsiDouble 2 # here: specifying both maximum number of SpinUp- and -Down-states 58 PsiMaxNoUp 2 # here: specifying maximum number of SpinUp-states 59 PsiMaxNoDown 2 # here: specifying maximum number of SpinDown-states 60 60 AddPsis 0 # Additional unoccupied Psis for bandgap determination 61 61 -
tests/regression/Simple_configuration/4/post/test.conf.xyz
rc39cc4 rbdb143 1 1 1 2 2 Created by molecuilder on Tue Oct 6 18:31:23 2009 3 C 10 10 10 3 C 10 10 10 -
tests/regression/Tesselation/1/post/NonConvexEnvelope.dat
rc39cc4 rbdb143 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 9.78209 2.64589 2.64589 05 9.78209 2.64589 4.42589 06 10.672 3.90454 3.53589 07 8.53279 4.78789 2.64589 08 8.53279 4.78789 4.42589 09 6.39363 3.90454 3.53589 010 7.28359 2.64589 2.64589 011 7.28359 2.64589 4.42589 04 9.78209 2.64589 2.64589 -9.24443 5 9.78209 2.64589 4.42589 -11.4804 6 10.672 3.90454 3.53589 -9.35464 7 8.53279 4.78789 2.64589 -9.11459 8 8.53279 4.78789 4.42589 -9.11459 9 6.39363 3.90454 3.53589 -9.35431 10 7.28359 2.64589 2.64589 -11.4803 11 7.28359 2.64589 4.42589 -9.24433 12 12 13 13 1 3 4 -
tests/regression/Tesselation/1/post/NonConvexEnvelope.r3d
rc39cc4 rbdb143 3 3 # All atoms as spheres 4 4 2 5 1. 37419 -0.26503 -4.44089e-160.1 1. 1. 1.5 1.24926 -0.870237 -0.89 0.1 1. 1. 1. 6 6 2 7 0.12489 0.61837 -4.44089e-160.1 1. 1. 1.7 1.24926 -0.870237 0.89 0.1 1. 1. 1. 8 8 2 9 -1.12431 -0.26503 -4.44089e-160.1 1. 1. 1.9 2.13922 0.388414 0 0.1 1. 1. 1. 10 10 2 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. 12 12 2 13 1.37419 -0.894330.89 0.1 1. 1. 1.13 -3.63639e-05 1.27176 0.89 0.1 1. 1. 1. 14 14 2 15 2.26414 0.364321 -4.44089e-160.1 1. 1. 1.15 -2.13919 0.388414 0 0.1 1. 1. 1. 16 16 2 17 0.12489 1.24767 -0.89 0.1 1. 1. 1.17 -1.24924 -0.870237 -0.89 0.1 1. 1. 1. 18 18 2 19 0.12489 1.24767 0.89 0.1 1. 1. 1.19 -1.24924 -0.870237 0.89 0.1 1. 1. 1. 20 20 2 21 -2.01426 0.364321 -4.44089e-160.1 1. 1. 1.21 1.24926 -0.240937 0 0.1 1. 1. 1. 22 22 2 23 - 1.12431 -0.89433 -0.890.1 1. 1. 1.23 -3.63639e-05 0.642463 0 0.1 1. 1. 1. 24 24 2 25 -1. 12431 -0.89433 0.890.1 1. 1. 1.25 -1.24924 -0.240937 0 0.1 1. 1. 1. 26 26 # All tesselation triangles 27 27 8 … … 30 30 BACKFACE 0.3 0.3 1.0 0 0 31 31 1 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. 33 33 1 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. 35 35 1 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. 37 37 1 38 2. 26414 0.364321 -4.44089e-16 0.12489 1.24767 -0.89 0.12489 1.247670.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. 39 39 1 40 0.12489 1.24767 -0.89 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-161. 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. 41 41 1 42 1. 37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-16 0.12489 1.247670.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. 43 43 1 44 1. 37419 -0.89433 0.89 0.12489 1.24767 0.89 -1.12431 -0.894330.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. 45 45 1 46 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.894330.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. 47 47 1 48 -2. 01426 0.364321 -4.44089e-16 -1.12431 -0.89433 -0.89 -1.12431 -0.894330.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. 49 49 1 50 1. 37419 -0.89433 0.89 -1.12431 -0.89433 -0.89 -1.12431 -0.894330.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. 51 51 1 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. 53 53 1 54 1. 37419 -0.89433 -0.89 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-161. 0. 0.54 1.24926 -0.870237 -0.89 1.24926 -0.870237 0.89 2.13922 0.388414 0 1. 0. 0. 55 55 9 56 56 # terminating special property … … 59 59 25.0 0.6 -1.0 -1.0 -1.0 0.2 0 0 0 0 60 60 2 61 1. 67084 -0.47478 -8.88178e-16 5 1 0 061 1.54591 -0.450686 -4.44089e-16 5 1 0 0 62 62 9 63 63 terminating special property -
tests/regression/Tesselation/2/post/ConvexEnvelope.dat
rc39cc4 rbdb143 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 9.78209 2.64589 2.64589 05 9.78209 2.64589 4.42589 06 10.672 3.90454 3.53589 07 8.53279 4.78789 2.64589 08 8.53279 4.78789 4.42589 09 6.39363 3.90454 3.53589 010 7.28359 2.64589 2.64589 011 7.28359 2.64589 4.42589 04 9.78209 2.64589 2.64589 -9.24443 5 9.78209 2.64589 4.42589 -11.4804 6 10.672 3.90454 3.53589 -9.35464 7 8.53279 4.78789 2.64589 -9.11459 8 8.53279 4.78789 4.42589 -9.11459 9 6.39363 3.90454 3.53589 -9.35431 10 7.28359 2.64589 2.64589 -11.4803 11 7.28359 2.64589 4.42589 -9.24433 12 12 13 13 1 3 4 -
tests/regression/Tesselation/2/post/ConvexEnvelope.r3d
rc39cc4 rbdb143 3 3 # All atoms as spheres 4 4 2 5 1. 37419 -0.26503 -4.44089e-160.1 1. 1. 1.5 1.24926 -0.870237 -0.89 0.1 1. 1. 1. 6 6 2 7 0.12489 0.61837 -4.44089e-160.1 1. 1. 1.7 1.24926 -0.870237 0.89 0.1 1. 1. 1. 8 8 2 9 -1.12431 -0.26503 -4.44089e-160.1 1. 1. 1.9 2.13922 0.388414 0 0.1 1. 1. 1. 10 10 2 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. 12 12 2 13 1.37419 -0.894330.89 0.1 1. 1. 1.13 -3.63639e-05 1.27176 0.89 0.1 1. 1. 1. 14 14 2 15 2.26414 0.364321 -4.44089e-160.1 1. 1. 1.15 -2.13919 0.388414 0 0.1 1. 1. 1. 16 16 2 17 0.12489 1.24767 -0.89 0.1 1. 1. 1.17 -1.24924 -0.870237 -0.89 0.1 1. 1. 1. 18 18 2 19 0.12489 1.24767 0.89 0.1 1. 1. 1.19 -1.24924 -0.870237 0.89 0.1 1. 1. 1. 20 20 2 21 -2.01426 0.364321 -4.44089e-160.1 1. 1. 1.21 1.24926 -0.240937 0 0.1 1. 1. 1. 22 22 2 23 - 1.12431 -0.89433 -0.890.1 1. 1. 1.23 -3.63639e-05 0.642463 0 0.1 1. 1. 1. 24 24 2 25 -1. 12431 -0.89433 0.890.1 1. 1. 1.25 -1.24924 -0.240937 0 0.1 1. 1. 1. 26 26 # All tesselation triangles 27 27 8 … … 30 30 BACKFACE 0.3 0.3 1.0 0 0 31 31 1 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. 33 33 1 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. 35 35 1 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. 37 37 1 38 2. 26414 0.364321 -4.44089e-16 0.12489 1.24767 -0.89 0.12489 1.247670.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. 39 39 1 40 0.12489 1.24767 -0.89 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-161. 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. 41 41 1 42 1. 37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-16 0.12489 1.247670.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. 43 43 1 44 1. 37419 -0.89433 0.89 0.12489 1.24767 0.89 -1.12431 -0.894330.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. 45 45 1 46 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.894330.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. 47 47 1 48 -2. 01426 0.364321 -4.44089e-16 -1.12431 -0.89433 -0.89 -1.12431 -0.894330.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. 49 49 1 50 1. 37419 -0.89433 0.89 -1.12431 -0.89433 -0.89 -1.12431 -0.894330.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. 51 51 1 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. 53 53 1 54 1. 37419 -0.89433 -0.89 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-161. 0. 0.54 1.24926 -0.870237 -0.89 1.24926 -0.870237 0.89 2.13922 0.388414 0 1. 0. 0. 55 55 9 56 56 # terminating special property … … 59 59 25.0 0.6 -1.0 -1.0 -1.0 0.2 0 0 0 0 60 60 2 61 1. 67084 -0.47478 -8.88178e-16 5 1 0 061 1.54591 -0.450686 -4.44089e-16 5 1 0 0 62 62 9 63 63 terminating special property -
tests/regression/Tesselation/2/post/NonConvexEnvelope.dat
rc39cc4 rbdb143 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 9.78209 2.64589 2.64589 05 9.78209 2.64589 4.42589 06 10.672 3.90454 3.53589 07 8.53279 4.78789 2.64589 08 8.53279 4.78789 4.42589 09 6.39363 3.90454 3.53589 010 7.28359 2.64589 2.64589 011 7.28359 2.64589 4.42589 04 9.78209 2.64589 2.64589 -9.24443 5 9.78209 2.64589 4.42589 -11.4804 6 10.672 3.90454 3.53589 -9.35464 7 8.53279 4.78789 2.64589 -9.11459 8 8.53279 4.78789 4.42589 -9.11459 9 6.39363 3.90454 3.53589 -9.35431 10 7.28359 2.64589 2.64589 -11.4803 11 7.28359 2.64589 4.42589 -9.24433 12 12 13 13 1 3 4 -
tests/regression/Tesselation/2/post/NonConvexEnvelope.r3d
rc39cc4 rbdb143 3 3 # All atoms as spheres 4 4 2 5 1. 37419 -0.26503 -4.44089e-160.1 1. 1. 1.5 1.24926 -0.870237 -0.89 0.1 1. 1. 1. 6 6 2 7 0.12489 0.61837 -4.44089e-160.1 1. 1. 1.7 1.24926 -0.870237 0.89 0.1 1. 1. 1. 8 8 2 9 -1.12431 -0.26503 -4.44089e-160.1 1. 1. 1.9 2.13922 0.388414 0 0.1 1. 1. 1. 10 10 2 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. 12 12 2 13 1.37419 -0.894330.89 0.1 1. 1. 1.13 -3.63639e-05 1.27176 0.89 0.1 1. 1. 1. 14 14 2 15 2.26414 0.364321 -4.44089e-160.1 1. 1. 1.15 -2.13919 0.388414 0 0.1 1. 1. 1. 16 16 2 17 0.12489 1.24767 -0.89 0.1 1. 1. 1.17 -1.24924 -0.870237 -0.89 0.1 1. 1. 1. 18 18 2 19 0.12489 1.24767 0.89 0.1 1. 1. 1.19 -1.24924 -0.870237 0.89 0.1 1. 1. 1. 20 20 2 21 -2.01426 0.364321 -4.44089e-160.1 1. 1. 1.21 1.24926 -0.240937 0 0.1 1. 1. 1. 22 22 2 23 - 1.12431 -0.89433 -0.890.1 1. 1. 1.23 -3.63639e-05 0.642463 0 0.1 1. 1. 1. 24 24 2 25 -1. 12431 -0.89433 0.890.1 1. 1. 1.25 -1.24924 -0.240937 0 0.1 1. 1. 1. 26 26 # All tesselation triangles 27 27 8 … … 30 30 BACKFACE 0.3 0.3 1.0 0 0 31 31 1 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. 33 33 1 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. 35 35 1 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. 37 37 1 38 2. 26414 0.364321 -4.44089e-16 0.12489 1.24767 -0.89 0.12489 1.247670.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. 39 39 1 40 0.12489 1.24767 -0.89 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-161. 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. 41 41 1 42 1. 37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-16 0.12489 1.247670.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. 43 43 1 44 1. 37419 -0.89433 0.89 0.12489 1.24767 0.89 -1.12431 -0.894330.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. 45 45 1 46 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.894330.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. 47 47 1 48 -2. 01426 0.364321 -4.44089e-16 -1.12431 -0.89433 -0.89 -1.12431 -0.894330.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. 49 49 1 50 1. 37419 -0.89433 0.89 -1.12431 -0.89433 -0.89 -1.12431 -0.894330.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. 51 51 1 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. 53 53 1 54 1. 37419 -0.89433 -0.89 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-161. 0. 0.54 1.24926 -0.870237 -0.89 1.24926 -0.870237 0.89 2.13922 0.388414 0 1. 0. 0. 55 55 9 56 56 # terminating special property … … 59 59 25.0 0.6 -1.0 -1.0 -1.0 0.2 0 0 0 0 60 60 2 61 1. 67084 -0.47478 -8.88178e-16 5 1 0 061 1.54591 -0.450686 -4.44089e-16 5 1 0 0 62 62 9 63 63 terminating special property -
tests/regression/Tesselation/3/post/NonConvexEnvelope.dat
rc39cc4 rbdb143 2 2 VARIABLES = "X" "Y" "Z" "U" 3 3 ZONE T="test", N=44, E=86, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 6.9077 1.1106 0.1214 15 0.3612 -3.628 1.323 16 0.4884 -3.5983 -0.4521 37 1.4985 -2.5112 0.5308 48 -1.9534 -3.5752 0.5362 29 -1.1883 -0.199 1.5176 310 -0.7165 -1.6046 2.5129 111 1.7627 -1.4479 -0.8349 412 -1.003 -1.3584 -2.8848 213 0.0217 -2.6629 -2.2008 1 14 -2.8885 -1.5706 1.7543 215 -2.0579 -3.6765 -1.7622 016 -2.9259 -2.1146 -1.7672 117 1.0353 0.1785 2.542 318 1.6325 -1.3323 1.8306 219 0.7271 1.177 0.3594 320 1.3374 -0.2942 -2.961 221 0.6036 1.0859 -2.1126 322 -3.2034 -0.5041 -1.0881 323 -5.1809 -1.8679 0.9687 124 -4.6025 -2.4721 -0.6025 225 -4.3385 -3.4329 0.8725 026 3.191 1.3217 -2.8354 127 -4.0905 0.6312 1.6028 328 2.8131 1.4776 2.5103 029 3.9137 2.2936 1.3739 030 2.159 2.5738 1.2698 531 3.6606 -0.4593 2.1396 2 32 3.2007 -1.4419 0.7311 433 -3.3002 2.3589 0.0094 834 -4.377 1.6962 -1.2433 335 5.2593 1.4547 -1.7445 036 4.6863 2.7674 -0.6775 037 5.746 -0.9031 1.204 038 5.1212 -0.8867 -0.4582 439 -5.2641 2.8314 1.4476 040 5.2727 1.6068 1.2828 241 -6.2394 4.6427 0.0632 042 -4.4738 4.5591 -0.1458 343 -5.5506 3.8964 -1.3985 044 -6.7081 0.9923 0.6224 245 -7.5442 2.5597 0.5118 046 -6.8554 1.8134 -0.9499 147 7.1391 2.0447 0.0264 04 6.9077 1.1106 0.1214 -6.99715 5 0.3612 -3.628 1.323 6.00416 6 0.4884 -3.5983 -0.4521 11.8428 7 1.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 11 1.7627 -1.4479 -0.8349 7.15053 12 -1.003 -1.3584 -2.8848 32.043 13 0.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 17 1.0353 0.1785 2.542 48.8869 18 1.6325 -1.3323 1.8306 1.44108 19 0.7271 1.177 0.3594 27.9872 20 1.3374 -0.2942 -2.961 13.6459 21 0.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 26 3.191 1.3217 -2.8354 -10.5968 27 -4.0905 0.6312 1.6028 21.8745 28 2.8131 1.4776 2.5103 -0.774194 29 3.9137 2.2936 1.3739 -2.51806 30 2.159 2.5738 1.2698 151.494 31 3.6606 -0.4593 2.1396 2.60004 32 3.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 35 5.2593 1.4547 -1.7445 -6.26082 36 4.6863 2.7674 -0.6775 -8.55931 37 5.746 -0.9031 1.204 -1.29544 38 5.1212 -0.8867 -0.4582 31.5177 39 -5.2641 2.8314 1.4476 21.5516 40 5.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 47 7.1391 2.0447 0.0264 -7.88713 48 48 49 49 1 32 44 -
tests/regression/Tesselation/3/post/NonConvexEnvelope.r3d
rc39cc4 rbdb143 3 3 # All atoms as spheres 4 4 2 5 0.9 52534 -3.05798 0.4201710.1 1. 1. 1.6 2 7 -0.1 39866 -1.98848 0.3597710.1 1. 1. 1.8 2 9 0.0 788342 -1.07508 -0.8752290.1 1. 1. 1.10 2 11 -1. 49147 -2.63828 0.0780712 0.1 1. 1. 1.12 2 13 -0.0 588658 -1.09478 1.583470.1 1. 1. 1.14 2 15 1.5 3473 -0.644479 -0.8681290.1 1. 1. 1.16 2 17 -0.3 33166 -2.00128 -2.024430.1 1. 1. 1.18 2 19 -2.6 2147 -1.78218 0.6535710.1 1. 1. 1.20 2 21 -1.6 0077 -2.70398 -1.465630.1 1. 1. 1.22 2 23 1.3 7913 -0.560579 1.656070.1 1. 1. 1.24 2 25 1.7 5933 0.205421 0.3953710.1 1. 1. 1.26 2 27 1.7 9893 0.246421 -2.088830.1 1. 1. 1.28 2 29 -2.6 4037 -0.423279 -0.0491288 0.1 1. 1. 1.30 2 31 -3.9 6017 -2.48928 0.4326710.1 1. 1. 1.32 2 33 3.2 3013 0.593821 0.4844710.1 1. 1. 1.34 2 35 3.1 4803 0.889821 -1.968330.1 1. 1. 1.36 2 37 -3. 79507 0.418021 0.4983710.1 1. 1. 1.38 2 39 3.3 6023 1.76962 1.454870.1 1. 1. 1.40 2 41 3.7 8273 1.01752 -0.8494290.1 1. 1. 1.42 2 43 4.0 7093 -0.563879 1.017670.1 1. 1. 1.44 2 45 -3.8 1397 1.77692 -0.2043290.1 1. 1. 1.46 2 47 5.1 7783 1.62112 -0.8428290.1 1. 1. 1.48 2 49 5.4 9863 -0.464179 0.4820710.1 1. 1. 1.50 2 51 -4.9 6867 2.61822 0.3431710.1 1. 1. 1.52 2 53 5.9 3083 0.990421 0.3373710.1 1. 1. 1.54 2 55 - 4.98757 3.97722 -0.3595290.1 1. 1. 1.56 2 57 -6. 29237 1.89422 0.0890712 0.1 1. 1. 1.58 2 59 7.3 3693 1.04442 0.0886712 0.1 1. 1. 1.60 2 61 0.7 90434 -3.69418 1.290270.1 1. 1. 1.62 2 63 0.9 17634 -3.66448 -0.4848290.1 1. 1. 1.64 2 65 1.9 2773 -2.57738 0.4980710.1 1. 1. 1.66 2 67 -0.5 74266 -0.203779 -0.8247290.1 1. 1. 1.68 2 69 -1.5 2417 -3.64138 0.5034710.1 1. 1. 1.70 2 71 -0.7 59066 -0.265179 1.484870.1 1. 1. 1.72 2 73 -0. 287266 -1.67078 2.480170.1 1. 1. 1.74 2 75 2.1 9193 -1.51408 -0.8676290.1 1. 1. 1.76 2 77 -0.5 73766 -1.42458 -2.917530.1 1. 1. 1.78 2 79 0.4 50934 -2.72908 -2.233530.1 1. 1. 1.80 2 81 -2.4 5927 -1.63678 1.721570.1 1. 1. 1.82 2 83 -1.6 2867 -3.74268 -1.794930.1 1. 1. 1.84 2 85 -2. 49667 -2.18078 -1.799930.1 1. 1. 1.86 2 87 1.4 6453 0.112321 2.509270.1 1. 1. 1.88 2 89 2.0 6173 -1.39848 1.797870.1 1. 1. 1.90 2 91 1.1 5633 1.11082 0.3266710.1 1. 1. 1.92 2 93 1.7 6663 -0.360379 -2.993730.1 1. 1. 1.94 2 95 1.0 3283 1.01972 -2.145330.1 1. 1. 1.96 2 97 -1. 69727 0.0925205 0.1319710.1 1. 1. 1.98 2 99 -2.7 7417 -0.570279 -1.120830.1 1. 1. 1.100 2 101 -4.7 5167 -1.93408 0.9359710.1 1. 1. 1.102 2 103 -4.1 7327 -2.53828 -0.6352290.1 1. 1. 1.104 2 105 -3.9 0927 -3.49908 0.8397710.1 1. 1. 1.106 2 107 3.6 2023 1.25552 -2.868130.1 1. 1. 1.108 2 109 -4.7 3807 -0.0977795 0.3173710.1 1. 1. 1.110 2 111 -3.6 6127 0.565021 1.570070.1 1. 1. 1.112 2 113 3.2 4233 1.41142 2.477570.1 1. 1. 1.114 2 115 4.3 4293 2.22742 1.341170.1 1. 1. 1.116 2 117 2.5 8823 2.50762 1.237070.1 1. 1. 1.118 2 119 4.0 8983 -0.525479 2.106870.1 1. 1. 1.120 2 121 3.6 2993 -1.50808 0.6983710.1 1. 1. 1.122 2 123 -2.8 7097 2.29272 -0.0233288 0.1 1. 1. 1.124 2 125 -3.9 4777 1.63002 -1.276030.1 1. 1. 1.126 2 127 5.6 8853 1.38852 -1.777230.1 1. 1. 1.128 2 129 5.1 1553 2.70122 -0.7102290.1 1. 1. 1.130 2 131 6.1 7523 -0.969279 1.171270.1 1. 1. 1.132 2 133 5.5 5043 -0.952879 -0.4909290.1 1. 1. 1.134 2 135 -4.8 3487 2.76522 1.414870.1 1. 1. 1.136 2 137 5. 70193 1.54062 1.250070.1 1. 1. 1.138 2 139 -5.8 1017 4.57652 0.0304712 0.1 1. 1. 1.140 2 141 -4.0 4457 4.49292 -0.1785290.1 1. 1. 1.142 2 143 -5.1 2137 3.83022 -1.431230.1 1. 1. 1.144 2 145 -6.2 7887 0.926121 0.5896710.1 1. 1. 1.146 2 147 -7.1 1497 2.49352 0.4790710.1 1. 1. 1.148 2 149 -6.4 2617 1.74722 -0.9826290.1 1. 1. 1.150 2 151 7.5 6833 1.97852 -0.006328770.1 1. 1. 1.5 0.939662 -3.01666 0.414493 0.1 1. 1. 1. 6 2 7 -0.152738 -1.94716 0.354093 0.1 1. 1. 1. 8 2 9 0.0659622 -1.03376 -0.880907 0.1 1. 1. 1. 10 2 11 -1.50434 -2.59696 0.0723932 0.1 1. 1. 1. 12 2 13 -0.0717378 -1.05346 1.57779 0.1 1. 1. 1. 14 2 15 1.52186 -0.603155 -0.873807 0.1 1. 1. 1. 16 2 17 -0.346038 -1.95996 -2.03011 0.1 1. 1. 1. 18 2 19 -2.63434 -1.74086 0.647893 0.1 1. 1. 1. 20 2 21 -1.61364 -2.66266 -1.47131 0.1 1. 1. 1. 22 2 23 1.36626 -0.519255 1.65039 0.1 1. 1. 1. 24 2 25 1.74646 0.246745 0.389693 0.1 1. 1. 1. 26 2 27 1.78606 0.287745 -2.09451 0.1 1. 1. 1. 28 2 29 -2.65324 -0.381955 -0.0548068 0.1 1. 1. 1. 30 2 31 -3.97304 -2.44796 0.426993 0.1 1. 1. 1. 32 2 33 3.21726 0.635145 0.478793 0.1 1. 1. 1. 34 2 35 3.13516 0.931145 -1.97401 0.1 1. 1. 1. 36 2 37 -3.80794 0.459345 0.492693 0.1 1. 1. 1. 38 2 39 3.34736 1.81094 1.44919 0.1 1. 1. 1. 40 2 41 3.76986 1.05884 -0.855107 0.1 1. 1. 1. 42 2 43 4.05806 -0.522555 1.01199 0.1 1. 1. 1. 44 2 45 -3.82684 1.81824 -0.210007 0.1 1. 1. 1. 46 2 47 5.16496 1.66244 -0.848507 0.1 1. 1. 1. 48 2 49 5.48576 -0.422855 0.476393 0.1 1. 1. 1. 50 2 51 -4.98154 2.65954 0.337493 0.1 1. 1. 1. 52 2 53 5.91796 1.03174 0.331693 0.1 1. 1. 1. 54 2 55 -5.00044 4.01854 -0.365207 0.1 1. 1. 1. 56 2 57 -6.30524 1.93554 0.0833932 0.1 1. 1. 1. 58 2 59 7.32406 1.08574 0.0829932 0.1 1. 1. 1. 60 2 61 0.777562 -3.65286 1.28459 0.1 1. 1. 1. 62 2 63 0.904762 -3.62316 -0.490507 0.1 1. 1. 1. 64 2 65 1.91486 -2.53606 0.492393 0.1 1. 1. 1. 66 2 67 -0.587138 -0.162455 -0.830407 0.1 1. 1. 1. 68 2 69 -1.53704 -3.60006 0.497793 0.1 1. 1. 1. 70 2 71 -0.771938 -0.223855 1.47919 0.1 1. 1. 1. 72 2 73 -0.300138 -1.62946 2.47449 0.1 1. 1. 1. 74 2 75 2.17906 -1.47276 -0.873307 0.1 1. 1. 1. 76 2 77 -0.586638 -1.38326 -2.92321 0.1 1. 1. 1. 78 2 79 0.438062 -2.68776 -2.23921 0.1 1. 1. 1. 80 2 81 -2.47214 -1.59546 1.71589 0.1 1. 1. 1. 82 2 83 -1.64154 -3.70136 -1.80061 0.1 1. 1. 1. 84 2 85 -2.50954 -2.13946 -1.80561 0.1 1. 1. 1. 86 2 87 1.45166 0.153645 2.50359 0.1 1. 1. 1. 88 2 89 2.04886 -1.35716 1.79219 0.1 1. 1. 1. 90 2 91 1.14346 1.15214 0.320993 0.1 1. 1. 1. 92 2 93 1.75376 -0.319055 -2.99941 0.1 1. 1. 1. 94 2 95 1.01996 1.06104 -2.15101 0.1 1. 1. 1. 96 2 97 -1.71014 0.133845 0.126293 0.1 1. 1. 1. 98 2 99 -2.78704 -0.528955 -1.12651 0.1 1. 1. 1. 100 2 101 -4.76454 -1.89276 0.930293 0.1 1. 1. 1. 102 2 103 -4.18614 -2.49696 -0.640907 0.1 1. 1. 1. 104 2 105 -3.92214 -3.45776 0.834093 0.1 1. 1. 1. 106 2 107 3.60736 1.29684 -2.87381 0.1 1. 1. 1. 108 2 109 -4.75094 -0.0564554 0.311693 0.1 1. 1. 1. 110 2 111 -3.67414 0.606345 1.56439 0.1 1. 1. 1. 112 2 113 3.22946 1.45274 2.47189 0.1 1. 1. 1. 114 2 115 4.33006 2.26874 1.33549 0.1 1. 1. 1. 116 2 117 2.57536 2.54894 1.23139 0.1 1. 1. 1. 118 2 119 4.07696 -0.484155 2.10119 0.1 1. 1. 1. 120 2 121 3.61706 -1.46676 0.692693 0.1 1. 1. 1. 122 2 123 -2.88384 2.33404 -0.0290068 0.1 1. 1. 1. 124 2 125 -3.96064 1.67134 -1.28171 0.1 1. 1. 1. 126 2 127 5.67566 1.42984 -1.78291 0.1 1. 1. 1. 128 2 129 5.10266 2.74254 -0.715907 0.1 1. 1. 1. 130 2 131 6.16236 -0.927955 1.16559 0.1 1. 1. 1. 132 2 133 5.53756 -0.911555 -0.496607 0.1 1. 1. 1. 134 2 135 -4.84774 2.80654 1.40919 0.1 1. 1. 1. 136 2 137 5.68906 1.58194 1.24439 0.1 1. 1. 1. 138 2 139 -5.82304 4.61784 0.0247932 0.1 1. 1. 1. 140 2 141 -4.05744 4.53424 -0.184207 0.1 1. 1. 1. 142 2 143 -5.13424 3.87154 -1.43691 0.1 1. 1. 1. 144 2 145 -6.29174 0.967445 0.583993 0.1 1. 1. 1. 146 2 147 -7.12784 2.53484 0.473393 0.1 1. 1. 1. 148 2 149 -6.43904 1.78854 -0.988307 0.1 1. 1. 1. 150 2 151 7.55546 2.01984 -0.0120068 0.1 1. 1. 1. 152 152 # All tesselation triangles 153 153 8 … … 156 156 BACKFACE 0.3 0.3 1.0 0 0 157 157 1 158 7.3 3693 1.04442 0.0886712 5.68853 1.38852 -1.77723 7.56833 1.97852 -0.006328771. 0. 0.159 1 160 7.3 3693 1.04442 0.0886712 5.68853 1.38852 -1.77723 5.55043 -0.952879 -0.4909291. 0. 0.161 1 162 7.3 3693 1.04442 0.0886712 6.17523 -0.969279 1.17127 5.55043 -0.952879 -0.4909291. 0. 0.163 1 164 3.6 2023 1.25552 -2.86813 5.68853 1.38852 -1.77723 5.55043 -0.952879 -0.4909291. 0. 0.165 1 166 1.7 6663 -0.360379 -2.99373 3.62023 1.25552 -2.86813 5.55043 -0.952879 -0.4909291. 0. 0.167 1 168 2.1 9193 -1.51408 -0.867629 1.76663 -0.360379 -2.99373 5.55043 -0.952879 -0.4909291. 0. 0.169 1 170 2.1 9193 -1.51408 -0.867629 0.450934 -2.72908 -2.23353 1.76663 -0.360379 -2.993731. 0. 0.171 1 172 0.9 17634 -3.66448 -0.484829 2.19193 -1.51408 -0.867629 0.450934 -2.72908 -2.233531. 0. 0.173 1 174 0.9 17634 -3.66448 -0.484829 2.19193 -1.51408 -0.867629 5.55043 -0.952879 -0.4909291. 0. 0.175 1 176 0.9 17634 -3.66448 -0.484829 1.92773 -2.57738 0.498071 5.55043 -0.952879 -0.4909291. 0. 0.177 1 178 1.9 2773 -2.57738 0.498071 3.62993 -1.50808 0.698371 5.55043 -0.952879 -0.4909291. 0. 0.179 1 180 3.6 2993 -1.50808 0.698371 6.17523 -0.969279 1.17127 5.55043 -0.952879 -0.4909291. 0. 0.181 1 182 0.7 90434 -3.69418 1.29027 0.917634 -3.66448 -0.484829 1.92773 -2.57738 0.4980711. 0. 0.183 1 184 0.7 90434 -3.69418 1.29027 1.92773 -2.57738 0.498071 3.62993 -1.50808 0.6983711. 0. 0.185 1 186 0.7 90434 -3.69418 1.29027 2.06173 -1.39848 1.79787 3.62993 -1.50808 0.6983711. 0. 0.187 1 188 2.0 6173 -1.39848 1.79787 4.08983 -0.525479 2.10687 3.62993 -1.50808 0.6983711. 0. 0.189 1 190 4.0 8983 -0.525479 2.10687 3.62993 -1.50808 0.698371 6.17523 -0.969279 1.171271. 0. 0.191 1 192 0.7 90434 -3.69418 1.29027 -0.287266 -1.67078 2.48017 2.06173 -1.39848 1.797871. 0. 0.193 1 194 -0. 287266 -1.67078 2.48017 1.46453 0.112321 2.50927 2.06173 -1.39848 1.797871. 0. 0.195 1 196 1.4 6453 0.112321 2.50927 2.06173 -1.39848 1.79787 4.08983 -0.525479 2.106871. 0. 0.197 1 198 1.4 6453 0.112321 2.50927 3.24233 1.41142 2.47757 4.08983 -0.525479 2.106871. 0. 0.199 1 200 3.2 4233 1.41142 2.47757 4.08983 -0.525479 2.10687 5.70193 1.54062 1.250071. 0. 0.201 1 202 4.0 8983 -0.525479 2.10687 6.17523 -0.969279 1.17127 5.70193 1.54062 1.250071. 0. 0.203 1 204 7.3 3693 1.04442 0.0886712 6.17523 -0.969279 1.17127 5.70193 1.54062 1.250071. 0. 0.205 1 206 7.3 3693 1.04442 0.0886712 5.70193 1.54062 1.25007 7.56833 1.97852 -0.006328771. 0. 0.207 1 208 3.2 4233 1.41142 2.47757 4.34293 2.22742 1.34117 5.70193 1.54062 1.250071. 0. 0.209 1 210 3.2 4233 1.41142 2.47757 4.34293 2.22742 1.34117 2.58823 2.50762 1.237071. 0. 0.211 1 212 4.3 4293 2.22742 1.34117 2.58823 2.50762 1.23707 5.11553 2.70122 -0.7102291. 0. 0.213 1 214 4.3 4293 2.22742 1.34117 5.11553 2.70122 -0.710229 7.56833 1.97852 -0.006328771. 0. 0.215 1 216 4.3 4293 2.22742 1.34117 5.70193 1.54062 1.25007 7.56833 1.97852 -0.006328771. 0. 0.217 1 218 1.4 6453 0.112321 2.50927 3.24233 1.41142 2.47757 2.58823 2.50762 1.237071. 0. 0.219 1 220 1.4 6453 0.112321 2.50927 2.58823 2.50762 1.23707 -2.87097 2.29272 -0.0233288 1. 0. 0.221 1 222 -0.7 59066 -0.265179 1.48487 1.46453 0.112321 2.50927 -2.87097 2.29272 -0.0233288 1. 0. 0.223 1 224 -0.7 59066 -0.265179 1.48487 -3.66127 0.565021 1.57007 -2.87097 2.29272 -0.0233288 1. 0. 0.225 1 226 -3.6 6127 0.565021 1.57007 -2.87097 2.29272 -0.0233288 -4.83487 2.76522 1.414871. 0. 0.227 1 228 -2.8 7097 2.29272 -0.0233288 -4.83487 2.76522 1.41487 -4.04457 4.49292 -0.1785291. 0. 0.229 1 230 2.5 8823 2.50762 1.23707 -2.87097 2.29272 -0.0233288 -4.04457 4.49292 -0.1785291. 0. 0.231 1 232 2.5 8823 2.50762 1.23707 -2.87097 2.29272 -0.0233288 -4.04457 4.49292 -0.1785291. 0. 0.233 1 234 1.1 5633 1.11082 0.326671 2.58823 2.50762 1.23707 -2.87097 2.29272 -0.0233288 1. 0. 0.235 1 236 1.1 5633 1.11082 0.326671 1.03283 1.01972 -2.14533 -2.87097 2.29272 -0.0233288 1. 0. 0.237 1 238 1.1 5633 1.11082 0.326671 1.03283 1.01972 -2.14533 2.58823 2.50762 1.237071. 0. 0.239 1 240 1.0 3283 1.01972 -2.14533 2.58823 2.50762 1.23707 5.11553 2.70122 -0.7102291. 0. 0.241 1 242 1.0 3283 1.01972 -2.14533 3.62023 1.25552 -2.86813 5.11553 2.70122 -0.7102291. 0. 0.243 1 244 -0.7 59066 -0.265179 1.48487 -0.287266 -1.67078 2.48017 -3.66127 0.565021 1.570071. 0. 0.245 1 246 -0.7 59066 -0.265179 1.48487 -0.287266 -1.67078 2.48017 1.46453 0.112321 2.509271. 0. 0.247 1 248 -0. 287266 -1.67078 2.48017 -2.45927 -1.63678 1.72157 -3.66127 0.565021 1.570071. 0. 0.249 1 250 -2.4 5927 -1.63678 1.72157 -4.75167 -1.93408 0.935971 -3.66127 0.565021 1.570071. 0. 0.251 1 252 -4.7 5167 -1.93408 0.935971 -3.66127 0.565021 1.57007 -6.27887 0.926121 0.5896711. 0. 0.253 1 254 -3.6 6127 0.565021 1.57007 -4.83487 2.76522 1.41487 -6.27887 0.926121 0.5896711. 0. 0.255 1 256 -4.8 3487 2.76522 1.41487 -6.27887 0.926121 0.589671 -7.11497 2.49352 0.4790711. 0. 0.257 1 258 -2.4 5927 -1.63678 1.72157 -4.75167 -1.93408 0.935971 -3.90927 -3.49908 0.8397711. 0. 0.259 1 260 -1.5 2417 -3.64138 0.503471 -2.45927 -1.63678 1.72157 -3.90927 -3.49908 0.8397711. 0. 0.261 1 262 -1.5 2417 -3.64138 0.503471 -0.287266 -1.67078 2.48017 -2.45927 -1.63678 1.721571. 0. 0.263 1 264 0.7 90434 -3.69418 1.29027 -1.52417 -3.64138 0.503471 -0.287266 -1.67078 2.480171. 0. 0.265 1 266 -4.8 3487 2.76522 1.41487 -5.81017 4.57652 0.0304712 -4.04457 4.49292 -0.1785291. 0. 0.267 1 268 -4.8 3487 2.76522 1.41487 -5.81017 4.57652 0.0304712 -7.11497 2.49352 0.4790711. 0. 0.269 1 270 1.0 3283 1.01972 -2.14533 -2.87097 2.29272 -0.0233288 -3.94777 1.63002 -1.276031. 0. 0.271 1 272 -2.8 7097 2.29272 -0.0233288 -3.94777 1.63002 -1.27603 -4.04457 4.49292 -0.1785291. 0. 0.273 1 274 -3.9 4777 1.63002 -1.27603 -4.04457 4.49292 -0.178529 -5.12137 3.83022 -1.431231. 0. 0.275 1 276 -0.5 73766 -1.42458 -2.91753 1.03283 1.01972 -2.14533 -3.94777 1.63002 -1.276031. 0. 0.277 1 278 -0.5 73766 -1.42458 -2.91753 1.76663 -0.360379 -2.99373 1.03283 1.01972 -2.145331. 0. 0.279 1 280 1.7 6663 -0.360379 -2.99373 1.03283 1.01972 -2.14533 3.62023 1.25552 -2.868131. 0. 0.281 1 282 -0.5 73766 -1.42458 -2.91753 -2.77417 -0.570279 -1.12083 -3.94777 1.63002 -1.276031. 0. 0.283 1 284 -0.5 73766 -1.42458 -2.91753 -2.49667 -2.18078 -1.79993 -2.77417 -0.570279 -1.120831. 0. 0.285 1 286 -2. 49667 -2.18078 -1.79993 -2.77417 -0.570279 -1.12083 -3.94777 1.63002 -1.276031. 0. 0.287 1 288 -2. 49667 -2.18078 -1.79993 -4.17327 -2.53828 -0.635229 -3.94777 1.63002 -1.276031. 0. 0.289 1 290 -4.1 7327 -2.53828 -0.635229 -3.94777 1.63002 -1.27603 -6.42617 1.74722 -0.9826291. 0. 0.291 1 292 -3.9 4777 1.63002 -1.27603 -5.12137 3.83022 -1.43123 -6.42617 1.74722 -0.9826291. 0. 0.293 1 294 -0.5 73766 -1.42458 -2.91753 -1.62867 -3.74268 -1.79493 -2.49667 -2.18078 -1.799931. 0. 0.295 1 296 -0.5 73766 -1.42458 -2.91753 0.450934 -2.72908 -2.23353 -1.62867 -3.74268 -1.794931. 0. 0.297 1 298 -0.5 73766 -1.42458 -2.91753 0.450934 -2.72908 -2.23353 1.76663 -0.360379 -2.993731. 0. 0.299 1 300 -1.6 2867 -3.74268 -1.79493 -2.49667 -2.18078 -1.79993 -4.17327 -2.53828 -0.6352291. 0. 0.301 1 302 -1.6 2867 -3.74268 -1.79493 -4.17327 -2.53828 -0.635229 -3.90927 -3.49908 0.8397711. 0. 0.303 1 304 -1.5 2417 -3.64138 0.503471 -1.62867 -3.74268 -1.79493 -3.90927 -3.49908 0.8397711. 0. 0.305 1 306 0.9 17634 -3.66448 -0.484829 -1.52417 -3.64138 0.503471 -1.62867 -3.74268 -1.794931. 0. 0.307 1 308 0.7 90434 -3.69418 1.29027 0.917634 -3.66448 -0.484829 -1.52417 -3.64138 0.5034711. 0. 0.309 1 310 0.9 17634 -3.66448 -0.484829 0.450934 -2.72908 -2.23353 -1.62867 -3.74268 -1.794931. 0. 0.311 1 312 -4.7 5167 -1.93408 0.935971 -4.17327 -2.53828 -0.635229 -3.90927 -3.49908 0.8397711. 0. 0.313 1 314 -4.7 5167 -1.93408 0.935971 -4.17327 -2.53828 -0.635229 -6.27887 0.926121 0.5896711. 0. 0.315 1 316 -4.1 7327 -2.53828 -0.635229 -6.27887 0.926121 0.589671 -6.42617 1.74722 -0.9826291. 0. 0.317 1 318 -6.2 7887 0.926121 0.589671 -7.11497 2.49352 0.479071 -6.42617 1.74722 -0.9826291. 0. 0.319 1 320 3.6 2023 1.25552 -2.86813 5.68853 1.38852 -1.77723 5.11553 2.70122 -0.7102291. 0. 0.321 1 322 5.6 8853 1.38852 -1.77723 5.11553 2.70122 -0.710229 7.56833 1.97852 -0.006328771. 0. 0.323 1 324 -5.1 2137 3.83022 -1.43123 -7.11497 2.49352 0.479071 -6.42617 1.74722 -0.9826291. 0. 0.325 1 326 -5.8 1017 4.57652 0.0304712 -5.12137 3.83022 -1.43123 -7.11497 2.49352 0.4790711. 0. 0.327 1 328 -5.8 1017 4.57652 0.0304712 -4.04457 4.49292 -0.178529 -5.12137 3.83022 -1.431231. 0. 0.158 7.32406 1.08574 0.0829932 5.67566 1.42984 -1.78291 7.55546 2.01984 -0.0120068 1. 0. 0. 159 1 160 7.32406 1.08574 0.0829932 5.67566 1.42984 -1.78291 5.53756 -0.911555 -0.496607 1. 0. 0. 161 1 162 7.32406 1.08574 0.0829932 6.16236 -0.927955 1.16559 5.53756 -0.911555 -0.496607 1. 0. 0. 163 1 164 3.60736 1.29684 -2.87381 5.67566 1.42984 -1.78291 5.53756 -0.911555 -0.496607 1. 0. 0. 165 1 166 1.75376 -0.319055 -2.99941 3.60736 1.29684 -2.87381 5.53756 -0.911555 -0.496607 1. 0. 0. 167 1 168 2.17906 -1.47276 -0.873307 1.75376 -0.319055 -2.99941 5.53756 -0.911555 -0.496607 1. 0. 0. 169 1 170 2.17906 -1.47276 -0.873307 0.438062 -2.68776 -2.23921 1.75376 -0.319055 -2.99941 1. 0. 0. 171 1 172 0.904762 -3.62316 -0.490507 2.17906 -1.47276 -0.873307 0.438062 -2.68776 -2.23921 1. 0. 0. 173 1 174 0.904762 -3.62316 -0.490507 2.17906 -1.47276 -0.873307 5.53756 -0.911555 -0.496607 1. 0. 0. 175 1 176 0.904762 -3.62316 -0.490507 1.91486 -2.53606 0.492393 5.53756 -0.911555 -0.496607 1. 0. 0. 177 1 178 1.91486 -2.53606 0.492393 3.61706 -1.46676 0.692693 5.53756 -0.911555 -0.496607 1. 0. 0. 179 1 180 3.61706 -1.46676 0.692693 6.16236 -0.927955 1.16559 5.53756 -0.911555 -0.496607 1. 0. 0. 181 1 182 0.777562 -3.65286 1.28459 0.904762 -3.62316 -0.490507 1.91486 -2.53606 0.492393 1. 0. 0. 183 1 184 0.777562 -3.65286 1.28459 1.91486 -2.53606 0.492393 3.61706 -1.46676 0.692693 1. 0. 0. 185 1 186 0.777562 -3.65286 1.28459 2.04886 -1.35716 1.79219 3.61706 -1.46676 0.692693 1. 0. 0. 187 1 188 2.04886 -1.35716 1.79219 4.07696 -0.484155 2.10119 3.61706 -1.46676 0.692693 1. 0. 0. 189 1 190 4.07696 -0.484155 2.10119 3.61706 -1.46676 0.692693 6.16236 -0.927955 1.16559 1. 0. 0. 191 1 192 0.777562 -3.65286 1.28459 -0.300138 -1.62946 2.47449 2.04886 -1.35716 1.79219 1. 0. 0. 193 1 194 -0.300138 -1.62946 2.47449 1.45166 0.153645 2.50359 2.04886 -1.35716 1.79219 1. 0. 0. 195 1 196 1.45166 0.153645 2.50359 2.04886 -1.35716 1.79219 4.07696 -0.484155 2.10119 1. 0. 0. 197 1 198 1.45166 0.153645 2.50359 3.22946 1.45274 2.47189 4.07696 -0.484155 2.10119 1. 0. 0. 199 1 200 3.22946 1.45274 2.47189 4.07696 -0.484155 2.10119 5.68906 1.58194 1.24439 1. 0. 0. 201 1 202 4.07696 -0.484155 2.10119 6.16236 -0.927955 1.16559 5.68906 1.58194 1.24439 1. 0. 0. 203 1 204 7.32406 1.08574 0.0829932 6.16236 -0.927955 1.16559 5.68906 1.58194 1.24439 1. 0. 0. 205 1 206 7.32406 1.08574 0.0829932 5.68906 1.58194 1.24439 7.55546 2.01984 -0.0120068 1. 0. 0. 207 1 208 3.22946 1.45274 2.47189 4.33006 2.26874 1.33549 5.68906 1.58194 1.24439 1. 0. 0. 209 1 210 3.22946 1.45274 2.47189 4.33006 2.26874 1.33549 2.57536 2.54894 1.23139 1. 0. 0. 211 1 212 4.33006 2.26874 1.33549 2.57536 2.54894 1.23139 5.10266 2.74254 -0.715907 1. 0. 0. 213 1 214 4.33006 2.26874 1.33549 5.10266 2.74254 -0.715907 7.55546 2.01984 -0.0120068 1. 0. 0. 215 1 216 4.33006 2.26874 1.33549 5.68906 1.58194 1.24439 7.55546 2.01984 -0.0120068 1. 0. 0. 217 1 218 1.45166 0.153645 2.50359 3.22946 1.45274 2.47189 2.57536 2.54894 1.23139 1. 0. 0. 219 1 220 1.45166 0.153645 2.50359 2.57536 2.54894 1.23139 -2.88384 2.33404 -0.0290068 1. 0. 0. 221 1 222 -0.771938 -0.223855 1.47919 1.45166 0.153645 2.50359 -2.88384 2.33404 -0.0290068 1. 0. 0. 223 1 224 -0.771938 -0.223855 1.47919 -3.67414 0.606345 1.56439 -2.88384 2.33404 -0.0290068 1. 0. 0. 225 1 226 -3.67414 0.606345 1.56439 -2.88384 2.33404 -0.0290068 -4.84774 2.80654 1.40919 1. 0. 0. 227 1 228 -2.88384 2.33404 -0.0290068 -4.84774 2.80654 1.40919 -4.05744 4.53424 -0.184207 1. 0. 0. 229 1 230 2.57536 2.54894 1.23139 -2.88384 2.33404 -0.0290068 -4.05744 4.53424 -0.184207 1. 0. 0. 231 1 232 2.57536 2.54894 1.23139 -2.88384 2.33404 -0.0290068 -4.05744 4.53424 -0.184207 1. 0. 0. 233 1 234 1.14346 1.15214 0.320993 2.57536 2.54894 1.23139 -2.88384 2.33404 -0.0290068 1. 0. 0. 235 1 236 1.14346 1.15214 0.320993 1.01996 1.06104 -2.15101 -2.88384 2.33404 -0.0290068 1. 0. 0. 237 1 238 1.14346 1.15214 0.320993 1.01996 1.06104 -2.15101 2.57536 2.54894 1.23139 1. 0. 0. 239 1 240 1.01996 1.06104 -2.15101 2.57536 2.54894 1.23139 5.10266 2.74254 -0.715907 1. 0. 0. 241 1 242 1.01996 1.06104 -2.15101 3.60736 1.29684 -2.87381 5.10266 2.74254 -0.715907 1. 0. 0. 243 1 244 -0.771938 -0.223855 1.47919 -0.300138 -1.62946 2.47449 -3.67414 0.606345 1.56439 1. 0. 0. 245 1 246 -0.771938 -0.223855 1.47919 -0.300138 -1.62946 2.47449 1.45166 0.153645 2.50359 1. 0. 0. 247 1 248 -0.300138 -1.62946 2.47449 -2.47214 -1.59546 1.71589 -3.67414 0.606345 1.56439 1. 0. 0. 249 1 250 -2.47214 -1.59546 1.71589 -4.76454 -1.89276 0.930293 -3.67414 0.606345 1.56439 1. 0. 0. 251 1 252 -4.76454 -1.89276 0.930293 -3.67414 0.606345 1.56439 -6.29174 0.967445 0.583993 1. 0. 0. 253 1 254 -3.67414 0.606345 1.56439 -4.84774 2.80654 1.40919 -6.29174 0.967445 0.583993 1. 0. 0. 255 1 256 -4.84774 2.80654 1.40919 -6.29174 0.967445 0.583993 -7.12784 2.53484 0.473393 1. 0. 0. 257 1 258 -2.47214 -1.59546 1.71589 -4.76454 -1.89276 0.930293 -3.92214 -3.45776 0.834093 1. 0. 0. 259 1 260 -1.53704 -3.60006 0.497793 -2.47214 -1.59546 1.71589 -3.92214 -3.45776 0.834093 1. 0. 0. 261 1 262 -1.53704 -3.60006 0.497793 -0.300138 -1.62946 2.47449 -2.47214 -1.59546 1.71589 1. 0. 0. 263 1 264 0.777562 -3.65286 1.28459 -1.53704 -3.60006 0.497793 -0.300138 -1.62946 2.47449 1. 0. 0. 265 1 266 -4.84774 2.80654 1.40919 -5.82304 4.61784 0.0247932 -4.05744 4.53424 -0.184207 1. 0. 0. 267 1 268 -4.84774 2.80654 1.40919 -5.82304 4.61784 0.0247932 -7.12784 2.53484 0.473393 1. 0. 0. 269 1 270 1.01996 1.06104 -2.15101 -2.88384 2.33404 -0.0290068 -3.96064 1.67134 -1.28171 1. 0. 0. 271 1 272 -2.88384 2.33404 -0.0290068 -3.96064 1.67134 -1.28171 -4.05744 4.53424 -0.184207 1. 0. 0. 273 1 274 -3.96064 1.67134 -1.28171 -4.05744 4.53424 -0.184207 -5.13424 3.87154 -1.43691 1. 0. 0. 275 1 276 -0.586638 -1.38326 -2.92321 1.01996 1.06104 -2.15101 -3.96064 1.67134 -1.28171 1. 0. 0. 277 1 278 -0.586638 -1.38326 -2.92321 1.75376 -0.319055 -2.99941 1.01996 1.06104 -2.15101 1. 0. 0. 279 1 280 1.75376 -0.319055 -2.99941 1.01996 1.06104 -2.15101 3.60736 1.29684 -2.87381 1. 0. 0. 281 1 282 -0.586638 -1.38326 -2.92321 -2.78704 -0.528955 -1.12651 -3.96064 1.67134 -1.28171 1. 0. 0. 283 1 284 -0.586638 -1.38326 -2.92321 -2.50954 -2.13946 -1.80561 -2.78704 -0.528955 -1.12651 1. 0. 0. 285 1 286 -2.50954 -2.13946 -1.80561 -2.78704 -0.528955 -1.12651 -3.96064 1.67134 -1.28171 1. 0. 0. 287 1 288 -2.50954 -2.13946 -1.80561 -4.18614 -2.49696 -0.640907 -3.96064 1.67134 -1.28171 1. 0. 0. 289 1 290 -4.18614 -2.49696 -0.640907 -3.96064 1.67134 -1.28171 -6.43904 1.78854 -0.988307 1. 0. 0. 291 1 292 -3.96064 1.67134 -1.28171 -5.13424 3.87154 -1.43691 -6.43904 1.78854 -0.988307 1. 0. 0. 293 1 294 -0.586638 -1.38326 -2.92321 -1.64154 -3.70136 -1.80061 -2.50954 -2.13946 -1.80561 1. 0. 0. 295 1 296 -0.586638 -1.38326 -2.92321 0.438062 -2.68776 -2.23921 -1.64154 -3.70136 -1.80061 1. 0. 0. 297 1 298 -0.586638 -1.38326 -2.92321 0.438062 -2.68776 -2.23921 1.75376 -0.319055 -2.99941 1. 0. 0. 299 1 300 -1.64154 -3.70136 -1.80061 -2.50954 -2.13946 -1.80561 -4.18614 -2.49696 -0.640907 1. 0. 0. 301 1 302 -1.64154 -3.70136 -1.80061 -4.18614 -2.49696 -0.640907 -3.92214 -3.45776 0.834093 1. 0. 0. 303 1 304 -1.53704 -3.60006 0.497793 -1.64154 -3.70136 -1.80061 -3.92214 -3.45776 0.834093 1. 0. 0. 305 1 306 0.904762 -3.62316 -0.490507 -1.53704 -3.60006 0.497793 -1.64154 -3.70136 -1.80061 1. 0. 0. 307 1 308 0.777562 -3.65286 1.28459 0.904762 -3.62316 -0.490507 -1.53704 -3.60006 0.497793 1. 0. 0. 309 1 310 0.904762 -3.62316 -0.490507 0.438062 -2.68776 -2.23921 -1.64154 -3.70136 -1.80061 1. 0. 0. 311 1 312 -4.76454 -1.89276 0.930293 -4.18614 -2.49696 -0.640907 -3.92214 -3.45776 0.834093 1. 0. 0. 313 1 314 -4.76454 -1.89276 0.930293 -4.18614 -2.49696 -0.640907 -6.29174 0.967445 0.583993 1. 0. 0. 315 1 316 -4.18614 -2.49696 -0.640907 -6.29174 0.967445 0.583993 -6.43904 1.78854 -0.988307 1. 0. 0. 317 1 318 -6.29174 0.967445 0.583993 -7.12784 2.53484 0.473393 -6.43904 1.78854 -0.988307 1. 0. 0. 319 1 320 3.60736 1.29684 -2.87381 5.67566 1.42984 -1.78291 5.10266 2.74254 -0.715907 1. 0. 0. 321 1 322 5.67566 1.42984 -1.78291 5.10266 2.74254 -0.715907 7.55546 2.01984 -0.0120068 1. 0. 0. 323 1 324 -5.13424 3.87154 -1.43691 -7.12784 2.53484 0.473393 -6.43904 1.78854 -0.988307 1. 0. 0. 325 1 326 -5.82304 4.61784 0.0247932 -5.13424 3.87154 -1.43691 -7.12784 2.53484 0.473393 1. 0. 0. 327 1 328 -5.82304 4.61784 0.0247932 -4.05744 4.53424 -0.184207 -5.13424 3.87154 -1.43691 1. 0. 0. 329 329 9 330 330 # terminating special property … … 333 333 25.0 0.6 -1.0 -1.0 -1.0 0.2 0 0 0 0 334 334 2 335 - 4.99203 4.29989 -0.5264295 1 0 0335 -5.0049 4.34121 -0.532107 5 1 0 0 336 336 9 337 337 terminating special property
Note:
See TracChangeset
for help on using the changeset viewer.