Changeset e65878
- Timestamp:
- Oct 31, 2011, 11:49:19 AM (13 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:
- 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)
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/AnalysisAction/DipoleAngularCorrelationAction.cpp
r505d05 re65878 24 24 #include "linkedcell.hpp" 25 25 #include "CodePatterns/Log.hpp" 26 #include "Descriptors/AtomOfMoleculeSelectionDescriptor.hpp" 27 #include "Descriptors/MoleculeFormulaDescriptor.hpp" 26 28 #include "Element/element.hpp" 27 #include "molecule.hpp"28 29 #include "Element/periodentafel.hpp" 29 30 #include "LinearAlgebra/Vector.hpp" 31 #include "molecule.hpp" 30 32 #include "World.hpp" 31 33 #include "WorldTime.hpp" … … 53 55 54 56 // get selected atoms 55 std::vector<atom*> atoms= World::getInstance().getSelectedAtoms();56 ASSERT(atoms.size() != 0, "AnalysisDipoleAngularCorrelationAction() - not atoms selected.");57 std::vector<atom*> old_atom_selection = World::getInstance().getSelectedAtoms(); 58 std::vector<molecule*> old_molecule_selection = World::getInstance().getSelectedMolecules(); 57 59 58 60 // get current time step 59 61 const unsigned int oldtime = WorldTime::getTime(); 60 62 61 // obtain zero dipole orientation 63 // select atoms and obtain zero dipole orientation 64 Formula DipoleFormula(params.DipoleFormula); 62 65 World::getInstance().setTime(0); 63 std::map<atomId_t, Vector> ZeroVector = CalculateZeroAngularDipole(atoms); 66 World::getInstance().clearMoleculeSelection(); // TODO: This should be done in setTime or where molecules are re-done 67 World::getInstance().selectAllMolecules(MoleculeByFormula(DipoleFormula)); 68 std::vector<molecule *> molecules = World::getInstance().getSelectedMolecules(); 69 std::map<atomId_t, Vector> ZeroVector = CalculateZeroAngularDipole(molecules); 64 70 65 71 // go through each step of common trajectory of all atoms in set 72 World::getInstance().clearAtomSelection(); 73 World::getInstance().selectAllAtoms(AtomsByMoleculeSelection()); 74 std::vector<atom *> atoms = World::getInstance().getSelectedAtoms(); 66 75 range<size_t> timesteps = getMaximumTrajectoryBounds(atoms); 67 76 for (size_t step = 0; step < timesteps.first; ++step) { 68 77 // calculate dipoles relative to zero orientation 69 78 DipoleAngularCorrelationMap *correlationmap = NULL; 70 correlationmap = DipoleAngularCorrelation( atoms, step, ZeroVector, DontResetTime);79 correlationmap = DipoleAngularCorrelation(DipoleFormula, step, ZeroVector, DontResetTime); 71 80 72 81 // prepare step string in filename … … 102 111 World::getInstance().setTime(oldtime); 103 112 113 // reset to old selections 114 World::getInstance().clearAtomSelection(); 115 BOOST_FOREACH(atom *_atom, old_atom_selection) { 116 World::getInstance().selectAtom(_atom); 117 } 118 World::getInstance().clearMoleculeSelection(); 119 BOOST_FOREACH(molecule *_mol, old_molecule_selection) { 120 World::getInstance().selectMolecule(_mol); 121 } 122 104 123 // exit 105 124 return Action::success; -
src/Actions/AnalysisAction/DipoleAngularCorrelationAction.def
r505d05 re65878 13 13 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 14 14 // "undefine" if no parameters are required, use (NODEFAULT) for each (undefined) default value 15 #define paramtypes ( double)(double)(double)(boost::filesystem::path)(boost::filesystem::path)(bool)16 #define paramreferences ( BinStart)(BinWidth)(BinEnd)(outputname)(binoutputname)(periodic)17 #define paramtokens (" bin-start")("bin-width")("bin-end")("output-file")("bin-output-file")("periodic")18 #define paramdescriptions (" start of the first bin")("width of the bins")("start of the last bin")("name of the output file")("name of the bin output file")("system is constraint to periodic boundary conditions")19 #define paramdefaults (NODEFAULT)( "0.5")(NODEFAULT)(NODEFAULT)(NODEFAULT)("0")15 #define paramtypes (std::string)(double)(double)(double)(boost::filesystem::path)(boost::filesystem::path)(bool) 16 #define paramreferences (DipoleFormula)(BinStart)(BinWidth)(BinEnd)(outputname)(binoutputname)(periodic) 17 #define paramtokens ("dipole-angular-correlation")("bin-start")("bin-width")("bin-end")("output-file")("bin-output-file")("periodic") 18 #define paramdescriptions ("formula of molecules to calculate dipole of")("start of the first bin")("width of the bins")("start of the last bin")("name of the output file")("name of the bin output file")("system is constraint to periodic boundary conditions") 19 #define paramdefaults (NODEFAULT)(NODEFAULT)("0.5")(NODEFAULT)(NODEFAULT)(NODEFAULT)("0") 20 20 21 21 // some defines for all the names, you may use ACTION, STATE and PARAMS -
src/Analysis/analysis_correlation.cpp
r505d05 re65878 32 32 #include "CodePatterns/Log.hpp" 33 33 #include "CodePatterns/Verbose.hpp" 34 #include "Descriptors/AtomOfMoleculeSelectionDescriptor.hpp" 35 #include "Descriptors/MoleculeFormulaDescriptor.hpp" 34 36 #include "Descriptors/MoleculeOfAtomSelectionDescriptor.hpp" 35 37 #include "Formula.hpp" … … 100 102 * \return range with [min, max] 101 103 */ 102 range<size_t> getMaximumTrajectoryBounds( std::vector<atom *> &atoms)104 range<size_t> getMaximumTrajectoryBounds(const std::vector<atom *> &atoms) 103 105 { 104 106 // get highest trajectory size … … 121 123 122 124 /** Calculates the angular dipole zero orientation from current time step. 123 * \param atoms vector of atoms to calculate it for125 * \param molecules vector of molecules to calculate dipoles of 124 126 * \return map with orientation vector for each atomic id given in \a atoms. 125 127 */ 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 128 std::map<atomId_t, Vector> CalculateZeroAngularDipole(const std::vector<molecule *> &molecules) 129 { 133 130 // 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 ..."); 135 132 std::map<atomId_t, Vector> ZeroVector; 136 133 BOOST_FOREACH(molecule *_mol, molecules) { … … 154 151 * \a ZeroVector) 155 152 * \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.157 153 * \param DontResetTime don't reset time to old value (triggers re-creation of bond system) 158 154 * \return Map of doubles with values the pair of the two atoms. 159 155 */ 160 156 DipoleAngularCorrelationMap *DipoleAngularCorrelation( 161 std::vector<atom *> &atoms,157 const Formula &DipoleFormula, 162 158 const size_t timestep, 163 std::map<atomId_t, Vector> &ZeroVector,159 const std::map<atomId_t, Vector> &ZeroVector, 164 160 const enum ResetWorldTime DoTimeReset 165 161 ) … … 167 163 Info FunctionInfo(__func__); 168 164 DipoleAngularCorrelationMap *outmap = new DipoleAngularCorrelationMap; 169 170 // get zero orientation for each molecule if not given171 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 }177 165 178 166 unsigned int oldtime = 0; … … 187 175 188 176 // 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 << "."); 193 183 194 184 // 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 << " ..."); 196 186 size_t i=0; 197 187 BOOST_FOREACH(molecule *_mol, molecules) { 198 188 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 " 200 190 << _mol->getId() << " is " << Dipole); 191 // check that all atoms are valid (zeroVector known) 201 192 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 204 203 double angle = 0.; 205 204 LOG(2, "INFO: ZeroVector of first atom " << **iter << " is " 206 << ZeroVector[(*iter)->getId()]<< ".");205 << zeroValue->second << "."); 207 206 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); 211 210 else 212 211 LOG(2, "INFO: Both vectors (almost) coincide, numerically unstable, angle set to zero."); … … 216 215 ++i; 217 216 } 218 LOG( 0,"STATUS: Done with calculating dipoles.");217 LOG(1,"STATUS: Done with calculating dipoles."); 219 218 220 219 if (DoTimeReset == DoResetTime) { -
src/Analysis/analysis_correlation.hpp
r505d05 re65878 60 60 /********************************************** declarations *******************************/ 61 61 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);62 range<size_t> getMaximumTrajectoryBounds(const std::vector<atom *> &atoms); 63 std::map<atomId_t, Vector> CalculateZeroAngularDipole(const std::vector<molecule *> &molecules); 64 65 DipoleAngularCorrelationMap *DipoleAngularCorrelation(const Formula &DipoleFormula, const size_t timestep, const std::map<atomId_t, Vector> &ZeroVector, const enum ResetWorldTime DoTimeReset = DontResetTime); 66 66 DipoleCorrelationMap *DipoleCorrelation(std::vector<molecule *> &molecules); 67 67 PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements);
Note:
See TracChangeset
for help on using the changeset viewer.