Changeset 4455f4
- Timestamp:
- Oct 19, 2009, 1:09:29 PM (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:
- c75de1
- Parents:
- 9eefda
- Location:
- src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/atom.cpp
r9eefda r4455f4 16 16 /************************************* Functions for class atom *************************************/ 17 17 18 /** Constructor of class AtomInfo. 19 */ 20 AtomInfo::AtomInfo() : type(NULL) {}; 21 22 /** Destructor of class AtomInfo. 23 */ 24 AtomInfo::~AtomInfo() 25 { 26 }; 27 28 /** Constructor of class TrajectoryParticleInfo. 29 */ 30 TrajectoryParticleInfo::TrajectoryParticleInfo() : FixedIon(0) {}; 31 32 /** Destructor of class TrajectoryParticleInfo. 33 */ 34 TrajectoryParticleInfo::~TrajectoryParticleInfo() 35 { 36 Trajectory.R.clear(); 37 Trajectory.U.clear(); 38 Trajectory.F.clear(); 39 }; 40 41 /** Constructor of class TrajectoryParticle. 42 */ 43 TrajectoryParticle::TrajectoryParticle() 44 { 45 }; 46 47 /** Destructor of class TrajectoryParticle. 48 */ 49 TrajectoryParticle::~TrajectoryParticle() 50 { 51 }; 52 53 /** Constructor of class GraphNodeInfo. 54 */ 55 GraphNodeInfo::GraphNodeInfo() : GraphNr(-1), ComponentNr(NULL), LowpointNr(-1), SeparationVertex(false), IsCyclic(false), Ancestor(NULL) {}; 56 57 /** Destructor of class GraphNodeInfo. 58 */ 59 GraphNodeInfo::~GraphNodeInfo() 60 { 61 Free<int>(&ComponentNr, "atom::~atom: *ComponentNr"); 62 }; 63 64 /** Constructor of class GraphNode. 65 */ 66 GraphNode::GraphNode() 67 { 68 }; 69 70 /** Destructor of class GraphNode. 71 */ 72 GraphNode::~GraphNode() 73 { 74 }; 75 76 /** Constructor of class BondedParticleInfo. 77 */ 78 BondedParticleInfo::BondedParticleInfo() : AdaptiveOrder(0), MaxOrder(false) {}; 79 80 /** Destructor of class BondedParticleInfo. 81 */ 82 BondedParticleInfo::~BondedParticleInfo() 83 { 84 }; 85 86 /** Constructor of class BondedParticle. 87 */ 88 BondedParticle::BondedParticle(){}; 89 90 /** Destructor of class BondedParticle. 91 */ 92 BondedParticle::~BondedParticle() 93 { 94 BondList::const_iterator Runner; 95 while (!ListOfBonds.empty()) { 96 Runner = ListOfBonds.begin(); 97 removewithoutcheck(*Runner); 98 } 99 }; 100 18 101 /** Constructor of class atom. 19 102 */ … … 23 106 previous = NULL; 24 107 next = NULL; 25 Ancestor = NULL; 26 type = NULL; 27 sort = NULL; 28 FixedIon = 0; 29 GraphNr = -1; 30 ComponentNr = NULL; 31 IsCyclic = false; 32 SeparationVertex = false; 33 LowpointNr = -1; 34 AdaptiveOrder = 0; 35 MaxOrder = false; 108 sort = &nr; 109 36 110 // set LCNode::Vector to our Vector 37 111 node = &x; … … 42 116 atom::atom(atom *pointer) 43 117 { 44 Name = NULL;45 118 previous = NULL; 46 119 next = NULL; 47 120 father = pointer; // generally, father is itself 48 Ancestor = NULL; 49 GraphNr = -1; 50 ComponentNr = NULL; 51 IsCyclic = false; 52 SeparationVertex = false; 53 LowpointNr = -1; 54 AdaptiveOrder = 0; 55 MaxOrder = false; 121 56 122 type = pointer->type; // copy element of atom 57 123 x.CopyVector(&pointer->x); // copy coordination 58 124 v.CopyVector(&pointer->v); // copy velocity 59 125 FixedIon = pointer->FixedIon; 60 nr = -1;61 126 sort = &nr; 62 127 node = &x; … … 68 133 atom::~atom() 69 134 { 70 BondList::const_iterator Runner;71 while (!ListOfBonds.empty()) {72 Runner = ListOfBonds.begin();73 removewithoutcheck(*Runner);74 }75 135 unlink(this); 76 Free<int>(&ComponentNr, "atom::~atom: *ComponentNr");77 Free<char>(&Name, "atom::~atom: *Name");78 Trajectory.R.clear();79 Trajectory.U.clear();80 Trajectory.F.clear();81 136 }; 82 137 … … 130 185 * \param bonds times bond::BondDegree 131 186 */ 132 int atom::CountBonds() const187 int BondedParticle::CountBonds() const 133 188 { 134 189 int NoBonds = 0; … … 233 288 }; 234 289 235 /** Output graph info ofthis atom.290 /** Outputs the MPQC configuration line for this atom. 236 291 * \param *out output stream 237 */ 238 void atom::OutputGraphInfo(ofstream *out) const 239 { 240 *out << Verbose(2) << "Atom " << Name << " is " << ((SeparationVertex) ? "a" : "not a") << " separation vertex, components are "; 241 OutputComponentNumber(out); 242 *out << " with Lowpoint " << LowpointNr << " and Graph Nr. " << GraphNr << "." << endl; 243 }; 244 245 /** Output a list of flags, stating whether the bond was visited or not. 246 * Note, we make use of the last entry of the ComponentNr always being -1 if allocated. 247 * \param *out output stream for debugging 248 */ 249 void atom::OutputComponentNumber(ofstream *out) const 250 { 251 if (ComponentNr != NULL) { 252 for (int i=0; ComponentNr[i] != -1; i++) 253 *out << ComponentNr[i] << " "; 254 } 255 }; 256 257 258 /** Prints all bonds of this atom with total degree. 259 * \param *out stream to output to 260 * \return true - \a *out present, false - \a *out is NULL 261 */ 262 bool atom::OutputBondOfAtom(ofstream *out) const 263 { 264 if (out != NULL) { 265 #ifdef ADDHYDROGEN 266 if (type->Z != 1) { // regard only non-hydrogen 267 #endif 268 *out << Verbose(4) << "Atom " << Name << "/" << nr << " with " << ListOfBonds.size() << " bonds: "; 269 int TotalDegree = 0; 270 for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); ++Runner) { 271 *out << **Runner << "\t"; 272 TotalDegree += (*Runner)->BondDegree; 273 } 274 *out << " -- TotalDegree: " << TotalDegree << endl; 275 #ifdef ADDHYDROGEN 276 } 277 #endif 292 * \param *center center of molecule subtracted from position 293 * \param *AtomNo pointer to atom counter that is increased by one 294 */ 295 void atom::OutputMPQCLine(ofstream *out, Vector *center, int *AtomNo = NULL) const 296 { 297 *out << "\t\t" << type->symbol << " [ " << x.x[0]-center->x[0] << "\t" << x.x[1]-center->x[1] << "\t" << x.x[2]-center->x[2] << " ]" << endl; 298 if (AtomNo != NULL) 299 *AtomNo++; 300 }; 301 302 ostream & operator << (ostream &ost, const ParticleInfo &a) 303 { 304 ost << "[" << a.Name << "|" << &a << "]"; 305 return ost; 306 }; 307 308 ostream & ParticleInfo::operator << (ostream &ost) 309 { 310 ost << "[" << Name << "|" << this << "]"; 311 return ost; 312 }; 313 314 /** Compares the indices of \a this atom with a given \a ptr. 315 * \param ptr atom to compare index against 316 * \return true - this one's is smaller, false - not 317 */ 318 bool atom::Compare(const atom &ptr) 319 { 320 if (nr < ptr.nr) 278 321 return true; 279 }else322 else 280 323 return false; 281 324 }; 282 325 283 /** Output of atom::nr along with all bond partners. 284 * \param *AdjacencyFile output stream 285 */ 286 void atom::OutputAdjacency(ofstream *AdjacencyFile) const 287 { 288 *AdjacencyFile << nr << "\t"; 289 for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); (++Runner)) 290 *AdjacencyFile << (*Runner)->GetOtherAtom(this)->nr << "\t"; 291 *AdjacencyFile << endl; 292 }; 293 294 /** Outputs the current atom::AdaptiveOrder and atom::MaxOrder to \a *file. 295 * \param *file output stream 296 */ 297 void atom::OutputOrder(ofstream *file) 298 { 299 *file << nr << "\t" << (int)AdaptiveOrder << "\t" << (int)MaxOrder << endl; 300 //cout << Verbose(2) << "Storing: " << nr << "\t" << (int)AdaptiveOrder << "\t" << (int)MaxOrder << "." << endl; 326 /** Returns squared distance to a given vector. 327 * \param origin vector to calculate distance to 328 * \return distance squared 329 */ 330 double atom::DistanceSquaredToVector(Vector &origin) 331 { 332 return origin.DistanceSquared(&x); 333 }; 334 335 /** Returns distance to a given vector. 336 * \param origin vector to calculate distance to 337 * \return distance 338 */ 339 double atom::DistanceToVector(Vector &origin) 340 { 341 return origin.Distance(&x); 301 342 }; 302 343 … … 313 354 }; 314 355 356 357 bool operator < (atom &a, atom &b) 358 { 359 return a.Compare(b); 360 }; 361 362 /** Output graph info of this atom. 363 * \param *out output stream 364 */ 365 void GraphNode::OutputGraphInfo(ofstream *out) const 366 { 367 *out << Verbose(2) << "Atom " << Name << " is " << ((SeparationVertex) ? "a" : "not a") << " separation vertex, components are "; 368 OutputComponentNumber(out); 369 *out << " with Lowpoint " << LowpointNr << " and Graph Nr. " << GraphNr << "." << endl; 370 }; 371 372 /** Output a list of flags, stating whether the bond was visited or not. 373 * Note, we make use of the last entry of the ComponentNr always being -1 if allocated. 374 * \param *out output stream for debugging 375 */ 376 void GraphNode::OutputComponentNumber(ofstream *out) const 377 { 378 if (ComponentNr != NULL) { 379 for (int i=0; ComponentNr[i] != -1; i++) 380 *out << ComponentNr[i] << " "; 381 } 382 }; 383 384 /** Outputs the current atom::AdaptiveOrder and atom::MaxOrder to \a *file. 385 * \param *file output stream 386 */ 387 void BondedParticle::OutputOrder(ofstream *file) 388 { 389 *file << nr << "\t" << (int)AdaptiveOrder << "\t" << (int)MaxOrder << endl; 390 //cout << Verbose(2) << "Storing: " << nr << "\t" << (int)AdaptiveOrder << "\t" << (int)MaxOrder << "." << endl; 391 }; 392 393 /** Prints all bonds of this atom with total degree. 394 * \param *out stream to output to 395 * \return true - \a *out present, false - \a *out is NULL 396 */ 397 bool BondedParticle::OutputBondOfAtom(ofstream *out) const 398 { 399 if (out != NULL) { 400 *out << Verbose(4) << "Atom " << Name << "/" << nr << " with " << ListOfBonds.size() << " bonds: "; 401 int TotalDegree = 0; 402 for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); ++Runner) { 403 *out << **Runner << "\t"; 404 TotalDegree += (*Runner)->BondDegree; 405 } 406 *out << " -- TotalDegree: " << TotalDegree << endl; 407 return true; 408 } else 409 return false; 410 }; 411 412 /** Output of atom::nr along with all bond partners. 413 * \param *AdjacencyFile output stream 414 */ 415 void BondedParticle::OutputAdjacency(ofstream *AdjacencyFile) const 416 { 417 *AdjacencyFile << nr << "\t"; 418 for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); (++Runner)) 419 *AdjacencyFile << (*Runner)->GetOtherAtom(this)->nr << "\t"; 420 *AdjacencyFile << endl; 421 }; 422 315 423 /** Puts a given bond into atom::ListOfBonds. 316 424 * \param *Binder bond to insert 317 425 */ 318 bool atom::RegisterBond(bond *Binder)426 bool BondedParticle::RegisterBond(bond *Binder) 319 427 { 320 428 bool status = false; … … 335 443 * \param *Binder bond to remove 336 444 */ 337 bool atom::UnregisterBond(bond *Binder)445 bool BondedParticle::UnregisterBond(bond *Binder) 338 446 { 339 447 bool status = false; … … 354 462 * \note Does not do any memory de-allocation. 355 463 */ 356 void atom::UnregisterAllBond()464 void BondedParticle::UnregisterAllBond() 357 465 { 358 466 ListOfBonds.clear(); … … 362 470 * \param *out output stream for debugging 363 471 */ 364 int atom::CorrectBondDegree(ofstream *out)472 int BondedParticle::CorrectBondDegree(ofstream *out) 365 473 { 366 474 int NoBonds = 0; … … 395 503 }; 396 504 397 ostream & operator << (ostream &ost, const atom &a) 398 { 399 ost << "[" << a.Name << "|" << &a << "]"; 400 return ost; 401 }; 402 403 ostream & atom::operator << (ostream &ost) 404 { 405 ost << "[" << Name << "|" << this << "]"; 406 return ost; 407 }; 408 409 /** Compares the indices of \a this atom with a given \a ptr. 410 * \param ptr atom to compare index against 411 * \return true - this one's is smaller, false - not 412 */ 413 bool atom::Compare(const atom &ptr) 414 { 415 if (nr < ptr.nr) 416 return true; 417 else 418 return false; 505 /** Adds kinetic energy of this atom to given temperature value. 506 * \param *temperature add on this value 507 * \param step given step of trajectory to add 508 */ 509 void TrajectoryParticle::AddKineticToTemperature(double *temperature, int step) const 510 { 511 for (int i=NDIM;i--;) 512 *temperature += type->mass * Trajectory.U.at(step).x[i]* Trajectory.U.at(step).x[i]; 513 }; 514 515 /** Evaluates some constraint potential if atom moves from \a startstep at once to \endstep in trajectory. 516 * \param startstep trajectory begins at 517 * \param endstep trajectory ends at 518 * \param **PermutationMap if atom switches places with some other atom, there is no translation but a permutaton noted here (not in the trajectories of each). 519 * \param *Force Force matrix to store result in 520 */ 521 void TrajectoryParticle::EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force) 522 { 523 double constant = 10.; 524 TrajectoryParticle *Sprinter = PermutationMap[nr]; 525 // set forces 526 for (int i=NDIM;i++;) 527 Force->Matrix[0][nr][5+i] += 2.*constant*sqrt(Trajectory.R.at(startstep).Distance(&Sprinter->Trajectory.R.at(endstep))); 528 }; 529 530 /** Correct velocity against the summed \a CoGVelocity for \a step. 531 * \param *ActualTemp sum up actual temperature meanwhile 532 * \param Step MD step in atom::Tracjetory 533 * \param *CoGVelocity remnant velocity (i.e. vector sum of all atom velocities) 534 */ 535 void TrajectoryParticle::CorrectVelocity(double *ActualTemp, int Step, Vector *CoGVelocity) 536 { 537 for(int d=0;d<NDIM;d++) { 538 Trajectory.U.at(Step).x[d] -= CoGVelocity->x[d]; 539 *ActualTemp += 0.5 * type->mass * Trajectory.U.at(Step).x[d] * Trajectory.U.at(Step).x[d]; 540 } 419 541 }; 420 542 … … 423 545 * \param MaxSteps 424 546 */ 425 void atom::ResizeTrajectory(int MaxSteps)547 void TrajectoryParticle::ResizeTrajectory(int MaxSteps) 426 548 { 427 549 if (Trajectory.R.size() <= (unsigned int)(MaxSteps)) { … … 437 559 * \param src index of source step 438 560 */ 439 void atom::CopyStepOnStep(int dest, int src)561 void TrajectoryParticle::CopyStepOnStep(int dest, int src) 440 562 { 441 563 if (dest == src) // self assignment check … … 455 577 * \param *Force matrix with forces 456 578 */ 457 void atom::VelocityVerletUpdate(int NextStep, config *configuration, ForceMatrix *Force)579 void TrajectoryParticle::VelocityVerletUpdate(int NextStep, config *configuration, ForceMatrix *Force) 458 580 { 459 581 //a = configuration.Deltat*0.5/walker->type->mass; // (F+F_old)/2m = a and thus: v = (F+F_old)/2m * t = (F + F_old) * a … … 484 606 * \param *TotalVelocity pointer to tota velocity sum 485 607 */ 486 void atom::SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity )608 void TrajectoryParticle::SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ) 487 609 { 488 610 *TotalMass += type->mass; // sum up total mass 489 611 for(int d=0;d<NDIM;d++) { 490 612 TotalVelocity->x[d] += Trajectory.U.at(Step).x[d]*type->mass; 491 }492 };493 494 /** Returns squared distance to a given vector.495 * \param origin vector to calculate distance to496 * \return distance squared497 */498 double atom::DistanceSquaredToVector(Vector &origin)499 {500 return origin.DistanceSquared(&x);501 };502 503 /** Adds kinetic energy of this atom to given temperature value.504 * \param *temperature add on this value505 * \param step given step of trajectory to add506 */507 void atom::AddKineticToTemperature(double *temperature, int step) const508 {509 for (int i=NDIM;i--;)510 *temperature += type->mass * Trajectory.U.at(step).x[i]* Trajectory.U.at(step).x[i];511 };512 513 /** Returns distance to a given vector.514 * \param origin vector to calculate distance to515 * \return distance516 */517 double atom::DistanceToVector(Vector &origin)518 {519 return origin.Distance(&x);520 };521 522 bool operator < (atom &a, atom &b)523 {524 return a.Compare(b);525 };526 527 /** Evaluates some constraint potential if atom moves from \a startstep at once to \endstep in trajectory.528 * \param startstep trajectory begins at529 * \param endstep trajectory ends at530 * \param **PermutationMap if atom switches places with some other atom, there is no translation but a permutaton noted here (not in the trajectories of each).531 * \param *Force Force matrix to store result in532 */533 void atom::EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force)534 {535 double constant = 10.;536 atom *Sprinter = PermutationMap[nr];537 // set forces538 for (int i=NDIM;i++;)539 Force->Matrix[0][nr][5+i] += 2.*constant*sqrt(Trajectory.R.at(startstep).Distance(&Sprinter->Trajectory.R.at(endstep)));540 };541 542 /** Correct velocity against the summed \a CoGVelocity for \a step.543 * \param *ActualTemp sum up actual temperature meanwhile544 * \param Step MD step in atom::Tracjetory545 * \param *CoGVelocity remnant velocity (i.e. vector sum of all atom velocities)546 */547 void atom::CorrectVelocity(double *ActualTemp, int Step, Vector *CoGVelocity)548 {549 for(int d=0;d<NDIM;d++) {550 Trajectory.U.at(Step).x[d] -= CoGVelocity->x[d];551 *ActualTemp += 0.5 * type->mass * Trajectory.U.at(Step).x[d] * Trajectory.U.at(Step).x[d];552 613 } 553 614 }; … … 558 619 * \param *ekin sum of kinetic energy 559 620 */ 560 void atom::Thermostat_Woodcock(double ScaleTempFactor, int Step, double *ekin)621 void TrajectoryParticle::Thermostat_Woodcock(double ScaleTempFactor, int Step, double *ekin) 561 622 { 562 623 double *U = Trajectory.U.at(Step).x; … … 573 634 * \param *E 574 635 */ 575 void atom::Thermostat_Gaussian_init(int Step, double *G, double *E)636 void TrajectoryParticle::Thermostat_Gaussian_init(int Step, double *G, double *E) 576 637 { 577 638 double *U = Trajectory.U.at(Step).x; … … 590 651 * \param *configuration configuration class with TempFrequency and TargetTemp 591 652 */ 592 void atom::Thermostat_Gaussian_least_constraint(int Step, double G_over_E, double *ekin, config *configuration)653 void TrajectoryParticle::Thermostat_Gaussian_least_constraint(int Step, double G_over_E, double *ekin, config *configuration) 593 654 { 594 655 double *U = Trajectory.U.at(Step).x; … … 606 667 * \param *configuration configuration class with TempFrequency and TargetTemp 607 668 */ 608 void atom::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration)669 void TrajectoryParticle::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration) 609 670 { 610 671 double sigma = sqrt(configuration->TargetTemp/type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime) … … 631 692 * \param *configuration configuration class with TempFrequency and Deltat 632 693 */ 633 void atom::Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration)694 void TrajectoryParticle::Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration) 634 695 { 635 696 double *U = Trajectory.U.at(Step).x; … … 646 707 * \param *delta_alpha additional sum of kinetic energy on return 647 708 */ 648 void atom::Thermostat_NoseHoover_init(int Step, double *delta_alpha)709 void TrajectoryParticle::Thermostat_NoseHoover_init(int Step, double *delta_alpha) 649 710 { 650 711 double *U = Trajectory.U.at(Step).x; … … 661 722 * \param *configuration configuration class with TempFrequency and Deltat 662 723 */ 663 void atom::Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration)724 void TrajectoryParticle::Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration) 664 725 { 665 726 double *U = Trajectory.U.at(Step).x; -
src/atom.hpp
r9eefda r4455f4 28 28 /****************************************** forward declarations *****************************/ 29 29 30 class atom; 30 31 class bond; 31 32 class config; … … 38 39 /********************************************** declarations *******************************/ 39 40 41 class AtomInfo { 42 public: 43 Vector x; //!< coordinate vector of atom, giving last position within cell 44 Vector v; //!< velocity vector of atom, giving last velocity within cell 45 Vector F; //!< Force vector of atom, giving last force within cell 46 element *type; //!< pointing to element 47 48 AtomInfo(); 49 ~AtomInfo(); 50 51 private: 52 }; 53 54 class TrajectoryParticleInfo { 55 public: 56 struct 57 { 58 vector<Vector> R; //!< position vector 59 vector<Vector> U; //!< velocity vector 60 vector<Vector> F; //!< last force vector 61 } Trajectory; 62 int FixedIon; //!< config variable that states whether forces act on the ion or not 63 64 TrajectoryParticleInfo(); 65 ~TrajectoryParticleInfo(); 66 67 private: 68 }; 69 70 class TrajectoryParticle : public TrajectoryParticleInfo, public virtual AtomInfo, public virtual ParticleInfo { 71 public: 72 73 TrajectoryParticle(); 74 virtual ~TrajectoryParticle(); 75 76 // constraint potential and dynamics stuff 77 void AddKineticToTemperature(double *temperature, int step) const; 78 void EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force); 79 void CorrectVelocity(double *ActualTemp, int Step, Vector *CoGVelocity); 80 81 // trajectory stuff 82 void ResizeTrajectory(int MaxSteps); 83 void CopyStepOnStep(int dest, int src); 84 void VelocityVerletUpdate(int MDSteps, config *configuration, ForceMatrix *Force); 85 void SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ); 86 87 // thermostats 88 void Thermostat_Woodcock(double ScaleTempFactor, int Step, double *ekin); 89 void Thermostat_Gaussian_init(int Step, double *G, double *E); 90 void Thermostat_Gaussian_least_constraint(int Step, double G_over_E, double *ekin, config *configuration); 91 void Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration); 92 void Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration); 93 void Thermostat_NoseHoover_init(int Step, double *delta_alpha); 94 void Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration); 95 96 private: 97 98 }; 99 100 class GraphNode; 101 102 class GraphNodeInfo { 103 public: 104 105 int GraphNr; //!< unique number, given in DepthFirstSearchAnalysis() 106 int *ComponentNr;//!< belongs to this non-separable components, given in DepthFirstSearchAnalysis() (if more than one, then is SeparationVertex) 107 int LowpointNr; //!< needed in DepthFirstSearchAnalysis() to detect non-separable components, is the lowest possible number of an atom to reach via tree edges only followed by at most one back edge. 108 bool SeparationVertex; //!< whether this atom separates off subsets of atoms or not, determined in DepthFirstSearchAnalysis() 109 bool IsCyclic; //!< whether atom belong to as cycle or not, determined in DepthFirstSearchAnalysis() 110 atom *Ancestor; //!< "Father" in Depth-First-Search 111 112 GraphNodeInfo(); 113 ~GraphNodeInfo(); 114 private: 115 116 }; 117 118 119 class GraphNode : public GraphNodeInfo, public virtual ParticleInfo { 120 public: 121 122 GraphNode(); 123 virtual ~GraphNode(); 124 125 void OutputGraphInfo(ofstream *out) const; 126 void OutputComponentNumber(ofstream *out) const; 127 128 private: 129 130 }; 131 132 class BondedParticleInfo { 133 public: 134 unsigned char AdaptiveOrder; //!< current present bond order at site (0 means "not set") 135 bool MaxOrder; //!< whether this atom as a root in fragmentation still creates more fragments on higher orders or not 136 BondList ListOfBonds; //!< list of all bonds 137 138 BondedParticleInfo(); 139 ~BondedParticleInfo(); 140 141 private: 142 143 }; 144 145 class BondedParticle : public BondedParticleInfo, public virtual ParticleInfo, public virtual AtomInfo { 146 public: 147 BondedParticle(); 148 virtual ~BondedParticle(); 149 150 bool RegisterBond(bond *Binder); 151 bool UnregisterBond(bond *Binder); 152 void UnregisterAllBond(); 153 int CountBonds() const; 154 int CorrectBondDegree(ofstream *out); 155 bool OutputBondOfAtom(ofstream *out) const; 156 void OutputAdjacency(ofstream *AdjacencyFile) const; 157 void OutputOrder(ofstream *file); 158 159 private: 160 161 }; 162 40 163 /** Single atom. 41 164 * Class incorporates position, type 42 165 */ 43 class atom : public TesselPoint {166 class atom : public TesselPoint, public TrajectoryParticle, public GraphNode, public BondedParticle, public virtual ParticleInfo, public virtual AtomInfo { 44 167 public: 45 struct46 {47 vector<Vector> R; //!< position vector48 vector<Vector> U; //!< velocity vector49 vector<Vector> F; //!< last force vector50 } Trajectory;51 52 Vector x; //!< coordinate vector of atom, giving last position within cell53 Vector v; //!< velocity vector of atom, giving last velocity within cell54 Vector F; //!< Force vector of atom, giving last force within cell55 BondList ListOfBonds; //!< list of all bonds56 element *type; //!< pointing to element57 168 atom *previous; //!< previous atom in molecule list 58 169 atom *next; //!< next atom in molecule list 59 170 atom *father; //!< In many-body bond order fragmentations points to originating atom 60 atom *Ancestor; //!< "Father" in Depth-First-Search61 //char *Name; //!< unique name used during many-body bond-order fragmentation, comes from TesselPoint62 int FixedIon; //!< config variable that states whether forces act on the ion or not63 171 int *sort; //!< sort criteria 64 //int nr; //!< continuous, unique number, comes from TesselPoint65 int GraphNr; //!< unique number, given in DepthFirstSearchAnalysis()66 int *ComponentNr;//!< belongs to this nonseparable components, given in DepthFirstSearchAnalysis() (if more than one, then is SeparationVertex)67 int LowpointNr; //!< needed in DepthFirstSearchAnalysis() to detect nonseparable components, is the lowest possible number of an atom to reach via tree edges only followed by at most one back edge.68 bool SeparationVertex; //!< whether this atom separates off subsets of atoms or not, determined in DepthFirstSearchAnalysis()69 bool IsCyclic; //!< whether atom belong to as cycle or not, determined in DepthFirstSearchAnalysis()70 unsigned char AdaptiveOrder; //!< current present bond order at site (0 means "not set")71 bool MaxOrder; //!< whether this atom as a root in fragmentation still creates more fragments on higher orders or not72 172 73 173 atom(); … … 80 180 bool OutputTrajectory(ofstream *out, int *ElementNo, int *AtomNo, int step) const; 81 181 bool OutputTrajectoryXYZ(ofstream *out, int step) const; 82 bool OutputBondOfAtom(ofstream *out) const; 83 void OutputAdjacency(ofstream *AdjacencyFile) const; 182 void OutputMPQCLine(ofstream *out, Vector *center, int *AtomNo) const; 84 183 184 void InitComponentNr(); 85 185 86 186 void EqualsFather ( atom *ptr, atom **res ); … … 89 189 bool Compare(const atom &ptr); 90 190 91 // trajectory stuff92 void ResizeTrajectory(int MaxSteps);93 void CopyStepOnStep(int dest, int src);94 void VelocityVerletUpdate(int MDSteps, config *configuration, ForceMatrix *Force);95 void SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity );96 97 191 double DistanceToVector(Vector &origin); 98 192 double DistanceSquaredToVector(Vector &origin); 99 100 193 bool IsInParallelepiped(Vector offset, double *parallelepiped); 101 102 // bond order stuff103 void OutputOrder(ofstream *file);104 void OutputGraphInfo(ofstream *out) const;105 void OutputComponentNumber(ofstream *out) const;106 void InitComponentNr();107 int CountBonds() const;108 int CorrectBondDegree(ofstream *out);109 110 bool RegisterBond(bond *Binder);111 bool UnregisterBond(bond *Binder);112 void UnregisterAllBond();113 114 // constraint potential and dynamics stuff115 void AddKineticToTemperature(double *temperature, int step) const;116 void EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force);117 void CorrectVelocity(double *ActualTemp, int Step, Vector *CoGVelocity);118 119 // thermostats120 void Thermostat_Woodcock(double ScaleTempFactor, int Step, double *ekin);121 void Thermostat_Gaussian_init(int Step, double *G, double *E);122 void Thermostat_Gaussian_least_constraint(int Step, double G_over_E, double *ekin, config *configuration);123 void Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration);124 void Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration);125 void Thermostat_NoseHoover_init(int Step, double *delta_alpha);126 void Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration);127 128 129 ostream & operator << (ostream &ost);130 194 131 195 private: 132 196 }; 133 197 134 ostream & operator << (ostream &ost, const atom &a);135 136 198 #endif /* ATOM_HPP_ */ -
src/bond.cpp
r9eefda r4455f4 95 95 * \return pointer to the other atom in the bond, NULL if no match (indicates something's wrong with the bond) 96 96 */ 97 atom * bond::GetOtherAtom(const atom*Atom) const97 atom * bond::GetOtherAtom(const ParticleInfo *Atom) const 98 98 { 99 99 if(leftatom == Atom) … … 118 118 * \return true if it is either bond::leftatom or bond::rightatom, false otherwise 119 119 */ 120 bool bond::Contains(const atom*ptr)120 bool bond::Contains(const ParticleInfo *ptr) 121 121 { 122 122 return ((leftatom == ptr) || (rightatom == ptr)); -
src/bond.hpp
r9eefda r4455f4 21 21 22 22 class atom; 23 class ParticleInfo; 23 24 24 25 /********************************************** declarations *******************************/ … … 43 44 enum EdgeType Type;//!< whether this is a tree or back edge 44 45 45 atom * GetOtherAtom(const atom*Atom) const;46 atom * GetOtherAtom(const ParticleInfo *Atom) const; 46 47 47 48 bool MarkUsed(enum Shading color); 48 49 enum Shading IsUsed(); 49 50 void ResetUsed(); 50 bool Contains(const atom*ptr);51 bool Contains(const ParticleInfo *ptr); 51 52 bool Contains(const int nr); 52 53 -
src/config.cpp
r9eefda r4455f4 9 9 #include "element.hpp" 10 10 #include "helpers.hpp" 11 #include "molecule.hpp" 11 12 #include "memoryallocator.hpp" 12 13 #include "molecule.hpp" … … 1444 1445 bool config::SaveMPQC(const char *filename, molecule *mol) const 1445 1446 { 1446 int ElementNo = 0;1447 1447 int AtomNo; 1448 atom *Walker = NULL;1449 element *runner = NULL;1450 1448 Vector *center = NULL; 1451 1449 ofstream *output = NULL; … … 1475 1473 center = mol->DetermineCenterOfAll(output); 1476 1474 // output of atoms 1477 runner = mol->elemente->start; 1478 while (runner->next != mol->elemente->end) { // go through every element 1479 runner = runner->next; 1480 if (mol->ElementsInMolecule[runner->Z]) { // if this element got atoms 1481 ElementNo++; 1482 AtomNo = 0; 1483 Walker = mol->start; 1484 while (Walker->next != mol->end) { // go through every atom of this element 1485 Walker = Walker->next; 1486 if (Walker->type == runner) { // if this atom fits to element 1487 AtomNo++; 1488 *output << "\t\t" << Walker->type->symbol << " [ " << Walker->x.x[0]-center->x[0] << "\t" << Walker->x.x[1]-center->x[1] << "\t" << Walker->x.x[2]-center->x[2] << " ]" << endl; 1489 } 1490 } 1491 } 1492 } 1475 AtomNo = 0; 1476 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, center, &AtomNo ); 1493 1477 delete(center); 1494 1478 *output << "\t}" << endl; … … 1524 1508 center = mol->DetermineCenterOfAll(output); 1525 1509 // output of atoms 1526 runner = mol->elemente->start; 1527 while (runner->next != mol->elemente->end) { // go through every element 1528 runner = runner->next; 1529 if (mol->ElementsInMolecule[runner->Z]) { // if this element got atoms 1530 ElementNo++; 1531 AtomNo = 0; 1532 Walker = mol->start; 1533 while (Walker->next != mol->end) { // go through every atom of this element 1534 Walker = Walker->next; 1535 if (Walker->type == runner) { // if this atom fits to element 1536 AtomNo++; 1537 *output << "\t\t" << Walker->type->symbol << " [ " << Walker->x.x[0]-center->x[0] << "\t" << Walker->x.x[1]-center->x[1] << "\t" << Walker->x.x[2]-center->x[2] << " ]" << endl; 1538 } 1539 } 1540 } 1541 } 1510 AtomNo = 0; 1511 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, center, &AtomNo ); 1542 1512 delete(center); 1543 1513 *output << "\t}" << endl; -
src/molecule.cpp
r9eefda r4455f4 1078 1078 for (int step=startstep;step < endstep; step++) { // loop over all time steps 1079 1079 temperature = 0.; 1080 ActOnAllAtoms( & atom::AddKineticToTemperature, &temperature, step);1080 ActOnAllAtoms( &TrajectoryParticle::AddKineticToTemperature, &temperature, step); 1081 1081 *output << step << "\t" << temperature*AtomicEnergyToKelvin << "\t" << temperature << endl; 1082 1082 } … … 1084 1084 }; 1085 1085 1086 void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int TesselPoint::*index)1086 void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index) 1087 1087 { 1088 1088 atom *Walker = start; -
src/molecule.hpp
r9eefda r4455f4 146 146 147 147 // templates for allowing global manipulation of all atoms 148 template <typename res > void ActOnAllAtoms( res (atom::*f)() );149 template <typename res > void ActOnAllAtoms( res (atom::*f)() const );150 template <typename res > void ActOnAllAtoms( res (atom::*f)() ) const;151 template <typename res > void ActOnAllAtoms( res (atom::*f)() const) const;152 template <typename res, typename T> void ActOnAllAtoms( res (atom::*f)(T), T t );153 template <typename res, typename T> void ActOnAllAtoms( res (atom::*f)(T) const, T t );154 template <typename res, typename T> void ActOnAllAtoms( res (atom::*f)(T), T t ) const;155 template <typename res, typename T> void ActOnAllAtoms( res (atom::*f)(T) const, T t ) const;156 template <typename res, typename T, typename U> void ActOnAllAtoms( res (atom::*f)(T, U), T t, U u );157 template <typename res, typename T, typename U> void ActOnAllAtoms( res (atom::*f)(T, U) const, T t, U u );158 template <typename res, typename T, typename U> void ActOnAllAtoms( res (atom::*f)(T, U), T t, U u ) const;159 template <typename res, typename T, typename U> void ActOnAllAtoms( res (atom::*f)(T, U) const, T t, U u ) const;160 template <typename res, typename T, typename U, typename V> void ActOnAllAtoms( res (atom::*f)(T, U, V), T t, U u, V v);161 template <typename res, typename T, typename U, typename V> void ActOnAllAtoms( res (atom::*f)(T, U, V) const, T t, U u, V v);162 template <typename res, typename T, typename U, typename V> void ActOnAllAtoms( res (atom::*f)(T, U, V), T t, U u, V v) const;163 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;164 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);165 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);166 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;167 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;148 template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() ); 149 template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() const ); 150 template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() ) const; 151 template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() const) const; 152 template <typename res, typename typ, typename T> void ActOnAllAtoms( res (typ::*f)(T), T t ); 153 template <typename res, typename typ, typename T> void ActOnAllAtoms( res (typ::*f)(T) const, T t ); 154 template <typename res, typename typ, typename T> void ActOnAllAtoms( res (typ::*f)(T), T t ) const; 155 template <typename res, typename typ, typename T> void ActOnAllAtoms( res (typ::*f)(T) const, T t ) const; 156 template <typename res, typename typ, typename T, typename U> void ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ); 157 template <typename res, typename typ, typename T, typename U> void ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ); 158 template <typename res, typename typ, typename T, typename U> void ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const; 159 template <typename res, typename typ, typename T, typename U> void ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const; 160 template <typename res, typename typ, typename T, typename U, typename V> void ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v); 161 template <typename res, typename typ, typename T, typename U, typename V> void ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v); 162 template <typename res, typename typ, typename T, typename U, typename V> void ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const; 163 template <typename res, typename typ, typename T, typename U, typename V> void ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const; 164 template <typename res, typename typ, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w); 165 template <typename res, typename typ, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w); 166 template <typename res, typename typ, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const; 167 template <typename res, typename typ, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const; 168 168 169 169 // templates for allowing conditional global copying of molecule with each atom as single argument … … 174 174 175 175 // templates for allowing global manipulation of an array with one entry per atom 176 void SetIndexedArrayForEachAtomTo ( atom **array, int TesselPoint::* index);177 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::* index, void (*Setor)(T *, T *));178 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::* index, void (*Setor)(T *, T *), T t);179 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::* index, void (*Setor)(T *, T *), T *t);180 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *));181 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *), T t);182 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *), T *t);183 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, T (atom::*Setor)(Vector &), Vector atom::*value);184 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, T (atom::*Setor)(Vector &), Vector &vect );176 void SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::* index); 177 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *)); 178 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *), T t); 179 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *), T *t); 180 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *)); 181 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *), T t); 182 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *), T *t); 183 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(Vector &), Vector atom::*value); 184 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(Vector &), Vector &vect ); 185 185 186 186 // templates for allowing global manipulation of each atom by entries in an array 187 template <typename T> void SetAtomValueToIndexedArray ( T *array, int TesselPoint::*index, T atom::*value ); 188 template <typename T> void SetAtomValueToIndexedArray ( T *array, int element::*index, T atom::*value ); 189 template <typename T> void SetAtomValueToValue ( T value, T atom::*ptr ); 190 191 template <typename res> res SumPerAtom(res (atom::*f)() ); 192 template <typename res> res SumPerAtom(res (atom::*f)() const ); 193 template <typename res> res SumPerAtom(res (atom::*f)() ) const; 194 template <typename res> res SumPerAtom(res (atom::*f)() const ) const; 195 template <typename T, typename res> res SumPerAtom(res (atom::*f)(T) , T t ); 196 template <typename T, typename res> res SumPerAtom(res (atom::*f)(T) const, T t ); 197 template <typename T, typename res> res SumPerAtom(res (atom::*f)(T) , T t ) const; 198 template <typename T, typename res> res SumPerAtom(res (atom::*f)(T) const, T t ) const; 187 template <typename T, typename typ, typename typ2> void SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ); 188 template <typename T, typename typ> void SetAtomValueToValue ( T value, T typ::*ptr ); 189 190 template <typename res, typename typ> res SumPerAtom(res (typ::*f)() ); 191 template <typename res, typename typ> res SumPerAtom(res (typ::*f)() const ); 192 template <typename res, typename typ> res SumPerAtom(res (typ::*f)() ) const; 193 template <typename res, typename typ> res SumPerAtom(res (typ::*f)() const ) const; 194 template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) , T t ); 195 template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) const, T t ); 196 template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) , T t ) const; 197 template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) const, T t ) const; 199 198 200 199 /// remove atoms from molecule. -
src/molecule_template.hpp
r9eefda r4455f4 156 156 157 157 // zero arguments 158 template <typename res > res molecule::SumPerAtom(res (atom::*f)() )158 template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() ) 159 159 { 160 160 res result = 0; … … 166 166 return result; 167 167 }; 168 template <typename res > res molecule::SumPerAtom(res (atom::*f)() const )168 template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const ) 169 169 { 170 170 res result = 0; … … 176 176 return result; 177 177 }; 178 template <typename res > res molecule::SumPerAtom(res (atom::*f)() ) const178 template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() ) const 179 179 { 180 180 res result = 0; … … 186 186 return result; 187 187 }; 188 template <typename res > res molecule::SumPerAtom(res (atom::*f)() const ) const188 template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const ) const 189 189 { 190 190 res result = 0; … … 197 197 }; 198 198 // one argument 199 template <typename T, typename res> res molecule::SumPerAtom(res (atom::*f)(T), T t )199 template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t ) 200 200 { 201 201 res result = 0; … … 207 207 return result; 208 208 }; 209 template <typename T, typename res> res molecule::SumPerAtom(res (atom::*f)(T) const, T t )209 template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t ) 210 210 { 211 211 res result = 0; … … 217 217 return result; 218 218 }; 219 template <typename T, typename res> res molecule::SumPerAtom(res (atom::*f)(T), T t ) const219 template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t ) const 220 220 { 221 221 res result = 0; … … 227 227 return result; 228 228 }; 229 template <typename T, typename res> res molecule::SumPerAtom(res (atom::*f)(T) const, T t ) const229 template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t ) const 230 230 { 231 231 res result = 0; … … 357 357 358 358 // zero arguments 359 template <typename res > void molecule::ActOnAllAtoms( res (atom::*f)())359 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) 360 360 { 361 361 atom *Walker = start; … … 365 365 } 366 366 }; 367 template <typename res > void molecule::ActOnAllAtoms( res (atom::*f)() const)367 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) 368 368 { 369 369 atom *Walker = start; … … 373 373 } 374 374 }; 375 template <typename res > void molecule::ActOnAllAtoms( res (atom::*f)()) const375 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const 376 376 { 377 377 atom *Walker = start; … … 381 381 } 382 382 }; 383 template <typename res > void molecule::ActOnAllAtoms( res (atom::*f)() const) const383 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const 384 384 { 385 385 atom *Walker = start; … … 390 390 }; 391 391 // one argument 392 template <typename res, typename T> void molecule::ActOnAllAtoms( res (atom::*f)(T), T t )392 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) 393 393 { 394 394 atom *Walker = start; … … 398 398 } 399 399 }; 400 template <typename res, typename T> void molecule::ActOnAllAtoms( res (atom::*f)(T) const, T t )400 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) 401 401 { 402 402 atom *Walker = start; … … 406 406 } 407 407 }; 408 template <typename res, typename T> void molecule::ActOnAllAtoms( res (atom::*f)(T), T t ) const408 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const 409 409 { 410 410 atom *Walker = start; … … 414 414 } 415 415 }; 416 template <typename res, typename T> void molecule::ActOnAllAtoms( res (atom::*f)(T) const, T t ) const416 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const 417 417 { 418 418 atom *Walker = start; … … 423 423 }; 424 424 // two argument 425 template <typename res, typename T, typename U> void molecule::ActOnAllAtoms( res (atom::*f)(T, U), T t, U u )425 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) 426 426 { 427 427 atom *Walker = start; … … 431 431 } 432 432 }; 433 template <typename res, typename T, typename U> void molecule::ActOnAllAtoms( res (atom::*f)(T, U) const, T t, U u )433 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) 434 434 { 435 435 atom *Walker = start; … … 439 439 } 440 440 }; 441 template <typename res, typename T, typename U> void molecule::ActOnAllAtoms( res (atom::*f)(T, U), T t, U u ) const441 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const 442 442 { 443 443 atom *Walker = start; … … 447 447 } 448 448 }; 449 template <typename res, typename T, typename U> void molecule::ActOnAllAtoms( res (atom::*f)(T, U) const, T t, U u ) const449 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const 450 450 { 451 451 atom *Walker = start; … … 456 456 }; 457 457 // three argument 458 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V), T t, U u, V v)458 template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) 459 459 { 460 460 atom *Walker = start; … … 464 464 } 465 465 }; 466 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)466 template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) 467 467 { 468 468 atom *Walker = start; … … 472 472 } 473 473 }; 474 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V), T t, U u, V v) const474 template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const 475 475 { 476 476 atom *Walker = start; … … 480 480 } 481 481 }; 482 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) const482 template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const 483 483 { 484 484 atom *Walker = start; … … 489 489 }; 490 490 // four arguments 491 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)491 template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) 492 492 { 493 493 atom *Walker = start; … … 497 497 } 498 498 }; 499 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)499 template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) 500 500 { 501 501 atom *Walker = start; … … 505 505 } 506 506 }; 507 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) const507 template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const 508 508 { 509 509 atom *Walker = start; … … 513 513 } 514 514 }; 515 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) const515 template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const 516 516 { 517 517 atom *Walker = start; … … 525 525 526 526 // for atom ints 527 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, void (*Setor)(T *, T *) )527 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) 528 528 { 529 529 atom *Walker = start; … … 534 534 } 535 535 }; 536 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, void (*Setor)(T *, T *), T value )536 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) 537 537 { 538 538 atom *Walker = start; … … 542 542 } 543 543 }; 544 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, void (*Setor)(T *, T *), T *value )544 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) 545 545 { 546 546 atom *Walker = start; … … 550 550 } 551 551 }; 552 // for element ints inside atom class552 // for element ints 553 553 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) 554 554 { … … 576 576 } 577 577 }; 578 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, T (atom::*Setor)(Vector &), Vector atom::*value ) 578 579 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(Vector &), Vector atom::*value ) 579 580 { 580 581 atom *Walker = start; … … 584 585 } 585 586 }; 586 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, T (atom::*Setor)(Vector &), Vector &vect )587 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(Vector &), Vector &vect ) 587 588 { 588 589 atom *Walker = start; … … 593 594 }; 594 595 595 template <typename T > void molecule::SetAtomValueToIndexedArray ( T *array, int TesselPoint::*index, T atom::*value )596 template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) 596 597 { 597 598 atom *Walker = start; … … 603 604 }; 604 605 605 template <typename T> void molecule::SetAtomValueToIndexedArray ( T *array, int element::*index, T atom::*value ) 606 { 607 atom *Walker = start; 608 while (Walker->next != end) { 609 Walker = Walker->next; 610 Walker->*value = array[(Walker->type->*index)]; 611 //cout << Verbose(2) << *Walker << " gets " << (Walker->*value) << endl; 612 } 613 }; 614 template <typename T> void molecule::SetAtomValueToValue ( T value, T atom::*ptr ) 606 template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) 615 607 { 616 608 atom *Walker = start; -
src/tesselation.cpp
r9eefda r4455f4 16 16 17 17 class molecule; 18 19 // =========================================== ParticleInfo ==================================== 20 21 /** Constructor of ParticleInfo. 22 */ 23 ParticleInfo::ParticleInfo() : nr(-1), Name(NULL) {}; 24 25 /** Destructor of ParticleInfo. 26 */ 27 ParticleInfo::~ParticleInfo() 28 { 29 Free(&Name); 30 }; 18 31 19 32 // ======================================== Points on Boundary ================================= -
src/tesselation.hpp
r9eefda r4455f4 25 25 26 26 #include "vector.hpp" 27 #include "helpers.hpp" 27 28 28 29 /****************************************** forward declarations *****************************/ … … 144 145 // =========================================================== class TESSELPOINT =========================================== 145 146 147 class ParticleInfo { 148 public: 149 int nr; // index to easierly identify 150 char *Name; // some name to reference to on output 151 152 ParticleInfo(); 153 ~ParticleInfo(); 154 155 ostream & operator << (ostream &ost); 156 157 private: 158 }; 159 160 ostream & operator << (ostream &ost, const ParticleInfo &a); 161 146 162 /** Is a single point of the set of Vectors, also a super-class to be inherited and and its functions to be implemented. 147 163 */ 148 class TesselPoint {164 class TesselPoint : virtual public ParticleInfo { 149 165 public: 150 166 TesselPoint(); … … 152 168 153 169 Vector *node; // pointer to position of the dot in space 154 int nr; // index to easierly identify155 char *Name; // some name to reference to on output156 170 157 171 virtual ostream & operator << (ostream &ost);
Note:
See TracChangeset
for help on using the changeset viewer.