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


C++ Species::atomTypeId方法代码示例

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


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

示例1: readParameters

   /* 
   * Read parameter speciesId.
   */
   void EndSwapMove::readParameters(std::istream& in) 
   {
      readProbability(in);
      read<int>(in, "speciesId", speciesId_);

      Species* speciesPtr = &(simulation().species(speciesId_));
      int nAtom = speciesPtr->nAtom();

      // Preconditions
      if (speciesPtr->isMutable()) {
         UTIL_THROW("EndSwapMove on mutable Species");
      }
      Linear* linearPtr = dynamic_cast<Linear*>(speciesPtr);
      if (linearPtr == 0) {
         UTIL_THROW("EndSwapMove on Species that is not a Linear");
      }

      // Allocate memory 
      atomTypeIds_.allocate(nAtom);
      positions_.allocate(nAtom);

      // Set array of atom type ids
      for (int i = 0; i < nAtom; ++i) {
           atomTypeIds_[i] = speciesPtr->atomTypeId(i); 
      }
   }
开发者ID:TaherGhasimakbari,项目名称:simpatico,代码行数:29,代码来源:EndSwapMove.cpp

示例2: loadParameters

   /*
   * Load state from a binary file archive.
   */
   void McMuExchange::loadParameters(Serializable::IArchive& ar)
   { 
      loadInterval(ar);  
      loadOutputFileName(ar);  
      loadParameter(ar, "speciesId", speciesId_);
      ar >> nAtom_;
      Species* speciesPtr;
      speciesPtr = &(system().simulation().species(speciesId_));
      if (nAtom_ != speciesPtr->nAtom()) {
         UTIL_THROW("Inconsistent values of nAtom on loading");
      }
      newTypeIds_.allocate(nAtom_);
      loadDArray(ar, "newTypeIds", newTypeIds_, nAtom_);

      flipAtomIds_.allocate(nAtom_);
      isAtomFlipped_.allocate(nAtom_);
      for (int i = 0; i < nAtom_; ++i) {
         if (newTypeIds_[i] != speciesPtr->atomTypeId(i)) {
            flipAtomIds_.append(i);
            isAtomFlipped_[i] = 1;
         } else {
            isAtomFlipped_[i] = 0;
         }
      }
      accumulators_.allocate(speciesPtr->capacity());

      ar >> nMolecule_;
      for (int i = 0; i < nMolecule_; ++i) {
         ar >> accumulators_[i];
      }
      isInitialized_ = true;
   }
开发者ID:TaherGhasimakbari,项目名称:simpatico,代码行数:35,代码来源:McMuExchange.cpp

示例3: initializeSpecies

   /*
   * Initialize all Molecule and Atom objects for one Species (private).
   *
   * This function creates associations between Species, Molecule, and
   * Atom objects for all molecules of one species, and sets atom typeIds.
   *
   * For each molecule, it sets the id, species pointer, nAtom, and the 
   * firstAtom pointer. The molecule id is only unique within each species.
   *
   * For each atom, it sets the molecule pointer and an integer typeId.
   *
   * This method also pushes all molecules of the species onto the
   * reservoir, pushing them in order of decreasing molecule id.
   */
   void Simulation::initializeSpecies(int iSpecies)
   {

      Species*  speciesPtr;
      Molecule* moleculePtr;
      Atom*     atomPtr;
      int       iMol, iAtom;
      int       capacity, nAtom;

      speciesPtr = &species(iSpecies);
      capacity   = speciesPtr->capacity();
      nAtom      = speciesPtr->nAtom();

      // Initialize pointers before loop
      moleculePtr = &molecules_[firstMoleculeIds_[iSpecies]];
      atomPtr     = &atoms_[firstAtomIds_[iSpecies]];

      // Loop over all molecules in Species
      for (iMol = 0; iMol < capacity; ++iMol) {

         // Initialize a Molecule
         moleculePtr->setId(iMol);
         moleculePtr->setSpecies(*speciesPtr);
         moleculePtr->setNAtom(nAtom);
         moleculePtr->setFirstAtom(*atomPtr);

         // Loop over atoms in a molecule, set molecule and atom TypeId
         for (iAtom = 0; iAtom < nAtom; ++iAtom) {
            atomPtr->setMolecule(*moleculePtr);
            atomPtr->setTypeId(speciesPtr->atomTypeId(iAtom));
            ++atomPtr;
         }

         ++moleculePtr;
      }

      // Push all molecules of this species onto the reservoir stack
      // Push on in reverse order, so that they pop off in sequence
      moleculePtr = &molecules_[firstMoleculeIds_[iSpecies] + capacity - 1];
      for (iMol = 0; iMol < capacity; ++iMol) {
         speciesPtr->reservoir().push(*moleculePtr);
         --moleculePtr;
      }

   }
开发者ID:tdunn19,项目名称:simpatico,代码行数:59,代码来源:Simulation.cpp


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