Changeset be945c


Ignore:
Timestamp:
Feb 3, 2011, 9:51:18 AM (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:
caa30b
Parents:
67c92b
git-author:
Frederik Heber <heber@…> (12/17/10 18:52:44)
git-committer:
Frederik Heber <heber@…> (02/03/11 09:51:18)
Message:

New DipoleAngularCorrelationAction that calculates angular correlation between dipoles.

Location:
src
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/Actions/Makefile.am

    r67c92b rbe945c  
    3737 
    3838ANALYSISACTIONSOURCE = \
     39  AnalysisAction/DipoleAngularCorrelationAction.cpp \
    3940  AnalysisAction/MolecularVolumeAction.cpp \
    4041  AnalysisAction/PairCorrelationAction.cpp \
     
    4344  AnalysisAction/SurfaceCorrelationAction.cpp
    4445ANALYSISACTIONHEADER = \
     46  AnalysisAction/DipoleAngularCorrelationAction.hpp \
    4547  AnalysisAction/MolecularVolumeAction.hpp \
    4648  AnalysisAction/PairCorrelationAction.hpp \
  • TabularUnified src/analysis_correlation.cpp

    r67c92b rbe945c  
    2323#include <iomanip>
    2424
     25#include "atom.hpp"
     26#include "bond.hpp"
    2527#include "BoundaryTriangleSet.hpp"
    26 #include "analysis_correlation.hpp"
     28#include "Box.hpp"
    2729#include "element.hpp"
    2830#include "CodePatterns/Info.hpp"
     
    3335#include "tesselationhelpers.hpp"
    3436#include "triangleintersectionlist.hpp"
     37#include "World.hpp"
    3538#include "LinearAlgebra/Vector.hpp"
    3639#include "LinearAlgebra/RealSpaceMatrix.hpp"
     
    3942#include "Box.hpp"
    4043
     44#include "analysis_correlation.hpp"
     45
     46/** Calculates the dipole vector of a given atomSet.
     47 *
     48 *  Note that we use the following procedure as rule of thumb:
     49 *   -# go through every bond of the atom
     50 *   -# calculate the difference of electronegativities \f$\Delta\text{EN}\f$
     51 *   -# if \f$\Delta\text{EN} > 0.5\f$, we align the bond vector in direction of the more negative element
     52 *   -# sum up all vectors
     53 *   -# finally, divide by the number of summed vectors
     54 *
     55 * @param atomsbegin begin iterator of atomSet
     56 * @param atomsend end iterator of atomset
     57 * @return dipole vector
     58 */
     59Vector getDipole(molecule::const_iterator atomsbegin, molecule::const_iterator atomsend)
     60{
     61  Vector DipoleVector;
     62  size_t SumOfVectors = 0;
     63  // go through all atoms
     64  for (molecule::const_iterator atomiter = atomsbegin;
     65      atomiter != atomsend;
     66      ++atomiter) {
     67    // go through all bonds
     68    for (BondList::const_iterator bonditer = (*atomiter)->ListOfBonds.begin();
     69        bonditer != (*atomiter)->ListOfBonds.end();
     70        ++bonditer) {
     71      const atom * Otheratom = (*bonditer)->GetOtherAtom(*atomiter);
     72      if (Otheratom->getId() > (*atomiter)->getId()) {
     73        const double DeltaEN = (*atomiter)->getType()->getElectronegativity()
     74            -Otheratom->getType()->getElectronegativity();
     75        Vector BondDipoleVector = (*atomiter)->getPosition() - Otheratom->getPosition();
     76        // DeltaEN is always positive, gives correct orientation of vector
     77        BondDipoleVector.Normalize();
     78        BondDipoleVector *= DeltaEN;
     79        DipoleVector += BondDipoleVector;
     80        SumOfVectors++;
     81      }
     82    }
     83  }
     84  DipoleVector *= 1./(double)SumOfVectors;
     85  DoLog(1) && (Log() << Verbose(1) << "Resulting dipole vector is " << DipoleVector << std::endl);
     86
     87  return DipoleVector;
     88};
     89
    4190/** Calculates the dipole angular correlation for given molecule type.
    4291 * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
     92 * Angles are given in degrees.
    4393 * \param *molecules vector of molecules
    44  * \param &elements vector of elements to correlate
    4594 * \return Map of doubles with values the pair of the two atoms.
    4695 */
    47 DipoleAngularCorrelationMap *DipoleAngularCorrelation(std::vector<molecule *> &molecules, const Formula &formula)
     96DipoleAngularCorrelationMap *DipoleAngularCorrelation(std::vector<molecule *> &molecules)
    4897{
    4998  Info FunctionInfo(__func__);
     
    52101//  Box &domain = World::getInstance().getDomain();
    53102//
    54 //  if (molecules.empty()) {
    55 //    DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
    56 //    return outmap;
    57 //  }
    58 //  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
    59 //    (*MolWalker)->doCountAtoms();
    60 //
    61 //  // create all possible pairs of elements
    62 //  set <pair<const element *,const element *> > PairsOfElements;
    63 //  if (elements.size() >= 2) {
    64 //    for (vector<const element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
    65 //      for (vector<const element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
    66 //        if (type1 != type2) {
    67 //          PairsOfElements.insert( make_pair(*type1,*type2) );
    68 //          DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << *(*type1) << " and " << *(*type2) << "." << endl);
    69 //        }
    70 //  } else if (elements.size() == 1) { // one to all are valid
    71 //    const element *elemental = *elements.begin();
    72 //    PairsOfElements.insert( pair<const element *,const element*>(elemental,0) );
    73 //    PairsOfElements.insert( pair<const element *,const element*>(0,elemental) );
    74 //  } else { // all elements valid
    75 //    PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
    76 //  }
    77 //
    78 //  outmap = new PairCorrelationMap;
    79 //  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++){
    80 //    DoLog(2) && (Log()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    81 //    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    82 //      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    83 //      for (std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules.end(); MolOtherWalker++){
    84 //        DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    85 //        for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
    86 //          DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
    87 //          if ((*iter)->getId() < (*runner)->getId()){
    88 //            for (set <pair<const element *, const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
    89 //              if ((PairRunner->first == (**iter).getType()) && (PairRunner->second == (**runner).getType())) {
    90 //                distance = domain.periodicDistance((*iter)->getPosition(),(*runner)->getPosition());
    91 //                //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
    92 //                outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
    93 //              }
    94 //          }
    95 //        }
    96 //      }
    97 //    }
    98 //  }
     103  if (molecules.empty()) {
     104    DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
     105    return outmap;
     106  }
     107
     108  outmap = new DipoleAngularCorrelationMap;
     109  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin();
     110      MolWalker != molecules.end();) {
     111    DoLog(2) && (Log()<< Verbose(2) << "Current molecule is "
     112        << (*MolWalker)->getId() << "." << endl);
     113    const Vector Dipole = getDipole((*MolWalker)->begin(), (*MolWalker)->end());
     114    for (std::vector<molecule *>::const_iterator MolOtherWalker = ++MolWalker;
     115        MolOtherWalker != molecules.end();
     116        MolOtherWalker++) {
     117      DoLog(2) && (Log() << Verbose(2) << "Current other molecule is "
     118          << (*MolOtherWalker)->getId() << "." << endl);
     119      const Vector OtherDipole = getDipole((*MolOtherWalker)->begin(), (*MolOtherWalker)->end());
     120      const double angle = Dipole.Angle(OtherDipole) * (180./M_PI);
     121      DoLog(1) && (Log() << Verbose(1) << "Angle is " << angle << "." << endl);
     122      outmap->insert ( make_pair (angle, make_pair ((*MolWalker), (*MolOtherWalker)) ) );
     123    }
     124  }
    99125  return outmap;
    100126};
     
    466492 * \param *map map to write
    467493 */
     494void OutputDipoleAngularCorrelation( ofstream * const file, const DipoleAngularCorrelationMap * const map )
     495{
     496  Info FunctionInfo(__func__);
     497  *file << "BinStart\tMolecule1\tMolecule2" << endl;
     498  for (DipoleAngularCorrelationMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
     499    *file << setprecision(8) << runner->first << "\t" << runner->second.first->getId() << "\t" << runner->second.second->getId() << endl;
     500  }
     501};
     502
     503/** Prints correlation (double, (atom*,atom*) ) pairs to file.
     504 * \param *file file to write to
     505 * \param *map map to write
     506 */
    468507void OutputPairCorrelation( ofstream * const file, const PairCorrelationMap * const map )
    469508{
  • TabularUnified src/analysis_correlation.hpp

    r67c92b rbe945c  
    4949/********************************************** declarations *******************************/
    5050
    51 DipoleAngularCorrelationMap *DipoleAngularCorrelation(std::vector<molecule *> &molecules, const Formula &formula);
     51DipoleAngularCorrelationMap *DipoleAngularCorrelation(std::vector<molecule *> &molecules);
    5252PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements);
    5353CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point );
     
    5858int GetBin ( const double value, const double BinWidth, const double BinStart );
    5959void OutputCorrelation( ofstream * const file, const BinPairMap * const map );
     60void OutputDipoleAngularCorrelation( ofstream * const file, const DipoleAngularCorrelationMap * const map );
    6061void OutputPairCorrelation( ofstream * const file, const PairCorrelationMap * const map );
    6162void OutputCorrelationToPoint( ofstream * const file, const CorrelationToPointMap * const map );
Note: See TracChangeset for help on using the changeset viewer.