New application classes to handle flexible QMC applications.

git-svn-id: https://subversion.assembla.com/svn/qmcdev/trunk@347 e5b18d87-469d-4833-9cc0-8cdfa06e9491
This commit is contained in:
Jeongnim Kim 2005-05-14 22:09:07 +00:00
parent 86d48244d0
commit b90e2ee127
15 changed files with 1811 additions and 0 deletions

93
src/QMCApp/CMakeLists.txt Normal file
View File

@ -0,0 +1,93 @@
PROJECT(newqmc)
####################################
# common wavefunctions and hamiltonians
####################################
SET(WFSRCS
../QMCWaveFunctions/OrbitalBuilderBase.cpp
../QMCWaveFunctions/AtomicOrbitals/HFAtomicSTOSet.cpp
../QMCWaveFunctions/AtomicOrbitals/HFAtomicSTOSetBuilder.cpp
../QMCWaveFunctions/AtomicOrbitals/HeSTOClementiRottie.cpp
../QMCWaveFunctions/MolecularOrbitals/STOMolecularOrbitals.cpp
../QMCWaveFunctions/MolecularOrbitals/RGFBuilderBase.cpp
../QMCWaveFunctions/MolecularOrbitals/STO2GridBuilder.cpp
../QMCWaveFunctions/MolecularOrbitals/GTO2GridBuilder.cpp
../QMCWaveFunctions/MolecularOrbitals/Any2GridBuilder.cpp
../QMCWaveFunctions/MolecularOrbitals/NumericalRGFBuilder.cpp
../QMCWaveFunctions/MolecularOrbitals/GridMolecularOrbitals.cpp
../QMCWaveFunctions/MolecularOrbitals/MolecularOrbitalBuilder.cpp
../QMCWaveFunctions/MolecularOrbitals/NumericalMolecularOrbitals.cpp
../QMCHamiltonians/LocalPPotential.cpp
../QMCHamiltonians/NonLocalPPotential.cpp
../QMCHamiltonians/GeCorePolPotential.cpp
)
####################################
# QMC Drivers which implements various QMC algorithms
####################################
SET(QMCDRIVERS
../QMCDrivers/QMCDriver.cpp
../QMCDrivers/VMC.cpp
../QMCDrivers/VMCParticleByParticle.cpp
../QMCDrivers/DMCParticleByParticle.cpp
../QMCDrivers/VMC_OPT.cpp
../QMCDrivers/MolecuDMC.cpp
../QMCDrivers/ReptationMC.cpp
../Estimators/ScalarEstimatorManager.cpp
)
####################################
#sources for new qmcapp, general QMC code to handle multiple
#configurations, hamiltonians and wavefunctions.
####################################
SET(MAINSRCS
${WFSRCS}
${QMCDRIVERS}
ParticleSetPool.cpp
WaveFunctionPool.cpp
HamiltonianPool.cpp
QMCAppBase.cpp
QMCMain.cpp
qmcapp.cpp
)
####################################
# sources for mo2grid
####################################
SET(MOSRCS
${WFSRCS}
${QMCDRIVERS}
QMCAppBase.cpp
MO2Grid3D.cpp
mo2grid3d_main.cpp
)
####################################
# link lapack/blas and fortran library
####################################
LINK_LIBRARIES(
${LAPACK_LIBRARY}
${BLAS_LIBRARY}
${FORTRAN_LIBS}
)
####################################
# adding thread library: e.g., -lguide -lpthread
####################################
IF(${BLAS_EXTRA_LIBRARY} MATCHES "guide")
LINK_LIBRARIES(${BLAS_EXTRA_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
ELSE(${BLAS_EXTRA_LIBRARY} MATCHES "guide")
LINK_LIBRARIES(${CMAKE_THREAD_LIBS_INIT})
ENDIF(${BLAS_EXTRA_LIBRARY} MATCHES "guide")
####################################
# build mo2grid3d executable
####################################
ADD_EXECUTABLE(mo2grid3d ${MOSRCS})
TARGET_LINK_LIBRARIES(mo2grid3d qmc qmcbase)
####################################
#general qmcapp for multiple configurations, hamiltonians and wavefunctions.
####################################
ADD_EXECUTABLE(oops ${MAINSRCS})
TARGET_LINK_LIBRARIES(oops qmc qmcbase)

View File

@ -0,0 +1,144 @@
//////////////////////////////////////////////////////////////////
// (c) Copyright 2003- by Jeongnim Kim
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Jeongnim Kim
// National Center for Supercomputing Applications &
// Materials Computation Center
// University of Illinois, Urbana-Champaign
// Urbana, IL 61801
// e-mail: jnkim@ncsa.uiuc.edu
// Tel: 217-244-6319 (NCSA) 217-333-3324 (MCC)
//
// Supported by
// National Center for Supercomputing Applications, UIUC
// Materials Computation Center, UIUC
// Department of Physics, Ohio State University
// Ohio Supercomputer Center
//////////////////////////////////////////////////////////////////
// -*- C++ -*-
#include "QMCApp/HamiltonianPool.h"
#include "QMCApp/WaveFunctionPool.h"
#include "QMCApp/ParticleSetPool.h"
using namespace std;
#include "OhmmsData/AttributeSet.h"
#include "Utilities/OhmmsInfo.h"
#include "QMCHamiltonians/QMCHamiltonian.h"
#include "QMCHamiltonians/CoulombPotential.h"
#include "QMCHamiltonians/IonIonPotential.h"
#include "QMCHamiltonians/LocalPPotential.h"
#include "QMCHamiltonians/NonLocalPPotential.h"
#include "QMCHamiltonians/BareKineticEnergy.h"
namespace ohmmsqmc {
HamiltonianPool::HamiltonianPool(const char* aname):
OhmmsElementBase(aname), curH(0), ptclPool(0), psiPool(0){ }
bool HamiltonianPool::put(xmlNodePtr cur) {
string id("primary"), htype("generic"), target("e");
OhmmsAttributeSet hAttrib;
hAttrib.add(id,"id"); hAttrib.add(id,"name");
hAttrib.add(htype,"type");
hAttrib.add(target,"target");
hAttrib.put(cur);
ParticleSet* qp=ptclPool->getParticleSet(target);
if(qp == 0) {
ERRORMSG("No target particle " << target << " exists.")
return false;
}
curH = getHamiltonian(id);
if(curH) {
WARNMSG("hamiltonian with " << id << " is already created. Ignore the input")
return true;
}
curH = new QMCHamiltonian;
curH->add(new BareKineticEnergy,"Kinetic");
myPool[id]=curH;
cur=cur->children;
while(cur != NULL) {
string cname((const char*)cur->name);
if(cname == "pairpot") {
const xmlChar* t = xmlGetProp(cur,(const xmlChar*)"type");
if(t == NULL) continue;
string pot_type((const char*)t);
if(pot_type == "coulomb") {
addCoulombPotential(cur,qp);
} else if(cname == "pseudo") {
addPseudoPotential(cur,qp);
}
}
cur = cur->next;
}
return true;
}
void
HamiltonianPool::addCoulombPotential(xmlNodePtr cur, ParticleSet* target) {
string a("e"),title("ElecElec");
OhmmsAttributeSet hAttrib;
hAttrib.add(title,"id"); hAttrib.add(title,"name");
hAttrib.add(a,"source");
hAttrib.put(cur);
ParticleSet* source = ptclPool->getParticleSet(a);
if(source ==0) {
ERRORMSG("Missing source ParticleSet" << a)
return;
}
if(source->getTotalNum()>1) {
if(source == target) {
curH->add(new CoulombPotentialAA(*target),title);
} else {
curH->add(new CoulombPotentialAB(*source,*target),title);
}
}
}
void HamiltonianPool::addPseudoPotential(xmlNodePtr cur, ParticleSet* target) {
string src("i"),title("PseudoPot"),wfname("primary");
OhmmsAttributeSet pAttrib;
pAttrib.add(title,"name");
pAttrib.add(src,"source");
pAttrib.add(wfname,"wavefunction");
pAttrib.put(cur);
ParticleSet* ion=ptclPool->getParticleSet(src);
if(ion == 0) return;
TrialWaveFunction* psi = psiPool->getWaveFunction(wfname);
if(psi == 0) return;
LOGMSG("Creating non-local pseudopotential nuclei = " << src)
curH->add(new NonLocalPPotential(*ion,*target,*psi), title);
}
bool HamiltonianPool::put(std::istream& is) {
return true;
}
bool HamiltonianPool::get(std::ostream& os) const {
return true;
}
void HamiltonianPool::reset() {
}
}
/***************************************************************************
* $RCSfile$ $Author$
* $Revision$ $Date$
* $Id$
***************************************************************************/

View File

@ -0,0 +1,77 @@
//////////////////////////////////////////////////////////////////
// (c) Copyright 2003- by Jeongnim Kim
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Jeongnim Kim
// National Center for Supercomputing Applications &
// Materials Computation Center
// University of Illinois, Urbana-Champaign
// Urbana, IL 61801
// e-mail: jnkim@ncsa.uiuc.edu
// Tel: 217-244-6319 (NCSA) 217-333-3324 (MCC)
//
// Supported by
// National Center for Supercomputing Applications, UIUC
// Materials Computation Center, UIUC
// Department of Physics, Ohio State University
// Ohio Supercomputer Center
//////////////////////////////////////////////////////////////////
// -*- C++ -*-
#ifndef OHMMS_QMC_QMCHAMILTONIANS_H
#define OHMMS_QMC_QMCHAMILTONIANS_H
#include "OhmmsData/OhmmsElementBase.h"
#include <map>
namespace ohmmsqmc {
class ParticleSet;
class QMCHamiltonian;
class ParticleSetPool;
class WaveFunctionPool;
/* A collection of ParticleSet
*/
class HamiltonianPool : public OhmmsElementBase {
public:
typedef std::map<std::string,QMCHamiltonian*> PoolType;
HamiltonianPool(const char* aname = "hamiltonian");
bool get(std::ostream& os) const;
bool put(std::istream& is);
bool put(xmlNodePtr cur);
void reset();
inline bool empty() const { return myPool.empty();}
QMCHamiltonian* getHamiltonian(const std::string& pname) {
PoolType::iterator hit(myPool.find(pname));
if(hit == myPool.end())
return 0;
else
(*hit).second;
}
inline void setParticleSetPool(ParticleSetPool* pset) { ptclPool=pset;}
inline void setWaveFunctionPool(WaveFunctionPool* pset) { psiPool=pset;}
void addCoulombPotential(xmlNodePtr cur, ParticleSet* target);
void addPseudoPotential(xmlNodePtr cur, ParticleSet* target);
private:
QMCHamiltonian* curH;
ParticleSetPool* ptclPool;
WaveFunctionPool* psiPool;
PoolType myPool;
};
}
#endif
/***************************************************************************
* $RCSfile$ $Author$
* $Revision$ $Date$
* $Id$
***************************************************************************/

450
src/QMCApp/MO2Grid3D.cpp Normal file
View File

@ -0,0 +1,450 @@
//////////////////////////////////////////////////////////////////
// (c) Copyright 2003- by Jeongnim Kim
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Jeongnim Kim
// National Center for Supercomputing Applications &
// Materials Computation Center
// University of Illinois, Urbana-Champaign
// Urbana, IL 61801
// e-mail: jnkim@ncsa.uiuc.edu
// Tel: 217-244-6319 (NCSA) 217-333-3324 (MCC)
//
// Supported by
// National Center for Supercomputing Applications, UIUC
// Materials Computation Center, UIUC
// Department of Physics, Ohio State University
// Ohio Supercomputer Center
//////////////////////////////////////////////////////////////////
// -*- C++ -*-
#include "QMCApp/MO2Grid3D.h"
#include "Utilities/OhmmsInfo.h"
#include "Particle/DistanceTableData.h"
#include "Particle/DistanceTable.h"
#include "ParticleIO/XMLParticleIO.h"
#include "QMCWaveFunctions/MolecularOrbitals/GridMolecularOrbitals.h"
#include "QMCWaveFunctions/LCOrbitals.h"
#include "OhmmsData/AttributeSet.h"
#include "Numerics/HDFSTLAttrib.h"
#include "Numerics/HDFTriCubicSpline.h"
#include "Utilities/Clock.h"
#include "QMCTools/QMCUtilities.h"
namespace ohmmsqmc {
MO2Grid3D::MO2Grid3D(int argc, char** argv): QMCAppBase(argc,argv) {
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;
}
///destructor
MO2Grid3D::~MO2Grid3D() {
DEBUGMSG("MO2Grid3D::~MO2Grid3D")
map<string,TriCubicSplineT<ValueType>* >::iterator it(SPOSet.begin());
while(it != SPOSet.end()) {
if((*it).second) delete (*it).second; ++it;
}
}
bool MO2Grid3D::validateXML() {
return true;
}
bool MO2Grid3D::execute() {
xmlXPathContextPtr m_context = xmlXPathNewContext(m_doc);
if(!setParticleSets(m_root)) {
ERRORMSG("Failed to initialize the ions and electrons. Exit now.")
return false;
}
setWavefunctions(m_root);
string fname(myProject.CurrentRoot());
fname.append(".debug");
ofstream fout(fname.c_str());
fout << "Ionic configuration : " << ion.getName() << endl;
ion.get(fout);
fout << "Electronic configuration : " << el.getName() << endl;
el.get(fout);
Psi.VarList.print(fout);
//return false to stop it
return false;
}
bool MO2Grid3D::setParticleSets(xmlNodePtr aroot) {
bool init_els = determineNumOfElectrons(el,m_context);
xmlXPathObjectPtr 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(ion_ptr) {
XMLParticleParser pread(ion);
pread.put(ion_ptr);
}
if(el_ptr) {
XMLParticleParser pread(el,donotresize);
pread.put(el_ptr);
}
xmlXPathFreeObject(result);
if(!ion.getTotalNum()) {
ion.setName("i");
ion.create(1);
ion.R[0] = 0.0;
}
return true;
}
bool MO2Grid3D::setWavefunctions(xmlNodePtr aroot) {
xmlXPathObjectPtr result
= xmlXPathEvalExpression((const xmlChar*)"//determinantset",m_context);
///make a temporary array to pass over JastrowBuilder
vector<ParticleSet*> PtclSets;
PtclSets.push_back(&ion);
PtclSets.push_back(&el);
bool foundwfs=true;
if(xmlXPathNodeSetIsEmpty(result->nodesetval)) {
ERRORMSG("wavefunction/determinantset is missing. Exit." << endl)
foundwfs=false;
} else {
xmlNodePtr cur = result->nodesetval->nodeTab[0];
const xmlChar* a=xmlGetProp(cur,(const xmlChar*)"src");
if(a) { //need to open an external file
xmlDocPtr tdoc = xmlParseFile((const char*)a);
if (tdoc == NULL) {
xmlFreeDoc(tdoc);
foundwfs=false;
} else {
foundwfs=setWavefunctions(xmlDocGetRootElement(tdoc));
}
} else {
generateNumericalOrbitals(cur);
}
}
xmlXPathFreeObject(result);
return foundwfs;
}
void
MO2Grid3D::copyOrbitalSet(map<string,TriCubicSplineT<ValueType>* >& other) {
map<string,TriCubicSplineT<ValueType>* >::iterator it(SPOSet.begin());
while(it != SPOSet.end()) {
other[(*it).first]=(*it).second; ++it;
}
//clear the set so that it does not delete the objects
SPOSet.clear();
}
xmlNodePtr MO2Grid3D::generateNumericalOrbitals(xmlNodePtr cur) {
LOGMSG("MO2Grid3D::generateNumericalOrbitals from Molecular Orbitals")
xmlNodePtr curRoot=cur;
string troot(myProject.m_title);
const xmlChar* a=xmlGetProp(cur,(const xmlChar*)"target");
if(a) {
troot = (const char*)a;
}
GridMolecularOrbitals Original(el,Psi,ion);
typedef GridMolecularOrbitals::BasisSetType BasisSetType;
typedef LCOrbitals<BasisSetType> SPOSetType;
int nels=0;
std::vector<RealType> ri(3,-5.0);
std::vector<RealType> rf(3,5.0);
std::vector<int> npts(3,101);
vector<SPOSetType*> InOrbs;
map<string,int> DetCounter;
vector<xmlNodePtr> SlaterDetPtr;
xmlNodePtr splinePtr=0, firstSlaterDetPtr=0;
BasisSetType *basisSet=0;
vector<xmlNodePtr> nodeToBeRemoved;
cur = cur->xmlChildrenNode;
int idir=0;
//first pass to check if basisset is used
while(cur != NULL) {
string cname((const char*)(cur->name));
if(cname == "spline") {
splinePtr=cur; // save spline data
xmlNodePtr tcur = cur->xmlChildrenNode;
while(tcur != NULL) {
string tname((const char*)(tcur->name));
if(tname == "grid") {
a=xmlGetProp(tcur,(const xmlChar*)"dir");
if(a) { idir=atoi((const char*)a);}
a=xmlGetProp(tcur,(const xmlChar*)"ri");
if(a) { ri[idir]=atof((const char*)a);}
a=xmlGetProp(tcur,(const xmlChar*)"rf");
if(a) { rf[idir]=atof((const char*)a);}
a=xmlGetProp(tcur,(const xmlChar*)"npts");
if(a) { npts[idir]=atoi((const char*)a);}
}
tcur = tcur->next;
}
} else if(cname == OrbitalBuilderBase::basisset_tag) {
//basisptr=cur;
nodeToBeRemoved.push_back(cur);
basisSet = Original.addBasisSet(cur);
}
cur = cur->next;
}
//basisset is not given. return 0
if(basisSet == 0) return 0;
cur = curRoot->xmlChildrenNode;
while(cur != NULL) {
string cname((const char*)(cur->name));
if(cname == OrbitalBuilderBase::sd_tag) {
if(firstSlaterDetPtr==0) firstSlaterDetPtr=cur;
SlaterDetPtr.push_back(cur);
nels=0;
xmlNodePtr tcur = cur->xmlChildrenNode;
while(tcur != NULL) {
string tname((const char*)(tcur->name));
if(tname == OrbitalBuilderBase::det_tag) {
bool newset=true;
string detname("det");
a=xmlGetProp(tcur,(const xmlChar*)"id");
if(a) {
detname = (const char*)a;
} else {
//when id is not given, newset is set to false
if(DetCounter.size()) newset=false;
}
string detref(detname);
//else {
// ostringstream idassigned(detname);
// idassigned << "dummy";
//}
a=xmlGetProp(tcur,(const xmlChar*)"ref");
if(a) {
detref=(const char*)a;
if(DetCounter.find(detref) != DetCounter.end()) {
newset=false;
}
}
a=xmlGetProp(tcur,(const xmlChar*)"orbitals");
int norbs = atoi((const char*)a);
xmlNodePtr c=tcur->children;
while(c != NULL) {
nodeToBeRemoved.push_back(c);c=c->next;
}
if(newset) {
SPOSetType* psi=new SPOSetType(basisSet,nels);
psi->put(tcur);
psi->setName(detname);
psi->resize(norbs);
DetCounter[detname]=InOrbs.size();
InOrbs.push_back(psi);
//InOrbs[detname]=psi;
}
//add src attribute
string detsrc=troot+"."+detref;
if(xmlHasProp(tcur,(const xmlChar*)"src")) {
xmlSetProp(tcur,(const xmlChar*)"src",(const xmlChar*)detsrc.c_str());
} else {
xmlNewProp(tcur,(const xmlChar*)"src",(const xmlChar*)detsrc.c_str());
}
nels+=norbs;
}
tcur = tcur->next;
}
}
cur = cur->next;
}
//resize with respect to the number of electrons
basisSet->resize(nels);
//DistanceTable::create(1);
el.setUpdateMode(MCWalkerConfiguration::Update_Particle);
//Need only one electron to calculate this
//map<string,SPOSetType*>::iterator oit(InOrbs.begin());
//Create one-dimensional grids for three orthogonal directions
typedef LinearGrid<double> GridType;
GridType *gridX=new GridType;
GridType *gridY=new GridType;
GridType *gridZ=new GridType;
gridX->set(ri[0],rf[0],npts[0]);
gridY->set(ri[1],rf[1],npts[1]);
gridZ->set(ri[2],rf[2],npts[2]);
typedef TriCubicSplineT<ValueType> NOType;
XYZCubicGrid<RealType> *grid3 = new XYZCubicGrid<RealType>(gridX,gridY,gridZ);
int ntot = npts[0]*npts[1]*npts[2];
//vector<ValueType> phi(inorb->numOrbitals(),0.0);
vector<ValueType> dat(ntot);
Pooma::Clock timer;
char oname[128];
//sprintf(oname,"%s.wf.xml",troot.c_str());
//ofstream oxml(oname);
//oxml << "<?xml version=\"1.0\"?>" << endl;
//oxml << "<determinantset type=\"spline3d\" src=\"" << troot << "\">" << endl;
//oxml << " <basisset ref=\"i\">" << endl;
//oxml << " <distancetable source=\"i\" target=\"e\"/>" << endl;
//oxml << " <spline type=\"cubic\">" << endl;
//oxml << " <grid dir=\"0\" ri=\""<<ri[0] << "\" rf=\"" << rf[0] << "\" npts=\"" << npts[0] << "\"/>" << endl;
//oxml << " <grid dir=\"1\" ri=\""<<ri[1] << "\" rf=\"" << rf[1] << "\" npts=\"" << npts[1] << "\"/>" << endl;
//oxml << " <grid dir=\"2\" ri=\""<<ri[2] << "\" rf=\"" << rf[2] << "\" npts=\"" << npts[2] << "\"/>" << endl;
//oxml << " </spline>" << endl;
//oxml << "</determinantset>" << endl;
cout << "XYZCubicGrid " << endl;
cout << " x " << ri[0] << " " << rf[0] << " " << npts[0] << endl;
cout << " y " << ri[1] << " " << rf[1] << " " << npts[1] << endl;
cout << " z " << ri[2] << " " << rf[2] << " " << npts[2] << endl;
std::vector<RealType> lapsed_time(5,0.0);
PosType pos(el.R[0]);
map<string,int>::iterator dit(DetCounter.begin());
//loop over unique determinant sets
while(dit != DetCounter.end()) {
SPOSetType* inorb=InOrbs[(*dit).second];
string detID((*dit).first);
for(int iorb=0; iorb<inorb->numOrbitals(); iorb++) { //evaluate the values on the grid points
NOType *torb = new NOType(grid3);
timer.start();
for(int ix=1; ix<npts[0]-1; ix++) {
RealType x((*gridX)(ix));
for(int iy=1; iy<npts[1]-1; iy++) {
RealType y((*gridY)(iy));
for(int iz=1; iz<npts[2]-1; iz++) {
PosType dr(x,y,(*gridZ)(iz));
PosType newpos(el.makeMove(0,dr-pos));
(*torb)(ix,iy,iz) = inorb->evaluate(el,0,iorb);
}
}
}
timer.stop();
lapsed_time[0]+= timer.cpu_time();
//spline
timer.start();
torb->reset(false);
timer.stop();
lapsed_time[1]+= timer.cpu_time();
//test
timer.start();
for(int ix=0; ix<npts[0]-1; ix++) {
double x((*gridX)(ix));
for(int iy=0; iy<npts[1]-1; iy++) {
double y((*gridY)(iy));
int offset=npts[2]*(iy+npts[1]*ix);
for(int iz=0; iz<npts[2]-1; iz++,offset++) {
TinyVector<double,3> p(x,y,(*gridZ)(iz));
dat[offset]=torb->evaluate(p);
}
}
}
timer.stop();
lapsed_time[2]+= timer.cpu_time();
timer.start();
sprintf(oname,"%s.%s.wf%04d.h5",troot.c_str(),detID.c_str(),iorb);
hid_t h_file = H5Fcreate(oname,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);
HDFAttribIO<std::vector<double> > dump(dat,npts);
dump.write(h_file,"Orbital");
HDFAttribIO<TriCubicSplineT<double> > dump1(*torb);
dump1.write(h_file,"CubicSpline");
H5Fclose(h_file);
timer.stop();
lapsed_time[3]+= timer.cpu_time();
//add to SPOSet
sprintf(oname,"%s.%s.wf%04d",troot.c_str(),detID.c_str(),iorb);
SPOSet[oname]=torb;
}
++dit;
}
cout << "Timing results in sec" << endl;
cout << "Function evaluation " << nels << " orbitals = " << lapsed_time[0] << endl;
//cout << "Function evaluation " << inorb->numOrbitals() << " orbitals = " << lapsed_time[0] << endl;
cout << "Spline coefficients = " << lapsed_time[1] << endl;
cout << "Testing spline = " << lapsed_time[2] << endl;
cout << "Writing hdf5 files = " << lapsed_time[3] << endl;
//HDFAttribIO<TriCubicSplineT<double> > dump1(torb);
//dump1.write(h_file,"spline0000");
//
for(int i=0; i<nodeToBeRemoved.size(); i++) {
xmlUnlinkNode(nodeToBeRemoved[i]);
xmlFreeNode(nodeToBeRemoved[i]);
}
xmlSetProp(curRoot,(const xmlChar*)"type",(const xmlChar*)"spline3d");
//spline is missing
if(splinePtr == 0) {
splinePtr = xmlNewNode(NULL,(const xmlChar*)"spline");
for(int idir=0; idir<3; idir++) {
xmlNodePtr x = xmlNewNode(NULL,(const xmlChar*)"grid");
std::ostringstream dir_str, ri_str, rf_str, npts_str;
dir_str << idir; ri_str << ri[idir]; rf_str << rf[idir]; npts_str << npts[idir];
xmlNewProp(x,(const xmlChar*)"dir", (const xmlChar*)dir_str.str().c_str());
xmlNewProp(x,(const xmlChar*)"ri", (const xmlChar*)ri_str.str().c_str());
xmlNewProp(x,(const xmlChar*)"rf", (const xmlChar*)rf_str.str().c_str());
xmlNewProp(x,(const xmlChar*)"npts",(const xmlChar*)npts_str.str().c_str());
xmlAddChild(splinePtr,x);
}
xmlAddPrevSibling(firstSlaterDetPtr,splinePtr);
}
//clean up temporary orbitals
for(int i=0; i<InOrbs.size(); i++) delete InOrbs[i];
//return the modified node
return curRoot;
}
}
/***************************************************************************
* $RCSfile$ $Author$
* $Revision$ $Date$
* $Id$
***************************************************************************/

83
src/QMCApp/MO2Grid3D.h Normal file
View File

@ -0,0 +1,83 @@
//////////////////////////////////////////////////////////////////
// (c) Copyright 2003- by Jeongnim Kim
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Jeongnim Kim
// National Center for Supercomputing Applications &
// Materials Computation Center
// University of Illinois, Urbana-Champaign
// Urbana, IL 61801
// e-mail: jnkim@ncsa.uiuc.edu
// Tel: 217-244-6319 (NCSA) 217-333-3324 (MCC)
//
// Supported by
// National Center for Supercomputing Applications, UIUC
// Materials Computation Center, UIUC
// Department of Physics, Ohio State University
// Ohio Supercomputer Center
//////////////////////////////////////////////////////////////////
// -*- C++ -*-
#ifndef OHMMS_QMC_MOLECULARORBITALS2GRID3D_H
#define OHMMS_QMC_MOLECULARORBITALS2GRID3D_H
#include "QMCApp/QMCAppBase.h"
#include "Particle/MCWalkerConfiguration.h"
#include "QMCWaveFunctions/TrialWaveFunction.h"
#include "Numerics/TriCubicSplineT.h"
namespace ohmmsqmc {
/** An application to transform Molecular Orbitals on a regular grid
*/
class MO2Grid3D: public QMCAppBase {
public:
typedef OrbitalBase::RealType RealType;
typedef OrbitalBase::ValueType ValueType;
typedef OrbitalBase::PosType PosType;
///constructor
MO2Grid3D(int argc, char** argv);
///destructor
~MO2Grid3D();
///validate an input file
bool validateXML();
///do something
bool execute();
///generate a set of numerical orbitals
xmlNodePtr generateNumericalOrbitals(xmlNodePtr cur);
/** transfer the wavefunction to other
* @param other container to which SPOSet will be copied.
*
* This function is introduced for an OrbitalBuilder object
* which takes a normal XML file for Molecular Orbitals represented
* by radial orbitals and spherical harmonics and requests
* mapping to numerical 3D data for QMC.
* See QMCWaveFunctions/NumericalOrbitalBuilder.cpp
*/
void copyOrbitalSet(map<string,TriCubicSplineT<ValueType>* >& other);
private:
xmlXPathContextPtr m_context;
MCWalkerConfiguration el;
ParticleSet ion;
TrialWaveFunction Psi;
bool setParticleSets(xmlNodePtr aroot);
bool setWavefunctions(xmlNodePtr aroot);
map<string,TriCubicSplineT<ValueType>* > SPOSet;
};
}
#endif
/***************************************************************************
* $RCSfile$ $Author$
* $Revision$ $Date$
* $Id$
***************************************************************************/

View File

@ -0,0 +1,70 @@
//////////////////////////////////////////////////////////////////
// (c) Copyright 2003- by Jeongnim Kim
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Jeongnim Kim
// National Center for Supercomputing Applications &
// Materials Computation Center
// University of Illinois, Urbana-Champaign
// Urbana, IL 61801
// e-mail: jnkim@ncsa.uiuc.edu
// Tel: 217-244-6319 (NCSA) 217-333-3324 (MCC)
//
// Supported by
// National Center for Supercomputing Applications, UIUC
// Materials Computation Center, UIUC
// Department of Physics, Ohio State University
// Ohio Supercomputer Center
//////////////////////////////////////////////////////////////////
// -*- C++ -*-
#include "QMCApp/ParticleSetPool.h"
#include "OhmmsData/AttributeSet.h"
#include "ParticleIO/XMLParticleIO.h"
namespace ohmmsqmc {
ParticleSetPool::ParticleSetPool(const char* aname):
OhmmsElementBase(aname){ }
bool ParticleSetPool::put(xmlNodePtr cur) {
string id("e"), role("none");
OhmmsAttributeSet pAttrib;
pAttrib.add(id,"id"); pAttrib.add(id,"name");
pAttrib.add(role,"role");
//backward compatibility
if(id == "e" && role=="none") role="MC";
ParticleSet* pTemp = getParticleSet(id);
if(pTemp == 0) {
pTemp = new MCWalkerConfiguration;
//if(role == "MC")
// pTemp = new MCWalkerConfiguration;
//else
// pTemp = new ParticleSet;
myPool[id] = pTemp;
XMLParticleParser pread(*pTemp);
return pread.put(cur);
}//possible overwrite
return true;
}
bool ParticleSetPool::put(std::istream& is) {
return true;
}
bool ParticleSetPool::get(std::ostream& os) const {
return true;
}
void ParticleSetPool::reset() {
}
}
/***************************************************************************
* $RCSfile$ $Author$
* $Revision$ $Date$
* $Id$
***************************************************************************/

View File

@ -0,0 +1,72 @@
//////////////////////////////////////////////////////////////////
// (c) Copyright 2003- by Jeongnim Kim
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Jeongnim Kim
// National Center for Supercomputing Applications &
// Materials Computation Center
// University of Illinois, Urbana-Champaign
// Urbana, IL 61801
// e-mail: jnkim@ncsa.uiuc.edu
// Tel: 217-244-6319 (NCSA) 217-333-3324 (MCC)
//
// Supported by
// National Center for Supercomputing Applications, UIUC
// Materials Computation Center, UIUC
// Department of Physics, Ohio State University
// Ohio Supercomputer Center
//////////////////////////////////////////////////////////////////
// -*- C++ -*-
#ifndef OHMMS_QMC_PARTICLESETPOOL_H
#define OHMMS_QMC_PARTICLESETPOOL_H
#include "OhmmsData/OhmmsElementBase.h"
#include "Particle/MCWalkerConfiguration.h"
namespace ohmmsqmc {
/* A collection of ParticleSet
*/
class ParticleSetPool : public OhmmsElementBase {
public:
typedef map<string,ParticleSet*> PoolType;
ParticleSetPool(const char* aname = "particleset");
bool get(std::ostream& os) const;
bool put(std::istream& is);
bool put(xmlNodePtr cur);
void reset();
inline bool empty() const { return myPool.empty();}
ParticleSet* getParticleSet(const string& pname) {
map<string,ParticleSet*>::iterator pit(myPool.find(pname));
if(pit == myPool.end())
return 0;
else
(*pit).second;
}
MCWalkerConfiguration* getWalkerSet(const string& pname) {
map<string,ParticleSet*>::iterator pit(myPool.find(pname));
if(pit == myPool.end())
return 0;
else
return dynamic_cast<MCWalkerConfiguration*>((*pit).second);
}
inline PoolType& getPool() { return myPool;}
private:
map<string,ParticleSet*> myPool;
};
}
#endif
/***************************************************************************
* $RCSfile$ $Author$
* $Revision$ $Date$
* $Id$
***************************************************************************/

78
src/QMCApp/QMCAppBase.cpp Normal file
View File

@ -0,0 +1,78 @@
//////////////////////////////////////////////////////////////////
// (c) Copyright 2003- by Jeongnim Kim
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Jeongnim Kim
// National Center for Supercomputing Applications &
// Materials Computation Center
// University of Illinois, Urbana-Champaign
// Urbana, IL 61801
// e-mail: jnkim@ncsa.uiuc.edu
// Tel: 217-244-6319 (NCSA) 217-333-3324 (MCC)
//
// Supported by
// National Center for Supercomputing Applications, UIUC
// Materials Computation Center, UIUC
// Department of Physics, Ohio State University
// Ohio Supercomputer Center
//////////////////////////////////////////////////////////////////
// -*- C++ -*-
#include "QMCApp/QMCAppBase.h"
#include "Utilities/OhmmsInfo.h"
namespace ohmmsqmc {
QMCAppBase::QMCAppBase(int argc, char** argv):
m_doc(NULL),m_root(NULL)
{
}
QMCAppBase::~QMCAppBase() {
if(m_doc != NULL) {
xmlFreeDoc(m_doc);
}
DEBUGMSG("QMCAppBase::~QMCAppBase")
}
/** parse an input file
* @param infile name of an input file
* @return true, if the document is a valid xml file.
*
* The data members m_doc and m_root point to the "current" document and
* root element.
*/
bool QMCAppBase::parse(const string& infile) {
//clear the context and document
if(m_doc != NULL) xmlFreeDoc(m_doc);
// build an XML tree from a the file;
m_doc = xmlParseFile(infile.c_str());
if (m_doc == NULL) {
ERRORMSG("File " << infile << " is invalid")
return false;
}
// Check the document is of the right kind
xmlNodePtr cur = xmlDocGetRootElement(m_doc);
if (cur == NULL) {
ERRORMSG("Empty document");
return false;
}
//set the root and create the context map
m_root = cur;
return true;
}
void QMCAppBase::saveXml() {
string newxml(myProject.CurrentRoot());
newxml.append(".cont.xml");
xmlSaveFormatFile(newxml.c_str(),m_doc,1);
}
}
/***************************************************************************
* $RCSfile$ $Author$
* $Revision$ $Date$
* $Id$
***************************************************************************/

66
src/QMCApp/QMCAppBase.h Normal file
View File

@ -0,0 +1,66 @@
//////////////////////////////////////////////////////////////////
// (c) Copyright 2003- by Jeongnim Kim
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Jeongnim Kim
// National Center for Supercomputing Applications &
// Materials Computation Center
// University of Illinois, Urbana-Champaign
// Urbana, IL 61801
// e-mail: jnkim@ncsa.uiuc.edu
// Tel: 217-244-6319 (NCSA) 217-333-3324 (MCC)
//
// Supported by
// National Center for Supercomputing Applications, UIUC
// Materials Computation Center, UIUC
// Department of Physics, Ohio State University
// Ohio Supercomputer Center
//////////////////////////////////////////////////////////////////
// -*- C++ -*-
#ifndef OHMMS_QMC_QMCAPPLICATIONBASE_H
#define OHMMS_QMC_QMCAPPLICATIONBASE_H
#include "OhmmsData/OhmmsElementBase.h"
#include "OhmmsApp/ProjectData.h"
#include "OhmmsApp/RandomNumberControl.h"
namespace ohmmsqmc {
/** Main application to perform QMC simulations
*
* This is a generalized QMC application which can handle multiple particle sets,
* walker configurations, hamiltonians and wavefunctions
*/
class QMCAppBase {
public:
///constructor
QMCAppBase(int argc, char** argv);
///destructor
~QMCAppBase();
bool parse(const string& infile);
void saveXml();
virtual bool validateXML() = 0;
virtual bool execute() = 0;
protected:
xmlDocPtr m_doc;
xmlNodePtr m_root;
///project description
OHMMS::ProjectData myProject;
///random number controller
OHMMS::RandomNumberControl myRandomControl;
};
}
#endif
/***************************************************************************
* $RCSfile$ $Author$
* $Revision$ $Date$
* $Id$
***************************************************************************/

323
src/QMCApp/QMCMain.cpp Normal file
View File

@ -0,0 +1,323 @@
//////////////////////////////////////////////////////////////////
// (c) Copyright 2003- by Jeongnim Kim
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Jeongnim Kim
// National Center for Supercomputing Applications &
// Materials Computation Center
// University of Illinois, Urbana-Champaign
// Urbana, IL 61801
// e-mail: jnkim@ncsa.uiuc.edu
// Tel: 217-244-6319 (NCSA) 217-333-3324 (MCC)
//
// Supported by
// National Center for Supercomputing Applications, UIUC
// Materials Computation Center, UIUC
// Department of Physics, Ohio State University
// Ohio Supercomputer Center
//////////////////////////////////////////////////////////////////
// -*- C++ -*-
#include "QMCApp/QMCMain.h"
#include "QMCApp/ParticleSetPool.h"
#include "QMCApp/WaveFunctionPool.h"
#include "QMCApp/HamiltonianPool.h"
#include "QMCWaveFunctions/TrialWaveFunction.h"
#include "QMCHamiltonians/QMCHamiltonian.h"
#include "QMCHamiltonians/ConservedEnergy.h"
#include "QMCDrivers/VMC.h"
#include "QMCDrivers/VMCParticleByParticle.h"
#include "QMCDrivers/DMCParticleByParticle.h"
#include "QMCDrivers/VMC_OPT.h"
#include "QMCDrivers/MolecuDMC.h"
#include "QMCDrivers/ReptationMC.h"
#include "Utilities/OhmmsInfo.h"
#include "Particle/HDFWalkerIO.h"
using namespace std;
namespace ohmmsqmc {
QMCMain::QMCMain(int argc, char** argv): QMCAppBase(argc,argv),
qmcDriver(0),qmcSystem(0){
//create ParticleSetPool
ptclPool = new ParticleSetPool;
//create WaveFunctionPool
psiPool = new WaveFunctionPool;
psiPool->setParticleSetPool(ptclPool);
//create HamiltonianPool
hamPool = new HamiltonianPool;
hamPool->setParticleSetPool(ptclPool);
hamPool->setWaveFunctionPool(psiPool);
}
///destructor
QMCMain::~QMCMain() {
DEBUGMSG("QMCMain::~QMCMain")
delete hamPool;
delete psiPool;
delete hamPool;
xmlFreeDoc(m_doc);
}
bool QMCMain::execute() {
bool success = validateXML();
if(!success) return false;
curMethod = string("invalid");
xmlNodePtr cur=m_root->children;
while(cur != NULL) {
string cname((const char*)cur->name);
if(cname == "qmc") runQMC(cur);
xmlNodePtr tcur= cur;
cur=cur->next;
xmlUnlinkNode(tcur);
xmlFreeNode(tcur);
}
xmlNodePtr aqmc = xmlNewNode(NULL,(const xmlChar*)"qmc");
xmlNewProp(aqmc,(const xmlChar*)"method",(const xmlChar*)"dmc");
xmlNodePtr aparam = xmlNewNode(NULL,(const xmlChar*)"parameter");
xmlNewProp(aparam,(const xmlChar*)"name",(const xmlChar*)"en_ref");
char ref_energy[128];
sprintf(ref_energy,"%15.5e",qmcSystem->getLocalEnergy());
xmlNodeSetContent(aparam,(const xmlChar*)ref_energy);
xmlAddChild(aqmc,aparam);
xmlAddChild(m_root,aqmc);
saveXml();
return true;
}
/** create basic objects
* @return false, if any of the basic objects is not properly created.
*
* Current xml schema is changing. Instead validating the input file,
* we use xpath to create necessary objects. The order follows
* - project: determine the simulation title and sequence
* - random: initialize random number generator
* - particleset: create all the particleset
* - wavefunction: create wavefunctions
* - hamiltonian: create hamiltonians
* Finally, if /simulation/mcwalkerset exists, read the configurations
* from the external files.
*/
bool QMCMain::validateXML() {
xmlXPathContextPtr 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);
}
//check particleset/wavefunction/hamiltonian of the current document
processContext(m_context);
//check if there are any include
xmlNodePtr cur=m_root->children;
while(cur != NULL) {
string cname((const char*)cur->name);
if(cname == "include") {//file is provided
const xmlChar* a=xmlGetProp(cur,(const xmlChar*)"href");
if(a) {
//root and document are saved
xmlNodePtr root_save=m_root;
xmlDocPtr doc_save=m_doc;
//parse a new file
m_doc=NULL;
parse((const char*)a);
xmlXPathContextPtr context_=xmlXPathNewContext(m_doc);
processContext(context_);
xmlXPathFreeContext(context_);
xmlFreeDoc(m_doc);
//copy the original root and document
m_root = root_save;
m_doc = doc_save;
}
}
cur=cur->next;
}
if(ptclPool->empty()) {
ERRORMSG("Illegal input. Missing particleset ")
return false;
}
if(psiPool->empty()) {
ERRORMSG("Illegal input. Missing wavefunction. ")
return false;
}
if(hamPool->empty()) {
ERRORMSG("Illegal input. Missing hamiltonian. ")
return false;
}
setMCWalkers(m_context);
xmlXPathFreeContext(m_context);
return true;
}
void QMCMain::processContext(xmlXPathContextPtr context_) {
xmlXPathObjectPtr result
= xmlXPathEvalExpression((const xmlChar*)"//particleset",context_);
for(int i=0; i<result->nodesetval->nodeNr; i++) {
ptclPool->put(result->nodesetval->nodeTab[i]);
}
xmlXPathFreeObject(result);
result=xmlXPathEvalExpression((const xmlChar*)"//wavefunction",context_);
for(int i=0; i<result->nodesetval->nodeNr; i++) {
psiPool->put(result->nodesetval->nodeTab[i]);
}
xmlXPathFreeObject(result);
result=xmlXPathEvalExpression((const xmlChar*)"//hamiltonian",context_);
for(int i=0; i<result->nodesetval->nodeNr; i++) {
hamPool->put(result->nodesetval->nodeTab[i]);
}
xmlXPathFreeObject(result);
}
/** prepare for a QMC run
* @param cur qmc element
* @return true, if a valid QMCDriver is set.
*/
bool QMCMain::runQMC(xmlNodePtr cur) {
string what("invalid");
xmlChar* att=xmlGetProp(cur,(const xmlChar*)"method");
if(att) what = (const char*)att;
//if(qmcDriver) {
// if(what == curMethod) {
// return true;
// } else {
// delete qmcDriver;
// qmcDriver = 0;
// }
//}
qmcDriver=0;
qmcSystem = ptclPool->getWalkerSet("e");
TrialWaveFunction* psi= psiPool->getWaveFunction("primary");
QMCHamiltonian* h=hamPool->getHamiltonian("primary");
if (what == "vmc"){
h->add(new ConservedEnergy,"Flux");
qmcDriver = new VMC(*qmcSystem,*psi,*h);
} else if(what == "vmc-ptcl"){
h->add(new ConservedEnergy,"Flux");
qmcDriver = new VMCParticleByParticle(*qmcSystem,*psi,*h);
} else if(what == "dmc"){
MolecuDMC *dmc = new MolecuDMC(*qmcSystem,*psi,*h);
dmc->setBranchInfo(PrevConfigFile);
qmcDriver=dmc;
} else if(what == "dmc-ptcl"){
DMCParticleByParticle *dmc = new DMCParticleByParticle(*qmcSystem,*psi,*h);
dmc->setBranchInfo(PrevConfigFile);
qmcDriver=dmc;
} else if(what == "optimize"){
VMC_OPT *vmc = new VMC_OPT(*qmcSystem,*psi,*h);
vmc->addConfiguration(PrevConfigFile);
qmcDriver=vmc;
} else if(what == "rmc") {
qmcDriver = new ReptationMC(*qmcSystem,*psi,*h);
//} else if(what == "vmc-multi") {
// qmcDriver = new VMCMultiple(*qmcSystem,*psi,*h);
}
if(qmcDriver) {
LOGMSG("Starting a QMC simulation " << curMethod)
qmcDriver->setFileRoot(myProject.CurrentRoot());
qmcDriver->process(cur);
qmcDriver->run();
//keeps track of the configuration file
PrevConfigFile = myProject.CurrentRoot();
//change the content of mcwalkerset/@file attribute
for(int i=0; i<m_walkerset.size(); i++) {
xmlSetProp(m_walkerset[i],
(const xmlChar*)"file", (const xmlChar*)myProject.CurrentRoot());
}
myProject.advance();
curMethod = what;
//may want to reuse!
delete qmcDriver;
} else {
return false;
}
}
bool QMCMain::setMCWalkers(xmlXPathContextPtr context_) {
xmlXPathObjectPtr result
= xmlXPathEvalExpression((const xmlChar*)"/simulation/mcwalkerset",context_);
if(xmlXPathNodeSetIsEmpty(result->nodesetval)) {
if(m_walkerset.empty()) {
xmlNodePtr newnode_ptr = xmlNewNode(NULL,(const xmlChar*)"mcwalkerset");
xmlNewProp(newnode_ptr,(const xmlChar*)"file", (const xmlChar*)"nothing");
xmlAddChild(m_root,newnode_ptr);
m_walkerset.push_back(newnode_ptr);
}
} else {
int pid=OHMMS::Controller->mycontext();
for(int iconf=0; iconf<result->nodesetval->nodeNr; iconf++) {
int pid_target=pid;
xmlNodePtr mc_ptr = result->nodesetval->nodeTab[iconf];
m_walkerset.push_back(mc_ptr);
xmlChar* att=xmlGetProp(mc_ptr,(const xmlChar*)"file");
xmlChar* anode=xmlGetProp(mc_ptr,(const xmlChar*)"node");
if(anode) {
pid_target = atoi((const char*)anode);
}
if(pid_target == pid && att) {
string cfile((const char*)att);
string target("e");
xmlChar* pref=xmlGetProp(mc_ptr,(const xmlChar*)"ref");
if(pref) target = (const char*)pref;
MCWalkerConfiguration* el=ptclPool->getWalkerSet(target);
XMLReport("Using previous configuration from " << cfile)
HDFWalkerInput WO(cfile);
//read only the last ensemble of walkers
WO.put(*el,-1);
PrevConfigFile = cfile;
}
}
}
xmlXPathFreeObject(result);
return true;
}
}
/***************************************************************************
* $RCSfile$ $Author$
* $Revision$ $Date$
* $Id$
***************************************************************************/

