当前位置: 首页>>代码示例>>C++>>正文


C++ Crystal::getVectorOfAtomicNums方法代码示例

本文整理汇总了C++中Crystal::getVectorOfAtomicNums方法的典型用法代码示例。如果您正苦于以下问题:C++ Crystal::getVectorOfAtomicNums方法的具体用法?C++ Crystal::getVectorOfAtomicNums怎么用?C++ Crystal::getVectorOfAtomicNums使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Crystal的用法示例。


在下文中一共展示了Crystal::getVectorOfAtomicNums方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: randSpgCrystal


//.........这里部分代码省略.........
         << "turned off, but the correct spacegroup will not be guaranteed.\n";
    return Crystal();
  }

  // The tuple is as follows: <atomicNum, wyckLet, numTimesUsed>
  vector<tuple<uint, char, uint>> forcedWyckAssignmentsAndNumber = getForcedWyckAssignmentsAndNumber(forcedWyckAssignments);

  for (size_t i = 0; i < forcedWyckAssignmentsAndNumber.size(); i++) {
    possibilities =
      RandSpgCombinatorics::removePossibilitiesWithoutWyckPos(possibilities,
                  get<1>(forcedWyckAssignmentsAndNumber[i]),
                  get<2>(forcedWyckAssignmentsAndNumber[i]),
                  get<0>(forcedWyckAssignmentsAndNumber[i]));
  }

  if (possibilities.size() == 0) {
    cout << "Error in RandSpg::" << __FUNCTION__ << "(): this spg '" << spg
         << "' cannot be generated with this composition due to the forced "
         << "Wyckoff position constraints.\nPlease change them or remove them "
         << "if you wish to generate the space group.\n";
    return Crystal();
  }

  //RandSpgCombinatorics::printSystemPossibilities(possibilities);
  // If we desire verbose output, print the system possibility to the log file
  if (verbosity == 'v')
    appendToLogFile(RandSpgCombinatorics::getVerbosePossibilitiesString(possibilities));

  // Create a modified forced wyck vector for later...
  vector<pair<uint, wyckPos>> modifiedForcedWyckVector = getModifiedForcedWyckVector(forcedWyckAssignments, spg);

  // Begin the attempt loop!
  for (size_t i = 0; i < numAttempts; i++) {

    Crystal crystal = createValidCrystal(spg, latticeMins, latticeMaxes,
                                         minVolume, maxVolume);

    // Now, let's assign some atoms!
    atomAssignments assignments = RandSpgCombinatorics::getRandomAtomAssignments(possibilities, modifiedForcedWyckVector);

    //printAtomAssignments(assignments);
    // If we desire any output, print the atom assignments to the log file
    if (verbosity == 'r' || verbosity == 'v')
      appendToLogFile(getAtomAssignmentsString(assignments));

    if (assignments.size() == 0) {
      cout << "Error in RandSpg::randSpgXtal(): atoms were not successfully"
           << " assigned positions in assignAtomsToWyckPos()\n";
      continue;
    }

#ifdef RANDSPG_DEBUG
    cout << "\natomAssignments are the following (atomicNum, wyckLet, wyckPos):"
         << "\n";
    for (size_t j = 0; j < assignments.size(); j++)
      cout << "  " << assignments[j].second << ", "
           << getWyckLet(assignments[j].first)
           << ", " << getWyckCoords(assignments[j].first) << "\n";
    cout << "\n";
#endif

    bool assignmentsSuccessful = true;
    for (size_t j = 0; j < assignments.size(); j++) {
      const wyckPos& pos = assignments[j].first;
      uint atomicNum = assignments[j].second;
      if (!addWyckoffAtomRandomly(crystal, pos, atomicNum, spg)) {
        assignmentsSuccessful = false;
        break;
      }
    }

    // If we succeeded, and the number of atoms match, return the crystal!
    // There are rare cases where an atom may be placed on top of another
    // one and the essentially get merged into one. We check to make sure the
    // sizes of the atomic numbers match for this reason. We shouldn't have to
    // worry about types.
    if (assignmentsSuccessful &&
        atoms.size() == crystal.getVectorOfAtomicNums().size()) {
      if (verbosity != 'n') appendToLogFile("*** Success! ***\n");
      return crystal;
    }
    else {
      if (verbosity == 'r' || verbosity == 'v') {
        stringstream ss;
        ss << "Failed to add atoms to satisfy MinIAD.\nObtaining new atom "
           << "assignments and trying again. Failure count: " << i + 1 << "\n\n";
        appendToLogFile(ss.str());
      }
      continue;
    }
  }

  // If we made it here, we failed to generate the crystal
  stringstream errMsg;
  errMsg << "After " << numAttempts << " attempts: failed to generate "
         << "a crystal of spg " << spg << ".\n";
  if (verbosity != 'n') appendToLogFile(errMsg.str());
  cerr << errMsg.str();
  return Crystal();
}
开发者ID:xtalopt,项目名称:XtalOpt,代码行数:101,代码来源:randSpg.cpp


注:本文中的Crystal::getVectorOfAtomicNums方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。