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


C++ ParticleSet::setName方法代码示例

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


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

示例1: put

  /** process an xml element
   * @param cur current xmlNodePtr
   * @return true, if successful.
   *
   * Creating MCWalkerConfiguration for all the ParticleSet
   * objects. 
   */
  bool ParticleSetPool::put(xmlNodePtr cur) 
  {

    ReportEngine PRE("ParticleSetPool","put");

    //const ParticleSet::ParticleLayout_t* sc=DistanceTable::getSimulationCell();
    //ParticleSet::ParticleLayout_t* sc=0;

    string id("e"), role("none");
    OhmmsAttributeSet pAttrib;
    pAttrib.add(id,"id"); pAttrib.add(id,"name"); 
    pAttrib.add(role,"role");
    pAttrib.put(cur);

    //backward compatibility
    if(id == "e" && role=="none") role="MC";

    ParticleSet* pTemp = getParticleSet(id);
    if(pTemp == 0) 
    {
      app_log() << "  Creating " << id << " particleset" << endl;
      pTemp = new MCWalkerConfiguration;
      //if(role == "MC") 
      //  pTemp = new MCWalkerConfiguration;
      //else 
      //  pTemp = new ParticleSet;
      if(SimulationCell) 
      {
        app_log() << "  Initializing the lattice of " << id << " by the global supercell" << endl;
        pTemp->Lattice.copy(*SimulationCell);
      }
      myPool[id] = pTemp;
      XMLParticleParser pread(*pTemp,TileMatrix);
      bool success = pread.put(cur);
      pTemp->setName(id);
      app_log() << pTemp->getName() <<endl;
      return success;
    } else {
      app_warning() << "particleset " << id << " is already created. Ignore this" << endl;
    }

    return true;
  }
开发者ID:digideskio,项目名称:qmcpack,代码行数:50,代码来源:ParticleSetPool.cpp

示例2: main

int main(int argc, char **argv) {

    using namespace ohmmsqmc;

    xmlDocPtr m_doc;
    xmlNodePtr m_root;
    xmlXPathContextPtr m_context;

    enum {SourceIndex  = DistanceTableData::SourceIndex};

    OHMMS::Controller->initialize(argc,argv);
    OhmmsInfo welcome(argc,argv,OHMMS::Controller->mycontext());

    ///project description
    OHMMS::ProjectData myProject;

    ///random number controller
    OHMMS::RandomNumberControl myRandomControl;

    if(argc>1) {
        // build an XML tree from a the file;
        LOGMSG("Opening file " << argv[1])
        m_doc = xmlParseFile(argv[1]);
        if (m_doc == NULL) {
            ERRORMSG("File " << argv[1] << " is invalid")
            xmlFreeDoc(m_doc);
            return 1;
        }
        // Check the document is of the right kind
        m_root = xmlDocGetRootElement(m_doc);
        if (m_root == NULL) {
            ERRORMSG("Empty document");
            xmlFreeDoc(m_doc);
            return 1;
        }
    } else {
        WARNMSG("No argument is given. Assume that  does not need an input file")
    }

    m_context = xmlXPathNewContext(m_doc);


    xmlXPathObjectPtr result
        = xmlXPathEvalExpression((const xmlChar*)"//project",m_context);
    if(xmlXPathNodeSetIsEmpty(result->nodesetval)) {
        WARNMSG("Project is not defined")
        myProject.reset();
    } else {
        myProject.put(result->nodesetval->nodeTab[0]);
    }
    xmlXPathFreeObject(result);
    //initialize the random number generator
    xmlNodePtr rptr = myRandomControl.initialize(m_context);
    if(rptr) {
        xmlAddChild(m_root,rptr);
    }

    ///the ions
    ParticleSet ion;

    MCWalkerConfiguration el;
    el.setName("e");
    int iu = el.Species.addSpecies("u");
    int id = el.Species.addSpecies("d");
    int icharge = el.Species.addAttribute("charge");
    el.Species(icharge,iu) = -1;
    el.Species(icharge,id) = -1;

    bool init_els = determineNumOfElectrons(el,m_context);

    result
        = xmlXPathEvalExpression((const xmlChar*)"//particleset",m_context);

    xmlNodePtr el_ptr=NULL, ion_ptr=NULL;
    for(int i=0; i<result->nodesetval->nodeNr; i++) {
        xmlNodePtr cur=result->nodesetval->nodeTab[i];
        xmlChar* aname= xmlGetProp(cur,(const xmlChar*)"name");
        if(aname) {
            char fc = aname[0];
            if(fc == 'e') {
                el_ptr=cur;
            }
            else if(fc == 'i') {
                ion_ptr=cur;
            }
        }
    }

    bool donotresize = false;
    if(init_els) {
        el.setName("e");
        XMLReport("The configuration for electrons is already determined by the wave function")
        donotresize = true;
    }
    if(el_ptr) {
        XMLParticleParser pread(el,donotresize);
        pread.put(el_ptr);
    }

    if(ion_ptr) {
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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