source: src/Fragmentation/Summation/Converter/DataConverter.hpp@ 20bb3b

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 20bb3b was 94db13, checked in by Frederik Heber <heber@…>, 9 years ago

Again changes to obtain correct longrange forces, also forces are optional.

  • renamed particle_forces -> forces to make it consistent with MPQCData_Fused.
  • MPQCData_Fused and VMGData_Fused are structs and no longer namespace as the latter cannot serve as template arguments.
  • split off forces in VMGData into VMGDataForceMap_t and VMGDataForceVector_t.
  • changed ConvertMPQCDataToForceMap() into template function ConvertDataToForceMap(), working also on VMGDataForceMap_t.
  • this required changes in FragmentationShortRangeResults.
  • FragmentationLongRangeResults now also converts the longrange forces correctly.
  • AnalyseFragmentResults now prints also a ..VMGForces.dat file.
  • VMGData's forces are now optional to some degree and analysis chain can deal with it.
  • introducing forces we must still maintain working code when results without forces are calculated (e.g. as in the regression tests). Hence, a boolean im VMGData and FragmentationLongRangeResults states whether forces have been found or not and whether these should be summed up or not subsequently.
  • Property mode set to 100644
File size: 8.6 KB
RevLine 
[0398bd]1/*
2 * DataConverter.hpp
3 *
4 * Created on: Aug 27, 2012
5 * Author: heber
6 */
7
8#ifndef DATACONVERTER_HPP_
9#define DATACONVERTER_HPP_
10
11
12// include config.h
13#ifdef HAVE_CONFIG_H
14#include <config.h>
15#endif
16
[c9f9bb]17#include <map>
[0398bd]18#include <boost/fusion/sequence.hpp>
19
20#include "CodePatterns/Assert.hpp"
21
[8e84fe]22#ifdef HAVE_JOBMARKET
[0398bd]23#include "JobMarket/types.hpp"
[8e84fe]24#else
25typedef size_t JobId_t;
26#endif
[0398bd]27
28#include "Fragmentation/KeySetsContainer.hpp"
[5c867e]29#include "Fragmentation/Summation/SetValues/Eigenvalues.hpp"
[fbf143]30#include "Fragmentation/Summation/SetValues/Histogram.hpp"
31#include "Fragmentation/Summation/SetValues/Fragment.hpp"
32#include "Fragmentation/Summation/SetValues/IndexedVectors.hpp"
[0398bd]33
[fbf143]34#include "Fragmentation/Summation/Containers/MPQCData.hpp"
35#include "Fragmentation/Summation/Containers/MPQCDataFused.hpp"
36#include "Fragmentation/Summation/Containers/MPQCDataMap.hpp"
[0398bd]37#ifdef HAVE_VMG
[fbf143]38#include "Fragmentation/Summation/Containers/VMGData.hpp"
39#include "Fragmentation/Summation/Containers/VMGDataFused.hpp"
40#include "Fragmentation/Summation/Containers/VMGDataMap.hpp"
[0398bd]41#endif
42
43template <typename source, typename dest>
44inline void convertDataTo(
[c9f9bb]45 const std::map<JobId_t, source> &fragmentData,
46 std::map<JobId_t, dest> &MPQCData_fused)
[0398bd]47{
48 MPQCData_fused.clear();
49}
50
51template <>
52inline void convertDataTo<MPQCData, MPQCDataEnergyMap_t>(
[c9f9bb]53 const std::map<JobId_t, MPQCData> &fragmentData,
54 std::map<JobId_t, MPQCDataEnergyMap_t> &MPQCData_Energy_fused)
[0398bd]55{
56 // energy_t
57 MPQCData_Energy_fused.clear();
[c9f9bb]58 for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
[0398bd]59 dataiter != fragmentData.end(); ++dataiter) {
[c9f9bb]60 const MPQCData &extractedData = dataiter->second;
[0398bd]61 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
62 MPQCDataEnergyMap_t instance;
63 boost::fusion::at_key<MPQCDataFused::energy_total>(instance) = extractedData.energies.total;
64 boost::fusion::at_key<MPQCDataFused::energy_nuclear_repulsion>(instance) = extractedData.energies.nuclear_repulsion;
65 boost::fusion::at_key<MPQCDataFused::energy_electron_coulomb>(instance) = extractedData.energies.electron_coulomb;
66 boost::fusion::at_key<MPQCDataFused::energy_electron_exchange>(instance) = extractedData.energies.electron_exchange;
67 boost::fusion::at_key<MPQCDataFused::energy_correlation>(instance) = extractedData.energies.correlation;
68 boost::fusion::at_key<MPQCDataFused::energy_overlap>(instance) = extractedData.energies.overlap;
69 boost::fusion::at_key<MPQCDataFused::energy_kinetic>(instance) = extractedData.energies.kinetic;
70 boost::fusion::at_key<MPQCDataFused::energy_hcore>(instance) = extractedData.energies.hcore;
71 boost::fusion::at_key<MPQCDataFused::energy_eigenvalues>(instance) = extractedData.energies.eigenvalues;
[5c867e]72 boost::fusion::at_key<MPQCDataFused::energy_eigenhistogram>(instance) = extractedData.energies.eigenvalues;
[c9f9bb]73 MPQCData_Energy_fused.insert( std::make_pair(dataiter->first, instance) );
[0398bd]74 }
75}
76
77#ifdef HAVE_VMG
78template <>
79inline void convertDataTo<VMGData, VMGDataMap_t>(
[c9f9bb]80 const std::map<JobId_t, VMGData> &longrangeData,
81 std::map<JobId_t, VMGDataMap_t> &VMGData_fused)
[0398bd]82{
83 // energy_t
84 VMGData_fused.clear();
[c9f9bb]85 for(std::map<JobId_t, VMGData>::const_iterator dataiter = longrangeData.begin();
[0398bd]86 dataiter != longrangeData.end(); ++dataiter) {
[c9f9bb]87 const VMGData &extractedData = dataiter->second;
[0398bd]88 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
89 VMGDataMap_t instance;
[e2925fd]90 boost::fusion::at_key<VMGDataFused::nuclei_long>(instance) = extractedData.nuclei_long;
91 boost::fusion::at_key<VMGDataFused::electron_long>(instance) = extractedData.electron_long;
[c9f9bb]92 VMGData_fused.insert( std::make_pair(dataiter->first, instance) );
[0398bd]93 }
94}
[83a425]95
96template <>
97inline void convertDataTo<VMGData, VMGDataGridMap_t>(
98 const std::map<JobId_t, VMGData> &longrangeData,
99 std::map<JobId_t, VMGDataGridMap_t> &VMGData_fused)
100{
101 // energy_t
102 VMGData_fused.clear();
103 for(std::map<JobId_t, VMGData>::const_iterator dataiter = longrangeData.begin();
104 dataiter != longrangeData.end(); ++dataiter) {
105 const VMGData &extractedData = dataiter->second;
106 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
107 VMGDataGridMap_t instance;
108 boost::fusion::at_key<VMGDataFused::sampled_potential>(instance) = extractedData.sampled_potential;
109 boost::fusion::at_key<VMGDataFused::both_sampled_potential>(instance) = extractedData.both_sampled_potential;
110 VMGData_fused.insert( std::make_pair(dataiter->first, instance) );
111 }
112}
[0398bd]113#endif
114
[94db13]115template <class datatype, class dataforcemap, class dataforcefused>
116inline void convertDatatoForceMap(
117 const std::map<JobId_t, datatype> &fragmentData,
[0398bd]118 const KeySetsContainer &ForceKeySet,
[94db13]119 std::map<JobId_t, dataforcemap> &Data_Force_fused)
[0398bd]120{
121 // forces
122 ASSERT( ForceKeySet.KeySets.size() == fragmentData.size(),
123 "FragmentationAutomationAction::performCall() - indices and fragmentData differ in size.");
[94db13]124 Data_Force_fused.clear();
125 typename std::map<JobId_t, datatype>::const_iterator dataiter = fragmentData.begin();
[0398bd]126 KeySetsContainer::ArrayOfIntVectors::const_iterator arrayiter = ForceKeySet.KeySets.begin();
127 for(;dataiter != fragmentData.end(); ++dataiter, ++arrayiter) {
[94db13]128 const datatype &extractedData = dataiter->second;
[0398bd]129 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
[94db13]130 dataforcemap instance;
[0398bd]131 // must convert int to index_t
[98a293b]132 if (DoLog(5)) {
133 std::stringstream output;
134 for (KeySetsContainer::IntVector::const_iterator outiter = arrayiter->begin();
135 outiter != arrayiter->end(); ++outiter) {
136 output << *outiter << "\t";
137 }
138 LOG(5, "DEBUG: indices are " << output.str());
139 }
[0398bd]140 IndexedVectors::indices_t indices(arrayiter->begin(), arrayiter->end());
[94db13]141 boost::fusion::at_key<typename dataforcefused::forces>(instance) =
[0398bd]142 IndexedVectors(indices, extractedData.forces);
[94db13]143 Data_Force_fused.insert( std::make_pair(dataiter->first, instance) );
[0398bd]144 }
145}
146
147template <>
148inline void convertDataTo<MPQCData, MPQCDataGridMap_t>(
[c9f9bb]149 const std::map<JobId_t, MPQCData> &fragmentData,
150 std::map<JobId_t, MPQCDataGridMap_t> &MPQCData_Grid_fused)
[0398bd]151{
152 // sampled_grid
153 MPQCData_Grid_fused.clear();
[c9f9bb]154 for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
[0398bd]155 dataiter != fragmentData.end(); ++dataiter) {
[c9f9bb]156 const MPQCData &extractedData = dataiter->second;
[0398bd]157 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
158 MPQCDataGridMap_t instance;
159 boost::fusion::at_key<MPQCDataFused::sampled_grid>(instance) = extractedData.sampled_grid;
[c9f9bb]160 MPQCData_Grid_fused.insert( std::make_pair(dataiter->first, instance) );
[0398bd]161 }
162}
163
164template <>
165inline void convertDataTo<MPQCData, MPQCDataFragmentMap_t>(
[c9f9bb]166 const std::map<JobId_t, MPQCData> &fragmentData,
167 std::map<JobId_t, MPQCDataFragmentMap_t> &MPQCData_Fragment_fused)
[0398bd]168{
169 // fragment
170 MPQCData_Fragment_fused.clear();
[c9f9bb]171 for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
[0398bd]172 dataiter != fragmentData.end(); ++dataiter) {
[c9f9bb]173 const MPQCData &extractedData = dataiter->second;
[0398bd]174 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
175 MPQCDataFragmentMap_t instance;
176 boost::fusion::at_key<MPQCDataFused::fragment>(instance) =
177 Fragment(extractedData.positions, extractedData.charges);
[c9f9bb]178 MPQCData_Fragment_fused.insert( std::make_pair(dataiter->first, instance) );
[0398bd]179 }
180}
181
182template <>
183inline void convertDataTo<MPQCData, MPQCDataTimeMap_t>(
[c9f9bb]184 const std::map<JobId_t, MPQCData> &fragmentData,
185 std::map<JobId_t, MPQCDataTimeMap_t> &MPQCData_Time_fused)
[0398bd]186{
187 // times
188 MPQCData_Time_fused.clear();
[c9f9bb]189 for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
[0398bd]190 dataiter != fragmentData.end(); ++dataiter) {
[c9f9bb]191 const MPQCData &extractedData = dataiter->second;
[0398bd]192 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
193 MPQCDataTimeMap_t instance;
[4aee30]194 boost::fusion::at_key<MPQCDataFused::times_total_walltime>(instance) = extractedData.times.total_walltime;
195 boost::fusion::at_key<MPQCDataFused::times_total_cputime>(instance) = extractedData.times.total_cputime;
196 boost::fusion::at_key<MPQCDataFused::times_total_flops>(instance) = extractedData.times.total_flops;
197 boost::fusion::at_key<MPQCDataFused::times_gather_walltime>(instance) = extractedData.times.gather_walltime;
198 boost::fusion::at_key<MPQCDataFused::times_gather_cputime>(instance) = extractedData.times.gather_cputime;
199 boost::fusion::at_key<MPQCDataFused::times_gather_flops>(instance) = extractedData.times.gather_flops;
[c9f9bb]200 MPQCData_Time_fused.insert( std::make_pair(dataiter->first, instance) );
[0398bd]201 }
202}
203
204
205#endif /* DATACONVERTER_HPP_ */
Note: See TracBrowser for help on using the repository browser.