Ignore:
Timestamp:
Nov 10, 2012, 3:57:58 PM (12 years ago)
Author:
Frederik Heber <heber@…>
Branches:
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
Children:
8cae4c
Parents:
b420a5
git-author:
Frederik Heber <heber@…> (07/28/12 09:06:15)
git-committer:
Frederik Heber <heber@…> (11/10/12 15:57:58)
Message:

Added general-purpose Summator that is basis for OrthogonalSummation on an arbitrary struct of types.

  • Eventually, we need to sum up each variable in struct MPQCData. For this we need to place the initialisation and executing of OrthogonalSummation into a list and we need to enumerate the types in MPQCData in a unique fashion, i.e. to associate the name of the member variable and its type with a specific unique key. This is achieved via boost::fusion.
  • this is exemplarily used for energy.total.
  • later we add boost::fusion for_each to let the summation automatically go through each type by its own.
  • note that summing up a single IndexSet's must be specially treated as the single set corresponds to the full set also.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/FragmentationAction/FragmentationAutomationAction.cpp

    rb420a5 r56df37  
    5555#include "Fragmentation/KeySet.hpp"
    5656#include "Fragmentation/KeySetsContainer.hpp"
    57 #include "Fragmentation/Summation/OrthogonalSummation.hpp"
    58 #include "Fragmentation/Summation/SetValue.hpp"
     57#include "Fragmentation/Summation/Summator.hpp"
    5958#include "Graph/DepthFirstSearchAnalysis.hpp"
    6059#include "Jobs/MPQCJob.hpp"
     
    277276  SubsetMap::ptr subsetmap(new SubsetMap(*container));
    278277
     278  // convert all MPQCData to MPQCDataMap_t
     279  std::vector<MPQCDataMap_t> MPQCData_fused;
     280  MPQCData_fused.reserve(fragmentData.size());
     281  for(std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
     282      dataiter != fragmentData.end(); ++dataiter) {
     283    MPQCDataMap_t instance;
     284    boost::fusion::at_key<MPQCDataFused::energy_total>(instance) = dataiter->energies.total;
     285//    boost::fusion::at_key<MPQCDataFused::energy_eigenvalues>(instance) = dataiter->energies.eigenvalues;
     286//    boost::fusion::at_key<MPQCDataFused::forces>(instance) = dataiter->forces;
     287//    boost::fusion::at_key<MPQCDataFused::times_walltime>(instance) = dataiter->times.walltime;
     288  }
     289
     290  // get a vector of a job ids
     291  std::vector<JobId_t> jobids(results.size(), JobId::IllegalJob);
     292//  std::transform(results.begin(), results.end(), jobids.begin(),
     293//      boost::bind(&FragmentResult::getId,
     294//          boost::bind(&FragmentResult::ptr::, _1)));
     295  std::vector<JobId_t>::iterator iditer = jobids.begin();
     296  for (std::vector<FragmentResult::ptr>::const_iterator resultiter = results.begin();
     297      resultiter != results.end(); ++resultiter) {
     298    *iditer = (*resultiter)->getId();
     299    ++iditer;
     300  }
     301
    279302  // associate each index set with its value (do not use the full set, that is also contained!)
    280303  const IndexSetContainer::Container_t &_container = container->getContainer();
    281   {
    282     OrthogonalSummation<double>::InputSets_t indices(_container.begin(), _container.end()-1);
    283     OrthogonalSummation<double>::InputValues_t values(_container.size()-1, 0.);
    284     std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
    285     std::vector<FragmentResult::ptr>::const_iterator resultiter = results.begin();
    286     for (; dataiter != fragmentData.end(); ++dataiter, ++resultiter) {
    287       const MPQCData &extractedData = *dataiter;
    288       values[ MatrixNrLookup[(*resultiter)->getId()] ] = extractedData.energies.total;
    289     }
    290 
    291     // create the summation functor and evaluate
    292     OrthogonalSummation<double> OS(indices, values, subsetmap);
    293     const double energyresult = OS();
    294     LOG(0, "STATUS: Resulting energy is " << energyresult << ".");
    295   }
    296   {
    297     OrthogonalSummation<Histogram>::InputSets_t indices(_container.begin(), _container.end()-1);
    298     OrthogonalSummation<Histogram>::InputValues_t values(_container.size()-1);
    299     std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
    300     std::vector<FragmentResult::ptr>::const_iterator resultiter = results.begin();
    301     for (; dataiter != fragmentData.end(); ++dataiter, ++resultiter) {
    302       const MPQCData &extractedData = *dataiter;
    303       values[ MatrixNrLookup[(*resultiter)->getId()] ] = Histogram(extractedData.energies.eigenvalues, 0., 0.1);
    304     }
    305 
    306     // create the summation functor and evaluate
    307     OrthogonalSummation<Histogram> OS(indices, values, subsetmap);
    308     const Histogram eigenvaluegram = OS();
    309     LOG(0, "STATUS: Resulting histogram is " << eigenvaluegram << ".");
    310   }
     304  Summator<MPQCDataMap_t, MPQCDataFused::energy_total> sum_energy_total(
     305      subsetmap,
     306      MPQCData_fused,
     307      jobids,
     308      _container,
     309      MatrixNrLookup
     310      );
     311  double energy_total = sum_energy_total();
     312  LOG(0, "STATUS: Resulting total energy is " << energy_total << ".");
     313
     314  //  Summator<MPQCDataMap_t, MPQCDataFused::energy_eigenvalues> sum_energy_eigenvalues(
     315//      subsetmap,
     316//      MPQCData_fused,
     317//      jobids,
     318//      _container,
     319//      MatrixNrLookup
     320//      );
     321
     322  // associate each index set with its value (do not use the full set, that is also contained!)
     323//  {
     324//    OrthogonalSummation<double>::InputSets_t indices(_container.begin(), _container.end()-1);
     325//    OrthogonalSummation<double>::InputValues_t values(_container.size()-1, 0.);
     326//    std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
     327//    std::vector<FragmentResult::ptr>::const_iterator resultiter = results.begin();
     328//    for (; dataiter != fragmentData.end(); ++dataiter, ++resultiter) {
     329//      const MPQCData &extractedData = *dataiter;
     330//      values[ MatrixNrLookup[(*resultiter)->getId()] ] = extractedData.energies.total;
     331//    }
     332//
     333//    // create the summation functor and evaluate
     334//    OrthogonalSummation<double> OS(indices, values, subsetmap);
     335//    const double energyresult = OS();
     336//    LOG(0, "STATUS: Resulting energy is " << energyresult << ".");
     337//  }
     338//  {
     339//    OrthogonalSummation<Histogram>::InputSets_t indices(_container.begin(), _container.end()-1);
     340//    OrthogonalSummation<Histogram>::InputValues_t values(_container.size()-1);
     341//    std::vector<MPQCData>::const_iterator dataiter = fragmentData.begin();
     342//    std::vector<FragmentResult::ptr>::const_iterator resultiter = results.begin();
     343//    for (; dataiter != fragmentData.end(); ++dataiter, ++resultiter) {
     344//      const MPQCData &extractedData = *dataiter;
     345//      values[ MatrixNrLookup[(*resultiter)->getId()] ] = Histogram(extractedData.energies.eigenvalues, 0., 0.1);
     346//    }
     347//
     348//    // create the summation functor and evaluate
     349//    OrthogonalSummation<Histogram> OS(indices, values, subsetmap);
     350//    const Histogram eigenvaluegram = OS();
     351//    LOG(0, "STATUS: Resulting histogram is " << eigenvaluegram << ".");
     352//  }
    311353
    312354  // combine all found data
Note: See TracChangeset for help on using the changeset viewer.