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