Changeset e65878 for src/Analysis


Ignore:
Timestamp:
Oct 31, 2011, 11:49:19 AM (13 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:
870b4b
Parents:
505d05
git-author:
Frederik Heber <heber@…> (05/18/11 19:55:05)
git-committer:
Frederik Heber <heber@…> (10/31/11 11:49:19)
Message:

Selection is now done inside DipoleAngularCorrelation.

  • as molecules may change over time it makes more sense to select molecules internally right now.
  • DipoleAngularCorrelation() now takes Formula instead of std::vector<atom *>.
  • also adjusted const'ness of some parameters.
Location:
src/Analysis
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Analysis/analysis_correlation.cpp

    r505d05 re65878  
    3232#include "CodePatterns/Log.hpp"
    3333#include "CodePatterns/Verbose.hpp"
     34#include "Descriptors/AtomOfMoleculeSelectionDescriptor.hpp"
     35#include "Descriptors/MoleculeFormulaDescriptor.hpp"
    3436#include "Descriptors/MoleculeOfAtomSelectionDescriptor.hpp"
    3537#include "Formula.hpp"
     
    100102 * \return range with [min, max]
    101103 */
    102 range<size_t> getMaximumTrajectoryBounds(std::vector<atom *> &atoms)
     104range<size_t> getMaximumTrajectoryBounds(const std::vector<atom *> &atoms)
    103105{
    104106  // get highest trajectory size
     
    121123
    122124/** Calculates the angular dipole zero orientation from current time step.
    123  * \param atoms vector of atoms to calculate it for
     125 * \param molecules vector of molecules to calculate dipoles of
    124126 * \return map with orientation vector for each atomic id given in \a atoms.
    125127 */
    126 std::map<atomId_t, Vector> CalculateZeroAngularDipole(std::vector<atom *> &atoms)
    127 {
    128   // calculate molecules for this time step
    129   std::set<molecule *> molecules;
    130   BOOST_FOREACH(atom *_atom, atoms)
    131     molecules.insert(_atom->getMolecule());
    132 
     128std::map<atomId_t, Vector> CalculateZeroAngularDipole(const std::vector<molecule *> &molecules)
     129{
    133130  // get zero orientation for each molecule.
    134   LOG(0,"STATUS: Calculating dipoles for first time step ...");
     131  LOG(0,"STATUS: Calculating dipoles for current time step ...");
    135132  std::map<atomId_t, Vector> ZeroVector;
    136133  BOOST_FOREACH(molecule *_mol, molecules) {
     
    154151 *  \a ZeroVector)
    155152 * \param ZeroVector map with Zero orientation vector for each atom in \a atoms.
    156  *   Is filled from initial time step if size of map does not match size of \a atoms.
    157153 * \param DontResetTime don't reset time to old value (triggers re-creation of bond system)
    158154 * \return Map of doubles with values the pair of the two atoms.
    159155 */
    160156DipoleAngularCorrelationMap *DipoleAngularCorrelation(
    161     std::vector<atom *> &atoms,
     157    const Formula &DipoleFormula,
    162158    const size_t timestep,
    163     std::map<atomId_t, Vector> &ZeroVector,
     159    const std::map<atomId_t, Vector> &ZeroVector,
    164160    const enum ResetWorldTime DoTimeReset
    165161    )
     
    167163  Info FunctionInfo(__func__);
    168164  DipoleAngularCorrelationMap *outmap = new DipoleAngularCorrelationMap;
    169 
    170   // get zero orientation for each molecule if not given
    171   if (ZeroVector.size() != atoms.size()) {
    172     LOG(1, "INFO: Mismatch size of zero orientation map ("
    173         << ZeroVector.size() << ") and atom vector ("<< atoms.size() << +").");
    174     ZeroVector.clear();
    175     ZeroVector = CalculateZeroAngularDipole(atoms);
    176   }
    177165
    178166  unsigned int oldtime = 0;
     
    187175
    188176  // get all molecules for this time step
    189   LOG(0,"STATUS: Gathering molecules from " << atoms.size() << " atoms for time step " << timestep << " ...");
    190   std::set<molecule *> molecules;
    191   BOOST_FOREACH(atom *_atom, atoms)
    192     molecules.insert(_atom->getMolecule());
     177  World::getInstance().clearMoleculeSelection();
     178  World::getInstance().selectAllMolecules(MoleculeByFormula(DipoleFormula));
     179  World::getInstance().clearAtomSelection();
     180  World::getInstance().selectAllAtoms(AtomsByMoleculeSelection());
     181  std::vector<molecule *> molecules = World::getInstance().getSelectedMolecules();
     182  LOG(1,"STATUS: Gathering " << molecules.size() << " molecules for time step " << timestep << ".");
    193183
    194184  // calculate dipoles for each
    195   LOG(0,"STATUS: Calculating dipoles for " << molecules.size() << " molecules for time step " << timestep << " ...");
     185  LOG(1,"STATUS: Calculating dipoles for time step " << timestep << " ...");
    196186  size_t i=0;
    197187  BOOST_FOREACH(molecule *_mol, molecules) {
    198188    const Vector Dipole = getDipole(_mol->begin(), _mol->end());
    199     LOG(2,"INFO: Dipole vector at time step " << timestep << " for molecule "
     189    LOG(3,"INFO: Dipole vector at time step " << timestep << " for for molecule "
    200190        << _mol->getId() << " is " << Dipole);
     191    // check that all atoms are valid (zeroVector known)
    201192    molecule::const_iterator iter = _mol->begin();
    202     ASSERT(ZeroVector.count((*iter)->getId()),
    203         "DipoleAngularCorrelation() - ZeroVector for atom "+toString(**iter)+" not present.");
     193    for(; iter != _mol->end(); ++iter) {
     194      if (!ZeroVector.count((*iter)->getId()))
     195        break;
     196    }
     197    if (iter != _mol->end()) {
     198      ELOG(2, "Skipping molecule " << _mol->getName() << " as not all atoms have a valid zeroVector.");
     199      continue;
     200    } else
     201      iter = _mol->begin();
     202    std::map<atomId_t, Vector>::const_iterator zeroValue = ZeroVector.find((*iter)->getId()); //due to iter is const
    204203    double angle = 0.;
    205204    LOG(2, "INFO: ZeroVector of first atom " << **iter << " is "
    206         << ZeroVector[(*iter)->getId()] << ".");
     205        << zeroValue->second << ".");
    207206    LOG(4, "INFO: Squared norm of difference vector is "
    208         << (ZeroVector[(*iter)->getId()] - Dipole).NormSquared() << ".");
    209     if ((ZeroVector[(*iter)->getId()] - Dipole).NormSquared() > MYEPSILON)
    210       angle = Dipole.Angle(ZeroVector[(*iter)->getId()]) * (180./M_PI);
     207        << (zeroValue->second - Dipole).NormSquared() << ".");
     208    if ((zeroValue->second - Dipole).NormSquared() > MYEPSILON)
     209      angle = Dipole.Angle(zeroValue->second) * (180./M_PI);
    211210    else
    212211      LOG(2, "INFO: Both vectors (almost) coincide, numerically unstable, angle set to zero.");
     
    216215    ++i;
    217216  }
    218   LOG(0,"STATUS: Done with calculating dipoles.");
     217  LOG(1,"STATUS: Done with calculating dipoles.");
    219218
    220219  if (DoTimeReset == DoResetTime) {
  • src/Analysis/analysis_correlation.hpp

    r505d05 re65878  
    6060/********************************************** declarations *******************************/
    6161
    62 range<size_t> getMaximumTrajectoryBounds(std::vector<atom *> &atoms);
    63 std::map<atomId_t, Vector> CalculateZeroAngularDipole(std::vector<atom *> &atoms);
    64 
    65 DipoleAngularCorrelationMap *DipoleAngularCorrelation(std::vector<atom *> &atoms, const size_t timestep, std::map<atomId_t, Vector> &ZeroVector, const enum ResetWorldTime DoTimeReset = DontResetTime);
     62range<size_t> getMaximumTrajectoryBounds(const std::vector<atom *> &atoms);
     63std::map<atomId_t, Vector> CalculateZeroAngularDipole(const std::vector<molecule *> &molecules);
     64
     65DipoleAngularCorrelationMap *DipoleAngularCorrelation(const Formula &DipoleFormula, const size_t timestep, const std::map<atomId_t, Vector> &ZeroVector, const enum ResetWorldTime DoTimeReset = DontResetTime);
    6666DipoleCorrelationMap *DipoleCorrelation(std::vector<molecule *> &molecules);
    6767PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements);
Note: See TracChangeset for help on using the changeset viewer.