Пример #1
0
TypeVec getTypes()
{
  TypeVec types;
  // init types with predefined species (if any)
  vector<string> species = strsplit(args.getCString("species"));
  for (size_t i = 0; i < species.size(); ++i)
  {
    types.push_back(Type(species[i].c_str(), types.size()));
  }

  return types;
}
Пример #2
0
SquareSelector<double> getCoordCutoffs(const TypeVec &types)
{
  vector<string> cutstrs = strsplit(args.getCString("coordinationCutoffs"));

  if (cutstrs.size() != 0)
  {
    if (types.size() == 0)
    {
      cerr << "coordinationCutoffs: species not defined" << endl;
      exit(1);
    }
    if (cutstrs.size() < types.size() * types.size())
    {
      cerr
        << "coordinationCutoffs: too few values. Must be number of species squared"
        << endl;
      exit(1);
    }
    if (cutstrs.size() > types.size() * types.size())
    {
      cerr
        << "coordinationCutoffs: too many values. Must be number of species squared"
        << endl;
      exit(1);
    }

    vector<double> cutoffs(cutstrs.size());
    for (size_t i = 0; i < cutstrs.size(); ++i)
    {
      double value;
      if (convert(cutstrs[i].c_str(), &value))
      {
        cerr << "coordinationCutoffs: invalid double value '"
          << cutstrs[i].c_str() << "'" << endl;
        exit(1);
      }

      cutoffs[i] = value;
    }
    return SquareSelector<double>(cutoffs);
  }

  return SquareSelector<double>(vector<double>());
}