Changeset be945c
- Timestamp:
- Feb 3, 2011, 9:51:18 AM (14 years ago)
- 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)
- Location:
- src
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Actions/Makefile.am ¶
r67c92b rbe945c 37 37 38 38 ANALYSISACTIONSOURCE = \ 39 AnalysisAction/DipoleAngularCorrelationAction.cpp \ 39 40 AnalysisAction/MolecularVolumeAction.cpp \ 40 41 AnalysisAction/PairCorrelationAction.cpp \ … … 43 44 AnalysisAction/SurfaceCorrelationAction.cpp 44 45 ANALYSISACTIONHEADER = \ 46 AnalysisAction/DipoleAngularCorrelationAction.hpp \ 45 47 AnalysisAction/MolecularVolumeAction.hpp \ 46 48 AnalysisAction/PairCorrelationAction.hpp \ -
TabularUnified src/analysis_correlation.cpp ¶
r67c92b rbe945c 23 23 #include <iomanip> 24 24 25 #include "atom.hpp" 26 #include "bond.hpp" 25 27 #include "BoundaryTriangleSet.hpp" 26 #include " analysis_correlation.hpp"28 #include "Box.hpp" 27 29 #include "element.hpp" 28 30 #include "CodePatterns/Info.hpp" … … 33 35 #include "tesselationhelpers.hpp" 34 36 #include "triangleintersectionlist.hpp" 37 #include "World.hpp" 35 38 #include "LinearAlgebra/Vector.hpp" 36 39 #include "LinearAlgebra/RealSpaceMatrix.hpp" … … 39 42 #include "Box.hpp" 40 43 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 */ 59 Vector 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 41 90 /** Calculates the dipole angular correlation for given molecule type. 42 91 * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si)) 92 * Angles are given in degrees. 43 93 * \param *molecules vector of molecules 44 * \param &elements vector of elements to correlate45 94 * \return Map of doubles with values the pair of the two atoms. 46 95 */ 47 DipoleAngularCorrelationMap *DipoleAngularCorrelation(std::vector<molecule *> &molecules , const Formula &formula)96 DipoleAngularCorrelationMap *DipoleAngularCorrelation(std::vector<molecule *> &molecules) 48 97 { 49 98 Info FunctionInfo(__func__); … … 52 101 // Box &domain = World::getInstance().getDomain(); 53 102 // 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 } 99 125 return outmap; 100 126 }; … … 466 492 * \param *map map to write 467 493 */ 494 void 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 */ 468 507 void OutputPairCorrelation( ofstream * const file, const PairCorrelationMap * const map ) 469 508 { -
TabularUnified src/analysis_correlation.hpp ¶
r67c92b rbe945c 49 49 /********************************************** declarations *******************************/ 50 50 51 DipoleAngularCorrelationMap *DipoleAngularCorrelation(std::vector<molecule *> &molecules , const Formula &formula);51 DipoleAngularCorrelationMap *DipoleAngularCorrelation(std::vector<molecule *> &molecules); 52 52 PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements); 53 53 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point ); … … 58 58 int GetBin ( const double value, const double BinWidth, const double BinStart ); 59 59 void OutputCorrelation( ofstream * const file, const BinPairMap * const map ); 60 void OutputDipoleAngularCorrelation( ofstream * const file, const DipoleAngularCorrelationMap * const map ); 60 61 void OutputPairCorrelation( ofstream * const file, const PairCorrelationMap * const map ); 61 62 void OutputCorrelationToPoint( ofstream * const file, const CorrelationToPointMap * const map );
Note:
See TracChangeset
for help on using the changeset viewer.