Changeset 94db13


Ignore:
Timestamp:
Oct 13, 2015, 8:12:54 PM (9 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:
20bb3b
Parents:
83a425
git-author:
Frederik Heber <heber@…> (10/25/14 21:56:32)
git-committer:
Frederik Heber <heber@…> (10/13/15 20:12:54)
Message:

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.
Location:
src
Files:
13 edited

Legend:

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

    r83a425 r94db13  
    251251    filename += FRAGMENTPREFIX + std::string("_VMGEnergy.dat");
    252252    writeToFile(filename, gridresult);
     253  }
     254
     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);
    253263  }
    254264
  • src/Actions/FragmentationAction/FragmentationAutomationAction.cpp

    r83a425 r94db13  
    316316        destiter->second.both_sampled_potential = srciter->second.sampled_potential;
    317317        destiter->second.nuclei_long = srciter->second.nuclei_long;
    318         destiter->second.particle_forces = srciter->second.particle_forces;
     318        destiter->second.forces = srciter->second.forces;
     319        destiter->second.hasForces = srciter->second.hasForces;
    319320      }
    320321    }
  • src/Fragmentation/Summation/Containers/FragmentationLongRangeResults.cpp

    r83a425 r94db13  
    6565    const KeySetsContainer& _ForceKeySet) :
    6666    KeySet(_KeySet),
    67     ForceKeySet(_ForceKeySet)
     67    ForceKeySet(_ForceKeySet),
     68    hasForces((!longrangeData.empty()) && (longrangeData.begin()->second.hasForces))
    6869{
    6970  initLookups(fragmentData, longrangeData);
     
    125126        longrangeData, VMGMatrixNrLookup, container, subsetmap,
    126127        Result_LongRange_fused, Result_perIndexSet_LongRange);
     128
     129    if (hasLongRangeForces()) {
     130      // force has extra data converter (this is similar to MPQCData's forces
     131      std::map<JobId_t, VMGDataForceMap_t> VMGData_Force_fused;
     132      convertDatatoForceMap<VMGData, VMGDataForceMap_t, VMGDataFused>(
     133          longrangeData, ForceKeySet, VMGData_Force_fused);
     134      Result_ForceLongRange_fused.resize(MaxLevel); // we need the results of correct size already
     135      AllLevelOrthogonalSummator<VMGDataForceMap_t> forceSummer(
     136                  subsetmap,
     137                  VMGData_Force_fused,
     138                  container->getContainer(),
     139                  VMGMatrixNrLookup,
     140                  Result_ForceLongRange_fused,
     141                  Result_perIndexSet_LongRange_Force);
     142      boost::mpl::for_each<VMGDataForceVector_t>(boost::ref(forceSummer));
     143    }
    127144
    128145    // then sum up
  • src/Fragmentation/Summation/Containers/FragmentationLongRangeResults.hpp

    r83a425 r94db13  
    8787  }
    8888
     89  const bool hasLongRangeForces() const
     90  { return hasForces; }
     91
    8992private:
    9093  void initLookups(
     
    100103  IndexSetContainer::ptr container;
    101104  SubsetMap::ptr subsetmap;
     105  //!> indicates whether the longrange results contain VMG forces data or not
     106  bool hasForces;
    102107
    103108public:
    104109  //!> results per level of summed up sampled grid charge
    105110  std::vector<MPQCDataGridMap_t> Result_Grid_fused;
    106   //!> results per level of summed up long range energy and forces
     111  //!> results per level of summed up long range energies
    107112  std::vector<VMGDataMap_t> Result_LongRange_fused;
     113  //!> results per level of summed up long range forces
     114  std::vector<VMGDataForceMap_t> Result_ForceLongRange_fused;
    108115  //!> results per level of summed up long range potential grids
    109116  std::vector<VMGDataGridMap_t> Result_GridLongRange_fused;
     
    113120  //!> results per IndexSet of summed up sampled grid charge
    114121  std::map<IndexSet::ptr, std::pair<MPQCDataGridMap_t,MPQCDataGridMap_t> > Result_perIndexSet_Grid;
    115   //!> results per IndexSet of summed up long range energy and forces
     122  //!> results per IndexSet of summed up long range energies
    116123  std::map<IndexSet::ptr, std::pair<VMGDataMap_t, VMGDataMap_t> > Result_perIndexSet_LongRange;
     124  //!> results per IndexSet of summed up long range forces
     125  std::map<IndexSet::ptr, std::pair<VMGDataForceMap_t, VMGDataForceMap_t> > Result_perIndexSet_LongRange_Force;
    117126  //!> results per IndexSet of summed up long range potential grids
    118127  std::map<IndexSet::ptr, std::pair<VMGDataGridMap_t, VMGDataGridMap_t> > Result_perIndexSet_LongRange_Grid;
  • src/Fragmentation/Summation/Containers/FragmentationShortRangeResults.cpp

    r83a425 r94db13  
    109109    // force has extra data converter
    110110    std::map<JobId_t, MPQCDataForceMap_t> MPQCData_Force_fused;
    111     convertMPQCDatatoForceMap(fragmentData, ForceKeySet, MPQCData_Force_fused);
     111    convertDatatoForceMap<MPQCData, MPQCDataForceMap_t, MPQCDataFused>(fragmentData, ForceKeySet, MPQCData_Force_fused);
    112112    Result_Force_fused.resize(MaxLevel); // we need the results of correct size already
    113113    AllLevelOrthogonalSummator<MPQCDataForceMap_t> forceSummer(
  • src/Fragmentation/Summation/Containers/MPQCDataFused.hpp

    r83a425 r94db13  
    2222 * instance when going throughb the list with boost::mpl::for_each.
    2323 */
    24 namespace MPQCDataFused {
     24struct MPQCDataFused {
    2525  // keys for energy_t
    2626  struct energy_total {};
     
    5151  struct times_gather_cputime {};
    5252  struct times_gather_flops {};
    53 }
     53};
    5454
    5555
  • src/Fragmentation/Summation/Containers/VMGData.cpp

    r83a425 r94db13  
    4444  sampled_potential(_props),
    4545  nuclei_long(0.),
    46   electron_long(0.)
     46  electron_long(0.),
     47  hasForces(false)
    4748{}
    4849
     
    5455  ost << "Nuclei long-Range energy: " << data.nuclei_long << std::endl;
    5556  ost << "Electron long-Range energy: " << data.electron_long << std::endl;
    56   ost << "Nuclei long-Range forces: " << data.particle_forces << std::endl;
     57  ost << "Nuclei long-Range forces: " << data.forces << std::endl;
    5758  return ost;
    5859}
  • src/Fragmentation/Summation/Containers/VMGData.hpp

    r83a425 r94db13  
    5050  double electron_long;
    5151  //!> force vectors of all nuclei
    52   FragmentForces particle_forces;
     52  FragmentForces forces;
     53
     54  //!> internal value to check when we should sum forces and when not
     55  bool hasForces;
    5356
    5457private:
     
    6467      ar & nuclei_long;
    6568    ar & electron_long;
    66     if (version > 2)
    67       ar & particle_forces;
     69    if (version > 2) {
     70      ar & forces;
     71      hasForces = true;
     72    } else
     73      hasForces = false;
    6874  }
    6975};
  • src/Fragmentation/Summation/Containers/VMGDataFused.hpp

    r83a425 r94db13  
    2323 * instance when going throughb the list with boost::mpl::for_each.
    2424 */
    25 namespace VMGDataFused {
     25struct VMGDataFused {
    2626  // keys for sampled_potential
    2727  struct sampled_potential {};
     
    3030  struct electron_long {};
    3131  // keys for forces
    32   struct particle_forces {};
     32  struct forces {};
    3333
    3434  // keys for longrange
     
    4242  struct total_shortrange {};
    4343
    44 }
     44};
    4545
    4646
  • src/Fragmentation/Summation/Containers/VMGDataMap.hpp

    r83a425 r94db13  
    3434typedef boost::fusion::map<
    3535    boost::fusion::pair<VMGDataFused::nuclei_long, double >,
    36     boost::fusion::pair<VMGDataFused::electron_long, double >,
    37     boost::fusion::pair<VMGDataFused::particle_forces, IndexedVectors >
     36    boost::fusion::pair<VMGDataFused::electron_long, double >
    3837> VMGDataMap_t;
    3938
    4039typedef boost::mpl::list<
    4140    VMGDataFused::nuclei_long,
    42     VMGDataFused::electron_long,
    43         VMGDataFused::particle_forces
     41    VMGDataFused::electron_long
    4442> VMGDataVector_t;
     43
     44/** This boost::fusion map defines key-value or rather key-type pairs with
     45 * which we associate all forces data members in VMGData and their type.
     46 *
     47 * This lets us resolves any ambiguitites of types in VMGData, e.g.
     48 * to know vector<double> is forces or energy_eigenvalues.
     49 *
     50 */
     51typedef boost::fusion::map<
     52    boost::fusion::pair<VMGDataFused::forces, IndexedVectors >
     53> VMGDataForceMap_t;
     54
     55typedef boost::mpl::list<
     56    VMGDataFused::forces
     57> VMGDataForceVector_t;
    4558
    4659typedef boost::fusion::map<
  • src/Fragmentation/Summation/Containers/VMGData_printKeyNames.hpp

    r83a425 r94db13  
    3838  (nuclei_long) \
    3939  (electron_long) \
    40   (particle_forces) \
     40  (forces) \
    4141  (electron_longrange) \
    4242  (electron_shortrange) \
  • src/Fragmentation/Summation/Converter/DataConverter.hpp

    r83a425 r94db13  
    113113#endif
    114114
    115 inline void convertMPQCDatatoForceMap(
    116     const std::map<JobId_t, MPQCData> &fragmentData,
     115template <class datatype, class dataforcemap, class dataforcefused>
     116inline void convertDatatoForceMap(
     117    const std::map<JobId_t, datatype> &fragmentData,
    117118    const KeySetsContainer &ForceKeySet,
    118     std::map<JobId_t, MPQCDataForceMap_t> &MPQCData_Force_fused)
     119    std::map<JobId_t, dataforcemap> &Data_Force_fused)
    119120{
    120121  // forces
    121122  ASSERT( ForceKeySet.KeySets.size() == fragmentData.size(),
    122123      "FragmentationAutomationAction::performCall() - indices and fragmentData differ in size.");
    123   MPQCData_Force_fused.clear();
    124   std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
     124  Data_Force_fused.clear();
     125  typename std::map<JobId_t, datatype>::const_iterator dataiter = fragmentData.begin();
    125126  KeySetsContainer::ArrayOfIntVectors::const_iterator arrayiter = ForceKeySet.KeySets.begin();
    126127  for(;dataiter != fragmentData.end(); ++dataiter, ++arrayiter) {
    127     const MPQCData &extractedData = dataiter->second;
    128     LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
    129     MPQCDataForceMap_t instance;
     128    const datatype &extractedData = dataiter->second;
     129    LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
     130    dataforcemap instance;
    130131    // must convert int to index_t
    131132    if (DoLog(5)) {
     
    138139    }
    139140    IndexedVectors::indices_t indices(arrayiter->begin(), arrayiter->end());
    140     boost::fusion::at_key<MPQCDataFused::forces>(instance) =
     141    boost::fusion::at_key<typename dataforcefused::forces>(instance) =
    141142        IndexedVectors(indices, extractedData.forces);
    142     MPQCData_Force_fused.insert( std::make_pair(dataiter->first, instance) );
     143    Data_Force_fused.insert( std::make_pair(dataiter->first, instance) );
    143144  }
    144145}
  • src/Jobs/InterfaceVMGJob.cpp

    r83a425 r94db13  
    355355  {
    356356    size_t index = 0;
    357     returndata.particle_forces.resize(
     357    returndata.forces.resize(
    358358        num_particles_local, FragmentForces::force_t(3, 0.) );
    359     for (FragmentForces::forces_t::iterator iter = returndata.particle_forces.begin();
    360         iter != returndata.particle_forces.end(); ++iter)
     359    for (FragmentForces::forces_t::iterator iter = returndata.forces.begin();
     360        iter != returndata.forces.end(); ++iter)
    361361      for (size_t i=0;i<3;++i)
    362362          (*iter)[i] = f[index++];
Note: See TracChangeset for help on using the changeset viewer.