source: src/Actions/FragmentationAction/FragmentationAutomationAction.cpp@ 06865e

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 06865e was 06865e, checked in by Frederik Heber <heber@…>, 12 years ago

FragmentationAutomationAction now also treats the case correctly with sets including superset.

  • we don't need any extra... stuff, we just need to treate the last result extra.
  • Property mode set to 100644
File size: 40.6 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
5 *
6 *
7 * This file is part of MoleCuilder.
8 *
9 * MoleCuilder is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * MoleCuilder is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/*
24 * FragmentationAutomationAction.cpp
25 *
26 * Created on: May 18, 2012
27 * Author: heber
28 */
29
30// include config.h
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35#include <boost/archive/text_iarchive.hpp>
36// boost asio needs specific operator new
37#include <boost/asio.hpp>
38
39#include "CodePatterns/MemDebug.hpp"
40
41#include <boost/mpl/remove.hpp>
42
43#include "CodePatterns/Assert.hpp"
44#include "CodePatterns/Info.hpp"
45#include "CodePatterns/Log.hpp"
46#include "JobMarket/Controller/FragmentController.hpp"
47#include "JobMarket/Jobs/FragmentJob.hpp"
48
49#include "Atom/atom.hpp"
50#include "Box.hpp"
51#include "Element/element.hpp"
52#include "Fragmentation/EnergyMatrix.hpp"
53#include "Fragmentation/ForceMatrix.hpp"
54#include "Fragmentation/Fragmentation.hpp"
55#include "Fragmentation/SetValues/Fragment.hpp"
56#include "Fragmentation/SetValues/Histogram.hpp"
57#include "Fragmentation/SetValues/IndexedVectors.hpp"
58#include "Fragmentation/HydrogenSaturation_enum.hpp"
59#include "Fragmentation/KeySet.hpp"
60#include "Fragmentation/KeySetsContainer.hpp"
61#include "Fragmentation/Summation/AllLevelOrthogonalSummator.hpp"
62#include "Fragmentation/Summation/AllLevelSummator.hpp"
63#include "Fragmentation/Summation/OrthogonalFullSummator.hpp"
64#include "Fragmentation/Summation/OrthogonalSummation.hpp"
65#include "Fragmentation/Summation/writeTable.hpp"
66#include "Graph/DepthFirstSearchAnalysis.hpp"
67#include "Helpers/defs.hpp"
68#include "Jobs/MPQCJob.hpp"
69#include "Jobs/MPQCData.hpp"
70#include "Jobs/MPQCData_printKeyNames.hpp"
71#include "Jobs/Grid/SamplingGrid.hpp"
72#include "LinearAlgebra/RealSpaceMatrix.hpp"
73#ifdef HAVE_VMG
74#include "Jobs/VMGJob.hpp"
75#include "Jobs/VMGData.hpp"
76#include "Jobs/VMGDataFused.hpp"
77#include "Jobs/VMGDataMap.hpp"
78#include "Jobs/VMGData_printKeyNames.hpp"
79#endif
80#include "molecule.hpp"
81#include "World.hpp"
82
83#include <iostream>
84#include <string>
85#include <vector>
86
87#include <boost/mpl/for_each.hpp>
88
89#include "Actions/FragmentationAction/FragmentationAutomationAction.hpp"
90
91using namespace MoleCuilder;
92
93// and construct the stuff
94#include "FragmentationAutomationAction.def"
95#include "Action_impl_pre.hpp"
96/** =========== define the function ====================== */
97
98class controller_AddOn;
99
100// needs to be defined for using the FragmentController
101controller_AddOn *getAddOn()
102{
103 return NULL;
104}
105
106const int LEVEL = 5;
107
108/** Creates a MPQCCommandJob with argument \a filename.
109 *
110 * @param jobs created job is added to this vector
111 * @param command mpqc command to execute
112 * @param filename filename being argument to job
113 * @param nextid id for this job
114 */
115void parsejob(
116 std::vector<FragmentJob::ptr> &jobs,
117 const std::string &command,
118 const std::string &filename,
119 const JobId_t nextid)
120{
121 std::ifstream file;
122 file.open(filename.c_str());
123 ASSERT( file.good(), "parsejob() - file "+filename+" does not exist.");
124 std::string output((std::istreambuf_iterator<char>(file)),
125 std::istreambuf_iterator<char>());
126 double begin[NDIM] = { 0., 0., 0. };
127 const RealSpaceMatrix& M = World::getInstance().getDomain().getM();
128 const double size = M.at(0,0);
129 ASSERT( M.determinant() == size*size*size,
130 "parsejob() - current domain matrix "+toString(M)+" is not cubic.");
131 const int level = LEVEL;
132 FragmentJob::ptr testJob( new MPQCJob(nextid, output, begin, size, level) );
133 jobs.push_back(testJob);
134 file.close();
135 LOG(1, "INFO: Added MPQCCommandJob from file "+filename+".");
136}
137
138/** Helper function to get number of atoms somehow.
139 *
140 * Here, we just parse the number of lines in the adjacency file as
141 * it should correspond to the number of atoms, except when some atoms
142 * are not bonded, but then fragmentation makes no sense.
143 *
144 * @param path path to the adjacency file
145 */
146size_t getNoAtomsFromAdjacencyFile(const std::string &path)
147{
148 size_t NoAtoms = 0;
149
150 // parse in special file to get atom count (from line count)
151 std::string filename(path);
152 filename += FRAGMENTPREFIX;
153 filename += ADJACENCYFILE;
154 std::ifstream adjacency(filename.c_str());
155 if (adjacency.fail()) {
156 LOG(0, endl << "getNoAtomsFromAdjacencyFile() - Unable to open " << filename << ", is the directory correct?");
157 return false;
158 }
159 std::string buffer;
160 while (getline(adjacency, buffer))
161 NoAtoms++;
162 LOG(1, "INFO: There are " << NoAtoms << " atoms.");
163
164 return NoAtoms;
165}
166
167/** Extracts MPQCData from received vector of FragmentResults.
168 *
169 * @param results results to extract MPQCData from
170 * @param fragmentData on return array filled with extracted MPQCData
171 */
172template <typename T>
173void ConvertFragmentResultTo(
174 const std::vector<FragmentResult::ptr> &results,
175 std::vector<T> &fragmentData)
176{
177 // extract results
178 fragmentData.clear();
179 fragmentData.reserve(results.size());
180
181 LOG(2, "DEBUG: Parsing now through " << results.size() << " results.");
182 for (std::vector<FragmentResult::ptr>::const_iterator iter = results.begin();
183 iter != results.end(); ++iter) {
184 //LOG(1, "RESULT: job #"+toString((*iter)->getId())+": "+toString((*iter)->result));
185 T extractedData;
186 std::stringstream inputstream((*iter)->result);
187 LOG(2, "DEBUG: First 50 characters FragmentResult's string: "+(*iter)->result.substr(0, 50));
188 boost::archive::text_iarchive ia(inputstream);
189 ia >> extractedData;
190 LOG(1, "INFO: extracted data is " << extractedData << ".");
191 fragmentData.push_back(extractedData);
192 }
193
194 ASSERT( results.size() == fragmentData.size(),
195 "ConvertFragmentResultTo() - the number of extracted data differs from the number of results.");
196}
197
198/** Creates a lookup from FragmentJob::id to the true fragment number.
199 *
200 * @param results result with job ids
201 * @param MatrixNrLookup Lookup up-map, filled on return
202 * @param FragmentCounter total number of fragments on return
203 */
204void createMatrixNrLookup(
205 const std::vector<FragmentResult::ptr> &results,
206 std::map< JobId_t, size_t > &MatrixNrLookup,
207 size_t &FragmentCounter)
208{
209 // align fragments
210 MatrixNrLookup.clear();
211 FragmentCounter = 0;
212 {
213 // bring ids in order ...
214 typedef std::map< JobId_t, FragmentResult::ptr> IdResultMap_t;
215 IdResultMap_t IdResultMap;
216 for (std::vector<FragmentResult::ptr>::const_iterator iter = results.begin();
217 iter != results.end(); ++iter) {
218 #ifndef NDEBUG
219 std::pair< IdResultMap_t::iterator, bool> inserter =
220 #endif
221 IdResultMap.insert( make_pair((*iter)->getId(), *iter) );
222 ASSERT( inserter.second,
223 "ExtractMPQCDataFromResults() - two results have same id "
224 +toString((*iter)->getId())+".");
225 }
226 // ... and fill lookup
227 for(IdResultMap_t::const_iterator iter = IdResultMap.begin();
228 iter != IdResultMap.end(); ++iter)
229 MatrixNrLookup.insert( make_pair(iter->first, FragmentCounter++) );
230 }
231 LOG(1, "INFO: There are " << FragmentCounter << " fragments.");
232}
233
234/** Place results from FragmentResult into EnergyMatrix and ForceMatrix.
235 *
236 * @param results results with ids to associate with fragment number
237 * @param fragmentData MPQCData resulting from the jobs
238 * @param MatrixNrLookup Lookup up-map from job id to fragment number
239 * @param FragmentCounter total number of fragments
240 * @param NoAtoms total number of atoms
241 * @param Energy energy matrix to be filled on return
242 * @param Force force matrix to be filled on return
243 * @return true - everything ok, false - else
244 */
245bool putResultsintoMatrices(
246 const std::vector<FragmentResult::ptr> &results,
247 const std::vector<MPQCData> &fragmentData,
248 std::map< JobId_t, size_t > &MatrixNrLookup,
249 const size_t FragmentCounter,
250 const size_t NoAtoms,
251 EnergyMatrix &Energy,
252 ForceMatrix &Force)
253{
254 ASSERT( results.size() == fragmentData.size(),
255 "printReceivedMPQCResults() - results and fragmentData differ in size.");
256 std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
257 std::vector<FragmentResult::ptr>::const_iterator resultiter = results.begin();
258 for (; dataiter != fragmentData.end(); ++dataiter, ++resultiter) {
259 const MPQCData &extractedData = *dataiter;
260 // place results into EnergyMatrix ...
261 {
262 MatrixContainer::MatrixArray matrix;
263 matrix.resize(1);
264 matrix[0].resize(1, extractedData.energies.total);
265 if (!Energy.AddMatrix(
266 std::string("MPQCJob ")+toString((*resultiter)->getId()),
267 matrix,
268 MatrixNrLookup[(*resultiter)->getId()])) {
269 ELOG(1, "Adding energy matrix failed.");
270 return false;
271 }
272 }
273 // ... and ForceMatrix (with two empty columns in front)
274 {
275 MatrixContainer::MatrixArray matrix;
276 const size_t rows = extractedData.forces.size();
277 matrix.resize(rows);
278 for (size_t i=0;i<rows;++i) {
279 const size_t columns = 2+extractedData.forces[i].size();
280 matrix[i].resize(columns, 0.);
281 // for (size_t j=0;j<2;++j)
282 // matrix[i][j] = 0.;
283 for (size_t j=2;j<columns;++j)
284 matrix[i][j] = extractedData.forces[i][j-2];
285 }
286 if (!Force.AddMatrix(
287 std::string("MPQCJob ")+toString((*resultiter)->getId()),
288 matrix,
289 MatrixNrLookup[(*resultiter)->getId()])) {
290 ELOG(1, "Adding force matrix failed.");
291 return false;
292 }
293 }
294 }
295 // add one more matrix (not required for energy)
296 MatrixContainer::MatrixArray matrix;
297 matrix.resize(1);
298 matrix[0].resize(1, 0.);
299 if (!Energy.AddMatrix(std::string("MPQCJob total"), matrix, FragmentCounter))
300 return false;
301 // but for energy because we need to know total number of atoms
302 matrix.resize(NoAtoms);
303 for (size_t i = 0; i< NoAtoms; ++i)
304 matrix[i].resize(2+NDIM, 0.);
305 if (!Force.AddMatrix(std::string("MPQCJob total"), matrix, FragmentCounter))
306 return false;
307
308 return true;
309}
310
311template <typename source, typename dest>
312void convertDataTo(
313 const std::vector<source> &fragmentData,
314 std::vector<dest> &MPQCData_fused)
315{
316 MPQCData_fused.clear();
317}
318
319template <>
320void convertDataTo<MPQCData, MPQCDataEnergyMap_t>(
321 const std::vector<MPQCData> &fragmentData,
322 std::vector<MPQCDataEnergyMap_t> &MPQCData_Energy_fused)
323{
324 // energy_t
325 MPQCData_Energy_fused.clear();
326 MPQCData_Energy_fused.reserve(fragmentData.size());
327 for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
328 dataiter != fragmentData.end(); ++dataiter) {
329 const MPQCData &extractedData = *dataiter;
330 LOG(2, "DEBUG: Current extracted Data is " << extractedData << ".");
331 MPQCDataEnergyMap_t instance;
332 boost::fusion::at_key<MPQCDataFused::energy_total>(instance) = extractedData.energies.total;
333 boost::fusion::at_key<MPQCDataFused::energy_nuclear_repulsion>(instance) = extractedData.energies.nuclear_repulsion;
334 boost::fusion::at_key<MPQCDataFused::energy_electron_coulomb>(instance) = extractedData.energies.electron_coulomb;
335 boost::fusion::at_key<MPQCDataFused::energy_electron_exchange>(instance) = extractedData.energies.electron_exchange;
336 boost::fusion::at_key<MPQCDataFused::energy_correlation>(instance) = extractedData.energies.correlation;
337 boost::fusion::at_key<MPQCDataFused::energy_overlap>(instance) = extractedData.energies.overlap;
338 boost::fusion::at_key<MPQCDataFused::energy_kinetic>(instance) = extractedData.energies.kinetic;
339 boost::fusion::at_key<MPQCDataFused::energy_hcore>(instance) = extractedData.energies.hcore;
340 boost::fusion::at_key<MPQCDataFused::energy_eigenvalues>(instance) = extractedData.energies.eigenvalues;
341 MPQCData_Energy_fused.push_back(instance);
342 }
343}
344
345template <>
346void convertDataTo<VMGData, VMGDataMap_t>(
347 const std::vector<VMGData> &longrangeData,
348 std::vector<VMGDataMap_t> &VMGData_fused)
349{
350 // energy_t
351 VMGData_fused.clear();
352 VMGData_fused.reserve(longrangeData.size());
353 for(std::vector<VMGData>::const_iterator dataiter = longrangeData.begin();
354 dataiter != longrangeData.end(); ++dataiter) {
355 const VMGData &extractedData = *dataiter;
356 LOG(2, "DEBUG: Current extracted Data is " << extractedData << ".");
357 VMGDataMap_t instance;
358 boost::fusion::at_key<VMGDataFused::sampled_potential>(instance) = extractedData.sampled_potential;
359 boost::fusion::at_key<VMGDataFused::energy_long>(instance) = extractedData.e_long;
360 VMGData_fused.push_back(instance);
361 }
362}
363
364void convertMPQCDatatoForceMap(
365 const std::vector<MPQCData> &fragmentData,
366 const KeySetsContainer &ForceKeySet,
367 std::vector<MPQCDataForceMap_t> &MPQCData_Force_fused)
368{
369 // forces
370 ASSERT( ForceKeySet.KeySets.size() == fragmentData.size(),
371 "FragmentationAutomationAction::performCall() - indices and fragmentData differ in size.");
372 MPQCData_Force_fused.clear();
373 MPQCData_Force_fused.reserve(fragmentData.size());
374 std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
375 KeySetsContainer::ArrayOfIntVectors::const_iterator arrayiter = ForceKeySet.KeySets.begin();
376 for(;dataiter != fragmentData.end(); ++dataiter, ++arrayiter) {
377 const MPQCData &extractedData = *dataiter;
378 LOG(2, "DEBUG: Current extracted Data is " << extractedData << ".");
379 MPQCDataForceMap_t instance;
380 // must convert int to index_t
381 IndexedVectors::indices_t indices(arrayiter->begin(), arrayiter->end());
382 boost::fusion::at_key<MPQCDataFused::forces>(instance) =
383 IndexedVectors(indices, extractedData.forces);
384 MPQCData_Force_fused.push_back(instance);
385 }
386}
387
388template <>
389void convertDataTo<MPQCData, MPQCDataGridMap_t>(
390 const std::vector<MPQCData> &fragmentData,
391 std::vector<MPQCDataGridMap_t> &MPQCData_Grid_fused)
392{
393 // sampled_grid
394 MPQCData_Grid_fused.clear();
395 MPQCData_Grid_fused.reserve(fragmentData.size());
396 for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
397 dataiter != fragmentData.end(); ++dataiter) {
398 const MPQCData &extractedData = *dataiter;
399 LOG(2, "DEBUG: Current extracted Data is " << extractedData << ".");
400 MPQCDataGridMap_t instance;
401 boost::fusion::at_key<MPQCDataFused::sampled_grid>(instance) = extractedData.sampled_grid;
402 MPQCData_Grid_fused.push_back(instance);
403 }
404}
405
406template <>
407void convertDataTo<MPQCData, MPQCDataFragmentMap_t>(
408 const std::vector<MPQCData> &fragmentData,
409 std::vector<MPQCDataFragmentMap_t> &MPQCData_Fragment_fused)
410{
411 // fragment
412 MPQCData_Fragment_fused.clear();
413 MPQCData_Fragment_fused.reserve(fragmentData.size());
414 for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
415 dataiter != fragmentData.end(); ++dataiter) {
416 const MPQCData &extractedData = *dataiter;
417 LOG(2, "DEBUG: Current extracted Data is " << extractedData << ".");
418 MPQCDataFragmentMap_t instance;
419 boost::fusion::at_key<MPQCDataFused::fragment>(instance) =
420 Fragment(extractedData.positions, extractedData.charges);
421 MPQCData_Fragment_fused.push_back(instance);
422 }
423}
424
425template <>
426void convertDataTo<MPQCData, MPQCDataTimeMap_t>(
427 const std::vector<MPQCData> &fragmentData,
428 std::vector<MPQCDataTimeMap_t> &MPQCData_Time_fused)
429{
430 // times
431 MPQCData_Time_fused.clear();
432 MPQCData_Time_fused.reserve(fragmentData.size());
433 for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
434 dataiter != fragmentData.end(); ++dataiter) {
435 const MPQCData &extractedData = *dataiter;
436 LOG(2, "DEBUG: Current extracted Data is " << extractedData << ".");
437 MPQCDataTimeMap_t instance;
438 boost::fusion::at_key<MPQCDataFused::times_walltime>(instance) = extractedData.times.walltime;
439 boost::fusion::at_key<MPQCDataFused::times_cputime>(instance) = extractedData.times.cputime;
440 boost::fusion::at_key<MPQCDataFused::times_flops>(instance) = extractedData.times.flops;
441 MPQCData_Time_fused.push_back(instance);
442 }
443}
444
445template <typename TypeMap, typename TypeVector>
446std::vector<TypeMap> SumUpPerLevel(
447 const std::vector<MPQCData> &fragmentData,
448 const std::vector<JobId_t> &jobids,
449 std::map< JobId_t, size_t > &MatrixNrLookup,
450 const IndexSetContainer::ptr &container,
451 SubsetMap::ptr &subsetmap
452 )
453{
454 // place data into boost::fusion::map instance
455 std::vector<TypeMap> MPQCData_fused;
456 convertDataTo<MPQCData, TypeMap>(fragmentData, MPQCData_fused);
457 // instantiate summator
458 std::vector<TypeMap> Result_fused(subsetmap->getMaximumSubsetLevel());
459 AllLevelSummator<TypeMap> Summer(
460 subsetmap,
461 MPQCData_fused,
462 jobids,
463 container->getContainer(),
464 MatrixNrLookup,
465 Result_fused);
466 // sum up for each type key in TypeVector
467 boost::mpl::for_each<TypeVector>(boost::ref(Summer));
468 return Result_fused;
469}
470
471template <typename TypeMap, typename TypeVector>
472std::vector<TypeMap> OrthogonalSumUpPerLevel(
473 const std::vector<MPQCData> &fragmentData,
474 const std::vector<JobId_t> &jobids,
475 std::map< JobId_t, size_t > &MatrixNrLookup,
476 const IndexSetContainer::ptr &container,
477 SubsetMap::ptr &subsetmap
478 )
479{
480 // place data into boost::fusion::map instance
481 std::vector<TypeMap> MPQCData_fused;
482 convertDataTo<MPQCData, TypeMap>(fragmentData, MPQCData_fused);
483 // instantiate summator
484 std::vector<TypeMap> Result_fused(subsetmap->getMaximumSubsetLevel());
485 AllLevelOrthogonalSummator<TypeMap> Summer(
486 subsetmap,
487 MPQCData_fused,
488 jobids,
489 container->getContainer(),
490 MatrixNrLookup,
491 Result_fused);
492 // sum up for each type key in TypeVector
493 boost::mpl::for_each<TypeVector>(boost::ref(Summer));
494 return Result_fused;
495}
496
497/** Print MPQCData from received results.
498 *
499 * @param results results with ids to associate with fragment number
500 * @param fragmentData MPQCData resulting from the jobs
501 * @param KeySetFilename filename with keysets to associate forces correctly
502 * @param NoAtoms total number of atoms
503 * @param full_sample summed up charge density of electrons from fragments on return
504 * @param full_fragment summed up positions and charges of nuclei from fragments on return
505 */
506bool sumUpChargeDensity(
507 const std::vector<FragmentResult::ptr> &results,
508 const std::vector<MPQCData> &fragmentData,
509 const std::string &KeySetFilename,
510 SamplingGrid &full_sample,
511 Fragment &full_fragment)
512{
513 // create lookup from job nr to fragment number
514 std::map< JobId_t, size_t > MatrixNrLookup;
515 size_t FragmentCounter = 0;
516 createMatrixNrLookup(results, MatrixNrLookup, FragmentCounter);
517
518 // initialise keysets
519 KeySetsContainer KeySet;
520 {
521 // else needs keysets without hydrogens
522 std::stringstream filename;
523 filename << FRAGMENTPREFIX << KEYSETFILE;
524 if (!KeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false;
525 }
526
527 /// prepare for OrthogonalSummation
528
529 // convert KeySetContainer to IndexSetContainer
530 IndexSetContainer::ptr container(new IndexSetContainer(KeySet));
531 // create the map of all keysets
532 SubsetMap::ptr subsetmap(new SubsetMap(*container));
533
534 // create a vector of all job ids
535 std::vector<JobId_t> jobids(results.size(), JobId::IllegalJob);
536 std::transform(results.begin(), results.end(), jobids.begin(),
537 boost::bind(&FragmentResult::getId,
538 boost::bind(&FragmentResult::ptr::operator->, _1)));
539
540 /// convert all MPQCData to MPQCDataMap_t
541 std::vector<MPQCDataGridMap_t> Result_Grid_fused(
542 OrthogonalSumUpPerLevel<MPQCDataGridMap_t, MPQCDataGridVector_t>(
543 fragmentData, jobids, MatrixNrLookup, container, subsetmap));
544 std::vector<MPQCDataFragmentMap_t> Result_Fragment_fused(
545 OrthogonalSumUpPerLevel<MPQCDataFragmentMap_t, MPQCDataFragmentVector_t>(
546 fragmentData, jobids, MatrixNrLookup, container, subsetmap));
547 // obtain full grid
548 full_sample = boost::fusion::at_key<MPQCDataFused::sampled_grid>(Result_Grid_fused.back());
549 full_fragment = boost::fusion::at_key<MPQCDataFused::fragment>(Result_Fragment_fused.back());
550
551 return true;
552}
553
554
555/** Print MPQCData from received results.
556 *
557 * @param results results with ids to associate with fragment number
558 * @param fragmentData MPQCData resulting from the jobs
559 * @param KeySetFilename filename with keysets to associate forces correctly
560 * @param NoAtoms total number of atoms
561 * @param full_sample summed up charge from fragments on return
562 */
563bool printReceivedMPQCResults(
564 const std::vector<FragmentResult::ptr> &results,
565 const std::vector<MPQCData> &fragmentData,
566 const std::string &KeySetFilename,
567 size_t NoAtoms,
568 SamplingGrid &full_sample)
569{
570 // create lookup from job nr to fragment number
571 std::map< JobId_t, size_t > MatrixNrLookup;
572 size_t FragmentCounter = 0;
573 createMatrixNrLookup(results, MatrixNrLookup, FragmentCounter);
574
575 // place results into maps
576 EnergyMatrix Energy;
577 ForceMatrix Force;
578 if (!putResultsintoMatrices(results, fragmentData, MatrixNrLookup, FragmentCounter, NoAtoms, Energy, Force))
579 return false;
580
581 // initialise keysets
582 KeySetsContainer KeySet;
583 KeySetsContainer ForceKeySet;
584 if (!Energy.InitialiseIndices()) return false;
585
586 if (!Force.ParseIndices(KeySetFilename.c_str())) return false;
587
588 {
589 // else needs keysets without hydrogens
590 std::stringstream filename;
591 filename << FRAGMENTPREFIX << KEYSETFILE;
592 if (!KeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false;
593 }
594
595 {
596 // forces need keysets including hydrogens
597 std::stringstream filename;
598 filename << FRAGMENTPREFIX << FORCESFILE;
599 if (!ForceKeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false;
600 }
601
602 /// prepare for OrthogonalSummation
603
604 // convert KeySetContainer to IndexSetContainer
605 IndexSetContainer::ptr container(new IndexSetContainer(KeySet));
606 // create the map of all keysets
607 SubsetMap::ptr subsetmap(new SubsetMap(*container));
608
609 // create a vector of all job ids
610 std::vector<JobId_t> jobids(results.size(), JobId::IllegalJob);
611 std::transform(results.begin(), results.end(), jobids.begin(),
612 boost::bind(&FragmentResult::getId,
613 boost::bind(&FragmentResult::ptr::operator->, _1)));
614
615 /// convert all MPQCData to MPQCDataMap_t
616 {
617 ASSERT( ForceKeySet.KeySets.size() == fragmentData.size(),
618 "FragmentationAutomationAction::performCall() - ForceKeySet's KeySets and fragmentData differ in size.");
619
620 typedef boost::mpl::remove<MPQCDataEnergyVector_t, MPQCDataFused::energy_eigenvalues>::type MPQCDataEnergyVector_noeigenvalues_t;
621 std::vector<MPQCDataEnergyMap_t> Result_Energy_fused(
622 OrthogonalSumUpPerLevel<MPQCDataEnergyMap_t, MPQCDataEnergyVector_t>(
623 fragmentData, jobids, MatrixNrLookup, container, subsetmap));
624 std::vector<MPQCDataGridMap_t> Result_Grid_fused(
625 OrthogonalSumUpPerLevel<MPQCDataGridMap_t, MPQCDataGridVector_t>(
626 fragmentData, jobids, MatrixNrLookup, container, subsetmap));
627 std::vector<MPQCDataTimeMap_t> Result_Time_fused(
628 SumUpPerLevel<MPQCDataTimeMap_t, MPQCDataTimeVector_t>(
629 fragmentData, jobids, MatrixNrLookup, container, subsetmap));
630
631 // force has extra converter
632 std::vector<MPQCDataForceMap_t> MPQCData_Force_fused;
633 convertMPQCDatatoForceMap(fragmentData, ForceKeySet, MPQCData_Force_fused);
634 std::vector<MPQCDataForceMap_t> Result_Force_fused(subsetmap->getMaximumSubsetLevel());
635 AllLevelOrthogonalSummator<MPQCDataForceMap_t> forceSummer(
636 subsetmap,
637 MPQCData_Force_fused,
638 jobids,
639 container->getContainer(),
640 MatrixNrLookup,
641 Result_Force_fused);
642 boost::mpl::for_each<MPQCDataForceVector_t>(boost::ref(forceSummer));
643
644 // obtain full grid
645 full_sample = boost::fusion::at_key<MPQCDataFused::sampled_grid>(Result_Grid_fused.back());
646
647 // print tables (without eigenvalues, they go extra)
648 const size_t MaxLevel = subsetmap->getMaximumSubsetLevel();
649 const std::string energyresult =
650 writeTable<MPQCDataEnergyMap_t, MPQCDataEnergyVector_noeigenvalues_t >()(
651 Result_Energy_fused, MaxLevel);
652 LOG(0, "Energy table is \n" << energyresult);
653 const std::string eigenvalueresult;
654
655 LOG(0, "Eigenvalue table is \n" << eigenvalueresult);
656 const std::string forceresult =
657 writeTable<MPQCDataForceMap_t, MPQCDataForceVector_t>()(
658 Result_Force_fused, MaxLevel);
659 LOG(0, "Force table is \n" << forceresult);
660 // we don't want to print grid to a table
661 // print times (without flops for now)
662 typedef boost::mpl::remove<MPQCDataTimeVector_t, MPQCDataFused::times_flops>::type MPQCDataTimeVector_noflops_t;
663 const std::string timesresult =
664 writeTable<MPQCDataTimeMap_t, MPQCDataTimeVector_noflops_t >()(
665 Result_Time_fused, MaxLevel);
666 LOG(0, "Times table is \n" << timesresult);
667 }
668
669 // combine all found data
670 if (!KeySet.ParseManyBodyTerms()) return false;
671
672 EnergyMatrix EnergyFragments;
673 ForceMatrix ForceFragments;
674 if (!EnergyFragments.AllocateMatrix(Energy.Header, Energy.MatrixCounter, Energy.RowCounter, Energy.ColumnCounter)) return false;
675 if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return false;
676
677 if(!Energy.SetLastMatrix(0., 0)) return false;
678 if(!Force.SetLastMatrix(0., 2)) return false;
679
680 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
681 // --------- sum up energy --------------------
682 LOG(1, "INFO: Summing energy of order " << BondOrder+1 << " ...");
683 if (!EnergyFragments.SumSubManyBodyTerms(Energy, KeySet, BondOrder)) return false;
684 if (!Energy.SumSubEnergy(EnergyFragments, NULL, KeySet, BondOrder, 1.)) return false;
685
686 // --------- sum up Forces --------------------
687 LOG(1, "INFO: Summing forces of order " << BondOrder+1 << " ...");
688 if (!ForceFragments.SumSubManyBodyTerms(Force, KeySet, BondOrder)) return false;
689 if (!Force.SumSubForces(ForceFragments, KeySet, BondOrder, 1.)) return false;
690 }
691
692 // for debugging print resulting energy and forces
693 LOG(1, "INFO: Resulting energy is " << Energy.Matrix[ FragmentCounter ][0][0]);
694 std::stringstream output;
695 for (int i=0; i< Force.RowCounter[FragmentCounter]; ++i) {
696 for (int j=0; j< Force.ColumnCounter[FragmentCounter]; ++j)
697 output << Force.Matrix[ FragmentCounter ][i][j] << " ";
698 output << "\n";
699 }
700 LOG(1, "INFO: Resulting forces are " << std::endl << output.str());
701
702 return true;
703}
704
705/** Print MPQCData from received results.
706 *
707 * @param fragmentresults results with short-range job ids to associate with fragment number
708 * @param longrangeresults results with long-range job ids to associate with fragment number
709 * @param fragmentData MPQCData resulting from the jobs
710 * @param longrangeData VMGData resulting from long-range jobs
711 * @param KeySetFilename filename with keysets to associate forces correctly
712 * @param NoAtoms total number of atoms
713 * @param full_sample summed up charge from fragments on return
714 */
715bool printReceivedFullResults(
716 const std::vector<FragmentResult::ptr> &fragmentresults,
717 const std::vector<FragmentResult::ptr> &longrangeresults,
718 const std::vector<MPQCData> &fragmentData,
719 const std::vector<VMGData> &longrangeData,
720 const std::string &KeySetFilename,
721 size_t NoAtoms,
722 SamplingGrid &full_sample)
723{
724 // create lookup from job nr to fragment number
725 std::map< JobId_t, size_t > MatrixNrLookup;
726 size_t FragmentCounter = 0;
727 createMatrixNrLookup(fragmentresults, MatrixNrLookup, FragmentCounter);
728
729 // initialise keysets
730 KeySetsContainer KeySet;
731 KeySetsContainer ForceKeySet;
732 {
733 // else needs keysets without hydrogens
734 std::stringstream filename;
735 filename << FRAGMENTPREFIX << KEYSETFILE;
736 if (!KeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false;
737 }
738
739 {
740 // forces need keysets including hydrogens
741 std::stringstream filename;
742 filename << FRAGMENTPREFIX << FORCESFILE;
743 if (!ForceKeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false;
744 }
745
746 /// prepare for OrthogonalSummation
747
748 // convert KeySetContainer to IndexSetContainer
749 IndexSetContainer::ptr container(new IndexSetContainer(KeySet));
750 // create the map of all keysets
751 SubsetMap::ptr subsetmap(new SubsetMap(*container));
752
753 // create a vector of all job ids from short-range
754 std::vector<JobId_t> jobids(fragmentresults.size(), JobId::IllegalJob);
755 std::transform(fragmentresults.begin(), fragmentresults.end(), jobids.begin(),
756 boost::bind(&FragmentResult::getId,
757 boost::bind(&FragmentResult::ptr::operator->, _1)));
758
759 /// convert all MPQCData to MPQCDataMap_t
760 {
761 typedef boost::mpl::remove<MPQCDataEnergyVector_t, MPQCDataFused::energy_eigenvalues>::type MPQCDataEnergyVector_noeigenvalues_t;
762 std::vector<MPQCDataEnergyMap_t> Result_Energy_fused(
763 OrthogonalSumUpPerLevel<MPQCDataEnergyMap_t, MPQCDataEnergyVector_t>(
764 fragmentData, jobids, MatrixNrLookup, container, subsetmap));
765 std::vector<MPQCDataGridMap_t> Result_Grid_fused(
766 OrthogonalSumUpPerLevel<MPQCDataGridMap_t, MPQCDataGridVector_t>(
767 fragmentData, jobids, MatrixNrLookup, container, subsetmap));
768 std::vector<MPQCDataTimeMap_t> Result_Time_fused(
769 SumUpPerLevel<MPQCDataTimeMap_t, MPQCDataTimeVector_t>(
770 fragmentData, jobids, MatrixNrLookup, container, subsetmap));
771 std::vector<MPQCDataFragmentMap_t> Result_Fragment_fused(
772 OrthogonalSumUpPerLevel<MPQCDataFragmentMap_t, MPQCDataFragmentVector_t>(
773 fragmentData, jobids, MatrixNrLookup, container, subsetmap));
774
775 // force has extra converter
776 std::vector<MPQCDataForceMap_t> MPQCData_Force_fused;
777 convertMPQCDatatoForceMap(fragmentData, ForceKeySet, MPQCData_Force_fused);
778 std::vector<MPQCDataForceMap_t> Result_Force_fused(subsetmap->getMaximumSubsetLevel());
779 AllLevelOrthogonalSummator<MPQCDataForceMap_t> forceSummer(
780 subsetmap,
781 MPQCData_Force_fused,
782 jobids,
783 container->getContainer(),
784 MatrixNrLookup,
785 Result_Force_fused);
786 boost::mpl::for_each<MPQCDataForceVector_t>(boost::ref(forceSummer));
787
788 // full solution has to treated extra and not used in summation
789 std::vector<VMGData> temp_longrangeData(longrangeData.begin(), --longrangeData.end());
790
791 // obtain full grid
792 std::vector<VMGDataMap_t> VMGData_Potential_fused;
793 convertDataTo<VMGData, VMGDataMap_t>(temp_longrangeData, VMGData_Potential_fused);
794 OrthogonalFullSummator<VMGDataMap_t, VMGDataFused::sampled_potential> potentialSummer(
795 subsetmap,
796 VMGData_Potential_fused,
797 jobids,
798 container->getContainer(),
799 MatrixNrLookup);
800 potentialSummer(subsetmap->getMaximumSubsetLevel());
801 SamplingGrid full_sample = longrangeData.back().sampled_potential;
802 full_sample -= potentialSummer.getFullContribution();
803 LOG(0, "Remaining long-range energy from potential integral is " << full_sample.integral() << ".");
804
805 OrthogonalFullSummator<VMGDataMap_t, VMGDataFused::energy_long> elongSummer(
806 subsetmap,
807 VMGData_Potential_fused,
808 jobids,
809 container->getContainer(),
810 MatrixNrLookup);
811 elongSummer(subsetmap->getMaximumSubsetLevel());
812 double e_long = longrangeData.back().e_long;
813 e_long -= elongSummer.getFullContribution();
814 LOG(0, "Remaining long-range energy is " << e_long << ".");
815
816 // print tables (without eigenvalues, they go extra)
817 const size_t MaxLevel = subsetmap->getMaximumSubsetLevel();
818 const std::string energyresult =
819 writeTable<MPQCDataEnergyMap_t, MPQCDataEnergyVector_noeigenvalues_t >()(
820 Result_Energy_fused, MaxLevel);
821 LOG(0, "Energy table is \n" << energyresult);
822 const std::string eigenvalueresult;
823
824 LOG(0, "Eigenvalue table is \n" << eigenvalueresult);
825 const std::string forceresult =
826 writeTable<MPQCDataForceMap_t, MPQCDataForceVector_t>()(
827 Result_Force_fused, MaxLevel);
828 LOG(0, "Force table is \n" << forceresult);
829 // we don't want to print grid to a table
830 // print times (without flops for now)
831 typedef boost::mpl::remove<MPQCDataTimeVector_t, MPQCDataFused::times_flops>::type MPQCDataTimeVector_noflops_t;
832 const std::string timesresult =
833 writeTable<MPQCDataTimeMap_t, MPQCDataTimeVector_noflops_t >()(
834 Result_Time_fused, MaxLevel);
835 LOG(0, "Times table is \n" << timesresult);
836 }
837
838 return true;
839}
840
841
842void RunService(
843 boost::asio::io_service &io_service,
844 std::string message)
845{
846 message = std::string("io_service: ") + message;
847 io_service.reset();
848 Info info(message.c_str());
849 io_service.run();
850}
851
852void requestIds(
853 FragmentController &controller,
854 const FragmentationFragmentationAutomationAction::FragmentationFragmentationAutomationParameters &params,
855 const size_t numberjobs)
856{
857 controller.requestIds(params.host.get(), params.port.get(), numberjobs);
858}
859
860bool createJobsFromFiles(
861 FragmentController &controller,
862 const FragmentationFragmentationAutomationAction::FragmentationFragmentationAutomationParameters &params,
863 const std::vector< boost::filesystem::path > &jobfiles)
864{
865 std::vector<FragmentJob::ptr> jobs;
866 for (std::vector< boost::filesystem::path >::const_iterator iter = jobfiles.begin();
867 iter != jobfiles .end(); ++iter) {
868 const std::string &filename = (*iter).string();
869 if (boost::filesystem::exists(filename)) {
870 const JobId_t next_id = controller.getAvailableId();
871 LOG(1, "INFO: Creating MPQCCommandJob with filename'"
872 +filename+"', and id "+toString(next_id)+".");
873 parsejob(jobs, params.executable.get().string(), filename, next_id);
874 } else {
875 ELOG(1, "Fragment job "+filename+" does not exist.");
876 return false;
877 }
878 }
879 controller.addJobs(jobs);
880 controller.sendJobs(params.host.get(), params.port.get());
881 return true;
882}
883
884#ifdef HAVE_VMG
885bool createLongRangeJobs(
886 FragmentController &controller,
887 const FragmentationFragmentationAutomationAction::FragmentationFragmentationAutomationParameters &params,
888 const std::vector<MPQCData> &fragmentData,
889 const SamplingGrid &full_sampled_grid,
890 const Fragment &full_fragment)
891{
892 std::vector<FragmentJob::ptr> jobs;
893 // add one job for each fragment as the short-range correction which we need
894 // to subtract from the obtained full potential to get the long-range part only
895 for (std::vector<MPQCData>::const_iterator iter = fragmentData.begin();
896 iter != fragmentData.end(); ++iter) {
897 const JobId_t next_id = controller.getAvailableId();
898 LOG(1, "INFO: Creating VMGJob with " << iter->sampled_grid.sampled_grid.size()
899 << " gridpoints and " << iter->charges.size() << " particle charges.");
900 FragmentJob::ptr testJob(
901 new VMGJob(next_id, iter->sampled_grid, iter->positions, iter->charges) );
902 jobs.push_back(testJob);
903 }
904
905 {
906 const World::AtomComposite &atoms = World::getInstance().getAllAtoms();
907 std::vector< std::vector<double> > positions;
908 positions.reserve(atoms.size());
909 std::vector<double> charges;
910 charges.reserve(atoms.size());
911 std::vector<double> position(3, 0.);
912 for (World::AtomComposite::const_iterator iter = atoms.begin();
913 iter != atoms.end(); ++iter) {
914 const Vector &pos = (*iter)->getPosition();
915 for (size_t i=0;i<3;++i) position[i] = pos[i];
916 positions.push_back(position);
917 charges.push_back((double)((*iter)->getElement().getAtomicNumber()));
918 }
919 const JobId_t next_id = controller.getAvailableId();
920 LOG(1, "INFO: Creating full VMGJob with " << full_sampled_grid.sampled_grid.size()
921 << " gridpoints and " << charges.size() << " particle charges.");
922 FragmentJob::ptr testJob(
923 new VMGJob(next_id, full_sampled_grid, positions, charges) );
924 jobs.push_back(testJob);
925 }
926
927 // then send jobs to controller
928 controller.addJobs(jobs);
929 controller.sendJobs(params.host.get(), params.port.get());
930 return true;
931}
932#endif
933
934void WaitforResults(
935 boost::asio::io_service &io_service,
936 FragmentController &controller,
937 const FragmentationFragmentationAutomationAction::FragmentationFragmentationAutomationParameters &params,
938 const size_t NoExpectedResults
939 )
940{
941 size_t NoCalculatedResults = 0;
942 while (NoCalculatedResults != NoExpectedResults) {
943 // wait a bit
944 boost::asio::deadline_timer timer(io_service);
945 timer.expires_from_now(boost::posix_time::milliseconds(500));
946 timer.wait();
947 // then request status
948 controller.checkResults(params.host.get(), params.port.get());
949 RunService(io_service, "Checking on results");
950
951 const std::pair<size_t, size_t> JobStatus = controller.getJobStatus();
952 LOG(1, "INFO: #" << JobStatus.first << " are waiting in the queue and #" << JobStatus.second << " jobs are calculated so far.");
953 NoCalculatedResults = JobStatus.second;
954 }
955}
956
957
958Action::state_ptr FragmentationFragmentationAutomationAction::performCall() {
959 boost::asio::io_service io_service;
960 FragmentController controller(io_service);
961
962 // TODO: Have io_service run in second thread and merge with current again eventually
963
964 // Phase One: obtain ids
965 std::vector< boost::filesystem::path > jobfiles = params.jobfiles.get();
966 requestIds(controller, params, jobfiles.size());
967 RunService(io_service, "Requesting ids");
968
969 // Phase Two: create and add MPQCJobs
970 if (!createJobsFromFiles(controller, params, jobfiles))
971 return Action::failure;
972 RunService(io_service, "Adding MPQCJobs");
973
974 // Phase Three: calculate result
975 WaitforResults(io_service, controller, params, jobfiles.size());
976 controller.receiveResults(params.host.get(), params.port.get());
977 RunService(io_service, "Requesting short-range results");
978 std::vector<FragmentResult::ptr> MPQCresults = controller.getReceivedResults();
979 std::vector<MPQCData> fragmentData;
980 ConvertFragmentResultTo<MPQCData>(MPQCresults, fragmentData);
981
982#ifdef HAVE_VMG
983 if (params.DoLongrange.get()) {
984 ASSERT( World::getInstance().getAllAtoms().size() != 0,
985 "FragmentationFragmentationAutomationAction::performCall() - please load the full molecule into the World before.");
986
987 // obtain combined charge density
988 LOG(1, "INFO: Parsing fragment files from " << params.path.get() << ".");
989 SamplingGrid full_sample;
990 Fragment full_fragment;
991 sumUpChargeDensity(
992 MPQCresults,
993 fragmentData,
994 params.path.get(),
995 full_sample,
996 full_fragment);
997
998 // Phase Four: obtain more ids
999 requestIds(controller, params, fragmentData.size()+1);
1000 RunService(io_service, "Requesting ids");
1001
1002 // Phase Five: create VMGJobs
1003 if (!createLongRangeJobs(controller, params, fragmentData, full_sample, full_fragment))
1004 return Action::failure;
1005 RunService(io_service, "Adding VMGJobs");
1006
1007 // Phase Six: calculate result
1008 WaitforResults(io_service, controller, params, fragmentData.size()+1);
1009 controller.receiveResults(params.host.get(), params.port.get());
1010 RunService(io_service, "Requesting long-range results");
1011 std::vector<FragmentResult::ptr> VMGresults = controller.getReceivedResults();
1012 ASSERT( MPQCresults.size()+1 == VMGresults.size(),
1013 "FragmentationFragmentationAutomationAction::performCall() - number of MPQCresultd and VMGresults don't match.");
1014
1015 std::vector<VMGData> longrangeData;
1016 ConvertFragmentResultTo<VMGData>(VMGresults, longrangeData);
1017
1018 // Final phase: print result
1019 {
1020 LOG(1, "INFO: Parsing fragment files from " << params.path.get() << ".");
1021 printReceivedFullResults(
1022 MPQCresults,
1023 VMGresults,
1024 fragmentData,
1025 longrangeData,
1026 params.path.get(),
1027 getNoAtomsFromAdjacencyFile(params.path.get()),
1028 full_sample);
1029 }
1030 }
1031#else
1032 // Final phase: print result
1033 {
1034 LOG(1, "INFO: Parsing fragment files from " << params.path.get() << ".");
1035 printReceivedMPQCResults(
1036 MPQCresults,
1037 fragmentData,
1038 params.path.get(),
1039 getNoAtomsFromAdjacencyFile(params.path.get()),
1040 full_sample);
1041 }
1042#endif
1043 size_t Exitflag = controller.getExitflag();
1044
1045 return (Exitflag == 0) ? Action::success : Action::failure;
1046}
1047
1048Action::state_ptr FragmentationFragmentationAutomationAction::performUndo(Action::state_ptr _state) {
1049 return Action::success;
1050}
1051
1052Action::state_ptr FragmentationFragmentationAutomationAction::performRedo(Action::state_ptr _state){
1053 return Action::success;
1054}
1055
1056bool FragmentationFragmentationAutomationAction::canUndo() {
1057 return false;
1058}
1059
1060bool FragmentationFragmentationAutomationAction::shouldUndo() {
1061 return false;
1062}
1063/** =========== end of function ====================== */
Note: See TracBrowser for help on using the repository browser.