Changeset 49f802c
- Timestamp:
- Oct 9, 2009, 11:57:41 AM (15 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:
- c111db
- Parents:
- f66195
- Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/atom.cpp
rf66195 r49f802c 222 222 { 223 223 if (out != NULL) { 224 *out << Verbose(4) << "Atom " << Name << "/" << nr << " with " << NumberOfBondsPerAtom[nr] << " bonds: "; 225 int TotalDegree = 0; 226 for (int j=0;j<NumberOfBondsPerAtom[nr];j++) { 227 *out << *ListOfBondsPerAtom[nr][j] << "\t"; 228 TotalDegree += ListOfBondsPerAtom[nr][j]->BondDegree; 224 #ifdef ADDHYDROGEN 225 if (type->Z != 1) { // regard only non-hydrogen 226 #endif 227 *out << Verbose(4) << "Atom " << Name << "/" << nr << " with " << NumberOfBondsPerAtom[nr] << " bonds: "; 228 int TotalDegree = 0; 229 for (int j=0;j<NumberOfBondsPerAtom[nr];j++) { 230 *out << *ListOfBondsPerAtom[nr][j] << "\t"; 231 TotalDegree += ListOfBondsPerAtom[nr][j]->BondDegree; 232 } 233 *out << " -- TotalDegree: " << TotalDegree << endl; 234 #ifdef ADDHYDROGEN 229 235 } 230 *out << " -- TotalDegree: " << TotalDegree << endl; 236 #endif 231 237 return true; 232 238 } else … … 258 264 }; 259 265 266 /** Returns squared distance to a given vector. 267 * \param origin vector to calculate distance to 268 * \return distance squared 269 */ 270 double atom::DistanceSquaredToVector(Vector &origin) 271 { 272 return origin.DistanceSquared(&x); 273 }; 274 275 /** Adds kinetic energy of this atom to given temperature value. 276 * \param *temperature add on this value 277 * \param step given step of trajectory to add 278 */ 279 void atom::AddKineticToTemperature(double *temperature, int step) const 280 { 281 for (int i=NDIM;i--;) 282 *temperature += type->mass * Trajectory.U.at(step).x[i]* Trajectory.U.at(step).x[i]; 283 }; 284 285 /** Returns distance to a given vector. 286 * \param origin vector to calculate distance to 287 * \return distance 288 */ 289 double atom::DistanceToVector(Vector &origin) 290 { 291 return origin.Distance(&x); 292 }; 293 260 294 bool operator < (atom &a, atom &b) 261 295 { -
src/atom.hpp
rf66195 r49f802c 79 79 bool Compare(const atom &ptr); 80 80 81 double DistanceToVector(Vector &origin); 82 double DistanceSquaredToVector(Vector &origin); 83 84 void AddKineticToTemperature(double *temperature, int step) const; 85 81 86 bool IsInParallelepiped(Vector offset, double *parallelepiped); 82 87 -
src/molecule.cpp
rf66195 r49f802c 779 779 { 780 780 *out << Verbose(2) << endl << "From Contents of ListOfBondsPerAtom, all non-hydrogen atoms:" << endl; 781 atom *Walker = start; 782 while (Walker->next != end) { 783 Walker = Walker->next; 784 #ifdef ADDHYDROGEN 785 if (Walker->type->Z != 1) { // regard only non-hydrogen 786 #endif 787 *out << Verbose(2) << "Atom " << Walker->Name << " has Bonds: "<<endl; 788 for(int j=0;j<NumberOfBondsPerAtom[Walker->nr];j++) { 789 *out << Verbose(3) << *(ListOfBondsPerAtom)[Walker->nr][j] << endl; 790 } 791 #ifdef ADDHYDROGEN 792 } 793 #endif 794 } 781 ActOnAllAtoms (&atom::OutputBondOfAtom, out, NumberOfBondsPerAtom, ListOfBondsPerAtom); 795 782 *out << endl; 796 783 }; … … 983 970 size_t *PermMap = NULL, *OtherPermMap = NULL; 984 971 int *PermutationMap = NULL; 985 atom *Walker = NULL;986 972 bool result = true; // status of comparison 987 973 … … 1042 1028 Distances = Malloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: Distances"); 1043 1029 OtherDistances = Malloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: OtherDistances"); 1044 Walker = start; 1045 while (Walker->next != end) { 1046 Walker = Walker->next; 1047 Distances[Walker->nr] = CenterOfGravity.DistanceSquared(&Walker->x); 1048 } 1049 Walker = OtherMolecule->start; 1050 while (Walker->next != OtherMolecule->end) { 1051 Walker = Walker->next; 1052 OtherDistances[Walker->nr] = OtherCenterOfGravity.DistanceSquared(&Walker->x); 1053 } 1030 SetIndexedArrayForEachAtomTo ( Distances, &atom::nr, &atom::DistanceSquaredToVector, CenterOfGravity); 1031 SetIndexedArrayForEachAtomTo ( OtherDistances, &atom::nr, &atom::DistanceSquaredToVector, CenterOfGravity); 1054 1032 1055 1033 /// ... sort each list (using heapsort (o(N log N)) from GSL) … … 1150 1128 { 1151 1129 double temperature; 1152 atom *Walker = NULL;1153 1130 // test stream 1154 1131 if (output == NULL) … … 1158 1135 for (int step=startstep;step < endstep; step++) { // loop over all time steps 1159 1136 temperature = 0.; 1160 Walker = start; 1161 while (Walker->next != end) { 1162 Walker = Walker->next; 1163 for (int i=NDIM;i--;) 1164 temperature += Walker->type->mass * Walker->Trajectory.U.at(step).x[i]* Walker->Trajectory.U.at(step).x[i]; 1165 } 1137 ActOnAllAtoms( &atom::AddKineticToTemperature, &temperature, step); 1166 1138 *output << step << "\t" << temperature*AtomicEnergyToKelvin << "\t" << temperature << endl; 1167 1139 } -
src/molecule.hpp
rf66195 r49f802c 108 108 template <typename res> void ActOnAllVectors( res (Vector::*f)() const); 109 109 template <typename res> void ActOnAllVectors( res (Vector::*f)() ) const; 110 template <typename res> void ActOnAllVectors( res (Vector::*f)() const) const; 110 111 template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T), T t ); 111 112 template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T) const, T t ); 112 113 template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T), T t ) const; 114 template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T) const, T t ) const; 113 115 template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ); 114 116 template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ); 115 117 template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const; 118 template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const; 116 119 template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v); 117 120 template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v); 118 121 template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const; 122 template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const; 119 123 120 124 // templates for allowing global manipulation of molecule with each atom as single argument … … 122 126 template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) const); 123 127 template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) ) const; 128 template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) const) const; 124 129 125 130 // templates for allowing global copying of molecule with each atom as single argument … … 127 132 template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const , molecule *copy); 128 133 template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const; 134 template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const; 129 135 130 136 // templates for allowing global manipulation of all atoms … … 132 138 template <typename res> void ActOnAllAtoms( res (atom::*f)() const ); 133 139 template <typename res> void ActOnAllAtoms( res (atom::*f)() ) const; 140 template <typename res> void ActOnAllAtoms( res (atom::*f)() const) const; 134 141 template <typename res, typename T> void ActOnAllAtoms( res (atom::*f)(T), T t ); 135 142 template <typename res, typename T> void ActOnAllAtoms( res (atom::*f)(T) const, T t ); 143 template <typename res, typename T> void ActOnAllAtoms( res (atom::*f)(T), T t ) const; 136 144 template <typename res, typename T> void ActOnAllAtoms( res (atom::*f)(T) const, T t ) const; 137 145 template <typename res, typename T, typename U> void ActOnAllAtoms( res (atom::*f)(T, U), T t, U u ); 138 146 template <typename res, typename T, typename U> void ActOnAllAtoms( res (atom::*f)(T, U) const, T t, U u ); 139 147 template <typename res, typename T, typename U> void ActOnAllAtoms( res (atom::*f)(T, U), T t, U u ) const; 148 template <typename res, typename T, typename U> void ActOnAllAtoms( res (atom::*f)(T, U) const, T t, U u ) const; 140 149 template <typename res, typename T, typename U, typename V> void ActOnAllAtoms( res (atom::*f)(T, U, V), T t, U u, V v); 141 150 template <typename res, typename T, typename U, typename V> void ActOnAllAtoms( res (atom::*f)(T, U, V) const, T t, U u, V v); 142 151 template <typename res, typename T, typename U, typename V> void ActOnAllAtoms( res (atom::*f)(T, U, V), T t, U u, V v) const; 152 template <typename res, typename T, typename U, typename V> void ActOnAllAtoms( res (atom::*f)(T, U, V) const, T t, U u, V v) const; 143 153 template <typename res, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (atom::*f)(T, U, V, W), T t, U u, V v, W w); 144 154 template <typename res, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (atom::*f)(T, U, V, W) const, T t, U u, V v, W w); 145 155 template <typename res, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (atom::*f)(T, U, V, W), T t, U u, V v, W w) const; 156 template <typename res, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (atom::*f)(T, U, V, W) const, T t, U u, V v, W w) const; 146 157 147 158 // templates for allowing conditional global copying of molecule with each atom as single argument … … 152 163 153 164 // templates for allowing global manipulation of an array with one entry per atom 154 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int atom::* index, void (*Setor)(T *, T));155 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int atom::* index, void (*Setor)(T *, T), T);165 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::* index, void (*Setor)(T *, T)); 166 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::* index, void (*Setor)(T *, T), T t); 156 167 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T)); 157 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T), T); 168 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T), T t); 169 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::* index, T (atom::*Setor)(Vector &), Vector atom::*value); 170 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, T (atom::*Setor)(Vector &), Vector &vect ); 158 171 159 172 /// remove atoms from molecule. -
src/molecule_template.hpp
rf66195 r49f802c 45 45 } 46 46 }; 47 template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const ) const 48 { 49 atom *Walker = start; 50 while (Walker->next != end) { 51 Walker = Walker->next; 52 ((Walker->node)->*f)(); 53 } 54 }; 47 55 // one argument 48 56 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) … … 70 78 } 71 79 }; 80 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const 81 { 82 atom *Walker = start; 83 while (Walker->next != end) { 84 Walker = Walker->next; 85 ((Walker->node)->*f)(t); 86 } 87 }; 72 88 // two arguments 73 89 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) … … 95 111 } 96 112 }; 113 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const 114 { 115 atom *Walker = start; 116 while (Walker->next != end) { 117 Walker = Walker->next; 118 ((Walker->node)->*f)(t, u); 119 } 120 }; 97 121 // three arguments 98 122 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) … … 120 144 } 121 145 }; 146 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const 147 { 148 atom *Walker = start; 149 while (Walker->next != end) { 150 Walker = Walker->next; 151 ((Walker->node)->*f)(t, u, v); 152 } 153 }; 122 154 123 155 // ================== Acting with each Atoms on same molecule ========================== // … … 148 180 } 149 181 }; 182 template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const 183 { 184 atom *Walker = start; 185 while (Walker->next != end) { 186 Walker = Walker->next; 187 (*f)(Walker); 188 } 189 }; 150 190 151 191 // ================== Acting with each Atoms on copy molecule ========================== // … … 176 216 } 177 217 }; 218 template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const 219 { 220 atom *Walker = start; 221 while (Walker->next != end) { 222 Walker = Walker->next; 223 (copy->*f)(Walker); 224 } 225 }; 178 226 179 227 // ================== Acting with each Atoms on copy molecule if true ========================== // … … 247 295 } 248 296 }; 297 template <typename res> void molecule::ActOnAllAtoms( res (atom::*f)() const) const 298 { 299 atom *Walker = start; 300 while (Walker->next != end) { 301 Walker = Walker->next; 302 (Walker->*f)(); 303 } 304 }; 249 305 // one argument 250 306 template <typename res, typename T> void molecule::ActOnAllAtoms( res (atom::*f)(T), T t ) … … 264 320 } 265 321 }; 322 template <typename res, typename T> void molecule::ActOnAllAtoms( res (atom::*f)(T), T t ) const 323 { 324 atom *Walker = start; 325 while (Walker->next != end) { 326 Walker = Walker->next; 327 (Walker->*f)(t); 328 } 329 }; 266 330 template <typename res, typename T> void molecule::ActOnAllAtoms( res (atom::*f)(T) const, T t ) const 267 331 { … … 297 361 } 298 362 }; 363 template <typename res, typename T, typename U> void molecule::ActOnAllAtoms( res (atom::*f)(T, U) const, T t, U u ) const 364 { 365 atom *Walker = start; 366 while (Walker->next != end) { 367 Walker = Walker->next; 368 (Walker->*f)(t, u); 369 } 370 }; 299 371 // three argument 300 372 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V), T t, U u, V v) … … 322 394 } 323 395 }; 396 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V) const, T t, U u, V v) const 397 { 398 atom *Walker = start; 399 while (Walker->next != end) { 400 Walker = Walker->next; 401 (Walker->*f)(t, u, v); 402 } 403 }; 324 404 // four arguments 325 405 template <typename res, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V, W), T t, U u, V v, W w) … … 347 427 } 348 428 }; 429 template <typename res, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V, W) const, T t, U u, V v, W w) const 430 { 431 atom *Walker = start; 432 while (Walker->next != end) { 433 Walker = Walker->next; 434 (Walker->*f)(t, u, v, w); 435 } 436 }; 349 437 350 438 // ===================== Accesssing arrays indexed by some integer for each atom ====================== 351 439 352 440 // for atom ints 353 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int atom::*index, void (*Setor)(T *, T) )441 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, void (*Setor)(T *, T) ) 354 442 { 355 443 atom *Walker = start; … … 359 447 } 360 448 }; 361 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int atom::*index, void (*Setor)(T *, T), T value )449 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, void (*Setor)(T *, T), T value ) 362 450 { 363 451 atom *Walker = start; … … 384 472 } 385 473 }; 474 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, T (atom::*Setor)(Vector &), Vector atom::*value ) 475 { 476 atom *Walker = start; 477 while (Walker->next != end) { 478 Walker = Walker->next; 479 array[(Walker->*index)] = (Walker->*Setor) (Walker->*value); 480 } 481 }; 482 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, T (atom::*Setor)(Vector &), Vector &vect ) 483 { 484 atom *Walker = start; 485 while (Walker->next != end) { 486 Walker = Walker->next; 487 array[(Walker->*index)] = (Walker->*Setor) (vect); 488 } 489 }; 386 490 387 491 #endif /* MOLECULE_TEMPLATE_HPP_ */
Note:
See TracChangeset
for help on using the changeset viewer.