77
src/QMCApp/QMCMain.h Normal file
View File

@ -0,0 +1,77 @@
//////////////////////////////////////////////////////////////////
// (c) Copyright 2003- by Jeongnim Kim
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Jeongnim Kim
// National Center for Supercomputing Applications &
// Materials Computation Center
// University of Illinois, Urbana-Champaign
// Urbana, IL 61801
// e-mail: jnkim@ncsa.uiuc.edu
// Tel: 217-244-6319 (NCSA) 217-333-3324 (MCC)
//
// Supported by
// National Center for Supercomputing Applications, UIUC
// Materials Computation Center, UIUC
// Department of Physics, Ohio State University
// Ohio Supercomputer Center
//////////////////////////////////////////////////////////////////
// -*- C++ -*-
#ifndef OHMMS_QMC_MAINAPPLICATIONS_H
#define OHMMS_QMC_MAINAPPLICATIONS_H
#include "QMCApp/QMCAppBase.h"
namespace ohmmsqmc {
class MCWalkerConfiguration;
class QMCDriver;
class ParticleSetPool;
class WaveFunctionPool;
class HamiltonianPool;
/** Main application to perform QMC simulations
*
* This is a generalized QMC application which can handle multiple particle sets,
* walker configurations, hamiltonians and wavefunctions
*/
class QMCMain: public QMCAppBase {
public:
///constructor
QMCMain(int argc, char** argv);
///destructor
~QMCMain();
bool validateXML();
bool execute();
private:
std::string curMethod;
QMCDriver *qmcDriver;
MCWalkerConfiguration *qmcSystem;
ParticleSetPool* ptclPool;
WaveFunctionPool* psiPool;
HamiltonianPool* hamPool;
///previous configuration file for next qmc node
string PrevConfigFile;
///name of file that stores configurations (walkers)
vector<xmlNodePtr> m_walkerset;
bool runQMC(xmlNodePtr cur);
bool setMCWalkers(xmlXPathContextPtr cur);
void processContext(xmlXPathContextPtr context_);
};
}
#endif
/***************************************************************************
* $RCSfile$ $Author$
* $Revision$ $Date$
* $Id$
***************************************************************************/

