source: src/molecule.cpp@ bf3817

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
Last change on this file since bf3817 was bf3817, checked in by Frederik Heber <heber@…>, 15 years ago

Added ifdef HAVE_CONFIG and config.h include to each and every cpp file.

  • is now topmost in front of MemDebug.hpp (and any other).
  • Property mode set to 100755
File size: 39.7 KB
Line 
1/** \file molecules.cpp
2 *
3 * Functions for the class molecule.
4 *
5 */
6
7// include config.h
8#ifdef HAVE_CONFIG_H
9#include <config.h>
10#endif
11
12#include "Helpers/MemDebug.hpp"
13
14#include <cstring>
15#include <boost/bind.hpp>
16#include <boost/foreach.hpp>
17
18#include <gsl/gsl_inline.h>
19#include <gsl/gsl_heapsort.h>
20
21#include "World.hpp"
22#include "atom.hpp"
23#include "bond.hpp"
24#include "config.hpp"
25#include "element.hpp"
26#include "graph.hpp"
27#include "Helpers/helpers.hpp"
28#include "leastsquaremin.hpp"
29#include "linkedcell.hpp"
30#include "lists.hpp"
31#include "Helpers/Log.hpp"
32#include "molecule.hpp"
33
34#include "periodentafel.hpp"
35#include "stackclass.hpp"
36#include "tesselation.hpp"
37#include "LinearAlgebra/Vector.hpp"
38#include "LinearAlgebra/Matrix.hpp"
39#include "World.hpp"
40#include "Box.hpp"
41#include "LinearAlgebra/Plane.hpp"
42#include "Exceptions/LinearDependenceException.hpp"
43
44
45/************************************* Functions for class molecule *********************************/
46
47/** Constructor of class molecule.
48 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero.
49 */
50molecule::molecule(const periodentafel * const teil) :
51 Observable("molecule"),
52 elemente(teil), MDSteps(0), BondCount(0), NoNonHydrogen(0), NoNonBonds(0),
53 NoCyclicBonds(0), BondDistance(0.), ActiveFlag(false), IndexNr(-1),
54 AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), last_atom(0), InternalPointer(atoms.begin())
55{
56
57 strcpy(name,World::getInstance().getDefaultName().c_str());
58};
59
60molecule *NewMolecule(){
61 return new molecule(World::getInstance().getPeriode());
62}
63
64/** Destructor of class molecule.
65 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero.
66 */
67molecule::~molecule()
68{
69 CleanupMolecule();
70};
71
72
73void DeleteMolecule(molecule *mol){
74 delete mol;
75}
76
77// getter and setter
78const std::string molecule::getName(){
79 return std::string(name);
80}
81
82int molecule::getAtomCount() const{
83 return *AtomCount;
84}
85
86void molecule::setName(const std::string _name){
87 OBSERVE;
88 cout << "Set name of molecule " << getId() << " to " << _name << endl;
89 strncpy(name,_name.c_str(),MAXSTRINGSIZE);
90}
91
92moleculeId_t molecule::getId(){
93 return id;
94}
95
96void molecule::setId(moleculeId_t _id){
97 id =_id;
98}
99
100const Formula &molecule::getFormula(){
101 return formula;
102}
103
104unsigned int molecule::getElementCount(){
105 return formula.getElementCount();
106}
107
108bool molecule::hasElement(const element *element) const{
109 return formula.hasElement(element);
110}
111
112bool molecule::hasElement(atomicNumber_t Z) const{
113 return formula.hasElement(Z);
114}
115
116bool molecule::hasElement(const string &shorthand) const{
117 return formula.hasElement(shorthand);
118}
119
120/************************** Access to the List of Atoms ****************/
121
122
123molecule::iterator molecule::begin(){
124 return molecule::iterator(atoms.begin(),this);
125}
126
127molecule::const_iterator molecule::begin() const{
128 return atoms.begin();
129}
130
131molecule::iterator molecule::end(){
132 return molecule::iterator(atoms.end(),this);
133}
134
135molecule::const_iterator molecule::end() const{
136 return atoms.end();
137}
138
139bool molecule::empty() const
140{
141 return (begin() == end());
142}
143
144size_t molecule::size() const
145{
146 size_t counter = 0;
147 for (molecule::const_iterator iter = begin(); iter != end (); ++iter)
148 counter++;
149 return counter;
150}
151
152molecule::const_iterator molecule::erase( const_iterator loc )
153{
154 OBSERVE;
155 molecule::const_iterator iter = loc;
156 iter--;
157 atom* atom = *loc;
158 atomIds.erase( atom->getId() );
159 atoms.remove( atom );
160 formula-=atom->getType();
161 atom->removeFromMolecule();
162 return iter;
163}
164
165molecule::const_iterator molecule::erase( atom * key )
166{
167 OBSERVE;
168 molecule::const_iterator iter = find(key);
169 if (iter != end()){
170 atomIds.erase( key->getId() );
171 atoms.remove( key );
172 formula-=key->getType();
173 key->removeFromMolecule();
174 }
175 return iter;
176}
177
178molecule::const_iterator molecule::find ( atom * key ) const
179{
180 molecule::const_iterator iter;
181 for (molecule::const_iterator Runner = begin(); Runner != end(); ++Runner) {
182 if (*Runner == key)
183 return molecule::const_iterator(Runner);
184 }
185 return molecule::const_iterator(atoms.end());
186}
187
188pair<molecule::iterator,bool> molecule::insert ( atom * const key )
189{
190 OBSERVE;
191 pair<atomIdSet::iterator,bool> res = atomIds.insert(key->getId());
192 if (res.second) { // push atom if went well
193 atoms.push_back(key);
194 formula+=key->getType();
195 return pair<iterator,bool>(molecule::iterator(--end()),res.second);
196 } else {
197 return pair<iterator,bool>(molecule::iterator(end()),res.second);
198 }
199}
200
201bool molecule::containsAtom(atom* key){
202 return (find(key) != end());
203}
204
205/** Adds given atom \a *pointer from molecule list.
206 * Increases molecule::last_atom and gives last number to added atom and names it according to its element::abbrev and molecule::AtomCount
207 * \param *pointer allocated and set atom
208 * \return true - succeeded, false - atom not found in list
209 */
210bool molecule::AddAtom(atom *pointer)
211{
212 OBSERVE;
213 if (pointer != NULL) {
214 pointer->sort = &pointer->nr;
215 if (pointer->getType() != NULL) {
216 formula += pointer->getType();
217 if (pointer->getType()->Z != 1)
218 NoNonHydrogen++;
219 if(pointer->getName() == "Unknown"){
220 stringstream sstr;
221 sstr << pointer->getType()->getSymbol() << pointer->nr+1;
222 pointer->setName(sstr.str());
223 }
224 }
225 insert(pointer);
226 pointer->setMolecule(this);
227 }
228 return true;
229};
230
231/** Adds a copy of the given atom \a *pointer from molecule list.
232 * Increases molecule::last_atom and gives last number to added atom.
233 * \param *pointer allocated and set atom
234 * \return pointer to the newly added atom
235 */
236atom * molecule::AddCopyAtom(atom *pointer)
237{
238 atom *retval = NULL;
239 OBSERVE;
240 if (pointer != NULL) {
241 atom *walker = pointer->clone();
242 formula += walker->getType();
243 walker->setName(pointer->getName());
244 walker->nr = last_atom++; // increase number within molecule
245 insert(walker);
246 if ((pointer->getType() != NULL) && (pointer->getType()->Z != 1))
247 NoNonHydrogen++;
248 retval=walker;
249 }
250 return retval;
251};
252
253/** Adds a Hydrogen atom in replacement for the given atom \a *partner in bond with a *origin.
254 * Here, we have to distinguish between single, double or triple bonds as stated by \a BondDegree, that each demand
255 * a different scheme when adding \a *replacement atom for the given one.
256 * -# Single Bond: Simply add new atom with bond distance rescaled to typical hydrogen one
257 * -# Double Bond: Here, we need the **BondList of the \a *origin atom, by scanning for the other bonds instead of
258 * *Bond, we use the through these connected atoms to determine the plane they lie in, vector::MakeNormalvector().
259 * The orthonormal vector to this plane along with the vector in *Bond direction determines the plane the two
260 * replacing hydrogens shall lie in. Now, all remains to do is take the usual hydrogen double bond angle for the
261 * element of *origin and form the sin/cos admixture of both plane vectors for the new coordinates of the two
262 * hydrogens forming this angle with *origin.
263 * -# Triple Bond: The idea is to set up a tetraoid (C1-H1-H2-H3) (however the lengths \f$b\f$ of the sides of the base
264 * triangle formed by the to be added hydrogens are not equal to the typical bond distance \f$l\f$ but have to be
265 * determined from the typical angle \f$\alpha\f$ for a hydrogen triple connected to the element of *origin):
266 * We have the height \f$d\f$ as the vector in *Bond direction (from triangle C1-H1-H2).
267 * \f[ h = l \cdot \cos{\left (\frac{\alpha}{2} \right )} \qquad b = 2l \cdot \sin{\left (\frac{\alpha}{2} \right)} \quad \rightarrow \quad d = l \cdot \sqrt{\cos^2{\left (\frac{\alpha}{2} \right)}-\frac{1}{3}\cdot\sin^2{\left (\frac{\alpha}{2}\right )}}
268 * \f]
269 * vector::GetNormalvector() creates one orthonormal vector from this *Bond vector and vector::MakeNormalvector creates
270 * the third one from the former two vectors. The latter ones form the plane of the base triangle mentioned above.
271 * The lengths for these are \f$f\f$ and \f$g\f$ (from triangle H1-H2-(center of H1-H2-H3)) with knowledge that
272 * the median lines in an isosceles triangle meet in the center point with a ratio 2:1.
273 * \f[ f = \frac{b}{\sqrt{3}} \qquad g = \frac{b}{2}
274 * \f]
275 * as the coordination of all three atoms in the coordinate system of these three vectors:
276 * \f$\pmatrix{d & f & 0}\f$, \f$\pmatrix{d & -0.5 \cdot f & g}\f$ and \f$\pmatrix{d & -0.5 \cdot f & -g}\f$.
277 *
278 * \param *out output stream for debugging
279 * \param *Bond pointer to bond between \a *origin and \a *replacement
280 * \param *TopOrigin son of \a *origin of upper level molecule (the atom added to this molecule as a copy of \a *origin)
281 * \param *origin pointer to atom which acts as the origin for scaling the added hydrogen to correct bond length
282 * \param *replacement pointer to the atom which shall be copied as a hydrogen atom in this molecule
283 * \param isAngstroem whether the coordination of the given atoms is in AtomicLength (false) or Angstrom(true)
284 * \return number of atoms added, if < bond::BondDegree then something went wrong
285 * \todo double and triple bonds splitting (always use the tetraeder angle!)
286 */
287bool molecule::AddHydrogenReplacementAtom(bond *TopBond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem)
288{
289 bool AllWentWell = true; // flag gathering the boolean return value of molecule::AddAtom and other functions, as return value on exit
290 OBSERVE;
291 double bondlength; // bond length of the bond to be replaced/cut
292 double bondangle; // bond angle of the bond to be replaced/cut
293 double BondRescale; // rescale value for the hydrogen bond length
294 bond *FirstBond = NULL, *SecondBond = NULL; // Other bonds in double bond case to determine "other" plane
295 atom *FirstOtherAtom = NULL, *SecondOtherAtom = NULL, *ThirdOtherAtom = NULL; // pointer to hydrogen atoms to be added
296 double b,l,d,f,g, alpha, factors[NDIM]; // hold temporary values in triple bond case for coordination determination
297 Vector Orthovector1, Orthovector2; // temporary vectors in coordination construction
298 Vector InBondvector; // vector in direction of *Bond
299 const Matrix &matrix = World::getInstance().getDomain().getM();
300 bond *Binder = NULL;
301
302// Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl;
303 // create vector in direction of bond
304 InBondvector = TopReplacement->getPosition() - TopOrigin->getPosition();
305 bondlength = InBondvector.Norm();
306
307 // is greater than typical bond distance? Then we have to correct periodically
308 // the problem is not the H being out of the box, but InBondvector have the wrong direction
309 // due to TopReplacement or Origin being on the wrong side!
310 if (bondlength > BondDistance) {
311// Log() << Verbose(4) << "InBondvector is: ";
312// InBondvector.Output(out);
313// Log() << Verbose(0) << endl;
314 Orthovector1.Zero();
315 for (int i=NDIM;i--;) {
316 l = TopReplacement->at(i) - TopOrigin->at(i);
317 if (fabs(l) > BondDistance) { // is component greater than bond distance
318 Orthovector1[i] = (l < 0) ? -1. : +1.;
319 } // (signs are correct, was tested!)
320 }
321 Orthovector1 *= matrix;
322 InBondvector -= Orthovector1; // subtract just the additional translation
323 bondlength = InBondvector.Norm();
324// Log() << Verbose(4) << "Corrected InBondvector is now: ";
325// InBondvector.Output(out);
326// Log() << Verbose(0) << endl;
327 } // periodic correction finished
328
329 InBondvector.Normalize();
330 // get typical bond length and store as scale factor for later
331 ASSERT(TopOrigin->getType() != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given.");
332 BondRescale = TopOrigin->getType()->HBondDistance[TopBond->BondDegree-1];
333 if (BondRescale == -1) {
334 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl);
335 return false;
336 BondRescale = bondlength;
337 } else {
338 if (!IsAngstroem)
339 BondRescale /= (1.*AtomicLengthToAngstroem);
340 }
341
342 // discern single, double and triple bonds
343 switch(TopBond->BondDegree) {
344 case 1:
345 FirstOtherAtom = World::getInstance().createAtom(); // new atom
346 FirstOtherAtom->setType(1); // element is Hydrogen
347 FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
348 FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
349 if (TopReplacement->getType()->Z == 1) { // neither rescale nor replace if it's already hydrogen
350 FirstOtherAtom->father = TopReplacement;
351 BondRescale = bondlength;
352 } else {
353 FirstOtherAtom->father = NULL; // if we replace hydrogen, we mark it as our father, otherwise we are just an added hydrogen with no father
354 }
355 InBondvector *= BondRescale; // rescale the distance vector to Hydrogen bond length
356 FirstOtherAtom->setPosition(TopOrigin->getPosition() + InBondvector); // set coordination to origin and add distance vector to replacement atom
357 AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
358// Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
359// FirstOtherAtom->x.Output(out);
360// Log() << Verbose(0) << endl;
361 Binder = AddBond(BottomOrigin, FirstOtherAtom, 1);
362 Binder->Cyclic = false;
363 Binder->Type = TreeEdge;
364 break;
365 case 2:
366 // determine two other bonds (warning if there are more than two other) plus valence sanity check
367 for (BondList::const_iterator Runner = TopOrigin->ListOfBonds.begin(); Runner != TopOrigin->ListOfBonds.end(); (++Runner)) {
368 if ((*Runner) != TopBond) {
369 if (FirstBond == NULL) {
370 FirstBond = (*Runner);
371 FirstOtherAtom = (*Runner)->GetOtherAtom(TopOrigin);
372 } else if (SecondBond == NULL) {
373 SecondBond = (*Runner);
374 SecondOtherAtom = (*Runner)->GetOtherAtom(TopOrigin);
375 } else {
376 DoeLog(2) && (eLog()<< Verbose(2) << "Detected more than four bonds for atom " << TopOrigin->getName());
377 }
378 }
379 }
380 if (SecondOtherAtom == NULL) { // then we have an atom with valence four, but only 3 bonds: one to replace and one which is TopBond (third is FirstBond)
381 SecondBond = TopBond;
382 SecondOtherAtom = TopReplacement;
383 }
384 if (FirstOtherAtom != NULL) { // then we just have this double bond and the plane does not matter at all
385// Log() << Verbose(3) << "Regarding the double bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") to be constructed: Taking " << FirstOtherAtom->Name << " and " << SecondOtherAtom->Name << " along with " << TopOrigin->Name << " to determine orthogonal plane." << endl;
386
387 // determine the plane of these two with the *origin
388 try {
389 Orthovector1 =Plane(TopOrigin->getPosition(), FirstOtherAtom->getPosition(), SecondOtherAtom->getPosition()).getNormal();
390 }
391 catch(LinearDependenceException &excp){
392 Log() << Verbose(0) << excp;
393 // TODO: figure out what to do with the Orthovector in this case
394 AllWentWell = false;
395 }
396 } else {
397 Orthovector1.GetOneNormalVector(InBondvector);
398 }
399 //Log() << Verbose(3)<< "Orthovector1: ";
400 //Orthovector1.Output(out);
401 //Log() << Verbose(0) << endl;
402 // orthogonal vector and bond vector between origin and replacement form the new plane
403 Orthovector1.MakeNormalTo(InBondvector);
404 Orthovector1.Normalize();
405 //Log() << Verbose(3) << "ReScaleCheck: " << Orthovector1.Norm() << " and " << InBondvector.Norm() << "." << endl;
406
407 // create the two Hydrogens ...
408 FirstOtherAtom = World::getInstance().createAtom();
409 SecondOtherAtom = World::getInstance().createAtom();
410 FirstOtherAtom->setType(1);
411 SecondOtherAtom->setType(1);
412 FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
413 FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
414 SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
415 SecondOtherAtom->FixedIon = TopReplacement->FixedIon;
416 FirstOtherAtom->father = NULL; // we are just an added hydrogen with no father
417 SecondOtherAtom->father = NULL; // we are just an added hydrogen with no father
418 bondangle = TopOrigin->getType()->HBondAngle[1];
419 if (bondangle == -1) {
420 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl);
421 return false;
422 bondangle = 0;
423 }
424 bondangle *= M_PI/180./2.;
425// Log() << Verbose(3) << "ReScaleCheck: InBondvector ";
426// InBondvector.Output(out);
427// Log() << Verbose(0) << endl;
428// Log() << Verbose(3) << "ReScaleCheck: Orthovector ";
429// Orthovector1.Output(out);
430// Log() << Verbose(0) << endl;
431// Log() << Verbose(3) << "Half the bond angle is " << bondangle << ", sin and cos of it: " << sin(bondangle) << ", " << cos(bondangle) << endl;
432 FirstOtherAtom->Zero();
433 SecondOtherAtom->Zero();
434 for(int i=NDIM;i--;) { // rotate by half the bond angle in both directions (InBondvector is bondangle = 0 direction)
435 FirstOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle)));
436 SecondOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle)));
437 }
438 FirstOtherAtom->Scale(BondRescale); // rescale by correct BondDistance
439 SecondOtherAtom->Scale(BondRescale);
440 //Log() << Verbose(3) << "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "." << endl;
441 *FirstOtherAtom += TopOrigin->getPosition();
442 *SecondOtherAtom += TopOrigin->getPosition();
443 // ... and add to molecule
444 AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
445 AllWentWell = AllWentWell && AddAtom(SecondOtherAtom);
446// Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
447// FirstOtherAtom->x.Output(out);
448// Log() << Verbose(0) << endl;
449// Log() << Verbose(4) << "Added " << *SecondOtherAtom << " at: ";
450// SecondOtherAtom->x.Output(out);
451// Log() << Verbose(0) << endl;
452 Binder = AddBond(BottomOrigin, FirstOtherAtom, 1);
453 Binder->Cyclic = false;
454 Binder->Type = TreeEdge;
455 Binder = AddBond(BottomOrigin, SecondOtherAtom, 1);
456 Binder->Cyclic = false;
457 Binder->Type = TreeEdge;
458 break;
459 case 3:
460 // take the "usual" tetraoidal angle and add the three Hydrogen in direction of the bond (height of the tetraoid)
461 FirstOtherAtom = World::getInstance().createAtom();
462 SecondOtherAtom = World::getInstance().createAtom();
463 ThirdOtherAtom = World::getInstance().createAtom();
464 FirstOtherAtom->setType(1);
465 SecondOtherAtom->setType(1);
466 ThirdOtherAtom->setType(1);
467 FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
468 FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
469 SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
470 SecondOtherAtom->FixedIon = TopReplacement->FixedIon;
471 ThirdOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
472 ThirdOtherAtom->FixedIon = TopReplacement->FixedIon;
473 FirstOtherAtom->father = NULL; // we are just an added hydrogen with no father
474 SecondOtherAtom->father = NULL; // we are just an added hydrogen with no father
475 ThirdOtherAtom->father = NULL; // we are just an added hydrogen with no father
476
477 // we need to vectors orthonormal the InBondvector
478 AllWentWell = AllWentWell && Orthovector1.GetOneNormalVector(InBondvector);
479// Log() << Verbose(3) << "Orthovector1: ";
480// Orthovector1.Output(out);
481// Log() << Verbose(0) << endl;
482 try{
483 Orthovector2 = Plane(InBondvector, Orthovector1,0).getNormal();
484 }
485 catch(LinearDependenceException &excp) {
486 Log() << Verbose(0) << excp;
487 AllWentWell = false;
488 }
489// Log() << Verbose(3) << "Orthovector2: ";
490// Orthovector2.Output(out);
491// Log() << Verbose(0) << endl;
492
493 // create correct coordination for the three atoms
494 alpha = (TopOrigin->getType()->HBondAngle[2])/180.*M_PI/2.; // retrieve triple bond angle from database
495 l = BondRescale; // desired bond length
496 b = 2.*l*sin(alpha); // base length of isosceles triangle
497 d = l*sqrt(cos(alpha)*cos(alpha) - sin(alpha)*sin(alpha)/3.); // length for InBondvector
498 f = b/sqrt(3.); // length for Orthvector1
499 g = b/2.; // length for Orthvector2
500// Log() << Verbose(3) << "Bond length and half-angle: " << l << ", " << alpha << "\t (b,d,f,g) = " << b << ", " << d << ", " << f << ", " << g << ", " << endl;
501// Log() << Verbose(3) << "The three Bond lengths: " << sqrt(d*d+f*f) << ", " << sqrt(d*d+(-0.5*f)*(-0.5*f)+g*g) << ", " << sqrt(d*d+(-0.5*f)*(-0.5*f)+g*g) << endl;
502 factors[0] = d;
503 factors[1] = f;
504 factors[2] = 0.;
505 FirstOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
506 factors[1] = -0.5*f;
507 factors[2] = g;
508 SecondOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
509 factors[2] = -g;
510 ThirdOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
511
512 // rescale each to correct BondDistance
513// FirstOtherAtom->x.Scale(&BondRescale);
514// SecondOtherAtom->x.Scale(&BondRescale);
515// ThirdOtherAtom->x.Scale(&BondRescale);
516
517 // and relative to *origin atom
518 *FirstOtherAtom += TopOrigin->getPosition();
519 *SecondOtherAtom += TopOrigin->getPosition();
520 *ThirdOtherAtom += TopOrigin->getPosition();
521
522 // ... and add to molecule
523 AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
524 AllWentWell = AllWentWell && AddAtom(SecondOtherAtom);
525 AllWentWell = AllWentWell && AddAtom(ThirdOtherAtom);
526// Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
527// FirstOtherAtom->x.Output(out);
528// Log() << Verbose(0) << endl;
529// Log() << Verbose(4) << "Added " << *SecondOtherAtom << " at: ";
530// SecondOtherAtom->x.Output(out);
531// Log() << Verbose(0) << endl;
532// Log() << Verbose(4) << "Added " << *ThirdOtherAtom << " at: ";
533// ThirdOtherAtom->x.Output(out);
534// Log() << Verbose(0) << endl;
535 Binder = AddBond(BottomOrigin, FirstOtherAtom, 1);
536 Binder->Cyclic = false;
537 Binder->Type = TreeEdge;
538 Binder = AddBond(BottomOrigin, SecondOtherAtom, 1);
539 Binder->Cyclic = false;
540 Binder->Type = TreeEdge;
541 Binder = AddBond(BottomOrigin, ThirdOtherAtom, 1);
542 Binder->Cyclic = false;
543 Binder->Type = TreeEdge;
544 break;
545 default:
546 DoeLog(1) && (eLog()<< Verbose(1) << "BondDegree does not state single, double or triple bond!" << endl);
547 AllWentWell = false;
548 break;
549 }
550
551// Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl;
552 return AllWentWell;
553};
554
555/** Adds given atom \a *pointer from molecule list.
556 * Increases molecule::last_atom and gives last number to added atom.
557 * \param filename name and path of xyz file
558 * \return true - succeeded, false - file not found
559 */
560bool molecule::AddXYZFile(string filename)
561{
562
563 istringstream *input = NULL;
564 int NumberOfAtoms = 0; // atom number in xyz read
565 int i, j; // loop variables
566 atom *Walker = NULL; // pointer to added atom
567 char shorthand[3]; // shorthand for atom name
568 ifstream xyzfile; // xyz file
569 string line; // currently parsed line
570 double x[3]; // atom coordinates
571
572 xyzfile.open(filename.c_str());
573 if (!xyzfile)
574 return false;
575
576 OBSERVE;
577 getline(xyzfile,line,'\n'); // Read numer of atoms in file
578 input = new istringstream(line);
579 *input >> NumberOfAtoms;
580 DoLog(0) && (Log() << Verbose(0) << "Parsing " << NumberOfAtoms << " atoms in file." << endl);
581 getline(xyzfile,line,'\n'); // Read comment
582 DoLog(1) && (Log() << Verbose(1) << "Comment: " << line << endl);
583
584 if (MDSteps == 0) // no atoms yet present
585 MDSteps++;
586 for(i=0;i<NumberOfAtoms;i++){
587 Walker = World::getInstance().createAtom();
588 getline(xyzfile,line,'\n');
589 istringstream *item = new istringstream(line);
590 //istringstream input(line);
591 //Log() << Verbose(1) << "Reading: " << line << endl;
592 *item >> shorthand;
593 *item >> x[0];
594 *item >> x[1];
595 *item >> x[2];
596 Walker->setType(elemente->FindElement(shorthand));
597 if (Walker->getType() == NULL) {
598 DoeLog(1) && (eLog()<< Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H.");
599 Walker->setType(1);
600 }
601 if (Walker->Trajectory.R.size() <= (unsigned int)MDSteps) {
602 Walker->Trajectory.R.resize(MDSteps+10);
603 Walker->Trajectory.U.resize(MDSteps+10);
604 Walker->Trajectory.F.resize(MDSteps+10);
605 }
606 Walker->setPosition(Vector(x));
607 for(j=NDIM;j--;) {
608 Walker->Trajectory.R.at(MDSteps-1)[j] = x[j];
609 Walker->Trajectory.U.at(MDSteps-1)[j] = 0;
610 Walker->Trajectory.F.at(MDSteps-1)[j] = 0;
611 }
612 AddAtom(Walker); // add to molecule
613 delete(item);
614 }
615 xyzfile.close();
616 delete(input);
617 return true;
618};
619
620/** Creates a copy of this molecule.
621 * \return copy of molecule
622 */
623molecule *molecule::CopyMolecule()
624{
625 molecule *copy = World::getInstance().createMolecule();
626
627 // copy all atoms
628 for_each(atoms.begin(),atoms.end(),bind1st(mem_fun(&molecule::AddCopyAtom),copy));
629
630 // copy all bonds
631 for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
632 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
633 if ((*BondRunner)->leftatom == *AtomRunner) {
634 bond *Binder = (*BondRunner);
635
636 // get the pendant atoms of current bond in the copy molecule
637 atomSet::iterator leftiter=find_if(atoms.begin(),atoms.end(),bind2nd(mem_fun(&atom::isFather),Binder->leftatom));
638 atomSet::iterator rightiter=find_if(atoms.begin(),atoms.end(),bind2nd(mem_fun(&atom::isFather),Binder->rightatom));
639 ASSERT(leftiter!=atoms.end(),"No original left atom for bondcopy found");
640 ASSERT(leftiter!=atoms.end(),"No original right atom for bondcopy found");
641 atom *LeftAtom = *leftiter;
642 atom *RightAtom = *rightiter;
643
644 bond *NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree);
645 NewBond->Cyclic = Binder->Cyclic;
646 if (Binder->Cyclic)
647 copy->NoCyclicBonds++;
648 NewBond->Type = Binder->Type;
649 }
650 // correct fathers
651 for_each(atoms.begin(),atoms.end(),mem_fun(&atom::CorrectFather));
652
653 // copy values
654 if (hasBondStructure()) { // if adjaceny list is present
655 copy->BondDistance = BondDistance;
656 }
657
658 return copy;
659};
660
661
662/**
663 * Copies all atoms of a molecule which are within the defined parallelepiped.
664 *
665 * @param offest for the origin of the parallelepiped
666 * @param three vectors forming the matrix that defines the shape of the parallelpiped
667 */
668molecule* molecule::CopyMoleculeFromSubRegion(const Shape &region) const {
669 molecule *copy = World::getInstance().createMolecule();
670
671 BOOST_FOREACH(atom *iter,atoms){
672 if(iter->IsInShape(region)){
673 copy->AddCopyAtom(iter);
674 }
675 }
676
677 //TODO: copy->BuildInducedSubgraph(this);
678
679 return copy;
680}
681
682/** Adds a bond to a the molecule specified by two atoms, \a *first and \a *second.
683 * Also updates molecule::BondCount and molecule::NoNonBonds.
684 * \param *first first atom in bond
685 * \param *second atom in bond
686 * \return pointer to bond or NULL on failure
687 */
688bond * molecule::AddBond(atom *atom1, atom *atom2, int degree)
689{
690 OBSERVE;
691 bond *Binder = NULL;
692
693 // some checks to make sure we are able to create the bond
694 ASSERT(atom1, "First atom in bond-creation was an invalid pointer");
695 ASSERT(atom2, "Second atom in bond-creation was an invalid pointer");
696 ASSERT(FindAtom(atom1->nr),"First atom in bond-creation was not part of molecule");
697 ASSERT(FindAtom(atom2->nr),"Second atom in bond-creation was not parto of molecule");
698
699 Binder = new bond(atom1, atom2, degree, BondCount++);
700 atom1->RegisterBond(Binder);
701 atom2->RegisterBond(Binder);
702 if ((atom1->getType() != NULL) && (atom1->getType()->Z != 1) && (atom2->getType() != NULL) && (atom2->getType()->Z != 1))
703 NoNonBonds++;
704
705 return Binder;
706};
707
708/** Remove bond from bond chain list and from the both atom::ListOfBonds.
709 * \todo Function not implemented yet
710 * \param *pointer bond pointer
711 * \return true - bound found and removed, false - bond not found/removed
712 */
713bool molecule::RemoveBond(bond *pointer)
714{
715 //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);
716 delete(pointer);
717 return true;
718};
719
720/** Remove every bond from bond chain list that atom \a *BondPartner is a constituent of.
721 * \todo Function not implemented yet
722 * \param *BondPartner atom to be removed
723 * \return true - bounds found and removed, false - bonds not found/removed
724 */
725bool molecule::RemoveBonds(atom *BondPartner)
726{
727 //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);
728 BondList::const_iterator ForeRunner;
729 while (!BondPartner->ListOfBonds.empty()) {
730 ForeRunner = BondPartner->ListOfBonds.begin();
731 RemoveBond(*ForeRunner);
732 }
733 return false;
734};
735
736/** Set molecule::name from the basename without suffix in the given \a *filename.
737 * \param *filename filename
738 */
739void molecule::SetNameFromFilename(const char *filename)
740{
741 int length = 0;
742 const char *molname = strrchr(filename, '/');
743 if (molname != NULL)
744 molname += sizeof(char); // search for filename without dirs
745 else
746 molname = filename; // contains no slashes
747 const char *endname = strchr(molname, '.');
748 if ((endname == NULL) || (endname < molname))
749 length = strlen(molname);
750 else
751 length = strlen(molname) - strlen(endname);
752 cout << "Set name of molecule " << getId() << " to " << molname << endl;
753 strncpy(name, molname, length);
754 name[length]='\0';
755};
756
757/** Sets the molecule::cell_size to the components of \a *dim (rectangular box)
758 * \param *dim vector class
759 */
760void molecule::SetBoxDimension(Vector *dim)
761{
762 Matrix domain;
763 for(int i =0; i<NDIM;++i)
764 domain.at(i,i) = dim->at(i);
765 World::getInstance().setDomain(domain);
766};
767
768/** Removes atom from molecule list and deletes it.
769 * \param *pointer atom to be removed
770 * \return true - succeeded, false - atom not found in list
771 */
772bool molecule::RemoveAtom(atom *pointer)
773{
774 ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom().");
775 OBSERVE;
776 formula-=pointer->getType();
777 RemoveBonds(pointer);
778 erase(pointer);
779 return true;
780};
781
782/** Removes atom from molecule list, but does not delete it.
783 * \param *pointer atom to be removed
784 * \return true - succeeded, false - atom not found in list
785 */
786bool molecule::UnlinkAtom(atom *pointer)
787{
788 if (pointer == NULL)
789 return false;
790 formula-=pointer->getType();
791 erase(pointer);
792 return true;
793};
794
795/** Removes every atom from molecule list.
796 * \return true - succeeded, false - atom not found in list
797 */
798bool molecule::CleanupMolecule()
799{
800 for (molecule::iterator iter = begin(); !empty(); iter = begin())
801 erase(iter);
802 return empty();
803};
804
805/** Finds an atom specified by its continuous number.
806 * \param Nr number of atom withim molecule
807 * \return pointer to atom or NULL
808 */
809atom * molecule::FindAtom(int Nr) const
810{
811 molecule::const_iterator iter = begin();
812 for (; iter != end(); ++iter)
813 if ((*iter)->nr == Nr)
814 break;
815 if (iter != end()) {
816 //Log() << Verbose(0) << "Found Atom Nr. " << walker->nr << endl;
817 return (*iter);
818 } else {
819 DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl);
820 return NULL;
821 }
822};
823
824/** Asks for atom number, and checks whether in list.
825 * \param *text question before entering
826 */
827atom * molecule::AskAtom(string text)
828{
829 int No;
830 atom *ion = NULL;
831 do {
832 //Log() << Verbose(0) << "============Atom list==========================" << endl;
833 //mol->Output((ofstream *)&cout);
834 //Log() << Verbose(0) << "===============================================" << endl;
835 DoLog(0) && (Log() << Verbose(0) << text);
836 cin >> No;
837 ion = this->FindAtom(No);
838 } while (ion == NULL);
839 return ion;
840};
841
842/** Checks if given coordinates are within cell volume.
843 * \param *x array of coordinates
844 * \return true - is within, false - out of cell
845 */
846bool molecule::CheckBounds(const Vector *x) const
847{
848 const Matrix &domain = World::getInstance().getDomain().getM();
849 bool result = true;
850 for (int i=0;i<NDIM;i++) {
851 result = result && ((x->at(i) >= 0) && (x->at(i) < domain.at(i,i)));
852 }
853 //return result;
854 return true; /// probably not gonna use the check no more
855};
856
857/** Prints molecule to *out.
858 * \param *out output stream
859 */
860bool molecule::Output(ostream * const output)
861{
862 if (output == NULL) {
863 return false;
864 } else {
865 int AtomNo[MAX_ELEMENTS];
866 memset(AtomNo,0,(MAX_ELEMENTS-1)*sizeof(*AtomNo));
867 enumeration<const element*> elementLookup = formula.enumerateElements();
868 for(map<const element*,unsigned int>::iterator iter=elementLookup.there.begin();
869 iter!=elementLookup.there.end();++iter){
870 cout << "Enumerated element " << *iter->first << " with number " << iter->second << endl;
871 }
872 *output << "#Ion_TypeNr._Nr.R[0] R[1] R[2] MoveType (0 MoveIon, 1 FixedIon)" << endl;
873 for_each(atoms.begin(),atoms.end(),boost::bind(&atom::OutputArrayIndexed,_1,output,elementLookup,AtomNo,(const char*)0));
874 return true;
875 }
876};
877
878/** Prints molecule with all atomic trajectory positions to *out.
879 * \param *out output stream
880 */
881bool molecule::OutputTrajectories(ofstream * const output)
882{
883 int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS];
884
885 if (output == NULL) {
886 return false;
887 } else {
888 for (int step = 0; step < MDSteps; step++) {
889 if (step == 0) {
890 *output << "#Ion_TypeNr._Nr.R[0] R[1] R[2] MoveType (0 MoveIon, 1 FixedIon)" << endl;
891 } else {
892 *output << "# ====== MD step " << step << " =========" << endl;
893 }
894 for (int i=0;i<MAX_ELEMENTS;++i) {
895 AtomNo[i] = 0;
896 ElementNo[i] = 0;
897 }
898 SetIndexedArrayForEachAtomTo ( ElementNo, &element::Z, &AbsoluteValue, 1);
899 int current=1;
900 for (int i=0;i<MAX_ELEMENTS;++i) {
901 if (ElementNo[i] == 1)
902 ElementNo[i] = current++;
903 }
904 ActOnAllAtoms( &atom::OutputTrajectory, output, (const int *)ElementNo, AtomNo, (const int)step );
905 }
906 return true;
907 }
908};
909
910/** Outputs contents of each atom::ListOfBonds.
911 * \param *out output stream
912 */
913void molecule::OutputListOfBonds() const
914{
915 DoLog(2) && (Log() << Verbose(2) << endl << "From Contents of ListOfBonds, all non-hydrogen atoms:" << endl);
916 for_each(atoms.begin(),atoms.end(),mem_fun(&atom::OutputBondOfAtom));
917 DoLog(0) && (Log() << Verbose(0) << endl);
918};
919
920/** Output of element before the actual coordination list.
921 * \param *out stream pointer
922 */
923bool molecule::Checkout(ofstream * const output) const
924{
925 return formula.checkOut(output);
926};
927
928/** Prints molecule with all its trajectories to *out as xyz file.
929 * \param *out output stream
930 */
931bool molecule::OutputTrajectoriesXYZ(ofstream * const output)
932{
933 time_t now;
934
935 if (output != NULL) {
936 now = time((time_t *)NULL); // Get the system time and put it into 'now' as 'calender time'
937 for (int step=0;step<MDSteps;step++) {
938 *output << getAtomCount() << "\n\tCreated by molecuilder, step " << step << ", on " << ctime(&now);
939 for_each(atoms.begin(),atoms.end(),boost::bind(&atom::OutputTrajectoryXYZ,_1,output,step));
940 }
941 return true;
942 } else
943 return false;
944};
945
946/** Prints molecule to *out as xyz file.
947* \param *out output stream
948 */
949bool molecule::OutputXYZ(ofstream * const output) const
950{
951 time_t now;
952
953 if (output != NULL) {
954 now = time((time_t *)NULL); // Get the system time and put it into 'now' as 'calender time'
955 *output << getAtomCount() << "\n\tCreated by molecuilder on " << ctime(&now);
956 for_each(atoms.begin(),atoms.end(),bind2nd(mem_fun(&atom::OutputXYZLine),output));
957 return true;
958 } else
959 return false;
960};
961
962/** Brings molecule::AtomCount and atom::*Name up-to-date.
963 * \param *out output stream for debugging
964 */
965int molecule::doCountAtoms()
966{
967 int res = size();
968 int i = 0;
969 NoNonHydrogen = 0;
970 for (molecule::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
971 (*iter)->nr = i; // update number in molecule (for easier referencing in FragmentMolecule lateron)
972 if ((*iter)->getType()->Z != 1) // count non-hydrogen atoms whilst at it
973 NoNonHydrogen++;
974 stringstream sstr;
975 sstr << (*iter)->getType()->getSymbol() << (*iter)->nr+1;
976 (*iter)->setName(sstr.str());
977 DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->getName() << "." << endl);
978 i++;
979 }
980 return res;
981};
982
983/** Returns an index map for two father-son-molecules.
984 * The map tells which atom in this molecule corresponds to which one in the other molecul with their fathers.
985 * \param *out output stream for debugging
986 * \param *OtherMolecule corresponding molecule with fathers
987 * \return allocated map of size molecule::AtomCount with map
988 * \todo make this with a good sort O(n), not O(n^2)
989 */
990int * molecule::GetFatherSonAtomicMap(molecule *OtherMolecule)
991{
992 DoLog(3) && (Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl);
993 int *AtomicMap = new int[getAtomCount()];
994 for (int i=getAtomCount();i--;)
995 AtomicMap[i] = -1;
996 if (OtherMolecule == this) { // same molecule
997 for (int i=getAtomCount();i--;) // no need as -1 means already that there is trivial correspondence
998 AtomicMap[i] = i;
999 DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl);
1000 } else {
1001 DoLog(4) && (Log() << Verbose(4) << "Map is ");
1002 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
1003 if ((*iter)->father == NULL) {
1004 AtomicMap[(*iter)->nr] = -2;
1005 } else {
1006 for (molecule::const_iterator runner = OtherMolecule->begin(); runner != OtherMolecule->end(); ++runner) {
1007 //for (int i=0;i<AtomCount;i++) { // search atom
1008 //for (int j=0;j<OtherMolecule->getAtomCount();j++) {
1009 //Log() << Verbose(4) << "Comparing father " << (*iter)->father << " with the other one " << (*runner)->father << "." << endl;
1010 if ((*iter)->father == (*runner))
1011 AtomicMap[(*iter)->nr] = (*runner)->nr;
1012 }
1013 }
1014 DoLog(0) && (Log() << Verbose(0) << AtomicMap[(*iter)->nr] << "\t");
1015 }
1016 DoLog(0) && (Log() << Verbose(0) << endl);
1017 }
1018 DoLog(3) && (Log() << Verbose(3) << "End of GetFatherAtomicMap." << endl);
1019 return AtomicMap;
1020};
1021
1022/** Stores the temperature evaluated from velocities in molecule::Trajectories.
1023 * We simply use the formula equivaleting temperature and kinetic energy:
1024 * \f$k_B T = \sum_i m_i v_i^2\f$
1025 * \param *output output stream of temperature file
1026 * \param startstep first MD step in molecule::Trajectories
1027 * \param endstep last plus one MD step in molecule::Trajectories
1028 * \return file written (true), failure on writing file (false)
1029 */
1030bool molecule::OutputTemperatureFromTrajectories(ofstream * const output, int startstep, int endstep)
1031{
1032 double temperature;
1033 // test stream
1034 if (output == NULL)
1035 return false;
1036 else
1037 *output << "# Step Temperature [K] Temperature [a.u.]" << endl;
1038 for (int step=startstep;step < endstep; step++) { // loop over all time steps
1039 temperature = 0.;
1040 ActOnAllAtoms( &TrajectoryParticle::AddKineticToTemperature, &temperature, step);
1041 *output << step << "\t" << temperature*AtomicEnergyToKelvin << "\t" << temperature << endl;
1042 }
1043 return true;
1044};
1045
1046void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index) const
1047{
1048 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
1049 array[((*iter)->*index)] = (*iter);
1050 }
1051};
1052
1053void molecule::flipActiveFlag(){
1054 ActiveFlag = !ActiveFlag;
1055}
Note: See TracBrowser for help on using the repository browser.