Ignore:
Timestamp:
Jun 27, 2014, 9:32:55 PM (11 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:
550f2a
Parents:
16227a
git-author:
Frederik Heber <heber@…> (02/27/14 20:15:41)
git-committer:
Frederik Heber <heber@…> (06/27/14 21:32:55)
Message:

FunctionModel now uses list_of_arguments to split sequence of subsets of distances.

  • this fixes ambiguities with the set of distances: Imagine the distances within a water molecule as OH (A) and HH (B). We then may have a sequence of argument_t as AABAAB. And with the current implementation of CompoundPotential::splitUpArgumentsByModels() we would always choose the latter (and more complex) model. Hence, we make two calls to TriplePotential_Angle, instead of calls twice to PairPotential_Harmonic for A, one to PairPotential_Harmonic for B, and once to TriplePotential_Angle for AAB.
  • now, we new list looks like A,A,B,AAB where each tuple of distances can be uniquely associated with a specific potential.
  • changed signatures of EmpiricalPotential::operator(), ::derivative(), ::parameter_derivative(). This involved changing all of the current specific potentials and CompoundPotential.
  • TrainingData must discern between the InputVector_t (just all distances) and the FilteredInputVector_t (tuples of subsets of distances).
  • FunctionApproximation now has list_of_arguments_t as parameter to evaluate() and evaluate_derivative().
  • DOCU: docu change in TrainingData.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Potentials/Specifics/PairPotential_Morse.cpp

    r16227a re1fe7e  
    124124PairPotential_Morse::results_t
    125125PairPotential_Morse::operator()(
    126     const arguments_t &arguments
     126    const list_of_arguments_t &listarguments
    127127    ) const
    128128{
    129   ASSERT( arguments.size() == 1,
    130       "PairPotential_Morse::operator() - requires exactly one argument.");
    131   ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes(
    132       arguments, getParticleTypes()),
    133       "PairPotential_Morse::operator() - types don't match with ones in arguments.");
    134   const argument_t &r_ij = arguments[0];
    135   // Maple: f(r,D,k,R,c) := D * (1 - exp(-k*(r-R)))^(2)+c
    136   const result_t result =
    137       params[dissociation_energy] * Helpers::pow( 1.
    138           - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])),2);
     129  result_t result = 0.;
     130  for(list_of_arguments_t::const_iterator iter = listarguments.begin();
     131      iter != listarguments.end(); ++iter) {
     132    const arguments_t &arguments = *iter;
     133    ASSERT( arguments.size() == 1,
     134        "PairPotential_Morse::operator() - requires exactly one argument.");
     135    ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes(
     136        arguments, getParticleTypes()),
     137        "PairPotential_Morse::operator() - types don't match with ones in arguments.");
     138    const argument_t &r_ij = arguments[0];
     139    // Maple: f(r,D,k,R,c) := D * (1 - exp(-k*(r-R)))^(2)+c
     140    result +=
     141        params[dissociation_energy] * Helpers::pow( 1.
     142            - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])),2);
     143  }
    139144  return std::vector<result_t>(1, result);
    140145}
     
    142147PairPotential_Morse::derivative_components_t
    143148PairPotential_Morse::derivative(
    144     const arguments_t &arguments
     149    const list_of_arguments_t &listarguments
    145150    ) const
    146151{
    147   ASSERT( arguments.size() == 1,
    148       "PairPotential_Morse::operator() - requires exactly one argument.");
    149   ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes(
    150       arguments, getParticleTypes()),
    151       "PairPotential_Morse::operator() - types don't match with ones in arguments.");
    152   derivative_components_t result;
    153   const argument_t &r_ij = arguments[0];
    154   // Maple result: 2*D*(1-exp(-k*(r-R)))*k*exp(-k*(r-R))
    155   result.push_back(
    156       2. * params[dissociation_energy]
    157       * ( 1. - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])))
    158       * (- params[spring_constant]) * exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance]))
    159   );
    160   ASSERT( result.size() == 1,
    161       "PairPotential_Morse::operator() - we did not create exactly one component.");
    162   return result;
     152  result_t result = 0.;
     153  for(list_of_arguments_t::const_iterator iter = listarguments.begin();
     154      iter != listarguments.end(); ++iter) {
     155    const arguments_t &arguments = *iter;
     156    ASSERT( arguments.size() == 1,
     157        "PairPotential_Morse::operator() - requires exactly one argument.");
     158    ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes(
     159        arguments, getParticleTypes()),
     160        "PairPotential_Morse::operator() - types don't match with ones in arguments.");
     161    const argument_t &r_ij = arguments[0];
     162    // Maple result: 2*D*(1-exp(-k*(r-R)))*k*exp(-k*(r-R))
     163    result +=
     164        2. * params[dissociation_energy]
     165        * ( 1. - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])))
     166        * (- params[spring_constant]) * exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance]));
     167  }
     168  return derivative_components_t(1, result);
    163169}
    164170
    165171PairPotential_Morse::results_t
    166172PairPotential_Morse::parameter_derivative(
    167     const arguments_t &arguments,
     173    const list_of_arguments_t &listarguments,
    168174    const size_t index
    169175    ) const
    170176{
    171   ASSERT( arguments.size() == 1,
    172       "PairPotential_Morse::parameter_derivative() - requires exactly one argument.");
    173   ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes(
    174       arguments, getParticleTypes()),
    175       "PairPotential_Morse::operator() - types don't match with ones in arguments.");
    176   const argument_t &r_ij = arguments[0];
    177   switch (index) {
    178     case spring_constant:
    179     {
    180       // Maple result: -2*D*(1-exp(-k*(r-R)))*(-r+R)*exp(-k*(r-R))
    181       const result_t result =
    182           - 2. * params[dissociation_energy]
    183           * ( 1. - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])))
    184           * (- r_ij.distance + params[equilibrium_distance])
    185           * exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance]))
    186           ;
    187       return std::vector<result_t>(1, result);
    188       break;
     177  result_t result = 0.;
     178  for(list_of_arguments_t::const_iterator iter = listarguments.begin();
     179      iter != listarguments.end(); ++iter) {
     180    const arguments_t &arguments = *iter;
     181    ASSERT( arguments.size() == 1,
     182        "PairPotential_Morse::parameter_derivative() - requires exactly one argument.");
     183    ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes(
     184        arguments, getParticleTypes()),
     185        "PairPotential_Morse::operator() - types don't match with ones in arguments.");
     186    const argument_t &r_ij = arguments[0];
     187    switch (index) {
     188      case spring_constant:
     189      {
     190        // Maple result: -2*D*(1-exp(-k*(r-R)))*(-r+R)*exp(-k*(r-R))
     191        result +=
     192            - 2. * params[dissociation_energy]
     193            * ( 1. - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])))
     194            * (- r_ij.distance + params[equilibrium_distance])
     195            * exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance]))
     196            ;
     197        break;
     198      }
     199      case equilibrium_distance:
     200      {
     201        // Maple result: -2*D*(1-exp(-k*(r-R)))*k*exp(-k*(r-R))
     202        result +=
     203            - 2. * params[dissociation_energy]
     204            * ( 1. - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])))
     205            * params[spring_constant] * exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance]))
     206            ;
     207        break;
     208      }
     209      case dissociation_energy:
     210      {
     211        // Maple result: (1-exp(-k*(r-R)))^2
     212        result +=
     213            Helpers::pow(1.
     214                - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])),2);
     215        break;
     216      }
     217      default:
     218        ASSERT(0, "PairPotential_Morse::parameter_derivative() - derivative to unknown parameter desired.");
     219        break;
    189220    }
    190     case equilibrium_distance:
    191     {
    192       // Maple result: -2*D*(1-exp(-k*(r-R)))*k*exp(-k*(r-R))
    193       const result_t result =
    194           - 2. * params[dissociation_energy]
    195           * ( 1. - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])))
    196           * params[spring_constant] * exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance]))
    197           ;
    198       return std::vector<result_t>(1, result);
    199       break;
    200     }
    201     case dissociation_energy:
    202     {
    203       // Maple result: (1-exp(-k*(r-R)))^2
    204       const result_t result =
    205           Helpers::pow(1.
    206               - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])),2);
    207       return std::vector<result_t>(1, result);
    208       break;
    209     }
    210     default:
    211       ASSERT(0, "PairPotential_Morse::parameter_derivative() - derivative to unknown parameter desired.");
    212       break;
    213221  }
    214   return std::vector<result_t>(1, 0.);
     222  return results_t(1, result);
    215223}
    216224
Note: See TracChangeset for help on using the changeset viewer.