View File

@ -0,0 +1,91 @@
//////////////////////////////////////////////////////////////////
// (c) Copyright 2003- by Jeongnim Kim
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Jeongnim Kim
// National Center for Supercomputing Applications &
// Materials Computation Center
// University of Illinois, Urbana-Champaign
// Urbana, IL 61801
// e-mail: jnkim@ncsa.uiuc.edu
// Tel: 217-244-6319 (NCSA) 217-333-3324 (MCC)
//
// Supported by
// National Center for Supercomputing Applications, UIUC
// Materials Computation Center, UIUC
// Department of Physics, Ohio State University
// Ohio Supercomputer Center
//////////////////////////////////////////////////////////////////
// -*- C++ -*-
#include "QMCApp/WaveFunctionPool.h"
#include "QMCApp/ParticleSetPool.h"
#include "QMCWaveFunctions/TrialWaveFunction.h"
#include "QMCWaveFunctions/JastrowBuilder.h"
#include "QMCWaveFunctions/MolecularOrbitals/MolecularOrbitalBuilder.h"
using namespace std;
#include "OhmmsData/AttributeSet.h"
#include "Utilities/OhmmsInfo.h"
namespace ohmmsqmc {
WaveFunctionPool::WaveFunctionPool(const char* aname):OhmmsElementBase(aname){ }
bool WaveFunctionPool::put(xmlNodePtr cur) {
string id("primary"), target("e");
OhmmsAttributeSet pAttrib;
pAttrib.add(id,"id"); pAttrib.add(id,"name");
pAttrib.add(target,"target"); pAttrib.add(target,"ref");
ParticleSet *p = ptclPool->getParticleSet(target);
if(p == 0) {
ERRORMSG("Wavefunction cannot be created because of missing particle set " << target)
return false;
}
TrialWaveFunction *psi = getWaveFunction(id);
if(psi) {
WARNMSG("wavefunction with " << id << " is already created. Ignore the input")
return true;
}
psi = new TrialWaveFunction;
//add particles associated with this wave function
cur = cur->children;
while(cur != NULL) {
string cname((const char*)(cur->name));
if (cname == OrbitalBuilderBase::detset_tag) {
string orbtype=(const char*)(xmlGetProp(cur, (const xmlChar *)"type"));
LOGMSG("Slater-determinant terms using " << orbtype)
if(orbtype == "MolecularOrbital") {
MolecularOrbitalBuilder a(*p,*psi,ptclPool->getPool());
a.put(cur);
}
} else if (cname == OrbitalBuilderBase::jastrow_tag) {
JastrowBuilder a(*p,*psi,ptclPool->getPool());
a.put(cur);
}
cur = cur->next;
}
return true;
}
bool WaveFunctionPool::put(std::istream& is) {
return true;
}
bool WaveFunctionPool::get(std::ostream& os) const {
return true;
}
void WaveFunctionPool::reset() {
}
}
/***************************************************************************
* $RCSfile$ $Author$
* $Revision$ $Date$
* $Id$
***************************************************************************/

