Ignore:
Timestamp:
Jul 8, 2013, 2:22:02 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, Candidate_v1.7.0, 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:
1e565c
Parents:
cf4905
git-author:
Frederik Heber <heber@…> (05/09/13 13:21:58)
git-committer:
Frederik Heber <heber@…> (07/08/13 14:22:02)
Message:

CompoundPotential now combines ConstantPotential and PairPotential_Morse successfully.

  • we set PairPotential_Morse::energy_offset to 0 as default value, but we need to remove the offsets fully from all potentials.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Potentials/CompoundPotential.cpp

    rcf4905 r7e5b94  
    7676    Extractors::elementcounts_t counts_per_charge =
    7777        Extractors::_detail::getElementCounts(charges);
    78     ASSERT( !counts_per_charge.empty(),
    79         "getFirstGraphwithSpecifiedElements() - charge counts are empty?");
     78//    ASSERT( !counts_per_charge.empty(),
     79//        "getFirstGraphwithSpecifiedElements() - charge counts are empty?");
    8080    LOG(2, "DEBUG: counts_per_charge is " << counts_per_charge << ".");
    8181
     
    120120      if (dim < model_dim) {
    121121        std::copy(iter, iter+dim, std::back_inserter(subparams));
     122        iter += dim;
    122123        dim = 0;
    123124      } else {
    124125        std::copy(iter, iter+model_dim, std::back_inserter(subparams));
     126        iter += model_dim;
    125127        dim -= model_dim;
    126128      }
     
    166168}
    167169
     170std::vector<CompoundPotential::arguments_t> CompoundPotential::splitUpArgumentsByModels(
     171    const arguments_t &arguments) const
     172{
     173  std::vector<arguments_t> partial_args(models.size());
     174  std::vector<arguments_t>::iterator partialiter = partial_args.begin();
     175  arguments_t::const_iterator argiter = arguments.begin();
     176  BOOST_FOREACH( const SerializablePotential::ParticleTypes_t &types, particletypes_per_model) {
     177    // we always expect N(N-1)/2 distances for N particle types
     178    arguments_t::const_iterator enditer = argiter+(types.size()*(types.size()-1)/2);
     179    ASSERT( argiter != arguments.end(),
     180        "CompoundPotential::splitUpArgumentsByModels() - incorrect number of arguments.");
     181    std::copy(argiter, enditer, std::back_inserter(*partialiter++));
     182    argiter = enditer;
     183  }
     184  ASSERT( argiter == arguments.end(),
     185      "CompoundPotential::splitUpArgumentsByModels() - incorrect number of arguments.");
     186  return partial_args;
     187}
     188
    168189CompoundPotential::results_t CompoundPotential::operator()(const arguments_t &arguments) const
    169190{
     191  // first, we have to split up the given arguments
     192  std::vector<arguments_t> partial_args =
     193      splitUpArgumentsByModels(arguments);
     194  // then, with each bunch of arguments, we call the specific model
    170195  results_t results(1,0.);
    171196  std::vector<results_t> partial_results(models.size());
    172   std::transform(models.begin(), models.end(), partial_results.begin(),
    173           boost::bind(&FunctionModel::operator(), _1, boost::cref(arguments))
     197  std::transform(
     198      models.begin(), models.end(),
     199      partial_args.begin(),
     200      partial_results.begin(),
     201      boost::bind(&FunctionModel::operator(), _1, _2)
    174202  );
     203  std::for_each(partial_results.begin(), partial_results.end(),
     204      std::cout << (boost::lambda::_1)[0] << "\t");
    175205  std::for_each(partial_results.begin(), partial_results.end(),
    176206      results[0] += (boost::lambda::_1)[0]);
     
    180210CompoundPotential::results_t CompoundPotential::parameter_derivative(const arguments_t &arguments, const size_t index) const
    181211{
     212  // first, we have to split up the given arguments
     213  std::vector<arguments_t> partial_args =
     214      splitUpArgumentsByModels(arguments);
     215  // then, with each bunch of arguments, we call the specific model
    182216  // get parameter dimensions per model
    183217  std::vector<size_t> dimensions(models.size(), 0);
     
    191225  std::vector<size_t>::const_iterator iter =
    192226      std::lower_bound(dimensions.begin(), dimensions.end(), index);
     227
     228  // step forward to same model
    193229  models_t::const_iterator modeliter = models.begin();
    194 
    195   // step forward to same model
    196230  std::advance(modeliter,
     231      std::distance(const_cast<const std::vector<size_t> &>(dimensions).begin(), iter) );
     232  std::vector<arguments_t>::const_iterator argiter = partial_args.begin();
     233  std::advance(argiter,
    197234      std::distance(const_cast<const std::vector<size_t> &>(dimensions).begin(), iter) );
    198235
     
    200237  const size_t indexbase = (iter == dimensions.begin()) ? 0 : *(--iter);
    201238  CompoundPotential::results_t results =
    202       (*modeliter)->parameter_derivative(arguments, index-indexbase);
     239      (*modeliter)->parameter_derivative(*argiter, index-indexbase);
    203240  return results;
    204241}
     
    268305
    269306    returnfunction =
    270           boost::bind(&Extractors::combineArguments,
     307          boost::bind(&Extractors::concatenateArguments,
    271308              boost::bind(returnfunction, _1, _2),
    272309              boost::bind(&Extractors::gatherAllDistancesFromFragment,
Note: See TracChangeset for help on using the changeset viewer.