Ignore:
Timestamp:
Feb 27, 2013, 12:39:03 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:
d52819
Parents:
69fcba
git-author:
Frederik Heber <heber@…> (11/30/12 15:33:58)
git-committer:
Frederik Heber <heber@…> (02/27/13 12:39:03)
Message:

Extended FunctionModel by getFragmentSpecificExtractor() definition.

  • shifted extractor_t from TrainingData to FunctionModel.
  • implemented function for every specific potential.
  • this is preparatory for generalizing function approximation in LevMartester.
  • we make use of the newly introduced extractors in the potentials and the required number of charges is ASSERT'd.
Location:
src/Potentials/Specifics
Files:
11 edited

Legend:

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

    r69fcba r7b019a  
    4848#include "CodePatterns/Log.hpp"
    4949
     50#include "FunctionApproximation/Extractors.hpp"
    5051#include "Potentials/helpers.hpp"
    5152#include "Potentials/ParticleTypeCheckers.hpp"
     53
     54class Fragment;
    5255
    5356// static definitions
     
    680683}
    681684
     685FunctionModel::extractor_t
     686ManyBodyPotential_Tersoff::getFragmentSpecificExtractor(
     687    const charges_t &charges) const
     688{
     689  ASSERT(charges.size() <= (size_t)2,
     690      "ManyBodyPotential_Tersoff::getFragmentSpecificExtractor() - requires 1 charge.");
     691  FunctionModel::extractor_t returnfunction =
     692      boost::bind(&Extractors::gatherAllDistances,
     693          boost::bind(&Fragment::getPositions, _1),
     694          boost::bind(&Fragment::getCharges, _1),
     695          _2);
     696  return returnfunction;
     697}
     698
  • src/Potentials/Specifics/ManyBodyPotential_Tersoff.hpp

    r69fcba r7b019a  
    178178  }
    179179
     180  /** Returns a bound function to be used with TrainingData, extracting distances
     181   * from a Fragment.
     182   *
     183   * \param charges vector of charges to be extracted
     184   * \return bound function extracting distances from a fragment
     185   */
     186  FunctionModel::extractor_t getFragmentSpecificExtractor(const charges_t &charges) const;
     187
    180188private:
    181189  /** Prohibit private default constructor.
  • src/Potentials/Specifics/PairPotential_Angle.cpp

    r69fcba r7b019a  
    4040
    4141#include <boost/assign/list_of.hpp> // for 'map_list_of()'
     42#include <boost/bind.hpp>
    4243#include <string>
    4344
    4445#include "CodePatterns/Assert.hpp"
    4546
     47#include "FunctionApproximation/Extractors.hpp"
    4648#include "Potentials/helpers.hpp"
    4749#include "Potentials/ParticleTypeCheckers.hpp"
     50
     51class Fragment;
    4852
    4953// static definitions
     
    199203  }
    200204}
     205
     206FunctionModel::extractor_t
     207PairPotential_Angle::getFragmentSpecificExtractor(
     208    const charges_t &charges) const
     209{
     210  ASSERT(charges.size() == (size_t)3,
     211      "PairPotential_Angle::getFragmentSpecificExtractor() - requires 3 charges.");
     212  FunctionModel::extractor_t returnfunction =
     213      boost::bind(&Extractors::gatherDistancesFromFragment,
     214          boost::bind(&Fragment::getPositions, _1),
     215          boost::bind(&Fragment::getCharges, _1),
     216          boost::cref(charges),
     217          _2);
     218  return returnfunction;
     219}
     220
  • src/Potentials/Specifics/PairPotential_Angle.hpp

    r69fcba r7b019a  
    145145  }
    146146
     147  /** Returns a bound function to be used with TrainingData, extracting distances
     148   * from a Fragment.
     149   *
     150   * \param charges vector of charges to be extracted
     151   * \return bound function extracting distances from a fragment
     152   */
     153  FunctionModel::extractor_t getFragmentSpecificExtractor(const charges_t &charges) const;
     154
    147155  enum parameter_enum_t {
    148156    spring_constant=0,
  • src/Potentials/Specifics/PairPotential_Harmonic.cpp

    r69fcba r7b019a  
    4040
    4141#include <boost/assign/list_of.hpp> // for 'map_list_of()'
     42#include <boost/bind.hpp>
    4243#include <string>
    4344
    4445#include "CodePatterns/Assert.hpp"
    4546
     47#include "FunctionApproximation/Extractors.hpp"
    4648#include "Potentials/helpers.hpp"
    4749#include "Potentials/ParticleTypeCheckers.hpp"
     50
     51class Fragment;
    4852
    4953// static definitions
     
    176180}
    177181
     182FunctionModel::extractor_t
     183PairPotential_Harmonic::getFragmentSpecificExtractor(
     184    const charges_t &charges) const
     185{
     186  ASSERT(charges.size() == (size_t)2,
     187      "PairPotential_Harmonic::getFragmentSpecificExtractor() - requires 2 charges.");
     188  FunctionModel::extractor_t returnfunction =
     189      boost::bind(&Extractors::gatherDistancesFromFragment,
     190          boost::bind(&Fragment::getPositions, _1),
     191          boost::bind(&Fragment::getCharges, _1),
     192          boost::cref(charges),
     193          _2);
     194  return returnfunction;
     195}
     196
  • src/Potentials/Specifics/PairPotential_Harmonic.hpp

    r69fcba r7b019a  
    127127  }
    128128
     129  /** Returns a bound function to be used with TrainingData, extracting distances
     130   * from a Fragment.
     131   *
     132   * \param charges vector of charges to be extracted
     133   * \return bound function extracting distances from a fragment
     134   */
     135  FunctionModel::extractor_t getFragmentSpecificExtractor(const charges_t &charges) const;
     136
    129137  /** Return the token name of this specific potential.
    130138   *
  • src/Potentials/Specifics/PairPotential_Morse.cpp

    r69fcba r7b019a  
    4040
    4141#include <boost/assign/list_of.hpp> // for 'map_list_of()'
     42#include <boost/bind.hpp>
    4243#include <cmath>
    4344#include <string>
     
    4546#include "CodePatterns/Assert.hpp"
    4647
     48#include "FunctionApproximation/Extractors.hpp"
    4749#include "Potentials/helpers.hpp"
    4850#include "Potentials/ParticleTypeCheckers.hpp"
     51
     52class Fragment;
    4953
    5054// static definitions
     
    204208  return std::vector<result_t>(1, 0.);
    205209}
     210
     211FunctionModel::extractor_t
     212PairPotential_Morse::getFragmentSpecificExtractor(
     213    const charges_t &charges) const
     214{
     215  ASSERT(charges.size() == (size_t)2,
     216      "PairPotential_Morse::getFragmentSpecificExtractor() - requires 2 charges.");
     217  FunctionModel::extractor_t returnfunction =
     218      boost::bind(&Extractors::gatherDistancesFromFragment,
     219          boost::bind(&Fragment::getPositions, _1),
     220          boost::bind(&Fragment::getCharges, _1),
     221          boost::cref(charges),
     222          _2);
     223  return returnfunction;
     224}
     225
  • src/Potentials/Specifics/PairPotential_Morse.hpp

    r69fcba r7b019a  
    144144  }
    145145
     146  /** Returns a bound function to be used with TrainingData, extracting distances
     147   * from a Fragment.
     148   *
     149   * \param charges vector of charges to be extracted
     150   * \return bound function extracting distances from a fragment
     151   */
     152  FunctionModel::extractor_t getFragmentSpecificExtractor(const charges_t &charges) const;
     153
    146154  enum parameter_enum_t {
    147155    spring_constant=0,
  • src/Potentials/Specifics/SaturationPotential.cpp

    r69fcba r7b019a  
    4747#include "CodePatterns/Log.hpp"
    4848
     49#include "FunctionApproximation/Extractors.hpp"
    4950#include "Potentials/helpers.hpp"
    5051#include "Potentials/ParticleTypeCheckers.hpp"
     52
     53class Fragment;
    5154
    5255using namespace boost::assign;
     
    7578  triplefunction(_triplefunction),
    7679  saturation_cutoff(_saturation_cutoff)
    77 {}
     80{
     81  // have some decent defaults for parameter_derivative checking
     82  // Morse and Angle have their own defaults, offset is set
     83  ASSERT( _ParticleTypes.size() == (size_t)2,
     84      "SaturationPotential::SaturationPotential() - exactly two types must be given.");
     85  ASSERT( _ParticleTypes[1] == 1,
     86      "SaturationPotential::SaturationPotential() - second type must be hydrogen.");
     87}
    7888
    7989SaturationPotential::SaturationPotential(
     
    94104  saturation_cutoff(_saturation_cutoff)
    95105{
     106  ASSERT( _ParticleTypes.size() == (size_t)2,
     107      "SaturationPotential::SaturationPotential() - exactly two types must be given.");
     108  ASSERT( _ParticleTypes[1] == 1,
     109      "SaturationPotential::SaturationPotential() - second type must be hydrogen.");
    96110  parameters_t morse_params(morse.getParameterDimension());
    97111  morse_params[PairPotential_Morse::spring_constant] = _morse_spring_constant;
     
    303317  return ist;
    304318}
     319
     320FunctionModel::extractor_t
     321SaturationPotential::getFragmentSpecificExtractor(
     322    const charges_t &charges) const
     323{
     324  ASSERT(charges.size() == (size_t)2,
     325      "SaturationPotential::getFragmentSpecificExtractor() - requires 2 charges.");
     326  FunctionModel::extractor_t returnfunction;
     327  if (charges[0] == charges[1]) {
     328    // In case both types are equal there is only a single pair of possible
     329    // type combinations.
     330     returnfunction =
     331        boost::bind(&Extractors::gatherAllDistancesFromFragment,
     332            boost::bind(&Fragment::getPositions, _1),
     333            boost::bind(&Fragment::getCharges, _1),
     334            boost::cref(charges),
     335            _2);
     336  } else {
     337    // we have to chain here a rather complex "tree" of functions
     338    // as we only have a couple of ParticleTypes but need to get
     339    // all possible three pairs of the set of the two types.
     340    // Finally, we also need to arrange them in correct order
     341    // (for PairPotentiale_Angle).
     342    charges_t firstpair(2, boost::cref(charges[0]));
     343    charges_t secondpair(2, boost::cref(charges[1]));
     344    const charges_t &thirdpair = charges;
     345    returnfunction =
     346        boost::bind(&Extractors::reorderArgumentsByParticleTypes,
     347          boost::bind(&Extractors::combineArguments,
     348            boost::bind(&Extractors::combineArguments,
     349              boost::bind(&Extractors::gatherAllDistancesFromFragment,
     350                  boost::bind(&Fragment::getPositions, _1),
     351                  boost::bind(&Fragment::getCharges, _1),
     352                  firstpair,  // no crefs here as are temporaries!
     353                  _2),
     354              boost::bind(&Extractors::gatherAllDistancesFromFragment,
     355                  boost::bind(&Fragment::getPositions, _1),
     356                  boost::bind(&Fragment::getCharges, _1),
     357                  secondpair,  // no crefs here as are temporaries!
     358                  _2)
     359            ),
     360            boost::bind(&Extractors::gatherAllDistancesFromFragment,
     361                boost::bind(&Fragment::getPositions, _1),
     362                boost::bind(&Fragment::getCharges, _1),
     363                boost::cref(thirdpair), // only the last one is no temporary
     364                _2)
     365          ),
     366          boost::cref(angle.getParticleTypes())
     367        );
     368}
     369  return returnfunction;
     370}
  • src/Potentials/Specifics/SaturationPotential.hpp

    r69fcba r7b019a  
    156156  }
    157157
     158  /** Returns a bound function to be used with TrainingData, extracting distances
     159   * from a Fragment.
     160   *
     161   * \param charges vector of charges to be extracted
     162   * \return bound function extracting distances from a fragment
     163   */
     164  FunctionModel::extractor_t getFragmentSpecificExtractor(const charges_t &charges) const;
     165
    158166  enum parameter_enum_t {
    159167    all_energy_offset,
  • src/Potentials/Specifics/unittests/Makefile.am

    r69fcba r7b019a  
    2626POTENTIALSSPECIFICSLIBS = \
    2727        ../libMolecuilderPotentials.la \
     28        ../libMolecuilderFragmentationSetValues.la \
     29        ../libMolecuilderFunctionApproximation.la \
    2830        $(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la \
    2931        ${CodePatterns_LIBS} \
    30   $(BOOST_SERIALIZATION_LDFLAGS) $(BOOST_SERIALIZATION_LIBS) \
     32        $(BOOST_SERIALIZATION_LDFLAGS) $(BOOST_SERIALIZATION_LIBS) \
    3133        $(BOOST_LIB)
    3234
Note: See TracChangeset for help on using the changeset viewer.