View File

@ -0,0 +1,68 @@
//////////////////////////////////////////////////////////////////
// (c) Copyright 2003- by Jeongnim Kim
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Jeongnim Kim
// National Center for Supercomputing Applications &
// Materials Computation Center
// University of Illinois, Urbana-Champaign
// Urbana, IL 61801
// e-mail: jnkim@ncsa.uiuc.edu
// Tel: 217-244-6319 (NCSA) 217-333-3324 (MCC)
//
// Supported by
// National Center for Supercomputing Applications, UIUC
// Materials Computation Center, UIUC
// Department of Physics, Ohio State University
// Ohio Supercomputer Center
//////////////////////////////////////////////////////////////////
// -*- C++ -*-
#ifndef OHMMS_QMC_WAVEFUNCTIONPOOL_H
#define OHMMS_QMC_WAVEFUNCTIONPOOL_H
#include "OhmmsData/OhmmsElementBase.h"
#include <map>
#include <string>
namespace ohmmsqmc {
class TrialWaveFunction;
class ParticleSetPool;
/* A collection of TrialWaveFunction s
*/
class WaveFunctionPool : public OhmmsElementBase {
public:
WaveFunctionPool(const char* aname = "wavefunction");
bool get(std::ostream& os) const;
bool put(std::istream& is);
bool put(xmlNodePtr cur);
void reset();
inline bool empty() const { return myPool.empty();}
TrialWaveFunction* getWaveFunction(const std::string& pname) {
std::map<std::string,TrialWaveFunction*>::iterator pit(myPool.find(pname));
if(pit == myPool.end())
return 0;
else
(*pit).second;
}
inline void setParticleSetPool(ParticleSetPool* pset) { ptclPool=pset;}
private:
ParticleSetPool* ptclPool;
std::map<std::string,TrialWaveFunction*> myPool;
};
}
#endif
/***************************************************************************
* $RCSfile$ $Author$
* $Revision$ $Date$
* $Id$
***************************************************************************/

