source: src/moleculelist.cpp@ e4a379

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 e4a379 was f7f7a4, checked in by Frederik Heber <heber@…>, 16 years ago

Implemenation of embedding merge, untested. LinearInterpolation now has switch for using identity map.

  • embed merge in MoleculeListClass determines the non-convex envelope and tries to fill the domain with the filler molecule everywhere outside of this domain
  • is added to MergeMolecule in builder.cpp, case 'e'
  • in molecule::LinearInterpolationBetweenConfiguration() now has additional parameter to tell whether we have to look for a mapping or use the identity.
  • Property mode set to 100755
File size: 40.4 KB
Line 
1/** \file MoleculeListClass.cpp
2 *
3 * Function implementations for the class MoleculeListClass.
4 *
5 */
6
7#include "boundary.hpp"
8#include "config.hpp"
9#include "molecules.hpp"
10
11/*********************************** Functions for class MoleculeListClass *************************/
12
13/** Constructor for MoleculeListClass.
14 */
15MoleculeListClass::MoleculeListClass()
16{
17 // empty lists
18 ListOfMolecules.clear();
19 MaxIndex = 1;
20};
21
22/** Destructor for MoleculeListClass.
23 */
24MoleculeListClass::~MoleculeListClass()
25{
26 cout << Verbose(3) << this << ": Freeing ListOfMolcules." << endl;
27 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
28 cout << Verbose(4) << "ListOfMolecules: Freeing " << *ListRunner << "." << endl;
29 delete (*ListRunner);
30 }
31 cout << Verbose(4) << "Freeing ListOfMolecules." << endl;
32 ListOfMolecules.clear(); // empty list
33};
34
35/** Insert a new molecule into the list and set its number.
36 * \param *mol molecule to add to list.
37 * \return true - add successful
38 */
39void MoleculeListClass::insert(molecule *mol)
40{
41 mol->IndexNr = MaxIndex++;
42 ListOfMolecules.push_back(mol);
43};
44
45/** Compare whether two molecules are equal.
46 * \param *a molecule one
47 * \param *n molecule two
48 * \return lexical value (-1, 0, +1)
49 */
50int MolCompare(const void *a, const void *b)
51{
52 int *aList = NULL, *bList = NULL;
53 int Count, Counter, aCounter, bCounter;
54 int flag;
55 atom *aWalker = NULL;
56 atom *bWalker = NULL;
57
58 // sort each atom list and put the numbers into a list, then go through
59 //cout << "Comparing fragment no. " << *(molecule **)a << " to " << *(molecule **)b << "." << endl;
60 if ((**(molecule **) a).AtomCount < (**(molecule **) b).AtomCount) {
61 return -1;
62 } else {
63 if ((**(molecule **) a).AtomCount > (**(molecule **) b).AtomCount)
64 return +1;
65 else {
66 Count = (**(molecule **) a).AtomCount;
67 aList = new int[Count];
68 bList = new int[Count];
69
70 // fill the lists
71 aWalker = (**(molecule **) a).start;
72 bWalker = (**(molecule **) b).start;
73 Counter = 0;
74 aCounter = 0;
75 bCounter = 0;
76 while ((aWalker->next != (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {
77 aWalker = aWalker->next;
78 bWalker = bWalker->next;
79 if (aWalker->GetTrueFather() == NULL)
80 aList[Counter] = Count + (aCounter++);
81 else
82 aList[Counter] = aWalker->GetTrueFather()->nr;
83 if (bWalker->GetTrueFather() == NULL)
84 bList[Counter] = Count + (bCounter++);
85 else
86 bList[Counter] = bWalker->GetTrueFather()->nr;
87 Counter++;
88 }
89 // check if AtomCount was for real
90 flag = 0;
91 if ((aWalker->next == (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {
92 flag = -1;
93 } else {
94 if ((aWalker->next != (**(molecule **) a).end) && (bWalker->next == (**(molecule **) b).end))
95 flag = 1;
96 }
97 if (flag == 0) {
98 // sort the lists
99 gsl_heapsort(aList, Count, sizeof(int), CompareDoubles);
100 gsl_heapsort(bList, Count, sizeof(int), CompareDoubles);
101 // compare the lists
102
103 flag = 0;
104 for (int i = 0; i < Count; i++) {
105 if (aList[i] < bList[i]) {
106 flag = -1;
107 } else {
108 if (aList[i] > bList[i])
109 flag = 1;
110 }
111 if (flag != 0)
112 break;
113 }
114 }
115 delete[] (aList);
116 delete[] (bList);
117 return flag;
118 }
119 }
120 return -1;
121};
122
123/** Output of a list of all molecules.
124 * \param *out output stream
125 */
126void MoleculeListClass::Enumerate(ofstream *out)
127{
128 element* Elemental = NULL;
129 atom *Walker = NULL;
130 int Counts[MAX_ELEMENTS];
131 double size=0;
132 Vector Origin;
133
134 // header
135 *out << "Index\tName\t\tAtoms\tFormula\tCenter\tSize" << endl;
136 cout << Verbose(0) << "-----------------------------------------------" << endl;
137 if (ListOfMolecules.size() == 0)
138 *out << "\tNone" << endl;
139 else {
140 Origin.Zero();
141 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
142 // reset element counts
143 for (int j = 0; j<MAX_ELEMENTS;j++)
144 Counts[j] = 0;
145 // count atoms per element and determine size of bounding sphere
146 size=0.;
147 Walker = (*ListRunner)->start;
148 while (Walker->next != (*ListRunner)->end) {
149 Walker = Walker->next;
150 Counts[Walker->type->Z]++;
151 if (Walker->x.DistanceSquared(&Origin) > size)
152 size = Walker->x.DistanceSquared(&Origin);
153 }
154 // output Index, Name, number of atoms, chemical formula
155 *out << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->AtomCount << "\t";
156 Elemental = (*ListRunner)->elemente->end;
157 while(Elemental->previous != (*ListRunner)->elemente->start) {
158 Elemental = Elemental->previous;
159 if (Counts[Elemental->Z] != 0)
160 *out << Elemental->symbol << Counts[Elemental->Z];
161 }
162 // Center and size
163 *out << "\t" << (*ListRunner)->Center << "\t" << sqrt(size) << endl;
164 }
165 }
166};
167
168/** Returns the molecule with the given index \a index.
169 * \param index index of the desired molecule
170 * \return pointer to molecule structure, NULL if not found
171 */
172molecule * MoleculeListClass::ReturnIndex(int index)
173{
174 for(MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++)
175 if ((*ListRunner)->IndexNr == index)
176 return (*ListRunner);
177 return NULL;
178};
179
180/** Simple merge of two molecules into one.
181 * \param *mol destination molecule
182 * \param *srcmol source molecule
183 * \return true - merge successful, false - merge failed (probably due to non-existant indices
184 */
185bool MoleculeListClass::SimpleMerge(molecule *mol, molecule *srcmol)
186{
187 if (srcmol == NULL)
188 return false;
189
190 // put all molecules of src into mol
191 atom *Walker = srcmol->start;
192 atom *NextAtom = Walker->next;
193 while (NextAtom != srcmol->end) {
194 Walker = NextAtom;
195 NextAtom = Walker->next;
196 srcmol->UnlinkAtom(Walker);
197 mol->AddAtom(Walker);
198 }
199
200 // remove src
201 ListOfMolecules.remove(srcmol);
202 delete(srcmol);
203 return true;
204};
205
206/** Simple add of one molecules into another.
207 * \param *mol destination molecule
208 * \param *srcmol source molecule
209 * \return true - merge successful, false - merge failed (probably due to non-existant indices
210 */
211bool MoleculeListClass::SimpleAdd(molecule *mol, molecule *srcmol)
212{
213 if (srcmol == NULL)
214 return false;
215
216 // put all molecules of src into mol
217 atom *Walker = srcmol->start;
218 atom *NextAtom = Walker->next;
219 while (NextAtom != srcmol->end) {
220 Walker = NextAtom;
221 NextAtom = Walker->next;
222 Walker = mol->AddCopyAtom(Walker);
223 Walker->father = Walker;
224 }
225
226 return true;
227};
228
229/** Simple merge of a given set of molecules into one.
230 * \param *mol destination molecule
231 * \param *src index of set of source molecule
232 * \param N number of source molecules
233 * \return true - merge successful, false - some merges failed (probably due to non-existant indices)
234 */
235bool MoleculeListClass::SimpleMultiMerge(molecule *mol, int *src, int N)
236{
237 bool status = true;
238 // check presence of all source molecules
239 for (int i=0;i<N;i++) {
240 molecule *srcmol = ReturnIndex(src[i]);
241 status = status && SimpleMerge(mol, srcmol);
242 }
243 return status;
244};
245
246/** Simple add of a given set of molecules into one.
247 * \param *mol destination molecule
248 * \param *src index of set of source molecule
249 * \param N number of source molecules
250 * \return true - merge successful, false - some merges failed (probably due to non-existant indices)
251 */
252bool MoleculeListClass::SimpleMultiAdd(molecule *mol, int *src, int N)
253{
254 bool status = true;
255 // check presence of all source molecules
256 for (int i=0;i<N;i++) {
257 molecule *srcmol = ReturnIndex(src[i]);
258 status = status && SimpleAdd(mol, srcmol);
259 }
260 return status;
261};
262
263/** Scatter merge of a given set of molecules into one.
264 * Scatter merge distributes the molecules in such a manner that they don't overlap.
265 * \param *mol destination molecule
266 * \param *src index of set of source molecule
267 * \param N number of source molecules
268 * \return true - merge successful, false - merge failed (probably due to non-existant indices
269 * \TODO find scatter center for each src molecule
270 */
271bool MoleculeListClass::ScatterMerge(molecule *mol, int *src, int N)
272{
273 // check presence of all source molecules
274 for (int i=0;i<N;i++) {
275 // get pointer to src molecule
276 molecule *srcmol = ReturnIndex(src[i]);
277 if (srcmol == NULL)
278 return false;
279 }
280 // adapt each Center
281 for (int i=0;i<N;i++) {
282 // get pointer to src molecule
283 molecule *srcmol = ReturnIndex(src[i]);
284 //srcmol->Center.Zero();
285 srcmol->Translate(&srcmol->Center);
286 }
287 // perform a simple multi merge
288 SimpleMultiMerge(mol, src, N);
289 return true;
290};
291
292/** Embedding merge of a given set of molecules into one.
293 * Embedding merge inserts one molecule into the other.
294 * \param *mol destination molecule (fixed one)
295 * \param *srcmol source molecule (variable one, where atoms are taken from)
296 * \return true - merge successful, false - merge failed (probably due to non-existant indices)
297 * \TODO linked cell dimensions for boundary points has to be as big as inner diameter!
298 */
299bool MoleculeListClass::EmbedMerge(molecule *mol, molecule *srcmol)
300{
301 if ((srcmol == NULL) || (mol == NULL)) {
302 cout << Verbose(1) << "ERROR: Either fixed or variable molecule is given as NULL." << endl;
303 return false;
304 }
305
306 // calculate envelope for *mol
307 LinkedCell *LCList = new LinkedCell(mol, 8.);
308 FindNonConvexBorder((ofstream *)&cout, mol, LCList, 4., NULL);
309 if (mol->TesselStruct == NULL) {
310 cout << Verbose(1) << "ERROR: Could not tesselate the fixed molecule." << endl;
311 return false;
312 }
313 delete(LCList);
314 LCList = new LinkedCell(mol->TesselStruct, 8.); // re-create with boundary points only!
315
316 // prepare index list for bonds
317 srcmol->CountAtoms((ofstream *)&cout);
318 atom ** CopyAtoms = new atom*[srcmol->AtomCount];
319 for(int i=0;i<srcmol->AtomCount;i++)
320 CopyAtoms[i] = NULL;
321
322 // for each of the source atoms check whether we are in- or outside and add copy atom
323 atom *Walker = srcmol->start;
324 int nr=0;
325 while (Walker->next != srcmol->end) {
326 Walker = Walker->next;
327 cout << Verbose(2) << "INFO: Current Walker is " << *Walker << "." << endl;
328 if (!mol->TesselStruct->IsInnerPoint((ofstream *)&cout, Walker->x, LCList)) {
329 CopyAtoms[Walker->nr] = new atom(Walker);
330 mol->AddAtom(CopyAtoms[Walker->nr]);
331 nr++;
332 } else {
333 // do nothing
334 }
335 }
336 cout << Verbose(1) << nr << " of " << srcmol->AtomCount << " atoms have been merged.";
337
338 // go through all bonds and add as well
339 bond *Binder = srcmol->first;
340 while(Binder->next != srcmol->last) {
341 Binder = Binder->next;
342 cout << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;
343 mol->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
344 }
345 delete(LCList);
346 return true;
347};
348
349/** Simple output of the pointers in ListOfMolecules.
350 * \param *out output stream
351 */
352void MoleculeListClass::Output(ofstream *out)
353{
354 *out << Verbose(1) << "MoleculeList: ";
355 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++)
356 *out << *ListRunner << "\t";
357 *out << endl;
358};
359
360/** Calculates necessary hydrogen correction due to unwanted interaction between saturated ones.
361 * If for a pair of two hydrogen atoms a and b, at least is a saturated one, and a and b are not
362 * bonded to the same atom, then we add for this pair a correction term constructed from a Morse
363 * potential function fit to QM calculations with respecting to the interatomic hydrogen distance.
364 * \param *out output stream for debugging
365 * \param *path path to file
366 */
367bool MoleculeListClass::AddHydrogenCorrection(ofstream *out, char *path)
368{
369 atom *Walker = NULL;
370 atom *Runner = NULL;
371 double ***FitConstant = NULL, **correction = NULL;
372 int a, b;
373 ofstream output;
374 ifstream input;
375 string line;
376 stringstream zeile;
377 double distance;
378 char ParsedLine[1023];
379 double tmp;
380 char *FragmentNumber = NULL;
381
382 cout << Verbose(1) << "Saving hydrogen saturation correction ... ";
383 // 0. parse in fit constant files that should have the same dimension as the final energy files
384 // 0a. find dimension of matrices with constants
385 line = path;
386 line.append("/");
387 line += FRAGMENTPREFIX;
388 line += "1";
389 line += FITCONSTANTSUFFIX;
390 input.open(line.c_str());
391 if (input == NULL) {
392 cerr << endl << "Unable to open " << line << ", is the directory correct?"
393 << endl;
394 return false;
395 }
396 a = 0;
397 b = -1; // we overcount by one
398 while (!input.eof()) {
399 input.getline(ParsedLine, 1023);
400 zeile.str(ParsedLine);
401 int i = 0;
402 while (!zeile.eof()) {
403 zeile >> distance;
404 i++;
405 }
406 if (i > a)
407 a = i;
408 b++;
409 }
410 cout << "I recognized " << a << " columns and " << b << " rows, ";
411 input.close();
412
413 // 0b. allocate memory for constants
414 FitConstant = (double ***) Malloc(sizeof(double **) * 3, "MoleculeListClass::AddHydrogenCorrection: ***FitConstant");
415 for (int k = 0; k < 3; k++) {
416 FitConstant[k] = (double **) Malloc(sizeof(double *) * a, "MoleculeListClass::AddHydrogenCorrection: **FitConstant[]");
417 for (int i = a; i--;) {
418 FitConstant[k][i] = (double *) Malloc(sizeof(double) * b, "MoleculeListClass::AddHydrogenCorrection: *FitConstant[][]");
419 }
420 }
421 // 0c. parse in constants
422 for (int i = 0; i < 3; i++) {
423 line = path;
424 line.append("/");
425 line += FRAGMENTPREFIX;
426 sprintf(ParsedLine, "%d", i + 1);
427 line += ParsedLine;
428 line += FITCONSTANTSUFFIX;
429 input.open(line.c_str());
430 if (input == NULL) {
431 cerr << endl << "Unable to open " << line << ", is the directory correct?" << endl;
432 return false;
433 }
434 int k = 0, l;
435 while ((!input.eof()) && (k < b)) {
436 input.getline(ParsedLine, 1023);
437 //cout << "Current Line: " << ParsedLine << endl;
438 zeile.str(ParsedLine);
439 zeile.clear();
440 l = 0;
441 while ((!zeile.eof()) && (l < a)) {
442 zeile >> FitConstant[i][l][k];
443 //cout << FitConstant[i][l][k] << "\t";
444 l++;
445 }
446 //cout << endl;
447 k++;
448 }
449 input.close();
450 }
451 for (int k = 0; k < 3; k++) {
452 cout << "Constants " << k << ":" << endl;
453 for (int j = 0; j < b; j++) {
454 for (int i = 0; i < a; i++) {
455 cout << FitConstant[k][i][j] << "\t";
456 }
457 cout << endl;
458 }
459 cout << endl;
460 }
461
462 // 0d. allocate final correction matrix
463 correction = (double **) Malloc(sizeof(double *) * a, "MoleculeListClass::AddHydrogenCorrection: **correction");
464 for (int i = a; i--;)
465 correction[i] = (double *) Malloc(sizeof(double) * b, "MoleculeListClass::AddHydrogenCorrection: *correction[]");
466
467 // 1a. go through every molecule in the list
468 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
469 // 1b. zero final correction matrix
470 for (int k = a; k--;)
471 for (int j = b; j--;)
472 correction[k][j] = 0.;
473 // 2. take every hydrogen that is a saturated one
474 Walker = (*ListRunner)->start;
475 while (Walker->next != (*ListRunner)->end) {
476 Walker = Walker->next;
477 //cout << Verbose(1) << "Walker: " << *Walker << " with first bond " << *(*Runner)->ListOfBondsPerAtom[Walker->nr][0] << "." << endl;
478 if ((Walker->type->Z == 1) && ((Walker->father == NULL)
479 || (Walker->father->type->Z != 1))) { // if it's a hydrogen
480 Runner = (*ListRunner)->start;
481 while (Runner->next != (*ListRunner)->end) {
482 Runner = Runner->next;
483 //cout << Verbose(2) << "Runner: " << *Runner << " with first bond " << *(*Runner)->ListOfBondsPerAtom[Runner->nr][0] << "." << endl;
484 // 3. take every other hydrogen that is the not the first and not bound to same bonding partner
485 if ((Runner->type->Z == 1) && (Runner->nr > Walker->nr) && ((*ListRunner)->ListOfBondsPerAtom[Runner->nr][0]->GetOtherAtom(Runner) != (*ListRunner)->ListOfBondsPerAtom[Walker->nr][0]->GetOtherAtom(Walker))) { // (hydrogens have only one bonding partner!)
486 // 4. evaluate the morse potential for each matrix component and add up
487 distance = Runner->x.Distance(&Walker->x);
488 //cout << "Fragment " << (*ListRunner)->name << ": " << *Runner << "<= " << distance << "=>" << *Walker << ":" << endl;
489 for (int k = 0; k < a; k++) {
490 for (int j = 0; j < b; j++) {
491 switch (k) {
492 case 1:
493 case 7:
494 case 11:
495 tmp = pow(FitConstant[0][k][j] * (1. - exp(-FitConstant[1][k][j] * (distance - FitConstant[2][k][j]))), 2);
496 break;
497 default:
498 tmp = FitConstant[0][k][j] * pow(distance, FitConstant[1][k][j]) + FitConstant[2][k][j];
499 };
500 correction[k][j] -= tmp; // ground state is actually lower (disturbed by additional interaction)
501 //cout << tmp << "\t";
502 }
503 //cout << endl;
504 }
505 //cout << endl;
506 }
507 }
508 }
509 }
510 // 5. write final matrix to file
511 line = path;
512 line.append("/");
513 line += FRAGMENTPREFIX;
514 FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), (*ListRunner)->IndexNr);
515 line += FragmentNumber;
516 delete (FragmentNumber);
517 line += HCORRECTIONSUFFIX;
518 output.open(line.c_str());
519 output << "Time\t\tTotal\t\tKinetic\t\tNonLocal\tCorrelation\tExchange\tPseudo\t\tHartree\t\t-Gauss\t\tEwald\t\tIonKin\t\tETotal" << endl;
520 for (int j = 0; j < b; j++) {
521 for (int i = 0; i < a; i++)
522 output << correction[i][j] << "\t";
523 output << endl;
524 }
525 output.close();
526 }
527 line = path;
528 line.append("/");
529 line += HCORRECTIONSUFFIX;
530 output.open(line.c_str());
531 output << "Time\t\tTotal\t\tKinetic\t\tNonLocal\tCorrelation\tExchange\tPseudo\t\tHartree\t\t-Gauss\t\tEwald\t\tIonKin\t\tETotal" << endl;
532 for (int j = 0; j < b; j++) {
533 for (int i = 0; i < a; i++)
534 output << 0 << "\t";
535 output << endl;
536 }
537 output.close();
538 // 6. free memory of parsed matrices
539 FitConstant = (double ***) Malloc(sizeof(double **) * a, "MoleculeListClass::AddHydrogenCorrection: ***FitConstant");
540 for (int k = 0; k < 3; k++) {
541 FitConstant[k] = (double **) Malloc(sizeof(double *) * a, "MoleculeListClass::AddHydrogenCorrection: **FitConstant[]");
542 for (int i = a; i--;) {
543 FitConstant[k][i] = (double *) Malloc(sizeof(double) * b, "MoleculeListClass::AddHydrogenCorrection: *FitConstant[][]");
544 }
545 }
546 cout << "done." << endl;
547 return true;
548};
549
550/** Store force indices, i.e. the connection between the nuclear index in the total molecule config and the respective atom in fragment config.
551 * \param *out output stream for debugging
552 * \param *path path to file
553 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config
554 * \return true - file written successfully, false - writing failed
555 */
556bool MoleculeListClass::StoreForcesFile(ofstream *out, char *path,
557 int *SortIndex)
558{
559 bool status = true;
560 ofstream ForcesFile;
561 stringstream line;
562 atom *Walker = NULL;
563 element *runner = NULL;
564
565 // open file for the force factors
566 *out << Verbose(1) << "Saving force factors ... ";
567 line << path << "/" << FRAGMENTPREFIX << FORCESFILE;
568 ForcesFile.open(line.str().c_str(), ios::out);
569 if (ForcesFile != NULL) {
570 //cout << Verbose(1) << "Final AtomicForcesList: ";
571 //output << prefix << "Forces" << endl;
572 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
573 runner = (*ListRunner)->elemente->start;
574 while (runner->next != (*ListRunner)->elemente->end) { // go through every element
575 runner = runner->next;
576 if ((*ListRunner)->ElementsInMolecule[runner->Z]) { // if this element got atoms
577 Walker = (*ListRunner)->start;
578 while (Walker->next != (*ListRunner)->end) { // go through every atom of this element
579 Walker = Walker->next;
580 if (Walker->type->Z == runner->Z) {
581 if ((Walker->GetTrueFather() != NULL) && (Walker->GetTrueFather() != Walker)) {// if there is a rea
582 //cout << "Walker is " << *Walker << " with true father " << *( Walker->GetTrueFather()) << ", it
583 ForcesFile << SortIndex[Walker->GetTrueFather()->nr] << "\t";
584 } else
585 // otherwise a -1 to indicate an added saturation hydrogen
586 ForcesFile << "-1\t";
587 }
588 }
589 }
590 }
591 ForcesFile << endl;
592 }
593 ForcesFile.close();
594 *out << Verbose(1) << "done." << endl;
595 } else {
596 status = false;
597 *out << Verbose(1) << "failed to open file " << line.str() << "." << endl;
598 }
599 ForcesFile.close();
600
601 return status;
602};
603
604/** Writes a config file for each molecule in the given \a **FragmentList.
605 * \param *out output stream for debugging
606 * \param *configuration standard configuration to attach atoms in fragment molecule to.
607 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config
608 * \param DoPeriodic true - call ScanForPeriodicCorrection, false - don't
609 * \param DoCentering true - call molecule::CenterEdge(), false - don't
610 * \return true - success (each file was written), false - something went wrong.
611 */
612bool MoleculeListClass::OutputConfigForListOfFragments(ofstream *out, config *configuration, int *SortIndex)
613{
614 ofstream outputFragment;
615 char FragmentName[MAXSTRINGSIZE];
616 char PathBackup[MAXSTRINGSIZE];
617 bool result = true;
618 bool intermediateResult = true;
619 atom *Walker = NULL;
620 Vector BoxDimension;
621 char *FragmentNumber = NULL;
622 char *path = NULL;
623 int FragmentCounter = 0;
624 ofstream output;
625
626 // store the fragments as config and as xyz
627 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
628 // save default path as it is changed for each fragment
629 path = configuration->GetDefaultPath();
630 if (path != NULL)
631 strcpy(PathBackup, path);
632 else
633 cerr << "OutputConfigForListOfFragments: NULL default path obtained from config!" << endl;
634
635 // correct periodic
636 (*ListRunner)->ScanForPeriodicCorrection(out);
637
638 // output xyz file
639 FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), FragmentCounter++);
640 sprintf(FragmentName, "%s/%s%s.conf.xyz", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
641 outputFragment.open(FragmentName, ios::out);
642 *out << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as XYZ ...";
643 if ((intermediateResult = (*ListRunner)->OutputXYZ(&outputFragment)))
644 *out << " done." << endl;
645 else
646 *out << " failed." << endl;
647 result = result && intermediateResult;
648 outputFragment.close();
649 outputFragment.clear();
650
651 // list atoms in fragment for debugging
652 *out << Verbose(2) << "Contained atoms: ";
653 Walker = (*ListRunner)->start;
654 while (Walker->next != (*ListRunner)->end) {
655 Walker = Walker->next;
656 *out << Walker->Name << " ";
657 }
658 *out << endl;
659
660 // center on edge
661 (*ListRunner)->CenterEdge(out, &BoxDimension);
662 (*ListRunner)->SetBoxDimension(&BoxDimension); // update Box of atoms by boundary
663 int j = -1;
664 for (int k = 0; k < NDIM; k++) {
665 j += k + 1;
666 BoxDimension.x[k] = 2.5 * (configuration->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);
667 (*ListRunner)->cell_size[j] += BoxDimension.x[k] * 2.;
668 }
669 (*ListRunner)->Translate(&BoxDimension);
670
671 // also calculate necessary orbitals
672 (*ListRunner)->CountElements(); // this is a bugfix, atoms should shoulds actually be added correctly to this fragment
673 (*ListRunner)->CalculateOrbitals(*configuration);
674
675 // change path in config
676 //strcpy(PathBackup, configuration->configpath);
677 sprintf(FragmentName, "%s/%s%s/", PathBackup, FRAGMENTPREFIX, FragmentNumber);
678 configuration->SetDefaultPath(FragmentName);
679
680 // and save as config
681 sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
682 *out << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as config ...";
683 if ((intermediateResult = configuration->Save(FragmentName, (*ListRunner)->elemente, (*ListRunner))))
684 *out << " done." << endl;
685 else
686 *out << " failed." << endl;
687 result = result && intermediateResult;
688
689 // restore old config
690 configuration->SetDefaultPath(PathBackup);
691
692 // and save as mpqc input file
693 sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
694 *out << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as mpqc input ...";
695 if ((intermediateResult = configuration->SaveMPQC(FragmentName, (*ListRunner))))
696 *out << " done." << endl;
697 else
698 *out << " failed." << endl;
699
700 result = result && intermediateResult;
701 //outputFragment.close();
702 //outputFragment.clear();
703 delete (FragmentNumber);
704 //Free((void **)&FragmentNumber, "MoleculeListClass::OutputConfigForListOfFragments: *FragmentNumber");
705 }
706 cout << " done." << endl;
707
708 // printing final number
709 *out << "Final number of fragments: " << FragmentCounter << "." << endl;
710
711 return result;
712};
713
714/** Counts the number of molecules with the molecule::ActiveFlag set.
715 * \return number of molecules with ActiveFlag set to true.
716 */
717int MoleculeListClass::NumberOfActiveMolecules()
718{
719 int count = 0;
720 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++)
721 count += ((*ListRunner)->ActiveFlag ? 1 : 0);
722 return count;
723};
724
725
726/******************************************* Class MoleculeLeafClass ************************************************/
727
728/** Constructor for MoleculeLeafClass root leaf.
729 * \param *Up Leaf on upper level
730 * \param *PreviousLeaf NULL - We are the first leaf on this level, otherwise points to previous in list
731 */
732//MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *Up = NULL, MoleculeLeafClass *Previous = NULL)
733MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf = NULL)
734{
735 // if (Up != NULL)
736 // if (Up->DownLeaf == NULL) // are we the first down leaf for the upper leaf?
737 // Up->DownLeaf = this;
738 // UpLeaf = Up;
739 // DownLeaf = NULL;
740 Leaf = NULL;
741 previous = PreviousLeaf;
742 if (previous != NULL) {
743 MoleculeLeafClass *Walker = previous->next;
744 previous->next = this;
745 next = Walker;
746 } else {
747 next = NULL;
748 }
749};
750
751/** Destructor for MoleculeLeafClass.
752 */
753MoleculeLeafClass::~MoleculeLeafClass()
754{
755 // if (DownLeaf != NULL) {// drop leaves further down
756 // MoleculeLeafClass *Walker = DownLeaf;
757 // MoleculeLeafClass *Next;
758 // do {
759 // Next = Walker->NextLeaf;
760 // delete(Walker);
761 // Walker = Next;
762 // } while (Walker != NULL);
763 // // Last Walker sets DownLeaf automatically to NULL
764 // }
765 // remove the leaf itself
766 if (Leaf != NULL) {
767 delete (Leaf);
768 Leaf = NULL;
769 }
770 // remove this Leaf from level list
771 if (previous != NULL)
772 previous->next = next;
773 // } else { // we are first in list (connects to UpLeaf->DownLeaf)
774 // if ((NextLeaf != NULL) && (NextLeaf->UpLeaf == NULL))
775 // NextLeaf->UpLeaf = UpLeaf; // either null as we are top level or the upleaf of the first node
776 // if (UpLeaf != NULL)
777 // UpLeaf->DownLeaf = NextLeaf; // either null as we are only leaf or NextLeaf if we are just the first
778 // }
779 // UpLeaf = NULL;
780 if (next != NULL) // are we last in list
781 next->previous = previous;
782 next = NULL;
783 previous = NULL;
784};
785
786/** Adds \a molecule leaf to the tree.
787 * \param *ptr ptr to molecule to be added
788 * \param *Previous previous MoleculeLeafClass referencing level and which on the level
789 * \return true - success, false - something went wrong
790 */
791bool MoleculeLeafClass::AddLeaf(molecule *ptr, MoleculeLeafClass *Previous)
792{
793 return false;
794};
795
796/** Fills the bond structure of this chain list subgraphs that are derived from a complete \a *reference molecule.
797 * Calls this routine in each MoleculeLeafClass::next subgraph if it's not NULL.
798 * \param *out output stream for debugging
799 * \param *reference reference molecule with the bond structure to be copied
800 * \param &FragmentCounter Counter needed to address \a **ListOfLocalAtoms
801 * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in \a *reference, may be NULL on start, then it is filled
802 * \param FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
803 * \return true - success, false - faoilure
804 */
805bool MoleculeLeafClass::FillBondStructureFromReference(ofstream *out, molecule *reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList)
806{
807 atom *Walker = NULL, *OtherWalker = NULL;
808 bond *Binder = NULL;
809 bool status = true;
810 int AtomNo;
811
812 *out << Verbose(1) << "Begin of FillBondStructureFromReference." << endl;
813 // fill ListOfLocalAtoms if NULL was given
814 if (!FillListOfLocalAtoms(out, ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) {
815 *out << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl;
816 return false;
817 }
818
819 if (status) {
820 *out << Verbose(1) << "Creating adjacency list for subgraph " << this
821 << "." << endl;
822 Walker = Leaf->start;
823 while (Walker->next != Leaf->end) {
824 Walker = Walker->next;
825 AtomNo = Walker->GetTrueFather()->nr; // global id of the current walker
826 for (int i = 0; i < reference->NumberOfBondsPerAtom[AtomNo]; i++) { // go through father's bonds and copy them all
827 Binder = reference->ListOfBondsPerAtom[AtomNo][i];
828 OtherWalker = ListOfLocalAtoms[FragmentCounter][Binder->GetOtherAtom(Walker->GetTrueFather())->nr]; // local copy of current bond partner of walker
829 if (OtherWalker != NULL) {
830 if (OtherWalker->nr > Walker->nr)
831 Leaf->AddBond(Walker, OtherWalker, Binder->BondDegree);
832 } else {
833 *out << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << Binder->GetOtherAtom(Walker->GetTrueFather())->nr << "] is NULL!" << endl;
834 status = false;
835 }
836 }
837 }
838 Leaf->CreateListOfBondsPerAtom(out);
839 FragmentCounter++;
840 if (next != NULL)
841 status = next->FillBondStructureFromReference(out, reference, FragmentCounter, ListOfLocalAtoms);
842 FragmentCounter--;
843 }
844
845 if ((FreeList) && (ListOfLocalAtoms != NULL)) {
846 // free the index lookup list
847 Free((void **) &ListOfLocalAtoms[FragmentCounter], "MoleculeLeafClass::FillBondStructureFromReference - **ListOfLocalAtoms[]");
848 if (FragmentCounter == 0) // first fragments frees the initial pointer to list
849 Free((void **) &ListOfLocalAtoms, "MoleculeLeafClass::FillBondStructureFromReference - ***ListOfLocalAtoms");
850 }
851 FragmentCounter--;
852 *out << Verbose(1) << "End of FillBondStructureFromReference." << endl;
853 return status;
854};
855
856/** Fills the root stack for sites to be used as root in fragmentation depending on order or adaptivity criteria
857 * Again, as in \sa FillBondStructureFromReference steps recursively through each Leaf in this chain list of molecule's.
858 * \param *out output stream for debugging
859 * \param *&RootStack stack to be filled
860 * \param *AtomMask defines true/false per global Atom::nr to mask in/out each nuclear site
861 * \param &FragmentCounter counts through the fragments in this MoleculeLeafClass
862 * \return true - stack is non-empty, fragmentation necessary, false - stack is empty, no more sites to update
863 */
864bool MoleculeLeafClass::FillRootStackForSubgraphs(ofstream *out,
865 KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter)
866{
867 atom *Walker = NULL, *Father = NULL;
868
869 if (RootStack != NULL) {
870 // find first root candidates
871 if (&(RootStack[FragmentCounter]) != NULL) {
872 RootStack[FragmentCounter].clear();
873 Walker = Leaf->start;
874 while (Walker->next != Leaf->end) { // go through all (non-hydrogen) atoms
875 Walker = Walker->next;
876 Father = Walker->GetTrueFather();
877 if (AtomMask[Father->nr]) // apply mask
878#ifdef ADDHYDROGEN
879 if (Walker->type->Z != 1) // skip hydrogen
880#endif
881 RootStack[FragmentCounter].push_front(Walker->nr);
882 }
883 if (next != NULL)
884 next->FillRootStackForSubgraphs(out, RootStack, AtomMask, ++FragmentCounter);
885 } else {
886 *out << Verbose(1) << "Rootstack[" << FragmentCounter << "] is NULL." << endl;
887 return false;
888 }
889 FragmentCounter--;
890 return true;
891 } else {
892 *out << Verbose(1) << "Rootstack is NULL." << endl;
893 return false;
894 }
895};
896
897/** Fills a lookup list of father's Atom::nr -> atom for each subgraph.
898 * \param *out output stream fro debugging
899 * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
900 * \param FragmentCounter counts the fragments as we move along the list
901 * \param GlobalAtomCount number of atoms in the complete molecule
902 * \param &FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
903 * \return true - succes, false - failure
904 */
905bool MoleculeLeafClass::FillListOfLocalAtoms(ofstream *out, atom ***&ListOfLocalAtoms, const int FragmentCounter, const int GlobalAtomCount, bool &FreeList)
906{
907 bool status = true;
908
909 int Counter = Count();
910 if (ListOfLocalAtoms == NULL) { // allocated initial pointer
911 // allocate and set each field to NULL
912 ListOfLocalAtoms = (atom ***) Malloc(sizeof(atom **) * Counter, "MoleculeLeafClass::FillBondStructureFromReference - ***ListOfLocalAtoms");
913 if (ListOfLocalAtoms != NULL) {
914 for (int i = Counter; i--;)
915 ListOfLocalAtoms[i] = NULL;
916 FreeList = FreeList && true;
917 } else
918 status = false;
919 }
920
921 if ((ListOfLocalAtoms != NULL) && (ListOfLocalAtoms[FragmentCounter] == NULL)) { // allocate and fill list of this fragment/subgraph
922 status = status && CreateFatherLookupTable(out, Leaf->start, Leaf->end, ListOfLocalAtoms[FragmentCounter], GlobalAtomCount);
923 FreeList = FreeList && true;
924 }
925
926 return status;
927};
928
929/** The indices per keyset are compared to the respective father's Atom::nr in each subgraph and thus put into \a **&FragmentList.
930 * \param *out output stream fro debugging
931 * \param *reference reference molecule with the bond structure to be copied
932 * \param *KeySetList list with all keysets
933 * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
934 * \param **&FragmentList list to be allocated and returned
935 * \param &FragmentCounter counts the fragments as we move along the list
936 * \param FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
937 * \retuen true - success, false - failure
938 */
939bool MoleculeLeafClass::AssignKeySetsToFragment(ofstream *out,
940 molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms,
941 Graph **&FragmentList, int &FragmentCounter, bool FreeList)
942{
943 bool status = true;
944 int KeySetCounter = 0;
945
946 *out << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl;
947 // fill ListOfLocalAtoms if NULL was given
948 if (!FillListOfLocalAtoms(out, ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) {
949 *out << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl;
950 return false;
951 }
952
953 // allocate fragment list
954 if (FragmentList == NULL) {
955 KeySetCounter = Count();
956 FragmentList = (Graph **) Malloc(sizeof(Graph *) * KeySetCounter, "MoleculeLeafClass::AssignKeySetsToFragment - **FragmentList");
957 for (int i = KeySetCounter; i--;)
958 FragmentList[i] = NULL;
959 KeySetCounter = 0;
960 }
961
962 if ((KeySetList != NULL) && (KeySetList->size() != 0)) { // if there are some scanned keysets at all
963 // assign scanned keysets
964 if (FragmentList[FragmentCounter] == NULL)
965 FragmentList[FragmentCounter] = new Graph;
966 KeySet *TempSet = new KeySet;
967 for (Graph::iterator runner = KeySetList->begin(); runner != KeySetList->end(); runner++) { // key sets contain global numbers!
968 if (ListOfLocalAtoms[FragmentCounter][reference->FindAtom(*((*runner).first.begin()))->nr] != NULL) {// as we may assume that that bond structure is unchanged, we only test the first key in each set
969 // translate keyset to local numbers
970 for (KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++)
971 TempSet->insert(ListOfLocalAtoms[FragmentCounter][reference->FindAtom(*sprinter)->nr]->nr);
972 // insert into FragmentList
973 FragmentList[FragmentCounter]->insert(GraphPair(*TempSet, pair<int, double> (KeySetCounter++, (*runner).second.second)));
974 }
975 TempSet->clear();
976 }
977 delete (TempSet);
978 if (KeySetCounter == 0) {// if there are no keysets, delete the list
979 *out << Verbose(1) << "KeySetCounter is zero, deleting FragmentList." << endl;
980 delete (FragmentList[FragmentCounter]);
981 } else
982 *out << Verbose(1) << KeySetCounter << " keysets were assigned to subgraph " << FragmentCounter << "." << endl;
983 FragmentCounter++;
984 if (next != NULL)
985 next->AssignKeySetsToFragment(out, reference, KeySetList, ListOfLocalAtoms, FragmentList, FragmentCounter, FreeList);
986 FragmentCounter--;
987 } else
988 *out << Verbose(1) << "KeySetList is NULL or empty." << endl;
989
990 if ((FreeList) && (ListOfLocalAtoms != NULL)) {
991 // free the index lookup list
992 Free((void **) &ListOfLocalAtoms[FragmentCounter], "MoleculeLeafClass::AssignKeySetsToFragment - **ListOfLocalAtoms[]");
993 if (FragmentCounter == 0) // first fragments frees the initial pointer to list
994 Free((void **) &ListOfLocalAtoms, "MoleculeLeafClass::AssignKeySetsToFragment - ***ListOfLocalAtoms");
995 }
996 *out << Verbose(1) << "End of AssignKeySetsToFragment." << endl;
997 return status;
998};
999
1000/** Translate list into global numbers (i.e. ones that are valid in "this" molecule, not in MolecularWalker->Leaf)
1001 * \param *out output stream for debugging
1002 * \param **FragmentList Graph with local numbers per fragment
1003 * \param &FragmentCounter counts the fragments as we move along the list
1004 * \param &TotalNumberOfKeySets global key set counter
1005 * \param &TotalGraph Graph to be filled with global numbers
1006 */
1007void MoleculeLeafClass::TranslateIndicesToGlobalIDs(ofstream *out,
1008 Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets,
1009 Graph &TotalGraph)
1010{
1011 *out << Verbose(1) << "Begin of TranslateIndicesToGlobalIDs." << endl;
1012 KeySet *TempSet = new KeySet;
1013 if (FragmentList[FragmentCounter] != NULL) {
1014 for (Graph::iterator runner = FragmentList[FragmentCounter]->begin(); runner != FragmentList[FragmentCounter]->end(); runner++) {
1015 for (KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++)
1016 TempSet->insert((Leaf->FindAtom(*sprinter))->GetTrueFather()->nr);
1017 TotalGraph.insert(GraphPair(*TempSet, pair<int, double> (TotalNumberOfKeySets++, (*runner).second.second)));
1018 TempSet->clear();
1019 }
1020 delete (TempSet);
1021 } else {
1022 *out << Verbose(1) << "FragmentList is NULL." << endl;
1023 }
1024 if (next != NULL)
1025 next->TranslateIndicesToGlobalIDs(out, FragmentList, ++FragmentCounter, TotalNumberOfKeySets, TotalGraph);
1026 FragmentCounter--;
1027 *out << Verbose(1) << "End of TranslateIndicesToGlobalIDs." << endl;
1028};
1029
1030/** Simply counts the number of items in the list, from given MoleculeLeafClass.
1031 * \return number of items
1032 */
1033int MoleculeLeafClass::Count() const
1034{
1035 if (next != NULL)
1036 return next->Count() + 1;
1037 else
1038 return 1;
1039};
1040
Note: See TracBrowser for help on using the repository browser.