| [a3427f] | 1 | /* | 
|---|
|  | 2 | * Project: MoleCuilder | 
|---|
|  | 3 | * Description: creates and alters molecular systems | 
|---|
| [16893f] | 4 | * Copyright (C)  2012 University of Bonn. All rights reserved. | 
|---|
| [5aaa43] | 5 | * Copyright (C)  2013 Frederik Heber. All rights reserved. | 
|---|
| [a3427f] | 6 | * | 
|---|
|  | 7 | * | 
|---|
|  | 8 | *   This file is part of MoleCuilder. | 
|---|
|  | 9 | * | 
|---|
|  | 10 | *    MoleCuilder is free software: you can redistribute it and/or modify | 
|---|
|  | 11 | *    it under the terms of the GNU General Public License as published by | 
|---|
|  | 12 | *    the Free Software Foundation, either version 2 of the License, or | 
|---|
|  | 13 | *    (at your option) any later version. | 
|---|
|  | 14 | * | 
|---|
|  | 15 | *    MoleCuilder is distributed in the hope that it will be useful, | 
|---|
|  | 16 | *    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
|  | 17 | *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
|  | 18 | *    GNU General Public License for more details. | 
|---|
|  | 19 | * | 
|---|
|  | 20 | *    You should have received a copy of the GNU General Public License | 
|---|
|  | 21 | *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>. | 
|---|
|  | 22 | */ | 
|---|
|  | 23 |  | 
|---|
|  | 24 | /* | 
|---|
|  | 25 | * AnalyseFragmentationResultsAction.cpp | 
|---|
|  | 26 | * | 
|---|
|  | 27 | *  Created on: Mar 8, 2013 | 
|---|
|  | 28 | *      Author: heber | 
|---|
|  | 29 | */ | 
|---|
|  | 30 |  | 
|---|
|  | 31 | // include config.h | 
|---|
|  | 32 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 33 | #include <config.h> | 
|---|
|  | 34 | #endif | 
|---|
|  | 35 |  | 
|---|
|  | 36 | // include headers that implement a archive in simple text format | 
|---|
|  | 37 | // and before MemDebug due to placement new | 
|---|
|  | 38 | #include <boost/archive/text_oarchive.hpp> | 
|---|
|  | 39 | #include <boost/archive/text_iarchive.hpp> | 
|---|
|  | 40 |  | 
|---|
|  | 41 | #include "CodePatterns/MemDebug.hpp" | 
|---|
|  | 42 |  | 
|---|
| [e5ebaf] | 43 | #include <boost/foreach.hpp> | 
|---|
| [0588e9] | 44 | #include <boost/lambda/lambda.hpp> | 
|---|
| [a3427f] | 45 | #include <boost/mpl/remove.hpp> | 
|---|
|  | 46 |  | 
|---|
| [0588e9] | 47 | #include <algorithm> | 
|---|
| [a3427f] | 48 | #include <fstream> | 
|---|
|  | 49 | #include <iostream> | 
|---|
| [e355b31] | 50 | //#include <numeric> | 
|---|
| [a3427f] | 51 | #include <string> | 
|---|
|  | 52 | #include <vector> | 
|---|
|  | 53 |  | 
|---|
|  | 54 | #include "CodePatterns/Assert.hpp" | 
|---|
|  | 55 | #include "CodePatterns/Log.hpp" | 
|---|
|  | 56 |  | 
|---|
|  | 57 | #ifdef HAVE_JOBMARKET | 
|---|
|  | 58 | #include "JobMarket/types.hpp" | 
|---|
|  | 59 | #else | 
|---|
|  | 60 | typedef size_t JobId_t; | 
|---|
|  | 61 | #endif | 
|---|
|  | 62 |  | 
|---|
| [e5ebaf] | 63 | #include "Descriptors/AtomIdDescriptor.hpp" | 
|---|
| [a3427f] | 64 | #include "Fragmentation/Summation/Containers/FragmentationChargeDensity.hpp" | 
|---|
|  | 65 | #include "Fragmentation/Summation/Containers/FragmentationResultContainer.hpp" | 
|---|
|  | 66 | #include "Fragmentation/Summation/Containers/FragmentationShortRangeResults.hpp" | 
|---|
|  | 67 | #include "Fragmentation/Summation/Containers/MPQCData.hpp" | 
|---|
|  | 68 | #include "Fragmentation/Summation/Containers/MPQCData_printKeyNames.hpp" | 
|---|
|  | 69 | #include "Fragmentation/Homology/HomologyContainer.hpp" | 
|---|
|  | 70 | #include "Fragmentation/Homology/HomologyGraph.hpp" | 
|---|
|  | 71 | #include "Fragmentation/KeySetsContainer.hpp" | 
|---|
| [5c867e] | 72 | #include "Fragmentation/Summation/SetValues/Eigenvalues.hpp" | 
|---|
| [a3427f] | 73 | #include "Fragmentation/Summation/SetValues/Fragment.hpp" | 
|---|
| [d200ae] | 74 | #include "Fragmentation/Summation/SetValues/FragmentForces.hpp" | 
|---|
| [a3427f] | 75 | #include "Fragmentation/Summation/SetValues/Histogram.hpp" | 
|---|
|  | 76 | #include "Fragmentation/Summation/SetValues/IndexedVectors.hpp" | 
|---|
|  | 77 | #include "Fragmentation/Summation/IndexSetContainer.hpp" | 
|---|
| [47cee7] | 78 | #include "Fragmentation/Summation/writeIndexedTable.hpp" | 
|---|
| [a3427f] | 79 | #include "Fragmentation/Summation/writeTable.hpp" | 
|---|
| [18ed8c] | 80 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) | 
|---|
|  | 81 | #include "Fragmentation/Summation/Containers/FragmentationLongRangeResults.hpp" | 
|---|
| [a3427f] | 82 | #include "Fragmentation/Summation/Containers/VMGData.hpp" | 
|---|
|  | 83 | #include "Fragmentation/Summation/Containers/VMGDataFused.hpp" | 
|---|
|  | 84 | #include "Fragmentation/Summation/Containers/VMGDataMap.hpp" | 
|---|
|  | 85 | #include "Fragmentation/Summation/Containers/VMGData_printKeyNames.hpp" | 
|---|
|  | 86 | #endif | 
|---|
| [e5ebaf] | 87 | #include "Helpers/defs.hpp" | 
|---|
| [a3427f] | 88 | #include "World.hpp" | 
|---|
|  | 89 |  | 
|---|
|  | 90 | #include "Actions/FragmentationAction/AnalyseFragmentationResultsAction.hpp" | 
|---|
|  | 91 |  | 
|---|
|  | 92 | using namespace MoleCuilder; | 
|---|
|  | 93 |  | 
|---|
|  | 94 | // and construct the stuff | 
|---|
|  | 95 | #include "AnalyseFragmentationResultsAction.def" | 
|---|
|  | 96 | #include "Action_impl_pre.hpp" | 
|---|
|  | 97 | /** =========== define the function ====================== */ | 
|---|
|  | 98 |  | 
|---|
|  | 99 | void writeToFile(const std::string &filename, const std::string contents) | 
|---|
|  | 100 | { | 
|---|
|  | 101 | std::ofstream tablefile(filename.c_str()); | 
|---|
|  | 102 | tablefile << contents; | 
|---|
|  | 103 | tablefile.close(); | 
|---|
|  | 104 | } | 
|---|
|  | 105 |  | 
|---|
| [0588e9] | 106 | /** Print cycle correction from received results. | 
|---|
|  | 107 | * | 
|---|
|  | 108 | * @param results summed up results container | 
|---|
|  | 109 | */ | 
|---|
|  | 110 | void printReceivedCycleResults( | 
|---|
|  | 111 | const FragmentationShortRangeResults &results) | 
|---|
|  | 112 | { | 
|---|
|  | 113 | typedef boost::mpl::remove< | 
|---|
|  | 114 | boost::mpl::remove<MPQCDataEnergyVector_t, MPQCDataFused::energy_eigenvalues>::type, | 
|---|
|  | 115 | MPQCDataFused::energy_eigenhistogram>::type | 
|---|
|  | 116 | MPQCDataEnergyVector_noeigenvalues_t; | 
|---|
|  | 117 | const std::string energyresult = | 
|---|
|  | 118 | writeTable<MPQCDataEnergyMap_t, MPQCDataEnergyVector_noeigenvalues_t >()( | 
|---|
|  | 119 | results.Result_Energy_fused, results.getMaxLevel()); | 
|---|
|  | 120 | LOG(2, "DEBUG: Energy table is \n" << energyresult); | 
|---|
|  | 121 | std::string filename; | 
|---|
|  | 122 | filename += FRAGMENTPREFIX + std::string("_CycleEnergy.dat"); | 
|---|
|  | 123 | writeToFile(filename, energyresult); | 
|---|
|  | 124 | } | 
|---|
|  | 125 |  | 
|---|
| [47cee7] | 126 | /** Print (short range) energy, forces, and timings from received results per index set. | 
|---|
|  | 127 | * | 
|---|
|  | 128 | * @param results summed up results container | 
|---|
|  | 129 | */ | 
|---|
|  | 130 | void printReceivedShortResultsPerIndex( | 
|---|
|  | 131 | const FragmentationShortRangeResults &results) | 
|---|
|  | 132 | { | 
|---|
|  | 133 | // print tables  per keyset(without eigenvalues, they go extra) | 
|---|
|  | 134 | typedef boost::mpl::remove< | 
|---|
|  | 135 | boost::mpl::remove<MPQCDataEnergyVector_t, MPQCDataFused::energy_eigenvalues>::type, | 
|---|
|  | 136 | MPQCDataFused::energy_eigenhistogram>::type | 
|---|
|  | 137 | MPQCDataEnergyVector_noeigenvalues_t; | 
|---|
|  | 138 | const std::string energyresult = | 
|---|
|  | 139 | writeIndexedTable<MPQCDataEnergyMap_t, MPQCDataEnergyVector_noeigenvalues_t >()( | 
|---|
|  | 140 | results.Result_perIndexSet_Energy, results.getMaxLevel()); | 
|---|
|  | 141 | LOG(2, "DEBUG: Indexed Energy table is \n" << energyresult); | 
|---|
|  | 142 | std::string filename; | 
|---|
|  | 143 | filename += FRAGMENTPREFIX + std::string("_IndexedEnergy.dat"); | 
|---|
|  | 144 | writeToFile(filename, energyresult); | 
|---|
|  | 145 | } | 
|---|
|  | 146 |  | 
|---|
| [a3427f] | 147 | /** Print (short range) energy, forces, and timings from received results. | 
|---|
|  | 148 | * | 
|---|
|  | 149 | * @param results summed up results container | 
|---|
|  | 150 | */ | 
|---|
|  | 151 | void printReceivedShortResults( | 
|---|
|  | 152 | const FragmentationShortRangeResults &results) | 
|---|
|  | 153 | { | 
|---|
|  | 154 | // print tables (without eigenvalues, they go extra) | 
|---|
|  | 155 | { | 
|---|
| [5c867e] | 156 | typedef boost::mpl::remove< | 
|---|
|  | 157 | boost::mpl::remove<MPQCDataEnergyVector_t, MPQCDataFused::energy_eigenvalues>::type, | 
|---|
|  | 158 | MPQCDataFused::energy_eigenhistogram>::type | 
|---|
| [a3427f] | 159 | MPQCDataEnergyVector_noeigenvalues_t; | 
|---|
|  | 160 | const std::string energyresult = | 
|---|
|  | 161 | writeTable<MPQCDataEnergyMap_t, MPQCDataEnergyVector_noeigenvalues_t >()( | 
|---|
|  | 162 | results.Result_Energy_fused, results.getMaxLevel()); | 
|---|
| [1b5a40] | 163 | LOG(2, "DEBUG: Energy table is \n" << energyresult); | 
|---|
| [a3427f] | 164 | std::string filename; | 
|---|
|  | 165 | filename += FRAGMENTPREFIX + std::string("_Energy.dat"); | 
|---|
|  | 166 | writeToFile(filename, energyresult); | 
|---|
|  | 167 | } | 
|---|
|  | 168 |  | 
|---|
| [5c867e] | 169 | { | 
|---|
|  | 170 | typedef boost::mpl::list< | 
|---|
|  | 171 | MPQCDataFused::energy_eigenvalues | 
|---|
|  | 172 | > MPQCDataEigenvalues_t; | 
|---|
|  | 173 | const std::string eigenvalueresult = | 
|---|
|  | 174 | writeTable<MPQCDataEnergyMap_t, MPQCDataEigenvalues_t >()( | 
|---|
|  | 175 | results.Result_Energy_fused, results.getMaxLevel()); | 
|---|
| [1b5a40] | 176 | LOG(2, "DEBUG: Eigenvalue table is \n" << eigenvalueresult); | 
|---|
| [5c867e] | 177 | std::string filename; | 
|---|
|  | 178 | filename += FRAGMENTPREFIX + std::string("_Eigenvalues.dat"); | 
|---|
|  | 179 | writeToFile(filename, eigenvalueresult); | 
|---|
|  | 180 | } | 
|---|
|  | 181 |  | 
|---|
|  | 182 | { | 
|---|
|  | 183 | typedef boost::mpl::list< | 
|---|
|  | 184 | MPQCDataFused::energy_eigenhistogram | 
|---|
|  | 185 | > MPQCDataEigenhistogram_t; | 
|---|
|  | 186 | const std::string eigenhistogramresult = | 
|---|
|  | 187 | writeTable<MPQCDataEnergyMap_t, MPQCDataEigenhistogram_t >()( | 
|---|
|  | 188 | results.Result_Energy_fused, results.getMaxLevel()); | 
|---|
| [1b5a40] | 189 | LOG(2, "DEBUG: Eigenhistogram table is \n" << eigenhistogramresult); | 
|---|
| [5c867e] | 190 | std::string filename; | 
|---|
|  | 191 | filename += FRAGMENTPREFIX + std::string("_Eigenhistogram.dat"); | 
|---|
|  | 192 | writeToFile(filename, eigenhistogramresult); | 
|---|
|  | 193 | } | 
|---|
|  | 194 |  | 
|---|
| [a3427f] | 195 | { | 
|---|
|  | 196 | typedef boost::mpl::list< | 
|---|
|  | 197 | MPQCDataFused::energy_eigenvalues | 
|---|
|  | 198 | > MPQCDataEigenvalues_t; | 
|---|
|  | 199 | const std::string eigenvalueresult = | 
|---|
|  | 200 | writeTable<MPQCDataEnergyMap_t, MPQCDataEigenvalues_t >()( | 
|---|
|  | 201 | results.Result_Energy_fused, results.getMaxLevel()); | 
|---|
| [1b5a40] | 202 | LOG(2, "DEBUG: Eigenvalue table is \n" << eigenvalueresult); | 
|---|
| [a3427f] | 203 | std::string filename; | 
|---|
|  | 204 | filename += FRAGMENTPREFIX + std::string("_Eigenvalues.dat"); | 
|---|
|  | 205 | writeToFile(filename, eigenvalueresult); | 
|---|
|  | 206 | } | 
|---|
|  | 207 |  | 
|---|
|  | 208 | { | 
|---|
|  | 209 | const std::string forceresult = | 
|---|
|  | 210 | writeTable<MPQCDataForceMap_t, MPQCDataForceVector_t>()( | 
|---|
|  | 211 | results.Result_Force_fused, results.getMaxLevel()); | 
|---|
| [1b5a40] | 212 | LOG(2, "DEBUG: Force table is \n" << forceresult); | 
|---|
| [a3427f] | 213 | std::string filename; | 
|---|
|  | 214 | filename += FRAGMENTPREFIX + std::string("_Forces.dat"); | 
|---|
|  | 215 | writeToFile(filename, forceresult); | 
|---|
|  | 216 | } | 
|---|
|  | 217 | // we don't want to print grid to a table | 
|---|
|  | 218 | { | 
|---|
|  | 219 | // print times (without flops for now) | 
|---|
|  | 220 | typedef boost::mpl::remove< | 
|---|
|  | 221 | boost::mpl::remove<MPQCDataTimeVector_t, MPQCDataFused::times_total_flops>::type, | 
|---|
|  | 222 | MPQCDataFused::times_gather_flops>::type | 
|---|
|  | 223 | MPQCDataTimeVector_noflops_t; | 
|---|
|  | 224 | const std::string timesresult = | 
|---|
|  | 225 | writeTable<MPQCDataTimeMap_t, MPQCDataTimeVector_noflops_t >()( | 
|---|
|  | 226 | results.Result_Time_fused, results.getMaxLevel()); | 
|---|
| [1b5a40] | 227 | LOG(2, "DEBUG: Times table is \n" << timesresult); | 
|---|
| [a3427f] | 228 | std::string filename; | 
|---|
|  | 229 | filename += FRAGMENTPREFIX + std::string("_Times.dat"); | 
|---|
|  | 230 | writeToFile(filename, timesresult); | 
|---|
|  | 231 | } | 
|---|
|  | 232 | } | 
|---|
|  | 233 |  | 
|---|
|  | 234 |  | 
|---|
| [18ed8c] | 235 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) | 
|---|
| [a3427f] | 236 | /** Print long range energy from received results. | 
|---|
|  | 237 | * | 
|---|
|  | 238 | * @param results summed up results container | 
|---|
|  | 239 | */ | 
|---|
|  | 240 | void printReceivedFullResults( | 
|---|
|  | 241 | const FragmentationLongRangeResults &results) | 
|---|
|  | 242 | { | 
|---|
| [83a425] | 243 | // print tables per keyset(without grids, they go extra) | 
|---|
| [a3427f] | 244 |  | 
|---|
|  | 245 | { | 
|---|
|  | 246 | const std::string gridresult = | 
|---|
|  | 247 | writeTable<VMGDataMap_t, VMGDataVector_t >()( | 
|---|
| [d29b31] | 248 | results.Result_LongRange_fused, results.getMaxLevel(), 1); | 
|---|
| [1b5a40] | 249 | LOG(2, "DEBUG: VMG table is \n" << gridresult); | 
|---|
| [a3427f] | 250 | std::string filename; | 
|---|
|  | 251 | filename += FRAGMENTPREFIX + std::string("_VMGEnergy.dat"); | 
|---|
|  | 252 | writeToFile(filename, gridresult); | 
|---|
|  | 253 | } | 
|---|
|  | 254 |  | 
|---|
| [94db13] | 255 | if (results.hasLongRangeForces()) { | 
|---|
|  | 256 | const std::string forceresult = | 
|---|
|  | 257 | writeTable<VMGDataForceMap_t, VMGDataForceVector_t>()( | 
|---|
|  | 258 | results.Result_ForceLongRange_fused, results.getMaxLevel()); | 
|---|
|  | 259 | LOG(2, "DEBUG: Force table is \n" << forceresult); | 
|---|
|  | 260 | std::string filename; | 
|---|
|  | 261 | filename += FRAGMENTPREFIX + std::string("_VMGForces.dat"); | 
|---|
|  | 262 | writeToFile(filename, forceresult); | 
|---|
|  | 263 | } | 
|---|
|  | 264 |  | 
|---|
| [a3427f] | 265 | { | 
|---|
|  | 266 | const std::string gridresult = | 
|---|
|  | 267 | writeTable<VMGDataLongRangeMap_t, VMGDataLongRangeVector_t >()( | 
|---|
| [d29b31] | 268 | results.Result_LongRangeIntegrated_fused, results.getMaxLevel(), 1); | 
|---|
| [1b5a40] | 269 | LOG(2, "DEBUG: LongRange table is \n" << gridresult); | 
|---|
| [a3427f] | 270 | std::string filename; | 
|---|
|  | 271 | filename += FRAGMENTPREFIX + std::string("_LongRangeEnergy.dat"); | 
|---|
|  | 272 | writeToFile(filename, gridresult); | 
|---|
|  | 273 | } | 
|---|
| [ff347f] | 274 |  | 
|---|
|  | 275 | if (results.hasLongRangeForces()) { | 
|---|
|  | 276 | const std::string forceresult = | 
|---|
|  | 277 | writeTable<VMGDataLongRangeForceMap_t, VMGDataLongRangeForceVector_t >()( | 
|---|
|  | 278 | results.Result_ForcesLongRangeIntegrated_fused, results.getMaxLevel(), 1); | 
|---|
|  | 279 | LOG(2, "DEBUG: ForcesLongRange table is \n" << forceresult); | 
|---|
|  | 280 | std::string filename; | 
|---|
|  | 281 | filename += FRAGMENTPREFIX + std::string("_LongRangeForces.dat"); | 
|---|
|  | 282 | writeToFile(filename, forceresult); | 
|---|
|  | 283 | } | 
|---|
| [a3427f] | 284 | } | 
|---|
| [18ed8c] | 285 | #endif | 
|---|
| [a3427f] | 286 |  | 
|---|
| [98dbee] | 287 | void appendToHomologies( | 
|---|
|  | 288 | const FragmentationShortRangeResults &shortrangeresults, | 
|---|
| [18ed8c] | 289 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) | 
|---|
| [bf1d1b] | 290 | const FragmentationLongRangeResults &longrangeresults, | 
|---|
| [18ed8c] | 291 | #endif | 
|---|
| [bf1d1b] | 292 | const bool storeGrids | 
|---|
| [98dbee] | 293 | ) | 
|---|
|  | 294 | { | 
|---|
|  | 295 | /// read homology container (if present) | 
|---|
|  | 296 | HomologyContainer &homology_container = World::getInstance().getHomologies(); | 
|---|
| [a3427f] | 297 |  | 
|---|
|  | 298 | /// append all fragments to a HomologyContainer | 
|---|
|  | 299 | HomologyContainer::container_t values; | 
|---|
|  | 300 |  | 
|---|
|  | 301 | // convert KeySetContainer to IndexSetContainer | 
|---|
|  | 302 | IndexSetContainer::ptr ForceContainer(new IndexSetContainer(shortrangeresults.getForceKeySet())); | 
|---|
|  | 303 | const IndexSetContainer::Container_t &Indices = shortrangeresults.getContainer(); | 
|---|
|  | 304 | const IndexSetContainer::Container_t &ForceIndices = ForceContainer->getContainer(); | 
|---|
|  | 305 | IndexSetContainer::Container_t::const_iterator iter = Indices.begin(); | 
|---|
|  | 306 | IndexSetContainer::Container_t::const_iterator forceiter = ForceIndices.begin(); | 
|---|
| [e5ebaf] | 307 |  | 
|---|
| [a3427f] | 308 | /// go through all fragments | 
|---|
|  | 309 | for (;iter != Indices.end(); ++iter, ++forceiter) // go through each IndexSet | 
|---|
|  | 310 | { | 
|---|
|  | 311 | /// create new graph entry in HomologyContainer which is (key,value) type | 
|---|
|  | 312 | LOG(1, "INFO: Creating new graph with " << **forceiter << "."); | 
|---|
|  | 313 | HomologyGraph graph(**forceiter); | 
|---|
|  | 314 | LOG(2, "DEBUG: Created graph " << graph << "."); | 
|---|
|  | 315 | const IndexSet::ptr &index = *iter; | 
|---|
|  | 316 |  | 
|---|
| [bf1d1b] | 317 | /// we fill the value structure | 
|---|
|  | 318 | HomologyContainer::value_t value; | 
|---|
|  | 319 | value.containsGrids = storeGrids; | 
|---|
|  | 320 | // obtain fragment | 
|---|
| [a3427f] | 321 | std::map<IndexSet::ptr, std::pair< MPQCDataFragmentMap_t, MPQCDataFragmentMap_t> >::const_iterator fragmentiter | 
|---|
| [d76d65] | 322 | = shortrangeresults.Result_perIndexSet_Fragment.find(index); | 
|---|
|  | 323 | ASSERT( fragmentiter != shortrangeresults.Result_perIndexSet_Fragment.end(), | 
|---|
| [a3427f] | 324 | "appendToHomologyFile() - cannot find index "+toString(*index) | 
|---|
|  | 325 | +" in FragmentResults."); | 
|---|
| [bf1d1b] | 326 | value.fragment = boost::fusion::at_key<MPQCDataFused::fragment>(fragmentiter->second.first); | 
|---|
| [a3427f] | 327 |  | 
|---|
| [bf1d1b] | 328 | // obtain energy | 
|---|
| [a3427f] | 329 | std::map<IndexSet::ptr, std::pair< MPQCDataEnergyMap_t, MPQCDataEnergyMap_t> >::const_iterator energyiter | 
|---|
|  | 330 | = shortrangeresults.Result_perIndexSet_Energy.find(index); | 
|---|
|  | 331 | ASSERT( energyiter != shortrangeresults.Result_perIndexSet_Energy.end(), | 
|---|
|  | 332 | "appendToHomologyFile() - cannot find index "+toString(*index) | 
|---|
|  | 333 | +" in FragmentResults."); | 
|---|
| [bf1d1b] | 334 | value.energy = boost::fusion::at_key<MPQCDataFused::energy_total>(energyiter->second.second); // contributions | 
|---|
|  | 335 |  | 
|---|
|  | 336 | // only store sampled grids if desired | 
|---|
|  | 337 | if (storeGrids) { | 
|---|
| [18ed8c] | 338 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) | 
|---|
| [bf1d1b] | 339 | // obtain charge distribution | 
|---|
|  | 340 | std::map<IndexSet::ptr, std::pair< MPQCDataGridMap_t, MPQCDataGridMap_t> >::const_iterator chargeiter | 
|---|
|  | 341 | = longrangeresults.Result_perIndexSet_Grid.find(index); | 
|---|
|  | 342 | ASSERT( chargeiter != longrangeresults.Result_perIndexSet_Grid.end(), | 
|---|
|  | 343 | "appendToHomologyFile() - cannot find index "+toString(*index) | 
|---|
|  | 344 | +" in FragmentResults."); | 
|---|
|  | 345 | value.charge_distribution = boost::fusion::at_key<MPQCDataFused::sampled_grid>(chargeiter->second.second); // contributions | 
|---|
|  | 346 |  | 
|---|
|  | 347 | // obtain potential distribution | 
|---|
| [83a425] | 348 | std::map<IndexSet::ptr, std::pair< VMGDataGridMap_t, VMGDataGridMap_t> >::const_iterator potentialiter | 
|---|
|  | 349 | = longrangeresults.Result_perIndexSet_LongRange_Grid.find(index); | 
|---|
|  | 350 | ASSERT( potentialiter != longrangeresults.Result_perIndexSet_LongRange_Grid.end(), | 
|---|
| [bf1d1b] | 351 | "appendToHomologyFile() - cannot find index "+toString(*index) | 
|---|
|  | 352 | +" in FragmentResults."); | 
|---|
| [e355b31] | 353 | // add e+n potentials | 
|---|
| [83a425] | 354 | value.potential_distribution = | 
|---|
|  | 355 | boost::fusion::at_key<VMGDataFused::both_sampled_potential>(potentialiter->second.second); // contributions | 
|---|
| [e355b31] | 356 | //      // and re-average to zero (integral is times volume_element which we don't need here) | 
|---|
|  | 357 | //      const double sum = | 
|---|
|  | 358 | //          std::accumulate( | 
|---|
|  | 359 | //              value.potential_distribution.sampled_grid.begin(), | 
|---|
|  | 360 | //              value.potential_distribution.sampled_grid.end(), | 
|---|
|  | 361 | //              0.); | 
|---|
|  | 362 | //      const double offset = sum/(double)value.potential_distribution.sampled_grid.size(); | 
|---|
|  | 363 | //      for (SamplingGrid::sampledvalues_t::iterator iter = value.potential_distribution.sampled_grid.begin(); | 
|---|
|  | 364 | //          iter != value.potential_distribution.sampled_grid.end(); | 
|---|
|  | 365 | //          ++iter) | 
|---|
|  | 366 | //        *iter -= offset; | 
|---|
| [18ed8c] | 367 | #else | 
|---|
|  | 368 | ELOG(1, "Long-range information in homology desired but long-range analysis capability not compiled in."); | 
|---|
|  | 369 | #endif | 
|---|
| [bf1d1b] | 370 | } | 
|---|
| [a3427f] | 371 | values.insert( std::make_pair( graph, value) ); | 
|---|
|  | 372 | } | 
|---|
|  | 373 | homology_container.insert(values); | 
|---|
|  | 374 |  | 
|---|
| [1b5a40] | 375 | if (DoLog(2)) { | 
|---|
|  | 376 | LOG(2, "DEBUG: Listing all present atomic ids ..."); | 
|---|
|  | 377 | std::stringstream output; | 
|---|
|  | 378 | for (World::AtomIterator iter = World::getInstance().getAtomIter(); | 
|---|
|  | 379 | iter != World::getInstance().atomEnd(); ++iter) | 
|---|
|  | 380 | output << (*iter)->getId() << " "; | 
|---|
|  | 381 | LOG(2, "DEBUG: { " << output.str() << "} ."); | 
|---|
|  | 382 | } | 
|---|
| [a3427f] | 383 |  | 
|---|
|  | 384 | // for debugging: print container | 
|---|
| [1b5a40] | 385 | if (DoLog(2)) { | 
|---|
|  | 386 | LOG(2, "DEBUG: Listing all present homologies ..."); | 
|---|
|  | 387 | for (HomologyContainer::container_t::const_iterator iter = | 
|---|
|  | 388 | homology_container.begin(); iter != homology_container.end(); ++iter) { | 
|---|
| [d76d65] | 389 | std::stringstream output; | 
|---|
|  | 390 | output << "DEBUG: graph " << iter->first | 
|---|
| [bf1d1b] | 391 | << " has Fragment " << iter->second.fragment | 
|---|
| [d76d65] | 392 | << ", associated energy " << iter->second.energy; | 
|---|
|  | 393 | if (iter->second.containsGrids) | 
|---|
| [18ed8c] | 394 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) | 
|---|
| [d76d65] | 395 | output  << ", and sampled grid integral " << iter->second.charge_distribution.integral(); | 
|---|
| [18ed8c] | 396 | #else | 
|---|
|  | 397 | output << ", and there are sampled grids but capability not compiled in"; | 
|---|
|  | 398 | #endif | 
|---|
| [d76d65] | 399 | output << "."; | 
|---|
|  | 400 | LOG(2, output.str()); | 
|---|
| [1b5a40] | 401 | } | 
|---|
| [a3427f] | 402 | } | 
|---|
| [98dbee] | 403 | } | 
|---|
| [a3427f] | 404 |  | 
|---|
| [0588e9] | 405 | // this it taken from | 
|---|
|  | 406 | // http://stackoverflow.com/questions/2291802/is-there-a-c-iterator-that-can-iterate-over-a-file-line-by-line | 
|---|
|  | 407 | namespace detail | 
|---|
|  | 408 | { | 
|---|
|  | 409 | /** Extend the string class by a friend function. | 
|---|
|  | 410 | * | 
|---|
|  | 411 | */ | 
|---|
|  | 412 | class Line : public std::string | 
|---|
|  | 413 | { | 
|---|
|  | 414 | friend std::istream & operator>>(std::istream & is, Line & line) | 
|---|
|  | 415 | { | 
|---|
|  | 416 | return std::getline(is, line); | 
|---|
|  | 417 | } | 
|---|
|  | 418 | }; | 
|---|
|  | 419 | } | 
|---|
|  | 420 |  | 
|---|
|  | 421 | /** Parse the given stream line-by-line, passing each to \a dest. | 
|---|
|  | 422 | * | 
|---|
|  | 423 | * \param is stream to parse line-wise | 
|---|
|  | 424 | * \param dest output iterator | 
|---|
|  | 425 | */ | 
|---|
|  | 426 | template<class OutIt> | 
|---|
|  | 427 | void read_lines(std::istream& is, OutIt dest) | 
|---|
|  | 428 | { | 
|---|
|  | 429 | typedef std::istream_iterator<detail::Line> InIt; | 
|---|
|  | 430 | std::copy(InIt(is), InIt(), dest); | 
|---|
|  | 431 | } | 
|---|
|  | 432 |  | 
|---|
|  | 433 |  | 
|---|
| [f58e56] | 434 | /** Determines the largest cycle in the container and returns its size. | 
|---|
|  | 435 | * | 
|---|
|  | 436 | * \param cycles set of cycles | 
|---|
|  | 437 | * \return size if largest cycle | 
|---|
|  | 438 | */ | 
|---|
|  | 439 | size_t getMaxCycleSize(const KeySetsContainer &cycles) | 
|---|
|  | 440 | { | 
|---|
|  | 441 | // gather cycle sizes | 
|---|
|  | 442 | std::vector<size_t> cyclesizes(cycles.KeySets.size()); | 
|---|
|  | 443 | std::transform( | 
|---|
|  | 444 | cycles.KeySets.begin(), cycles.KeySets.end(), | 
|---|
|  | 445 | cyclesizes.begin(), | 
|---|
|  | 446 | boost::bind(&KeySetsContainer::IntVector::size, boost::lambda::_1) | 
|---|
|  | 447 | ); | 
|---|
|  | 448 | // get maximum | 
|---|
|  | 449 | std::vector<size_t>::const_iterator maximum_size = | 
|---|
|  | 450 | std::max_element(cyclesizes.begin(), cyclesizes.end()); | 
|---|
|  | 451 | if (maximum_size != cyclesizes.end()) | 
|---|
|  | 452 | return *maximum_size; | 
|---|
|  | 453 | else | 
|---|
|  | 454 | return 0; | 
|---|
|  | 455 | } | 
|---|
|  | 456 |  | 
|---|
|  | 457 | void calculateCycleFullContribution( | 
|---|
|  | 458 | const std::map<JobId_t, MPQCData> &shortrangedata, | 
|---|
|  | 459 | const KeySetsContainer &keysets, | 
|---|
|  | 460 | const KeySetsContainer &forcekeysets, | 
|---|
|  | 461 | const KeySetsContainer &cycles, | 
|---|
|  | 462 | const FragmentationShortRangeResults &shortrangeresults) | 
|---|
|  | 463 | { | 
|---|
|  | 464 | // copy the shortrangeresults such that private MaxLevel is set in | 
|---|
|  | 465 | // FragmentationShortRangeResults | 
|---|
|  | 466 | FragmentationShortRangeResults cycleresults(shortrangeresults); | 
|---|
|  | 467 | // get largest size | 
|---|
|  | 468 | const size_t maximum_size = getMaxCycleSize(cycles); | 
|---|
|  | 469 |  | 
|---|
|  | 470 | /// The idea here is that (Orthogonal)Summation will place a result | 
|---|
|  | 471 | /// consisting of level 1,2, and 3 fragment and a level 6 ring nonetheless | 
|---|
|  | 472 | /// in level 6. If we want to have this result already at level 3, we | 
|---|
|  | 473 | /// have to specifically inhibit all fragments from later levels but the | 
|---|
|  | 474 | /// cycles and then pick the result from the last level and placing it at | 
|---|
|  | 475 | /// the desired one | 
|---|
|  | 476 |  | 
|---|
|  | 477 | // loop from level 1 to max ring size and gather contributions | 
|---|
|  | 478 | for (size_t level = 1; level <= maximum_size; ++level) { | 
|---|
|  | 479 | // create ValueMask for this level by stepping through each keyset and checking size | 
|---|
|  | 480 | std::vector<bool> localValueMask(shortrangedata.size(), false); | 
|---|
|  | 481 | size_t index=0; | 
|---|
|  | 482 | // TODO: if only KeySetsContainer was usable as a compliant STL container, might be able to use set_difference or alike. | 
|---|
|  | 483 | KeySetsContainer::ArrayOfIntVectors::const_iterator keysetsiter = keysets.KeySets.begin(); | 
|---|
|  | 484 | KeySetsContainer::ArrayOfIntVectors::const_iterator cyclesiter = cycles.KeySets.begin(); | 
|---|
|  | 485 | for (; (keysetsiter != keysets.KeySets.end()) && (cyclesiter != cycles.KeySets.end());) { | 
|---|
|  | 486 | if (cyclesiter->size() > keysetsiter->size()) { | 
|---|
|  | 487 | // add if not greater than level in size | 
|---|
|  | 488 | if ((*keysetsiter).size() <= level) | 
|---|
|  | 489 | localValueMask[index] = true; | 
|---|
|  | 490 | ++keysetsiter; | 
|---|
|  | 491 | ++index; | 
|---|
|  | 492 | } else if (cyclesiter->size() < keysetsiter->size()) { | 
|---|
|  | 493 | ++cyclesiter; | 
|---|
|  | 494 | } else { // both sets have same size | 
|---|
|  | 495 | if (*cyclesiter > *keysetsiter) { | 
|---|
|  | 496 | // add if not greater than level in size | 
|---|
|  | 497 | if ((*keysetsiter).size() <= level) | 
|---|
|  | 498 | localValueMask[index] = true; | 
|---|
|  | 499 | ++keysetsiter; | 
|---|
|  | 500 | ++index; | 
|---|
|  | 501 | } else if (*cyclesiter < *keysetsiter) { | 
|---|
|  | 502 | ++cyclesiter; | 
|---|
|  | 503 | } else { | 
|---|
|  | 504 | // also always add all cycles | 
|---|
|  | 505 | localValueMask[index] = true; | 
|---|
|  | 506 | ++cyclesiter; | 
|---|
|  | 507 | ++keysetsiter; | 
|---|
|  | 508 | ++index; | 
|---|
|  | 509 | } | 
|---|
|  | 510 | } | 
|---|
|  | 511 | } | 
|---|
|  | 512 | // activate rest if desired by level | 
|---|
|  | 513 | for (; keysetsiter != keysets.KeySets.end(); ++keysetsiter) { | 
|---|
|  | 514 | if ((*keysetsiter).size() <= level) | 
|---|
|  | 515 | localValueMask[index] = true; | 
|---|
|  | 516 | ++index; | 
|---|
|  | 517 | } | 
|---|
|  | 518 | LOG(2, "DEBUG: ValueMask for cycle correction at level " << level << " is " | 
|---|
|  | 519 | << localValueMask << "."); | 
|---|
|  | 520 | // create FragmentationShortRangeResults | 
|---|
|  | 521 | FragmentationShortRangeResults localresults(shortrangedata, keysets, forcekeysets, localValueMask); | 
|---|
|  | 522 | // and perform summation | 
|---|
|  | 523 | localresults(shortrangedata); | 
|---|
|  | 524 | // finally, extract the corrections from last level | 
|---|
|  | 525 | cycleresults.Result_Energy_fused[level-1] = | 
|---|
|  | 526 | localresults.Result_Energy_fused.back(); | 
|---|
|  | 527 | cycleresults.Result_Time_fused[level-1] = | 
|---|
|  | 528 | localresults.Result_Time_fused.back(); | 
|---|
|  | 529 | cycleresults.Result_Force_fused[level-1] = | 
|---|
|  | 530 | localresults.Result_Force_fused.back(); | 
|---|
|  | 531 | } | 
|---|
|  | 532 | printReceivedCycleResults(cycleresults); | 
|---|
|  | 533 | } | 
|---|
|  | 534 |  | 
|---|
| [d93d2c] | 535 | static void AddForces( | 
|---|
|  | 536 | const IndexedVectors::indexedvectors_t &_forces, | 
|---|
|  | 537 | const bool _IsAngstroem) | 
|---|
|  | 538 | { | 
|---|
|  | 539 | for(IndexedVectors::indexedvectors_t::const_iterator iter = _forces.begin(); | 
|---|
|  | 540 | iter != _forces.end(); ++iter) { | 
|---|
|  | 541 | const IndexedVectors::index_t &index = iter->first; | 
|---|
|  | 542 | const IndexedVectors::vector_t &forcevector = iter->second; | 
|---|
|  | 543 | ASSERT( forcevector.size() == NDIM, | 
|---|
|  | 544 | "printReceivedShortResults() - obtained force vector has incorrect dimension."); | 
|---|
|  | 545 | // note that mpqc calculates a gradient, hence force pointing into opposite direction | 
|---|
|  | 546 | // we have to mind different units here: MPQC has a_o, while we may have angstroem | 
|---|
|  | 547 | Vector ForceVector(-forcevector[0], -forcevector[1], -forcevector[2]); | 
|---|
|  | 548 | if (_IsAngstroem) | 
|---|
|  | 549 | for (size_t i=0;i<NDIM;++i) | 
|---|
|  | 550 | ForceVector[i] *= AtomicLengthToAngstroem; | 
|---|
|  | 551 | atom *_atom = World::getInstance().getAtom(AtomById(index)); | 
|---|
|  | 552 | if(_atom != NULL) | 
|---|
|  | 553 | _atom->setAtomicForce(_atom->getAtomicForce() + ForceVector); | 
|---|
|  | 554 | else | 
|---|
|  | 555 | ELOG(2, "Could not find atom to id " << index << "."); | 
|---|
|  | 556 | } | 
|---|
|  | 557 | } | 
|---|
|  | 558 |  | 
|---|
| [b5b01e] | 559 | ActionState::ptr FragmentationAnalyseFragmentationResultsAction::performCall() { | 
|---|
| [a3427f] | 560 |  | 
|---|
| [0588e9] | 561 | /// if file is given, parse from file into ResultsContainer | 
|---|
| [a3427f] | 562 | FragmentationResultContainer& container = FragmentationResultContainer::getInstance(); | 
|---|
| [55e1bc] | 563 | if (!params.resultsfile.get().empty()) { | 
|---|
|  | 564 | boost::filesystem::path resultsfile = params.resultsfile.get(); | 
|---|
|  | 565 | if (boost::filesystem::exists(resultsfile)) { | 
|---|
|  | 566 | LOG(1, "INFO: Parsing results from " << resultsfile.string() << "."); | 
|---|
|  | 567 | std::ifstream returnstream(resultsfile.string().c_str()); | 
|---|
|  | 568 | if (returnstream.good()) { | 
|---|
|  | 569 | boost::archive::text_iarchive ia(returnstream); | 
|---|
|  | 570 | ia >> container; | 
|---|
|  | 571 | } | 
|---|
|  | 572 | } else { | 
|---|
|  | 573 | ELOG(1, "Given file" << resultsfile.string() << " does not exist."); | 
|---|
|  | 574 | } | 
|---|
|  | 575 | } | 
|---|
|  | 576 |  | 
|---|
| [0588e9] | 577 | /// get data and keysets from ResultsContainer | 
|---|
| [a3427f] | 578 | const std::map<JobId_t, MPQCData> &shortrangedata = container.getShortRangeResults(); | 
|---|
|  | 579 | const KeySetsContainer &keysets = container.getKeySets(); | 
|---|
|  | 580 | const KeySetsContainer &forcekeysets = container.getForceKeySets(); | 
|---|
|  | 581 | const bool DoLongrange = container.areFullRangeResultsPresent(); | 
|---|
| [e5ebaf] | 582 | const bool IsAngstroem = true; | 
|---|
| [a3427f] | 583 |  | 
|---|
| [55e1bc] | 584 | if (keysets.KeySets.empty()) { | 
|---|
| [26b4d62] | 585 | STATUS("There are no results in the container."); | 
|---|
| [55e1bc] | 586 | return Action::failure; | 
|---|
|  | 587 | } | 
|---|
|  | 588 |  | 
|---|
| [0588e9] | 589 | /// calculate normal contributions with (if present) cycles coming at their | 
|---|
|  | 590 | /// respective bond order. | 
|---|
| [e0ae58d] | 591 | std::vector<bool> ValueMask(shortrangedata.size(), true); | 
|---|
|  | 592 | FragmentationShortRangeResults shortrangeresults(shortrangedata, keysets, forcekeysets, ValueMask); | 
|---|
| [a3427f] | 593 | shortrangeresults(shortrangedata); | 
|---|
|  | 594 | printReceivedShortResults(shortrangeresults); | 
|---|
| [47cee7] | 595 | printReceivedShortResultsPerIndex(shortrangeresults); | 
|---|
| [c8d13f5] | 596 | // add summed results to container | 
|---|
|  | 597 | container.addShortRangeSummedResults(shortrangeresults.getSummedShortRangeResults()); | 
|---|
| [a3427f] | 598 |  | 
|---|
| [0588e9] | 599 | /// now do we need to calculate the cycle contribution | 
|---|
|  | 600 | // check whether there are cycles in container or else in file | 
|---|
|  | 601 | KeySetsContainer cycles = container.getCycles(); | 
|---|
|  | 602 | if (cycles.KeySets.empty()) { | 
|---|
|  | 603 | // parse from file if cycles is empty | 
|---|
|  | 604 | boost::filesystem::path filename( | 
|---|
|  | 605 | params.prefix.get() + std::string(CYCLEKEYSETFILE)); | 
|---|
|  | 606 | if (boost::filesystem::exists(filename)) { | 
|---|
|  | 607 | LOG(1, "INFO: Parsing cycles file " << filename.string() << "."); | 
|---|
|  | 608 | // parse file line by line | 
|---|
|  | 609 | std::ifstream File; | 
|---|
|  | 610 | File.open(filename.string().c_str()); | 
|---|
|  | 611 | typedef std::istream_iterator<detail::Line> InIt; | 
|---|
|  | 612 | for (InIt iter = InIt(File); iter != InIt(); ++iter) { | 
|---|
|  | 613 | KeySetsContainer::IntVector cycle; | 
|---|
|  | 614 | std::stringstream line(*iter); | 
|---|
|  | 615 | while (line.good()) { | 
|---|
|  | 616 | int id; | 
|---|
|  | 617 | line >> id >> ws; | 
|---|
|  | 618 | cycle.push_back(id); | 
|---|
|  | 619 | } | 
|---|
|  | 620 | if (!cycle.empty()) { | 
|---|
|  | 621 | LOG(2, "DEBUG: Adding cycle " << cycle << "."); | 
|---|
|  | 622 | cycles.insert( cycle, cycle.size()); | 
|---|
|  | 623 | } | 
|---|
|  | 624 | } | 
|---|
|  | 625 | File.close(); | 
|---|
|  | 626 | } else { | 
|---|
|  | 627 | LOG(1, "INFO: Cycles file not found at " << filename.string() << "."); | 
|---|
|  | 628 | } | 
|---|
|  | 629 | } | 
|---|
|  | 630 |  | 
|---|
|  | 631 | // calculate energy if cycles are calculated fully at each level already | 
|---|
|  | 632 | if (!cycles.KeySets.empty()) { | 
|---|
| [f58e56] | 633 | calculateCycleFullContribution( | 
|---|
|  | 634 | shortrangedata, | 
|---|
|  | 635 | keysets, | 
|---|
|  | 636 | forcekeysets, | 
|---|
|  | 637 | cycles, | 
|---|
|  | 638 | shortrangeresults); | 
|---|
| [0588e9] | 639 | } | 
|---|
|  | 640 |  | 
|---|
| [e5ebaf] | 641 | // adding obtained forces | 
|---|
| [a58c16] | 642 | if ( const_cast<const World &>(World::getInstance()).getAllAtoms().size() != 0) { | 
|---|
| [d93d2c] | 643 | const IndexedVectors::indexedvectors_t shortrange_forces = | 
|---|
| [e5ebaf] | 644 | boost::fusion::at_key<MPQCDataFused::forces>( | 
|---|
|  | 645 | shortrangeresults.Result_Force_fused.back() | 
|---|
|  | 646 | ).getVectors(); | 
|---|
| [d93d2c] | 647 | AddForces(shortrange_forces,IsAngstroem); | 
|---|
| [e5ebaf] | 648 | } else { | 
|---|
|  | 649 | LOG(1, "INFO: Full molecule not loaded, hence will not add forces to atoms."); | 
|---|
|  | 650 | } | 
|---|
|  | 651 |  | 
|---|
| [18ed8c] | 652 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) | 
|---|
| [a3427f] | 653 | if (DoLongrange) { | 
|---|
| [a58c16] | 654 | if ( const_cast<const World &>(World::getInstance()).getAllAtoms().size() == 0) { | 
|---|
| [057c8a] | 655 | STATUS("Please load the full molecule into std::map<JobId_t, VMGData> longrangeData the world before starting this action."); | 
|---|
| [a3427f] | 656 | return Action::failure; | 
|---|
|  | 657 | } | 
|---|
|  | 658 |  | 
|---|
|  | 659 | FragmentationChargeDensity summedChargeDensity(shortrangedata,keysets); | 
|---|
|  | 660 | const std::vector<SamplingGrid> full_sample = summedChargeDensity.getFullSampledGrid(); | 
|---|
|  | 661 |  | 
|---|
|  | 662 | std::map<JobId_t, VMGData> longrangeData = container.getLongRangeResults(); | 
|---|
|  | 663 | // remove full solution corresponding to full_sample from map (must be highest ids), has to be treated extra | 
|---|
|  | 664 | std::map<JobId_t, VMGData>::iterator iter = longrangeData.end(); | 
|---|
| [057c8a] | 665 | std::advance(iter, -full_sample.size()); | 
|---|
| [a3427f] | 666 | std::map<JobId_t, VMGData>::iterator remove_iter = iter; | 
|---|
|  | 667 | std::vector<VMGData> fullsolutionData; | 
|---|
|  | 668 | for (; iter != longrangeData.end(); ++iter) | 
|---|
|  | 669 | fullsolutionData.push_back(iter->second); | 
|---|
| [057c8a] | 670 | if (longrangeData.size() > 1) // when there's just a single fragment, it corresponds to full solution | 
|---|
|  | 671 | longrangeData.erase(remove_iter, longrangeData.end()); | 
|---|
| [a3427f] | 672 |  | 
|---|
|  | 673 | // Final phase: sum up and print result | 
|---|
|  | 674 | FragmentationLongRangeResults longrangeresults( | 
|---|
|  | 675 | shortrangedata,longrangeData,keysets, forcekeysets); | 
|---|
|  | 676 | longrangeresults( | 
|---|
|  | 677 | shortrangedata, | 
|---|
|  | 678 | longrangeData, | 
|---|
|  | 679 | fullsolutionData, | 
|---|
|  | 680 | full_sample); | 
|---|
|  | 681 | printReceivedFullResults(longrangeresults); | 
|---|
|  | 682 |  | 
|---|
| [d93d2c] | 683 | // add long-range forces | 
|---|
|  | 684 | if ( const_cast<const World &>(World::getInstance()).getAllAtoms().size() != 0) { | 
|---|
|  | 685 | const IndexedVectors::indexedvectors_t longrange_forces = | 
|---|
|  | 686 | boost::fusion::at_key<VMGDataFused::forces_longrange>( | 
|---|
|  | 687 | longrangeresults.Result_ForcesLongRangeIntegrated_fused.back() | 
|---|
|  | 688 | ).getVectors(); | 
|---|
|  | 689 | AddForces(longrange_forces,IsAngstroem); | 
|---|
|  | 690 | } else { | 
|---|
|  | 691 | LOG(1, "INFO: Full molecule not loaded, hence will not add forces to atoms."); | 
|---|
|  | 692 | } | 
|---|
|  | 693 |  | 
|---|
| [a3427f] | 694 | // append all keysets to homology file | 
|---|
| [bf1d1b] | 695 | appendToHomologies(shortrangeresults, longrangeresults, params.DoStoreGrids.get()); | 
|---|
| [d76d65] | 696 | } else { | 
|---|
|  | 697 | // append all keysets to homology file with short-range info only (without grids) | 
|---|
|  | 698 | std::map<JobId_t, VMGData> longrangeData; | 
|---|
|  | 699 | FragmentationLongRangeResults longrangeresults( | 
|---|
|  | 700 | shortrangedata,longrangeData,keysets, forcekeysets); | 
|---|
|  | 701 | appendToHomologies(shortrangeresults, longrangeresults, false); | 
|---|
| [a3427f] | 702 | } | 
|---|
| [e2925fd] | 703 | #else | 
|---|
| [18ed8c] | 704 | if (DoLongrange) { | 
|---|
| [e2925fd] | 705 | ELOG(2, "File contains long-range information but long-range analysis capability not compiled in."); | 
|---|
| [18ed8c] | 706 | } | 
|---|
| [d76d65] | 707 |  | 
|---|
|  | 708 | // append all keysets to homology file with short-range info only (without grids) | 
|---|
| [18ed8c] | 709 | appendToHomologies(shortrangeresults, false); | 
|---|
| [a3427f] | 710 | #endif | 
|---|
|  | 711 |  | 
|---|
| [16893f] | 712 | // we no longer clear the container | 
|---|
|  | 713 | //  container.clear(); | 
|---|
| [a3427f] | 714 |  | 
|---|
|  | 715 | return Action::success; | 
|---|
|  | 716 | } | 
|---|
|  | 717 |  | 
|---|
| [b5b01e] | 718 | ActionState::ptr FragmentationAnalyseFragmentationResultsAction::performUndo(ActionState::ptr _state) { | 
|---|
| [a3427f] | 719 | return Action::success; | 
|---|
|  | 720 | } | 
|---|
|  | 721 |  | 
|---|
| [b5b01e] | 722 | ActionState::ptr FragmentationAnalyseFragmentationResultsAction::performRedo(ActionState::ptr _state){ | 
|---|
| [a3427f] | 723 | return Action::success; | 
|---|
|  | 724 | } | 
|---|
|  | 725 |  | 
|---|
|  | 726 | bool FragmentationAnalyseFragmentationResultsAction::canUndo() { | 
|---|
|  | 727 | return false; | 
|---|
|  | 728 | } | 
|---|
|  | 729 |  | 
|---|
|  | 730 | bool FragmentationAnalyseFragmentationResultsAction::shouldUndo() { | 
|---|
|  | 731 | return false; | 
|---|
|  | 732 | } | 
|---|
|  | 733 | /** =========== end of function ====================== */ | 
|---|