source: src/Fragmentation/Summation/Converter/DataConverter.hpp@ 336da8

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator 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_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 336da8 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
Line 
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
17#include <map>
18#include <boost/fusion/sequence.hpp>
19
20#include "CodePatterns/Assert.hpp"
21
22#ifdef HAVE_JOBMARKET
23#include "JobMarket/types.hpp"
24#else
25typedef size_t JobId_t;
26#endif
27
28#include "Fragmentation/KeySetsContainer.hpp"
29#include "Fragmentation/Summation/SetValues/Eigenvalues.hpp"
30#include "Fragmentation/Summation/SetValues/Histogram.hpp"
31#include "Fragmentation/Summation/SetValues/Fragment.hpp"
32#include "Fragmentation/Summation/SetValues/IndexedVectors.hpp"
33
34#include "Fragmentation/Summation/Containers/MPQCData.hpp"
35#include "Fragmentation/Summation/Containers/MPQCDataFused.hpp"
36#include "Fragmentation/Summation/Containers/MPQCDataMap.hpp"
37#ifdef HAVE_VMG
38#include "Fragmentation/Summation/Containers/VMGData.hpp"
39#include "Fragmentation/Summation/Containers/VMGDataFused.hpp"
40#include "Fragmentation/Summation/Containers/VMGDataMap.hpp"
41#endif
42
43template <typename source, typename dest>
44inline void convertDataTo(
45 const std::map<JobId_t, source> &fragmentData,
46 std::map<JobId_t, dest> &MPQCData_fused)
47{
48 MPQCData_fused.clear();
49}
50
51template <>
52inline void convertDataTo<MPQCData, MPQCDataEnergyMap_t>(
53 const std::map<JobId_t, MPQCData> &fragmentData,
54 std::map<JobId_t, MPQCDataEnergyMap_t> &MPQCData_Energy_fused)
55{
56 // energy_t
57 MPQCData_Energy_fused.clear();
58 for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
59 dataiter != fragmentData.end(); ++dataiter) {
60 const MPQCData &extractedData = dataiter->second;
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;
72 boost::fusion::at_key<MPQCDataFused::energy_eigenhistogram>(instance) = extractedData.energies.eigenvalues;
73 MPQCData_Energy_fused.insert( std::make_pair(dataiter->first, instance) );
74 }
75}
76
77#ifdef HAVE_VMG
78template <>
79inline void convertDataTo<VMGData, VMGDataMap_t>(
80 const std::map<JobId_t, VMGData> &longrangeData,
81 std::map<JobId_t, VMGDataMap_t> &VMGData_fused)
82{
83 // energy_t
84 VMGData_fused.clear();
85 for(std::map<JobId_t, VMGData>::const_iterator dataiter = longrangeData.begin();
86 dataiter != longrangeData.end(); ++dataiter) {
87 const VMGData &extractedData = dataiter->second;
88 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
89 VMGDataMap_t instance;
90 boost::fusion::at_key<VMGDataFused::nuclei_long>(instance) = extractedData.nuclei_long;
91 boost::fusion::at_key<VMGDataFused::electron_long>(instance) = extractedData.electron_long;
92 VMGData_fused.insert( std::make_pair(dataiter->first, instance) );
93 }
94}
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}
113#endif
114
115template <class datatype, class dataforcemap, class dataforcefused>
116inline void convertDatatoForceMap(
117 const std::map<JobId_t, datatype> &fragmentData,
118 const KeySetsContainer &ForceKeySet,
119 std::map<JobId_t, dataforcemap> &Data_Force_fused)
120{
121 // forces
122 ASSERT( ForceKeySet.KeySets.size() == fragmentData.size(),
123 "FragmentationAutomationAction::performCall() - indices and fragmentData differ in size.");
124 Data_Force_fused.clear();
125 typename std::map<JobId_t, datatype>::const_iterator dataiter = fragmentData.begin();
126 KeySetsContainer::ArrayOfIntVectors::const_iterator arrayiter = ForceKeySet.KeySets.begin();
127 for(;dataiter != fragmentData.end(); ++dataiter, ++arrayiter) {
128 const datatype &extractedData = dataiter->second;
129 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
130 dataforcemap instance;
131 // must convert int to index_t
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 }
140 IndexedVectors::indices_t indices(arrayiter->begin(), arrayiter->end());
141 boost::fusion::at_key<typename dataforcefused::forces>(instance) =
142 IndexedVectors(indices, extractedData.forces);
143 Data_Force_fused.insert( std::make_pair(dataiter->first, instance) );
144 }
145}
146
147template <>
148inline void convertDataTo<MPQCData, MPQCDataGridMap_t>(
149 const std::map<JobId_t, MPQCData> &fragmentData,
150 std::map<JobId_t, MPQCDataGridMap_t> &MPQCData_Grid_fused)
151{
152 // sampled_grid
153 MPQCData_Grid_fused.clear();
154 for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
155 dataiter != fragmentData.end(); ++dataiter) {
156 const MPQCData &extractedData = dataiter->second;
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;
160 MPQCData_Grid_fused.insert( std::make_pair(dataiter->first, instance) );
161 }
162}
163
164template <>
165inline void convertDataTo<MPQCData, MPQCDataFragmentMap_t>(
166 const std::map<JobId_t, MPQCData> &fragmentData,
167 std::map<JobId_t, MPQCDataFragmentMap_t> &MPQCData_Fragment_fused)
168{
169 // fragment
170 MPQCData_Fragment_fused.clear();
171 for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
172 dataiter != fragmentData.end(); ++dataiter) {
173 const MPQCData &extractedData = dataiter->second;
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);
178 MPQCData_Fragment_fused.insert( std::make_pair(dataiter->first, instance) );
179 }
180}
181
182template <>
183inline void convertDataTo<MPQCData, MPQCDataTimeMap_t>(
184 const std::map<JobId_t, MPQCData> &fragmentData,
185 std::map<JobId_t, MPQCDataTimeMap_t> &MPQCData_Time_fused)
186{
187 // times
188 MPQCData_Time_fused.clear();
189 for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
190 dataiter != fragmentData.end(); ++dataiter) {
191 const MPQCData &extractedData = dataiter->second;
192 LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
193 MPQCDataTimeMap_t instance;
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;
200 MPQCData_Time_fused.insert( std::make_pair(dataiter->first, instance) );
201 }
202}
203
204
205#endif /* DATACONVERTER_HPP_ */
Note: See TracBrowser for help on using the repository browser.