Exemplo n.º 1
0
  protected void readEFPInBohrCoordinates() throws Exception {
    // it's really too bad that the EFP information is nowhere near
    // the ab initio molecule for single-point runs.

    int atomCountInFirstModel = atomSetCollection.getAtomCount();
    // should only contain the $DATA card
    discardLinesUntilContains("MULTIPOLE COORDINATES");

    readLine(); // blank line
    readLine(); // X              Y              Z           ELEC.   NUC.
    // at least for FRAGNAME=H2ORHF, the atoms come out as ZO1, ZH2, ZH3
    // Z stands for nuclear position.
    while (readLine() != null && line.length() >= 72) {
      String atomName = line.substring(1, 2);
      // Z is perhaps not officially deprecated, but the newer
      // H2ODFT potential doesn't use it.
      // It does however put the nuclear charge in the last column
      if (atomName.charAt(0) == 'Z') atomName = line.substring(2, 3);
      else if (parseFloat(line, 67, 73) == 0) continue;
      float x = parseFloat(line, 8, 25);
      float y = parseFloat(line, 25, 40);
      float z = parseFloat(line, 40, 56);
      if (Float.isNaN(x) || Float.isNaN(y) || Float.isNaN(z)) break;
      Atom atom = atomSetCollection.addNewAtom();
      atom.atomName = atomName + (++atomCountInFirstModel);
      setAtomCoord(atom, x * ANGSTROMS_PER_BOHR, y * ANGSTROMS_PER_BOHR, z * ANGSTROMS_PER_BOHR);
      atomNames.add(atomName);
    }
  }
Exemplo n.º 2
0
  @Override
  protected void readAtomsInBohrCoordinates() throws Exception {
    /*
     ATOM      ATOMIC                      COORDINATES (BOHR)
               CHARGE         X                   Y                   Z
     C           6.0     3.9770911639       -2.7036584676       -0.3453920672

    0         1         2         3         4         5         6         7
    01234567890123456789012345678901234567890123456789012345678901234567890123456789

    */

    readLine(); // discard one line
    String atomName;
    atomSetCollection.newAtomSet();
    int n = 0;
    while (readLine() != null && (atomName = parseToken(line, 1, 11)) != null) {
      float x = parseFloat(line, 17, 37);
      float y = parseFloat(line, 37, 57);
      float z = parseFloat(line, 57, 77);
      if (Float.isNaN(x) || Float.isNaN(y) || Float.isNaN(z)) break;
      Atom atom = atomSetCollection.addNewAtom();
      atom.elementSymbol = getElementSymbol(parseInt(line.substring(11, 14)));
      atom.atomName = atom.elementSymbol + (++n);
      setAtomCoord(atom, x * ANGSTROMS_PER_BOHR, y * ANGSTROMS_PER_BOHR, z * ANGSTROMS_PER_BOHR);
      atomNames.add(atomName);
    }
  }
Exemplo n.º 3
0
  private void readAtoms() throws Exception {

    // format (4X,I4,4X,F10.8,3X,F10.8,3X,F10.8)

    readLine();
    while (line != null && (line.indexOf("ATOM") == 0 || !doSymmetry && line.indexOf(":") == 8)) {
      int thisAtom = atomSetCollection.getAtomCount();
      addAtom();
      if (readLine().indexOf("MULT=") == 10)
        for (int i = parseInt(line.substring(15, 18)); --i >= 0; ) {
          readLine();
          if (!doSymmetry) addAtom();
        }
      // format (A10,5X,I5,5X,F10.8,5X,F10.5,5X,F5.2)

      String atomName = line.substring(0, 10);
      String sym = atomName.substring(0, 2).trim();
      if (sym.length() == 2 && Character.isDigit(sym.charAt(1))) sym = sym.substring(0, 1);
      atomName = TextFormat.simpleReplace(atomName, " ", "");
      int n = 0;
      for (int i = atomSetCollection.getAtomCount(); --i >= thisAtom; ) {
        Atom atom = atomSetCollection.getAtom(i);
        atom.elementSymbol = sym;
        atom.atomName = atomName + "_" + (n++);
      }
      while (readLine() != null && line.indexOf("ATOM") < 0 && line.indexOf("SYMMETRY") < 0) {}
    }
    // return with "SYMMETRY" line in buffer
  }
Exemplo n.º 4
0
  private void readAtomsInAngstromCoordinates() throws Exception {
    readLine();
    readLine(); // discard two lines
    String atomName;
    atomSetCollection.newAtomSet();
    /*
           COORDINATES OF ALL ATOMS ARE (ANGS)
       ATOM   CHARGE       X              Y              Z
     ------------------------------------------------------------
     C           6.0   2.1045861621  -1.4307145508  -0.1827736240

    0         1         2         3         4         5         6
    0123456789012345678901234567890123456789012345678901234567890

    */
    int n = 0;
    while (readLine() != null && (atomName = parseToken(line, 1, 11)) != null) {
      float x = parseFloat(line, 16, 31);
      float y = parseFloat(line, 31, 46);
      float z = parseFloat(line, 46, 61);
      if (Float.isNaN(x) || Float.isNaN(y) || Float.isNaN(z)) break;
      Atom atom = atomSetCollection.addNewAtom();
      setAtomCoord(atom, x, y, z);
      atom.elementSymbol = getElementSymbol(parseInt(line.substring(11, 14)));
      atom.atomName = atom.elementSymbol + (++n);
      atomNames.add(atomName);
    }

    /*
    During optimization, this will immediately appear after the
    ab initio molecule

    COORDINATES OF FRAGMENT MULTIPOLE CENTERS (ANGS)
    MULTIPOLE NAME        X              Y              Z
    ------------------------------------------------------------
    FRAGNAME=H2ORHF
    ZO1              -4.1459482636   0.4271933699   0.0417242924
    ZH2              -3.4514529072   1.0596960013  -0.0504444399
    ZH3              -4.5252917848   0.5632659571   0.8952236761

    or for H2ODFT

    COORDINATES OF FRAGMENT MULTIPOLE CENTERS (ANGS)
    MULTIPOLE NAME        X              Y              Z
    ------------------------------------------------------------
    FRAGNAME=H2ODFT
    O1                3.5571448937  -2.1158335714  -0.0044768463
    H2                3.9520351868  -2.4002052098  -0.8132245708
    H3                3.7885802785  -1.2074436330   0.1057222304

    */

    // Now is the time to read Effective Fragments (EFP)
    if (line.indexOf("COORDINATES OF FRAGMENT MULTIPOLE CENTERS (ANGS)") >= 0) {
      readLine(); // MULTIPONE NAME         X ...
      readLine(); // ------------------------ ...
      readLine(); // FRAGNAME=

      // at least for FRAGNAME=H2ORHF, the atoms come out as ZO1, ZH2, ZH3
      while (readLine() != null && (atomName = parseToken(line, 1, 2)) != null) {
        if (parseToken(line, 1, 2).equals("Z")) // Z means nuclear position
        atomName = parseToken(line, 2, 3);
        else if (parseToken(line, 1, 9).equals("FRAGNAME")) // Z is a deprecated requirement
        continue;
        else atomName = parseToken(line, 1, 2);
        float x = parseFloat(line, 16, 31);
        float y = parseFloat(line, 31, 46);
        float z = parseFloat(line, 46, 61);
        if (Float.isNaN(x) || Float.isNaN(y) || Float.isNaN(z)) break;
        Atom atom = atomSetCollection.addNewAtom();
        atom.atomName = atomName + (++n);
        setAtomCoord(atom, x, y, z);
        atomNames.add(atomName);
      }
    }
  }