View File

@ -0,0 +1,60 @@
//////////////////////////////////////////////////////////////////
// (c) Copyright 2003- by Jeongnim Kim
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Jeongnim Kim
// National Center for Supercomputing Applications &
// Materials Computation Center
// University of Illinois, Urbana-Champaign
// Urbana, IL 61801
// e-mail: jnkim@ncsa.uiuc.edu
// Tel: 217-244-6319 (NCSA) 217-333-3324 (MCC)
//
// Supported by
// National Center for Supercomputing Applications, UIUC
// Materials Computation Center, UIUC
// Department of Physics, Ohio State University
// Ohio Supercomputer Center
//////////////////////////////////////////////////////////////////
// -*- C++ -*-
#include "Message/Communicate.h"
#include "Utilities/OhmmsInfo.h"
#include "QMCApp/MO2Grid3D.h"
/**file main.cpp
*@brief a main function for QMC simulation.
*Actual works are done by QMCApps and its derived classe.
*For other simulations, one can derive a class from QMCApps, similarly to MolecuApps.
*
*Only requirements are the constructor and init function to initialize.
*/
int main(int argc, char **argv) {
OHMMS::Controller->initialize(argc,argv);
OhmmsInfo welcome(argc,argv,OHMMS::Controller->mycontext());
ohmmsqmc::MO2Grid3D qmc(argc,argv);
if(argc>1) {
if(qmc.parse(argv[1])) {
qmc.execute();
qmc.saveXml();
}
//xmlFreeDoc(m_doc);
} else {
ERRORMSG("No input file is given.")
ERRORMSG("usage: mo2grid3d input-file")
}
LOGMSG("Bye")
OHMMS::Controller->finalize();
return 0;
}
/***************************************************************************
* $RCSfile$ $Author$
* $Revision$ $Date$
* $Id$
***************************************************************************/

