Beispiel #1
0
qreal PosteRazorCore::convertCmToDistance(qreal cm) const
{
    return Types::convertBetweenUnitsOfLength(cm, Types::UnitOfLengthCentimeter, unitOfLength());
}
Beispiel #2
0
bool File::Mol::generate()
{
  int atomTypes = 0;
  float x, y, z;

  clear();

  addString(basisType_);
  addString(basisSet_);
  addString(comment_);

  QList<Chemistry::Atom*> atomsList;

  for (quint16 i = 0; i < molecule().atomsCount(); ++i)
  {
    atomsList << &molecule().atom(i);
  }

  while (atomsList.count() > 0)
  {
    QList<Chemistry::Atom*> atomsOfTheSameTypeList;
    atomsOfTheSameTypeList << atomsList.takeFirst();
    quint8 charge = atomsOfTheSameTypeList[0]->atomicNumber();
    int n = atomsList.count();
    int i = 0;
    while (i < n)
    {
      if (atomsList[i]->atomicNumber() == charge)
      {
        atomsOfTheSameTypeList << atomsList.takeAt(i);
        n--;
      }
      else
      {
        i++;
      }
    }

    QString atomsOfTheSameTypeHeader = QString("Charge=%1 Atoms=%2").arg(
        charge).arg(atomsOfTheSameTypeList.count());

    if (basisType_ == "ATOMBASIS")
      atomsOfTheSameTypeHeader += QString(" Basis=%1").arg(
          hashBasisSets_[charge]);

    addString(atomsOfTheSameTypeHeader);

    for (quint16 i = 0; i < atomsOfTheSameTypeList.count(); ++i)
    {
      x = atomsOfTheSameTypeList[i]->centre().x();
      y = atomsOfTheSameTypeList[i]->centre().y();
      z = atomsOfTheSameTypeList[i]->centre().z();

      if (unitOfLength() == UnitOfLengthBohr)
      {
        x = x / bohrsToAngstroms;
        y = y / bohrsToAngstroms;
        z = z / bohrsToAngstroms;
      }

      QString temp = QString("%1%2\t%3%4%5").arg(
          atomsOfTheSameTypeList[i]->symbol()).arg(
              i + 1).arg(
                  x, 12, 'f', 6).arg(
                      y, 12, 'f', 6).arg(
                          z, 12, 'f', 6);

      if (atomsOfTheSameTypeList[i]->isotope() != 0)
        temp += QString("\tIsotope=%1").arg(atomsOfTheSameTypeList[i]->isotope());

      addString(temp);
    }
    atomTypes++;
  }

  setAtomTypes(atomTypes);

  QString generalString(QString("Atomtypes=%1").arg(atomTypes));

  if (unitOfLength() == UnitOfLengthAngstrom)
    generalString.append(" Angstrom");

  if (molecule().charge() != 0)
    generalString.append(QString(" Charge=%1").arg(molecule().charge()));

  if (gaussiansType() == GaussiansTypeCartesian)
    generalString.append(" Cartesian");

  insertString(generalStringIndex_ - 1, generalString);

  return true;
}
Beispiel #3
0
qreal PosteRazorCore::convertDistanceToCm(qreal distance) const
{
    return Types::convertBetweenUnitsOfLength(distance, unitOfLength(), Types::UnitOfLengthCentimeter);
}
Beispiel #4
0
void File::Mol::parseAtoms()
{
  bool ok;
  int i = generalStringIndex_;

  QRegExp regExp;

  regExp.setPattern("Charge=((\\d)(\\.\\d+)?)\\s+Atoms=(\\d+)(\\s+Basis=(.+)$)?");

  for (int a = 0; a < atomTypes(); a++)
  {
    i++;
    if (regExp.indexIn(string(i)) != -1)
    {
      int protons = regExp.cap(2).toInt(&ok);
      int count = regExp.cap(4).toInt(&ok);

      if (regExp.cap(5) != "")
      {
        hashBasisSets_[protons] = regExp.cap(6);
      }

      QRegExp regExpAtom("(\\w{1,4})\\s+(-?\\d?\\.\\d+)\\s+(-?\\d?\\.\\d+)\\s+(-?\\d?\\.\\d+)(\\s+Isotope=(\\d+))?");
      for (int j = 0; j < count; j++)
      {
        i++;
        quint8 isotope = 0;
        float x, y, z;
        if (regExpAtom.indexIn(string(i)) != -1)
        {
          x = regExpAtom.cap(2).toFloat(&ok);
          if (!ok)
            addParseError(File::ParseError(i, "Wrong x coordinate."));

          y = regExpAtom.cap(3).toFloat(&ok);
          if (!ok)
            addParseError(File::ParseError(i, "Wrong y coordinate."));

          z = regExpAtom.cap(4).toFloat(&ok);
          if (!ok)
            addParseError(File::ParseError(i, "Wrong z coordinate."));

          if (unitOfLength() == UnitOfLengthBohr)
          {
            x = x * bohrsToAngstroms;
            y = y * bohrsToAngstroms;
            z = z * bohrsToAngstroms;
          }

          if (regExpAtom.cap(5) != "")
          {
            isotope = regExpAtom.cap(6).toInt(&ok);
            if (!ok)
              addParseError(File::ParseError(i, "Wrong isotope."));
          }

          molecule().newAtom(protons, isotope, Eigen::Vector3f(x, y, z));
        }
      }
    }
  }
}