Changeset eb33c4


Ignore:
Timestamp:
Mar 2, 2011, 9:40:51 PM (14 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:
435065
Parents:
e355762
Message:

LinearInterpolationofTrajectoriesAction only interpolates, does not save.

  • This should make the action more versatile.
  • Saving generated paths can easily be done (and is done so for regression test) by a specific SaveSelected..Action.
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp

    re355762 reb33c4  
    4646  getParametersfromValueStorage();
    4747
    48   DoLog(1) && (Log() << Verbose(1) << "Linear interpolation between configuration " << params.start << " and " << params.end << "." << endl);
    49   if (params.IdMapping)
    50     DoLog(1) && (Log() << Verbose(1) << "Using Identity for the permutation map." << endl);
     48  LOG(0, "STATUS: Linear interpolation between configuration " << params.start << " and " << params.end << "." << endl);
    5149  ASSERT(params.end > params.start, "MoleculeLinearInterpolationofTrajectoriesAction() - start step greater than end step.");
    5250  AtomSetMixin<std::vector<atom*> > set(World::getInstance().getSelectedAtoms());
    53   LinearInterpolationBetweenSteps<std::vector<atom*> > LinearInterpolate(set,(unsigned int)(params.end-params.start));
    54   if (!LinearInterpolate(params.start, params.end, params.filename.branch_path().string(), params.IdMapping))
    55     DoLog(2) && (Log() << Verbose(2) << "Could not store " << params.filename << " files." << endl);
    56   else
    57     DoLog(2) && (Log() << Verbose(2) << "Steps created and " << params.filename << " files stored." << endl);
     51  LinearInterpolationBetweenSteps<std::vector<atom*> > LinearInterpolate(set,(unsigned int)(params.interpolation_steps));
     52  LinearInterpolate(params.start, params.end, params.IdMapping);
     53  LOG(0, "STATUS: done." << endl);
    5854
    5955  return Action::success;
  • src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.def

    re355762 reb33c4  
    1212// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    1313// "undefine" if no parameters are required, use (NODEFAULT) for each (undefined) default value
    14 #define paramtypes (boost::filesystem::path)(int)(int)(bool)
    15 #define paramtokens ("linear-interpolation-of-trajectories")("start-step")("end-step")("id-mapping")
    16 #define paramdescriptions ("path where to store the intermediate configurations")("first or start step")("last or end step")("whether the identity shall be used in mapping atoms onto atoms or not")
     14#define paramtypes (int)(int)(int)(bool)
     15#define paramtokens ("start-step")("interpolation-steps")("end-step")("id-mapping")
     16#define paramdescriptions ("first or start step")("number of steps to interpolate in between start and end step")("last or end step")("whether the identity shall be used in mapping atoms onto atoms or not")
    1717#undef paramdefaults
    18 #define paramreferences (filename)(start)(end)(IdMapping)
     18#define paramreferences (start)(interpolation_steps)(end)(IdMapping)
    1919
    2020#undef statetypes
     
    3131// finally the information stored in the ActionTrait specialization
    3232#define DESCRIPTION "linear interpolation in discrete steps between start and end position of a molecule"
    33 #define SHORTFORM "L"
     33#undef SHORTFORM
  • src/Dynamics/LinearInterpolationBetweenSteps.hpp

    re355762 reb33c4  
    1818#include "atom.hpp"
    1919#include "AtomSet.hpp"
     20#include "CodePatterns/Assert.hpp"
    2021#include "CodePatterns/Info.hpp"
    2122#include "CodePatterns/Log.hpp"
     23#include "CodePatterns/toString.hpp"
    2224#include "CodePatterns/Verbose.hpp"
    2325#include "Dynamics/MinimiseConstrainedPotential.hpp"
     
    3133public:
    3234  LinearInterpolationBetweenSteps(AtomSetMixin<Set> &_atoms, unsigned int _MaxOuterStep) :
    33     MDSteps(0),
    3435    MaxOuterStep(_MaxOuterStep),
    3536    IsAngstroem(true),
     
    4445   * \param startstep stating initial configuration in molecule::Trajectories
    4546   * \param endstep stating final configuration in molecule::Trajectories
    46    * \param &prefix path and prefix
    4747   * \param MapByIdentity if true we just use the identity to map atoms in start config to end config, if not we find mapping by \sa MinimiseConstrainedPotential()
    48    * \return true - success in writing step files, false - error writing files or only one step in molecule::Trajectories
    4948   */
    50   bool operator()(int startstep, int endstep, std::string prefix, bool MapByIdentity)
     49  void operator()(int startstep, int endstep, bool MapByIdentity)
    5150  {
    5251    // TODO: rewrite permutationMaps using enumeration objects
    53     molecule *mol = NULL;
    54     bool status = true;
    5552    int MaxSteps = MaxOuterStep;
    56     MoleculeListClass *MoleculePerStep = new MoleculeListClass(World::getPointer());
     53
    5754    // Get the Permutation Map by MinimiseConstrainedPotential
    58     atom **PermutationMap = NULL;
    59     atom *Sprinter = NULL;
     55    std::map<atom*, atom *> PermutationMap;
    6056    if (!MapByIdentity) {
    61       std::map<atom *, atom*> PermutationMap;
     57      LOG(1, "STATUS: Constructing atom mapping from start to end position.");
    6258      molecule::atomSet atoms_list;
    6359      copy(atoms.begin(), atoms.end(), atoms_list.begin());
     
    6561      Minimiser(startstep, endstep, IsAngstroem);
    6662    } else {
     63      LOG(1, "STATUS: Using identity mapping.");
    6764      // TODO: construction of enumeration goes here
    68       PermutationMap = new atom *[atoms.size()];
    6965      for(typename AtomSetMixin<Set>::const_iterator iter = atoms.begin(); iter != atoms.end();++iter){
    70         PermutationMap[(*iter)->getNr()] = (*iter);
     66        PermutationMap[(*iter)] = (*iter);
    7167      }
    7268    }
    7369
    7470    // check whether we have sufficient space in Trajectories for each atom
     71    LOG(1, "STATUS: Extending trajectories.");
    7572    for(typename AtomSetMixin<Set>::iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
    7673      (*iter)->ResizeTrajectory(MaxSteps);
     
    8380
    8481    // go through all steps and add the molecular configuration to the list and to the Trajectories of \a this molecule
    85     DoLog(1) && (Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl);
     82    LOG(1, "STATUS: Filling intermediate " << MaxSteps << " steps." << endl);
    8683    for (int step = 0; step <= MaxSteps; step++) {
    87       mol = World::getInstance().createMolecule();
    88       MoleculePerStep->insert(mol);
     84      LOG(2, "INFO: Current step is " << step << "." << endl);
    8985      for (typename AtomSetMixin<Set>::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
    90         // add to molecule list
    91         Sprinter = mol->AddCopyAtom((*iter));
    9286        // add to Trajectories
    93         Vector temp = (*iter)->getPositionAtStep(startstep) + (PermutationMap[(*iter)->getNr()]->getPositionAtStep(endstep) - (*iter)->getPositionAtStep(startstep))*((double)step/(double)MaxSteps);
    94         Sprinter->setPosition(temp);
     87        ASSERT(PermutationMap.count((*iter)),
     88            "LinearInterpolationBetweenSteps::operator() - atom "+toString(**iter)+" not found in PermutationMap.");
     89        Vector temp = (*iter)->getPositionAtStep(startstep) + (PermutationMap[(*iter)]->getPositionAtStep(endstep) - (*iter)->getPositionAtStep(startstep))*((double)step/(double)MaxSteps);
     90        (*iter)->setPositionAtStep(step,temp);
    9591        (*iter)->setAtomicVelocityAtStep(step, zeroVec);
    9692        (*iter)->setAtomicForceAtStep(step, zeroVec);
    97         //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl;
     93        LOG(2, "INFO: Adding trajectory point for atom " << **iter << " at " << temp << ".");
    9894      }
    9995    }
    100     MDSteps = MaxSteps+1;   // otherwise new Trajectories' points aren't stored on save&exit
    10196
    102     // store the list to single step files
    103     int *SortIndex = new int[atoms.size()];
    104     for (int i=atoms.size(); i--; )
    105       SortIndex[i] = i;
    106 
    107     status = MoleculePerStep->OutputConfigForListOfFragments(prefix, SortIndex);
    108     delete[](SortIndex);
    109 
    110     // free and return
    111     delete[](PermutationMap);
    112     delete(MoleculePerStep);
    113     return status;
     97//    // store the list to single step files
     98//    int *SortIndex = new int[atoms.size()];
     99//    for (int i=atoms.size(); i--; )
     100//      SortIndex[i] = i;
     101//
     102//    status = MoleculePerStep->OutputConfigForListOfFragments(prefix, SortIndex);
     103//    delete[](SortIndex);
    114104  };
    115105
    116106private:
    117   unsigned int MDSteps;
    118107  unsigned int MaxOuterStep;
    119108  bool IsAngstroem;
  • tests/regression/Molecules/LinearInterpolationofTrajectories/testsuite-molecules-linear-interpolation-of-trajectories.at

    re355762 reb33c4  
    22
    33AT_SETUP([Molecules - Linear interpolation])
    4 # this is not working but the test as of now passes
    5 #AT_XFAIL_IF([/bin/true])
    64AT_KEYWORDS([Molecules])
    75AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/LinearInterpolationofTrajectories/pre/test.conf .], 0)
    8 AT_CHECK([../../molecuilder -i test.conf  --select-molecule-by-id 0 -L teststep --start-step 0 --end-step 1 --id-mapping 1], 0, [stdout], [stderr])
     6AT_CHECK([../../molecuilder -i test.conf  --select-all-atoms --linear-interpolation-of-trajectories --start-step 0 --interpolation-steps 9 --end-step 1 --id-mapping 1 -S teststep.conf], 0, [stdout], [stderr])
     7AT_CHECK([fgrep -c 'Ion_Type1_1' teststep.conf], 0, [10
     8], [ignore])
     9AT_CHECK([diff teststep.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/LinearInterpolationofTrajectories/post/teststep.conf], 0, [ignore], [ignore])
    910AT_CLEANUP
Note: See TracChangeset for help on using the changeset viewer.