Ignore:
Timestamp:
Jul 10, 2009, 9:01:40 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
c95b69
Parents:
598f76
git-author:
Frederik Heber <heber@…> (07/10/09 20:21:12)
git-committer:
Frederik Heber <heber@…> (07/10/09 21:01:40)
Message:

new class ConfigFileBuffer and new overloaded function ParseForParaneter() based on this buffer

  • the problem is that we need to use molecuilder for the periodic translating of atoms in a xzy file. However, molecuilder resorts them per element. This destroty the id mapping needed for the DBOND file. The storing was corrected, but also the loading relies on this order.
  • To solve this, we have to pull off quite something: Parse file into buffer, resort the Ion_Type ones (via a map only), load atoms and then put them into the molecule in the original order!
  • Hence, in config::Load we also have a LinearList (map<int, atom*>) in order to add the atoms after the scanning in their original order into the molecule.
  • class ConfigFileBuffer parses a config file line-wise into a buffer and allows for resorting (via a map) of lines containing key_word Ion_Type.
  • BUGFIX: molecule::Output...() were writing the wrong elements, as they were numbered during the output and not before in ascending order! (I.e. if the first atom is Si, but there is also H present, then this Si would become Ion_Type1_1 instead of Ion_Type2_1, because the elements are still sorted by their Z value, hence Ion_Type1 is H!)

This is basically tested and seems to work properly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/molecules.cpp

    r598f76 r88b936  
    14711471        atom *walker = NULL;
    14721472        int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS];
    1473         int CurrentMaxElement = 0;
    14741473        CountElements();
    14751474
     
    14851484    while (walker->next != end) { // go through every atom of this element
    14861485      walker = walker->next;
    1487       if (ElementNo[walker->type->Z] == 0) // new element
    1488         ElementNo[walker->type->Z] = ++CurrentMaxElement;
     1486      ElementNo[walker->type->Z] = 1;
     1487    }
     1488    int current=1;
     1489    for (int i=0;i<MAX_ELEMENTS;++i) {
     1490      if (ElementNo[i] == 1)
     1491        ElementNo[i] = current++;
     1492    }
     1493    walker = start;
     1494    while (walker->next != end) { // go through every atom of this element
     1495      walker = walker->next;
    14891496      AtomNo[walker->type->Z]++;
    14901497      walker->Output(ElementNo[walker->type->Z], AtomNo[walker->type->Z], out); // removed due to trajectories
     
    15011508        atom *walker = NULL;
    15021509  int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS];
    1503   int CurrentMaxElement = 0;
    15041510        CountElements();
    15051511
     
    15171523                    ElementNo[i] = 0;
    15181524                  }
    1519       walker = start;
     1525    walker = start;
     1526    while (walker->next != end) { // go through every atom of this element
     1527      walker = walker->next;
     1528      ElementNo[walker->type->Z] = 1;
     1529    }
     1530    int current=1;
     1531    for (int i=0;i<MAX_ELEMENTS;++i) {
     1532      if (ElementNo[i] == 1)
     1533        ElementNo[i] = current++;
     1534    }
     1535    walker = start;
    15201536      while (walker->next != end) { // go through every atom of this element
    15211537        walker = walker->next;
    1522         if (ElementNo[walker->type->Z] == 0) // new element
    1523           ElementNo[walker->type->Z] = ++CurrentMaxElement;
    15241538        AtomNo[walker->type->Z]++;
    15251539        *out << "Ion_Type" << ElementNo[walker->type->Z] << "_" << AtomNo[walker->type->Z] << "\t"      << fixed << setprecision(9) << showpoint;
Note: See TracChangeset for help on using the changeset viewer.