59
src/QMCApp/qmcapp.cpp Normal file
View File

@ -0,0 +1,59 @@
//////////////////////////////////////////////////////////////////
// (c) Copyright 2003- by Jeongnim Kim
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Jeongnim Kim
// National Center for Supercomputing Applications &
// Materials Computation Center
// University of Illinois, Urbana-Champaign
// Urbana, IL 61801
// e-mail: jnkim@ncsa.uiuc.edu
// Tel: 217-244-6319 (NCSA) 217-333-3324 (MCC)
//
// Supported by
// National Center for Supercomputing Applications, UIUC
// Materials Computation Center, UIUC
// Department of Physics, Ohio State University
// Ohio Supercomputer Center
//////////////////////////////////////////////////////////////////
// -*- C++ -*-
#include "Message/Communicate.h"
#include "Utilities/OhmmsInfo.h"
#include "QMCApp/QMCMain.h"
/**file main.cpp
*@brief a main function for QMC simulation.
*Actual works are done by QMCApps and its derived classe.
*For other simulations, one can derive a class from QMCApps, similarly to MolecuApps.
*
*Only requirements are the constructor and init function to initialize.
*/
int main(int argc, char **argv) {
OHMMS::Controller->initialize(argc,argv);
OhmmsInfo welcome(argc,argv,OHMMS::Controller->mycontext());
ohmmsqmc::QMCMain qmc(argc,argv);
if(argc>1) {
if(qmc.parse(argv[1])) {
qmc.execute();
}
//xmlFreeDoc(m_doc);
} else {
ERRORMSG("No input file is given.")
ERRORMSG("usage: qmcapp input-file")
}
LOGMSG("Bye")
OHMMS::Controller->finalize();
return 0;
}
/***************************************************************************
* $RCSfile$ $Author$
* $Revision$ $Date$
* $Id$
***************************************************************************/