source: src/molecule.cpp@ 60896f

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 Candidate_v1.7.0 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 60896f was 60896f, checked in by Frederik Heber <heber@…>, 15 years ago

BUGFIX: molecule::Add...Atom() and molecule::RemoveAtom() called formula::operator+ effectively twice.

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