From 281c63688eaf42b6a5f013d020eeeeda7968a96c Mon Sep 17 00:00:00 2001 From: Anouar Benali Date: Thu, 30 Mar 2023 13:56:01 -0500 Subject: [PATCH 1/5] Batch version of convert4qmc --- src/QMCTools/QMCGaussianParserBase.cpp | 296 +++++++++++++++++++++++++ src/QMCTools/QMCGaussianParserBase.h | 4 + src/QMCTools/convert4qmc.cpp | 26 ++- 3 files changed, 322 insertions(+), 4 deletions(-) diff --git a/src/QMCTools/QMCGaussianParserBase.cpp b/src/QMCTools/QMCGaussianParserBase.cpp index bb03f0bc71..938ac382bc 100644 --- a/src/QMCTools/QMCGaussianParserBase.cpp +++ b/src/QMCTools/QMCGaussianParserBase.cpp @@ -58,6 +58,8 @@ QMCGaussianParserBase::QMCGaussianParserBase() UseHDF5(false), PBC(false), production(false), + batched(false), + optJStaged(false), zeroCI(false), orderByExcitation(false), addJastrow(true), @@ -2185,6 +2187,300 @@ void QMCGaussianParserBase::dumpStdInputProd(const std::string& psi_tag, const s xmlFreeDoc(doc_input); } +void QMCGaussianParserBase::dumpStdInputBatch(const std::string& psi_tag, const std::string& ion_tag) +{ + std::cout << " Generating production input file designed for large calculations using Batched drivers." << std::endl; + std::cout << " Modify according to the accuracy you would like to achieve. Focus on the walkers_per_rank tag. It should be adjusted based on the number of electron and the type of CPU" << std::endl; + + std::string fname = Title + ".qmc.in-wf" + WFS_name + ".xml"; + + xmlDocPtr doc_input = xmlNewDoc((const xmlChar*)"1.0"); + xmlNodePtr qm_root_input = xmlNewNode(NULL, BAD_CAST "simulation"); + + ///Adding Project id + { + xmlNodePtr project = xmlNewNode(NULL, (const xmlChar*)"project"); + xmlNewProp(project, (const xmlChar*)"id", (const xmlChar*)Title.c_str()); + xmlNewProp(project, (const xmlChar*)"series", (const xmlChar*)"0"); + xmlAddChild(project, parameter(project, "driver_version", "batched")); + xmlAddChild(qm_root_input, project); + } + + ///Adding Link to Partcle Set and Wave function + { + std::string Ptclname = Title + ".structure.xml"; + xmlNodePtr ptcl = xmlNewNode(NULL, (const xmlChar*)"include"); + xmlNewProp(ptcl, (const xmlChar*)"href", (const xmlChar*)Ptclname.c_str()); + xmlAddChild(qm_root_input, ptcl); + + std::string Wfsname = Title + ".wf" + WFS_name + ".xml"; + xmlNodePtr wfs = xmlNewNode(NULL, (const xmlChar*)"include"); + xmlNewProp(wfs, (const xmlChar*)"href", (const xmlChar*)Wfsname.c_str()); + xmlAddChild(qm_root_input, wfs); + } + + ///Adding Hamiltonian + { + xmlAddChild(qm_root_input, createHamiltonian(ion_tag, psi_tag)); + } + ///Adding Optimization Block based on One Shift Only + if (addJastrow) + { + ///Adding a VMC Block to help equilibrate + xmlNodePtr initvmc = xmlNewNode(NULL, (const xmlChar*)"qmc"); + xmlNewProp(initvmc, (const xmlChar*)"method", (const xmlChar*)"vmc_batch"); + xmlNewProp(initvmc, (const xmlChar*)"move", (const xmlChar*)"pbyp"); + xmlNewProp(initvmc, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); + { + xmlAddChild(initvmc, parameter(initvmc, "walkers_per_rank", "100")); + xmlAddChild(initvmc, parameter(initvmc, "substeps", "3")); + xmlAddChild(initvmc, parameter(initvmc, "steps", "20")); + xmlAddChild(initvmc, parameter(initvmc, "warmupSteps", "5")); + xmlAddChild(initvmc, parameter(initvmc, "blocks", "10")); + xmlAddChild(initvmc, parameter(initvmc, "timestep", "0.5")); + xmlAddChild(initvmc, parameter(initvmc, "usedrift", "no")); + } + xmlAddChild(qm_root_input, initvmc); + + if(!optJStaged) + { + ///Adding First loop of Cheap optimization blocks + xmlNodePtr loopopt1 = xmlNewNode(NULL, (const xmlChar*)"loop"); + xmlNewProp(loopopt1, (const xmlChar*)"max", (const xmlChar*)"4"); + { + xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc"); + xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear_batch"); + xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp"); + xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); + //xmlNewProp(initopt,(const xmlChar*)"gpu", (const xmlChar*)"no"); + { + xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator"); + xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy"); + xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no"); + xmlAddChild(initopt, estimator); + + xmlAddChild(initopt, parameter(initopt, "blocks", "20")); + xmlAddChild(initopt, parameter(initopt, "warmupSteps", "10")); + xmlAddChild(initopt, parameter(initopt, "timestep", "0.5")); + xmlAddChild(initopt, parameter(initopt, "walkers_per_rank", "600")); + xmlAddChild(initopt, parameter(initopt, "substeps", "2")); + xmlAddChild(initopt, parameter(initopt, "usedrift", "no")); + xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly")); + xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.1")); + } + xmlAddChild(loopopt1, initopt); + } + xmlAddChild(qm_root_input, loopopt1); + + ///Adding loop for optimization blocks + xmlNodePtr loopopt = xmlNewNode(NULL, (const xmlChar*)"loop"); + xmlNewProp(loopopt, (const xmlChar*)"max", (const xmlChar*)"10"); + { + xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc"); + xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear_batch"); + xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp"); + xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); + //xmlNewProp(initopt,(const xmlChar*)"gpu", (const xmlChar*)"no"); + { + xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator"); + xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy"); + xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no"); + xmlAddChild(initopt, estimator); + + xmlAddChild(initopt, parameter(initopt, "blocks", "20")); + xmlAddChild(initopt, parameter(initopt, "warmupSteps", "10")); + xmlAddChild(initopt, parameter(initopt, "timestep", "0.5")); + xmlAddChild(initopt, parameter(initopt, "walkers_per_rank", "600")); + xmlAddChild(initopt, parameter(initopt, "substeps", "2")); + xmlAddChild(initopt, parameter(initopt, "usedrift", "no")); + xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly")); + xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.5")); + } + xmlAddChild(loopopt, initopt); + } + xmlAddChild(qm_root_input, loopopt); + } + else + { + + ///Adding First loop of Cheap optimization blocks + { + xmlNodePtr loopopt1 = xmlNewNode(NULL, (const xmlChar*)"loop"); + xmlNewProp(loopopt1, (const xmlChar*)"max", (const xmlChar*)"4"); + { + xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc"); + xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear_batch"); + xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp"); + xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); + //xmlNewProp(initopt,(const xmlChar*)"gpu", (const xmlChar*)"no"); + { + xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator"); + xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy"); + xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no"); + xmlAddChild(initopt, estimator); + + xmlAddChild(initopt, parameter(initopt, "variational_subset", "uu ud")); + xmlAddChild(initopt, parameter(initopt, "blocks", "20")); + xmlAddChild(initopt, parameter(initopt, "warmupSteps", "10")); + xmlAddChild(initopt, parameter(initopt, "timestep", "0.5")); + xmlAddChild(initopt, parameter(initopt, "walkers_per_rank", "600")); + xmlAddChild(initopt, parameter(initopt, "substeps", "2")); + xmlAddChild(initopt, parameter(initopt, "usedrift", "no")); + xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly")); + xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.1")); + } + xmlAddChild(loopopt1, initopt); + } + xmlAddChild(qm_root_input, loopopt1); + + ///Adding loop for optimization blocks + xmlNodePtr loopopt = xmlNewNode(NULL, (const xmlChar*)"loop"); + xmlNewProp(loopopt, (const xmlChar*)"max", (const xmlChar*)"10"); + { + xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc"); + xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear_batch"); + xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp"); + xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); + //xmlNewProp(initopt,(const xmlChar*)"gpu", (const xmlChar*)"no"); + { + xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator"); + xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy"); + xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no"); + xmlAddChild(initopt, estimator); + + xmlAddChild(initopt, parameter(initopt, "variational_subset", "uu ud")); + xmlAddChild(initopt, parameter(initopt, "blocks", "20")); + xmlAddChild(initopt, parameter(initopt, "warmupSteps", "10")); + xmlAddChild(initopt, parameter(initopt, "timestep", "0.5")); + xmlAddChild(initopt, parameter(initopt, "walkers_per_rank", "600")); + xmlAddChild(initopt, parameter(initopt, "substeps", "2")); + xmlAddChild(initopt, parameter(initopt, "usedrift", "no")); + xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly")); + xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.5")); + } + xmlAddChild(loopopt, initopt); + } + xmlAddChild(qm_root_input, loopopt); + } + { + + ///Optimizing for 3Body Jastrow + ///Adding First loop of Cheap optimization blocks + + std::vector AtomNames(GroupName); + sort(AtomNames.begin(), AtomNames.end()); + AtomNames.erase(unique(AtomNames.begin(), AtomNames.end()), AtomNames.end()); + + std::string o3("uu ud "); + for (int iat = 0; iat < AtomNames.size(); iat++) + { + std::string o1 = "uu" + AtomNames[iat]; + std::string o2 = "ud" + AtomNames[iat]; + o3=o3+" "+o1+" "+o2; + } + xmlNodePtr loopopt1 = xmlNewNode(NULL, (const xmlChar*)"loop"); + xmlNewProp(loopopt1, (const xmlChar*)"max", (const xmlChar*)"4"); + { + xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc"); + xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear_batch"); + xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp"); + xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); + //xmlNewProp(initopt,(const xmlChar*)"gpu", (const xmlChar*)"no"); + { + xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator"); + xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy"); + xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no"); + xmlAddChild(initopt, estimator); + + + + xmlAddChild(initopt, parameter(initopt, "variational_subset", o3)); + xmlAddChild(initopt, parameter(initopt, "blocks", "20")); + xmlAddChild(initopt, parameter(initopt, "warmupSteps", "10")); + xmlAddChild(initopt, parameter(initopt, "timestep", "0.5")); + xmlAddChild(initopt, parameter(initopt, "walkers_per_rank", "600")); + xmlAddChild(initopt, parameter(initopt, "substeps", "2")); + xmlAddChild(initopt, parameter(initopt, "usedrift", "no")); + xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly")); + xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.1")); + } + xmlAddChild(loopopt1, initopt); + } + xmlAddChild(qm_root_input, loopopt1); + + ///Adding loop for optimization blocks + xmlNodePtr loopopt = xmlNewNode(NULL, (const xmlChar*)"loop"); + xmlNewProp(loopopt, (const xmlChar*)"max", (const xmlChar*)"10"); + { + xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc"); + xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear_batch"); + xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp"); + xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); + //xmlNewProp(initopt,(const xmlChar*)"gpu", (const xmlChar*)"no"); + { + xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator"); + xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy"); + xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no"); + xmlAddChild(initopt, estimator); + + xmlAddChild(initopt, parameter(initopt, "variational_subset", o3)); + xmlAddChild(initopt, parameter(initopt, "blocks", "20")); + xmlAddChild(initopt, parameter(initopt, "warmupSteps", "10")); + xmlAddChild(initopt, parameter(initopt, "timestep", "0.5")); + xmlAddChild(initopt, parameter(initopt, "walkers_per_rank", "600")); + xmlAddChild(initopt, parameter(initopt, "substeps", "2")); + xmlAddChild(initopt, parameter(initopt, "usedrift", "no")); + xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly")); + xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.5")); + } + xmlAddChild(loopopt, initopt); + } + xmlAddChild(qm_root_input, loopopt); + } + } + } + + + ///Adding a VMC Block to the Input + xmlNodePtr vmc = xmlNewNode(NULL, (const xmlChar*)"qmc"); + xmlNewProp(vmc, (const xmlChar*)"method", (const xmlChar*)"vmc_batch"); + xmlNewProp(vmc, (const xmlChar*)"move", (const xmlChar*)"pbyp"); + xmlNewProp(vmc, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); + //xmlNewProp(vmc,(const xmlChar*)"gpu", (const xmlChar*)"no"); + { + + xmlAddChild(vmc, parameter(vmc, "walkers_per_rank", "100")); + xmlAddChild(vmc, parameter(vmc, "warmupSteps", "20")); + xmlAddChild(vmc, parameter(vmc, "blocks", "20")); + xmlAddChild(vmc, parameter(vmc, "step", "20")); + xmlAddChild(vmc, parameter(vmc, "substeps", "3")); + xmlAddChild(vmc, parameter(vmc, "timestep", "0.1")); + xmlAddChild(vmc, parameter(vmc, "usedrift", "no")); + } + xmlAddChild(qm_root_input, vmc); + + ///Adding a DMC Block to the Input + xmlNodePtr dmc = xmlNewNode(NULL, (const xmlChar*)"qmc"); + xmlNewProp(dmc, (const xmlChar*)"method", (const xmlChar*)"dmc_batch"); + xmlNewProp(dmc, (const xmlChar*)"move", (const xmlChar*)"pbyp"); + xmlNewProp(dmc, (const xmlChar*)"checkpoint", (const xmlChar*)"20"); + //xmlNewProp(dmc,(const xmlChar*)"gpu", (const xmlChar*)"no"); + { + + xmlAddChild(dmc, parameter(dmc, "walkers_per_rank", "200")); + xmlAddChild(dmc, parameter(dmc, "warmupSteps", "50")); + xmlAddChild(dmc, parameter(dmc, "timestep", "0.001")); + xmlAddChild(dmc, parameter(dmc, "steps", "40")); + xmlAddChild(dmc, parameter(dmc, "blocks", "1000")); + if(ECP) + xmlAddChild(dmc, parameter(dmc, "nonlocalmoves", "v3")); + } + xmlAddChild(qm_root_input, dmc); + + xmlDocSetRootElement(doc_input, qm_root_input); + xmlSaveFormatFile(fname.c_str(), doc_input, 1); + xmlFreeDoc(doc_input); +} void QMCGaussianParserBase::dumpStdInput(const std::string& psi_tag, const std::string& ion_tag) { std::cout << " Generating Standard Input file containing VMC, standard optmization, and DMC blocks." << std::endl; diff --git a/src/QMCTools/QMCGaussianParserBase.h b/src/QMCTools/QMCGaussianParserBase.h index 336f6519a1..4bd145bed4 100644 --- a/src/QMCTools/QMCGaussianParserBase.h +++ b/src/QMCTools/QMCGaussianParserBase.h @@ -43,6 +43,8 @@ struct QMCGaussianParserBase bool UseHDF5; bool PBC; bool production; + bool batched; + bool optJStaged; bool zeroCI; bool orderByExcitation; bool addJastrow; @@ -166,6 +168,8 @@ struct QMCGaussianParserBase void dumpStdInputProd(const std::string& psi_tag, const std::string& ion_tag); + void dumpStdInputBatch(const std::string& psi_tag, const std::string& ion_tag); + //static std::vector IonName; static std::map IonName; diff --git a/src/QMCTools/convert4qmc.cpp b/src/QMCTools/convert4qmc.cpp index 2e9529eb7f..b52467d088 100644 --- a/src/QMCTools/convert4qmc.cpp +++ b/src/QMCTools/convert4qmc.cpp @@ -38,10 +38,10 @@ int main(int argc, char** argv) if (argc < 2) { std::cout << "Usage: convert [-gaussian|-gamess|-orbitals|-dirac|-rmg] filename " << std::endl; - std::cout << "[-nojastrow -hdf5 -prefix title -addCusp -production -NbImages NimageX NimageY NimageZ]" << std::endl; + std::cout << "[-nojastrow -hdf5 -prefix title -addCusp -production -batched -optJStaged -NbImages NimageX NimageY NimageZ]" << std::endl; std::cout << "[-psi_tag psi0 -ion_tag ion0 -gridtype log|log0|linear -first ri -last rf]" << std::endl; std::cout << "[-size npts -multidet multidet.h5 -ci file.out -threshold cimin -TargetState state_number " - "-NaturalOrbitals NumToRead -optDetCoeffs]" + "-NaturalOrbitals NumToRead -optDetCoeffs -batched]" << std::endl; std::cout << "Defaults : -gridtype log -first 1e-6 -last 100 -size 1001 -ci required -threshold 0.01 -TargetState " "0 -prefix sample" @@ -77,6 +77,8 @@ int main(int argc, char** argv) int TargetState = 0; bool addJastrow = true; + bool batched = false; // Will become true by default in version 4. + bool optJStaged = false; //Selecting Staged optimization of J1+J2 the J3 bool usehdf5 = false; bool h5 = false; bool useprefix = false; @@ -127,6 +129,14 @@ int main(int argc, char** argv) { psi_tag = argv[++iargc]; } + else if (a == "-batched") + { + batched = true; + } + else if (a == "-optJStaged") + { + optJStaged = true; + } else if (a == "-production") { prod = true; @@ -300,6 +310,8 @@ int main(int argc, char** argv) { parser->addJastrow = addJastrow; parser->WFS_name = jastrow; + parser->batched = batched; + parser->optJStaged = optJStaged; if (parser->PBC) { std::cout << "Generating Inputs for Supertwist with coordinates:" << parser->STwist_Coord[0] << " " @@ -308,7 +320,10 @@ int main(int argc, char** argv) } else parser->dump(psi_tag, ion_tag); - parser->dumpStdInputProd(psi_tag, ion_tag); + if(batched) + parser->dumpStdInputBatch(psi_tag, ion_tag); + else + parser->dumpStdInputProd(psi_tag, ion_tag); } else { @@ -322,7 +337,10 @@ int main(int argc, char** argv) } else parser->dump(psi_tag, ion_tag); - parser->dumpStdInput(psi_tag, ion_tag); + if(batched) + parser->dumpStdInputBatch(psi_tag, ion_tag); + else + parser->dumpStdInputProd(psi_tag, ion_tag); } } catch (const std::exception& e) From 08aa8985b47df1943ef06e3157f2bd48def274ee Mon Sep 17 00:00:00 2001 From: Anouar Benali Date: Thu, 14 Nov 2024 23:24:23 -0600 Subject: [PATCH 2/5] Fix PyscfToqmcpack to handle gpu4pyscf --- src/QMCTools/PyscfToQmcpack.py | 59 ++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/src/QMCTools/PyscfToQmcpack.py b/src/QMCTools/PyscfToQmcpack.py index 41f54919d7..481262507b 100644 --- a/src/QMCTools/PyscfToQmcpack.py +++ b/src/QMCTools/PyscfToQmcpack.py @@ -20,7 +20,24 @@ def savetoqmcpack(cell,mf,title="Default",kpts=[],kmesh=[],sp_twist=[],weight=1. from pyscf.pbc import tools from numpy import empty import numpy - + + # Try to import cupy, but set a flag if it's unavailable + try: + import cupy as cp + CUPY_AVAILABLE = True + except ImportError: + CUPY_AVAILABLE = False + + + def ensure_numpy(arr): + """ + Ensures that the input array is a NumPy array. + If CuPy is available and the array is a CuPy array, it converts it to a NumPy array. + Otherwise, it returns the array unchanged. + """ + if CUPY_AVAILABLE and isinstance(arr, cp.ndarray): + return arr.get() # Convert CuPy array to NumPy + return arr # Return the array as is (if it's already a NumPy array or CuPy is not available) PBC=False Gamma=False @@ -43,12 +60,12 @@ def savetoqmcpack(cell,mf,title="Default",kpts=[],kmesh=[],sp_twist=[],weight=1. SizeMode=len(ComputeMode) for i in range(SizeMode): - if ComputeMode[i] in ("UHF","KUHF","UKS","SymAdaptedUHF","SymAdaptedUKS"): - Restricted=False + if ComputeMode[i] in ("UHF","KUHF","UKS","DFUKS","SymAdaptedUHF","SymAdaptedUKS"): + Restricted=False if ComputeMode[i]=="pbc": - PBC=True - if Restricted==False: - sys.exit("Unrestricted calculations with PBC not supported (yet) - contact Developers") + PBC=True + if Restricted==False: + sys.exit("Unrestricted calculations with PBC not supported (yet) - contact Developers") if PBC and len(kpts) == 0: Gamma=True @@ -500,26 +517,42 @@ def order_mo_coef(ll): GroupParameter.create_dataset("SpinRestricted",(1,),dtype="b1",data=Restricted) GroupDet=H5_qmcpack.create_group("Super_Twist") + + # Now ensure that all elements in mo_coeff are NumPy arrays + + if not PBC: if Restricted==True: NbAO, NbMO =mo_coeff.shape if loc_cell.cart==True: + mo_coeff = [ensure_numpy(coeff) for coeff in mo_coeff] eigenset=GroupDet.create_dataset("eigenset_0",(NbMO,NbAO),dtype="f8",data=order_mo_coef(mo_coeff)) else: + mo_coeff = [ensure_numpy(coeff) for coeff in mo_coeff] eigenset=GroupDet.create_dataset("eigenset_0",(NbMO,NbAO),dtype="f8",data=list(zip(*mo_coeff))) + mf.mo_energy = ensure_numpy(mf.mo_energy) eigenvalue=GroupDet.create_dataset("eigenval_0",(1,NbMO),dtype="f8",data=mf.mo_energy) else: NbAO, NbMO =mo_coeff[0].shape + mo_coeff0 = [ensure_numpy(coeff) for coeff in mo_coeff[0]] + mo_coeff1 = [ensure_numpy(coeff) for coeff in mo_coeff[1]] + if loc_cell.cart==True: - eigenset_up=GroupDet.create_dataset("eigenset_0",(NbMO,NbAO),dtype="f8",data=order_mo_coef(mo_coeff[0])) - eigenset_dn=GroupDet.create_dataset("eigenset_1",(NbMO,NbAO),dtype="f8",data=order_mo_coef(mo_coeff[1])) + eigenset_up=GroupDet.create_dataset("eigenset_0",(NbMO,NbAO),dtype="f8",data=order_mo_coef(mo_coeff0)) + eigenset_dn=GroupDet.create_dataset("eigenset_1",(NbMO,NbAO),dtype="f8",data=order_mo_coef(mo_coeff1)) + #eigenset_up=GroupDet.create_dataset("eigenset_0",(NbMO,NbAO),dtype="f8",data=order_mo_coef(mo_coeff[0])) + #eigenset_dn=GroupDet.create_dataset("eigenset_1",(NbMO,NbAO),dtype="f8",data=order_mo_coef(mo_coeff[1])) else: - eigenset_up=GroupDet.create_dataset("eigenset_0",(NbMO,NbAO),dtype="f8",data=list(zip(*mo_coeff[0]))) - eigenset_dn=GroupDet.create_dataset("eigenset_1",(NbMO,NbAO),dtype="f8",data=list(zip(*mo_coeff[1]))) - - eigenvalue_up=GroupDet.create_dataset("eigenval_0",(1,NbMO),dtype="f8",data=mf.mo_energy[0]) - eigenvalue_dn=GroupDet.create_dataset("eigenval_1",(1,NbMO),dtype="f8",data=mf.mo_energy[1]) + eigenset_up=GroupDet.create_dataset("eigenset_0",(NbMO,NbAO),dtype="f8",data=list(zip(*mo_coeff0))) + eigenset_dn=GroupDet.create_dataset("eigenset_1",(NbMO,NbAO),dtype="f8",data=list(zip(*mo_coeff1))) + #eigenset_up=GroupDet.create_dataset("eigenset_0",(NbMO,NbAO),dtype="f8",data=list(zip(*mo_coeff[0]))) + #eigenset_dn=GroupDet.create_dataset("eigenset_1",(NbMO,NbAO),dtype="f8",data=list(zip(*mo_coeff[1]))) + + mo_energy0 = ensure_numpy(mf.mo_energy[0]) + mo_energy1 = ensure_numpy(mf.mo_energy[1]) + eigenvalue_up=GroupDet.create_dataset("eigenval_0",(1,NbMO),dtype="f8",data=mo_energy0) + eigenvalue_dn=GroupDet.create_dataset("eigenval_1",(1,NbMO),dtype="f8",data=mo_energy1) else: #Cell Parameters From 142faed84f782f998aee3b3fcae007302fc1740b Mon Sep 17 00:00:00 2001 From: Anouar Benali Date: Thu, 14 Nov 2024 23:25:17 -0600 Subject: [PATCH 3/5] Making batched version of the code the default version --- src/QMCTools/QMCGaussianParserBase.cpp | 451 ++++++++++++++++++++++++- src/QMCTools/QMCGaussianParserBase.h | 3 + src/QMCTools/convert4qmc.cpp | 21 +- 3 files changed, 471 insertions(+), 4 deletions(-) diff --git a/src/QMCTools/QMCGaussianParserBase.cpp b/src/QMCTools/QMCGaussianParserBase.cpp index ab9ec75ea4..2f50613631 100644 --- a/src/QMCTools/QMCGaussianParserBase.cpp +++ b/src/QMCTools/QMCGaussianParserBase.cpp @@ -58,6 +58,7 @@ QMCGaussianParserBase::QMCGaussianParserBase() Periodicity(false), UseHDF5(false), PBC(false), + legacy(false), production(false), batched(false), optJStaged(false), @@ -125,6 +126,7 @@ QMCGaussianParserBase::QMCGaussianParserBase(int argc, char** argv) Periodicity(false), UseHDF5(false), PBC(false), + legacy(false), production(false), zeroCI(false), orderByExcitation(false), @@ -1739,7 +1741,7 @@ void QMCGaussianParserBase::createGridNode(int argc, char** argv) void QMCGaussianParserBase::dump(const std::string& psi_tag, const std::string& ion_tag) { - std::cout << " QMCGaussianParserBase::dump " << std::endl; + std::cout << " QMCGaussianParserBase::dump Batched Code" << std::endl; if (!Structure) { //if (UseHDF5 || multidetH5) @@ -1804,12 +1806,291 @@ void QMCGaussianParserBase::dump(const std::string& psi_tag, const std::string& } xmlDocPtr doc = xmlNewDoc((const xmlChar*)"1.0"); xmlNodePtr qm_root = xmlNewNode(NULL, BAD_CAST "qmcsystem"); + /* { //wavefunction xmlNodePtr wfPtr = xmlNewNode(NULL, (const xmlChar*)"wavefunction"); xmlNewProp(wfPtr, (const xmlChar*)"name", (const xmlChar*)psi_tag.c_str()); xmlNewProp(wfPtr, (const xmlChar*)"target", (const xmlChar*)"e"); { + + xmlNodePtr detset = xmlNewNode(NULL, (const xmlChar*)"determinantset"); + xmlNodePtr sposetCollPtr = xmlNewNode(NULL, (const xmlChar*)"sposet_collection"); + + xmlNewProp(sposetCollPtr, (const xmlChar*)"type", (const xmlChar*)"MolecularOrbital"); + xmlNewProp(sposetCollPtr, (const xmlChar*)"name", (const xmlChar*)"LCAOBSet"); + xmlNewProp(sposetCollPtr, (const xmlChar*)"source", (const xmlChar*)ion_tag.c_str()); + xmlNewProp(sposetCollPtr, (const xmlChar*)"transform", (const xmlChar*)"yes"); + + if (DoCusp == true) + xmlNewProp(sposetCollPtr, (const xmlChar*)"cuspCorrection", (const xmlChar*)"yes"); + if (UseHDF5 || singledetH5) + xmlNewProp(sposetCollPtr, (const xmlChar*)"href", (const xmlChar*)h5file.c_str()); + //BASISSET + { + std::ostringstream up_size, down_size, b_size; + up_size << NumberOfAlpha; + down_size << NumberOfBeta; + b_size << numMO; + + + xmlNodePtr sposetup = xmlNewNode(NULL, (const xmlChar*)"sposet"); + xmlNewProp(sposetup, (const xmlChar*)"name", (const xmlChar*)"spo-up"); + if (multideterminant) + xmlNewProp(sposetup, (const xmlChar*)"size", (const xmlChar*)b_size.str().c_str()); + else + xmlNewProp(sposetup, (const xmlChar*)"size", (const xmlChar*)up_size.str().c_str()); + if (DoCusp == true) + xmlNewProp(sposetup, (const xmlChar*)"cuspInfo", (const xmlChar*)"../spo-up.cuspInfo.xml"); + //add occupation + xmlNodePtr occ_data = xmlNewNode(NULL, (const xmlChar*)"occupation"); + xmlNewProp(occ_data, (const xmlChar*)"mode", (const xmlChar*)"ground"); + xmlAddChild(sposetup, occ_data); + + //add coefficients + xmlNodePtr coeff_data = xmlNewNode(NULL, (const xmlChar*)"coefficient"); + xmlNewProp(coeff_data, (const xmlChar*)"size", (const xmlChar*)b_size.str().c_str()); + xmlNewProp(coeff_data, (const xmlChar*)"spindataset", (const xmlChar*)"0"); + xmlAddChild(sposetup, coeff_data); + xmlAddChild(sposetCollPtr, sposetup); + + + ///DownDet + + xmlNodePtr sposetdn = xmlNewNode(NULL, (const xmlChar*)"sposet"); + xmlSetProp(sposetdn, (const xmlChar*)"name", (const xmlChar*)"spo-dn"); + if (multideterminant) + xmlSetProp(sposetdn, (const xmlChar*)"size", (const xmlChar*)b_size.str().c_str()); + else + xmlSetProp(sposetdn, (const xmlChar*)"size", (const xmlChar*)down_size.str().c_str()); + if (DoCusp == true) + xmlSetProp(sposetdn, (const xmlChar*)"cuspInfo", (const xmlChar*)"../spo-dn.cuspInfo.xml"); + //add occupation + xmlNodePtr occ_datadn = xmlNewNode(NULL, (const xmlChar*)"occupation"); + xmlNewProp(occ_datadn, (const xmlChar*)"mode", (const xmlChar*)"ground"); + xmlAddChild(sposetdn, occ_datadn); + //add coefficients + xmlNodePtr coeff_data_dn = xmlNewNode(NULL, (const xmlChar*)"coefficient"); + xmlNewProp(coeff_data_dn, (const xmlChar*)"size", (const xmlChar*)b_size.str().c_str()); + if (SpinRestricted) + xmlNewProp(coeff_data_dn, (const xmlChar*)"spindataset", (const xmlChar*)"0"); + else + xmlNewProp(coeff_data_dn, (const xmlChar*)"spindataset", (const xmlChar*)"1"); + xmlAddChild(sposetdn, coeff_data_dn); + xmlAddChild(sposetCollPtr, sposetdn); + + + xmlNodePtr slaterdet = xmlNewNode(NULL, (const xmlChar*)"slaterdeterminant"); + + if (multideterminant) + { + xmlNodePtr multislaterdetPtr = NULL; + multislaterdetPtr = createMultiDeterminantSetFromH5(); + xmlAddChild(slaterdet,multislaterdetPtr ); + } + else + { + xmlNodePtr udet = xmlNewNode(NULL, (const xmlChar*)"determinant"); + xmlNewProp(udet, (const xmlChar*)"id", (const xmlChar*)"spo-up"); + xmlAddChild(slaterdet,udet ); + + xmlNodePtr ddet = xmlNewNode(NULL, (const xmlChar*)"determinant"); + xmlNewProp(ddet, (const xmlChar*)"id", (const xmlChar*)"spo-dn"); + xmlAddChild(slaterdet,ddet ); + } + + xmlAddChild(detset, slaterdet); + + } + xmlAddChild(wfPtr, sposetCollPtr); + xmlAddChild(wfPtr, detset); + if (addJastrow) + { + std::cout << R"(Adding Two-Body and One-Body jastrows with rcut="10" and size="10")" << std::endl; + if (NumberOfEls > 1) + { + xmlAddChild(wfPtr, createJ2()); + } + xmlAddChild(wfPtr, createJ1()); + if (NumberOfEls > 1) + { + std::cout << "Adding Three-Body jastrows with rcut=\"5\"" << std::endl; + xmlAddChild(wfPtr, createJ3()); + } + } + } + xmlAddChild(qm_root, wfPtr); + }*/ +// Function to create sposet nodes with common properties +xmlNodePtr createSposetNode(const std::string &name, const std::string &size, bool doCusp, const std::string &cuspInfoPath) { + xmlNodePtr sposet = xmlNewNode(NULL, (const xmlChar*)"sposet"); + xmlNewProp(sposet, (const xmlChar*)"name", (const xmlChar*)name.c_str()); + xmlNewProp(sposet, (const xmlChar*)"size", (const xmlChar*)size.c_str()); + if (doCusp) { + xmlNewProp(sposet, (const xmlChar*)"cuspInfo", (const xmlChar*)cuspInfoPath.c_str()); + } + + // Add occupation + xmlNodePtr occ_data = xmlNewNode(NULL, (const xmlChar*)"occupation"); + xmlNewProp(occ_data, (const xmlChar*)"mode", (const xmlChar*)"ground"); + xmlAddChild(sposet, occ_data); + + // Add coefficients + xmlNodePtr coeff_data = xmlNewNode(NULL, (const xmlChar*)"coefficient"); + xmlNewProp(coeff_data, (const xmlChar*)"size", (const xmlChar*)size.c_str()); + xmlAddChild(sposet, coeff_data); + + return sposet; +} + +xmlNodePtr createDeterminantNode(const std::string &id) { + xmlNodePtr det = xmlNewNode(NULL, (const xmlChar*)"determinant"); + xmlNewProp(det, (const xmlChar*)"id", (const xmlChar*)id.c_str()); + return det; +} + +{ + // Wavefunction + xmlNodePtr wfPtr = xmlNewNode(NULL, (const xmlChar*)"wavefunction"); + xmlNewProp(wfPtr, (const xmlChar*)"name", (const xmlChar*)psi_tag.c_str()); + xmlNewProp(wfPtr, (const xmlChar*)"target", (const xmlChar*)"e"); + + // Determinant set + xmlNodePtr detset = xmlNewNode(NULL, (const xmlChar*)"determinantset"); + xmlNodePtr sposetCollPtr = xmlNewNode(NULL, (const xmlChar*)"sposet_collection"); + + xmlNewProp(sposetCollPtr, (const xmlChar*)"type", (const xmlChar*)"MolecularOrbital"); + xmlNewProp(sposetCollPtr, (const xmlChar*)"name", (const xmlChar*)"LCAOBSet"); + xmlNewProp(sposetCollPtr, (const xmlChar*)"source", (const xmlChar*)ion_tag.c_str()); + xmlNewProp(sposetCollPtr, (const xmlChar*)"transform", (const xmlChar*)"yes"); + + if (DoCusp) { + xmlNewProp(sposetCollPtr, (const xmlChar*)"cuspCorrection", (const xmlChar*)"yes"); + } + if (UseHDF5 || singledetH5) { + xmlNewProp(sposetCollPtr, (const xmlChar*)"href", (const xmlChar*)h5file.c_str()); + } + + // Create sposet nodes + std::ostringstream up_size, down_size, b_size; + up_size << NumberOfAlpha; + down_size << NumberOfBeta; + b_size << numMO; + + xmlAddChild(sposetCollPtr, createSposetNode("spo-up", multideterminant ? b_size.str() : up_size.str(), DoCusp, "../spo-up.cuspInfo.xml")); + xmlAddChild(sposetCollPtr, createSposetNode("spo-dn", multideterminant ? b_size.str() : down_size.str(), DoCusp, "../spo-dn.cuspInfo.xml")); + + xmlAddChild(wfPtr, sposetCollPtr); + + // Slater determinant + xmlNodePtr slaterdet = xmlNewNode(NULL, (const xmlChar*)"slaterdeterminant"); + + if (multideterminant) { + xmlNodePtr multislaterdetPtr = createMultiDeterminantSetFromH5(); + xmlAddChild(slaterdet, multislaterdetPtr); + } else { + xmlAddChild(slaterdet, createDeterminantNode("spo-up")); + xmlAddChild(slaterdet, createDeterminantNode("spo-dn")); + } + + xmlAddChild(detset, slaterdet); + xmlAddChild(wfPtr, detset); + + // Add Jastrow factors if needed + if (addJastrow) { + std::cout << R"(Adding Two-Body and One-Body jastrows with rcut="10" and size="10")" << std::endl; + if (NumberOfEls > 1) { + xmlAddChild(wfPtr, createJ2()); + } + xmlAddChild(wfPtr, createJ1()); + if (NumberOfEls > 1) { + std::cout << "Adding Three-Body jastrows with rcut=\"5\"" << std::endl; + xmlAddChild(wfPtr, createJ3()); + } + } + + xmlAddChild(qm_root, wfPtr); +} + + xmlDocSetRootElement(doc, qm_root); + std::string fname = Title + ".wf" + WFS_name + ".xml"; + xmlSaveFormatFile(fname.c_str(), doc, 1); + xmlFreeDoc(doc); +} +void QMCGaussianParserBase::dump_Legacy(const std::string& psi_tag, const std::string& ion_tag) +{ + std::cout << " QMCGaussianParserBase::dump Legacy" << std::endl; + if (!Structure) + { + //if (UseHDF5 || multidetH5) + if (UseHDF5) + { + bool IsComplex = (isSpinor) ? true : false; + hdf_archive hout; + hout.create(h5file.c_str(), H5F_ACC_TRUNC); + hout.push("PBC", true); + hout.write(PBC, "PBC"); + hout.pop(); + //Adding generic code name to the H5 file. + std::string CodeName("generic"); + hout.push("application", true); + hout.write(CodeName, "code"); + hout.pop(); + hout.push("parameters", true); + hout.write(ECP, "ECP"); + //Assumes MO-Coeff always real as this path is only for molecules and for generating stand alone H5file. + hout.write(IsComplex, "IsComplex"); + hout.write(multideterminant, "Multidet"); + hout.write(NumberOfAlpha, "NbAlpha"); + hout.write(NumberOfBeta, "NbBeta"); + hout.write(NumberOfEls, "NbTotElec"); + hout.write(SpinRestricted, "SpinRestricted"); + hout.write(BohrUnit, "Unit"); + hout.write(numMO, "numAO"); + hout.write(numMO, "numMO"); + hout.write(SpinMultiplicity, "spin"); + hout.pop(); + hout.close(); + } + + xmlDocPtr doc_p = xmlNewDoc((const xmlChar*)"1.0"); + xmlNodePtr qm_root_p = xmlNewNode(NULL, BAD_CAST "qmcsystem"); + if (PBC) + { + app_log() + << "ABORT::THIS IS NOT SUPPOSED TO HAPPEN. PBC are ON but you are not in an HDF5 path. Contact developers" + << std::endl; + exit(0); + // xmlAddChild(qm_root_p, createCell()); + } + auto ionSet = createIonSet(); + if (ionSet != nullptr) + { + xmlAddChild(qm_root_p, ionSet); + xmlAddChild(qm_root_p, createElectronSet(ion_tag)); + xmlDocSetRootElement(doc_p, qm_root_p); + std::string fname = Title + ".structure.xml"; + xmlSaveFormatFile(fname.c_str(), doc_p, 1); + xmlFreeDoc(doc_p); + } + else + { + xmlFreeNode(qm_root_p); + xmlFreeDoc(doc_p); + throw std::runtime_error("convert4qmc: IonSet creation failed in QMCGaussianParserBase::dump, check out of " + "bounds for valence calculation\n"); + } + Structure = true; + } + xmlDocPtr doc = xmlNewDoc((const xmlChar*)"1.0"); + xmlNodePtr qm_root = xmlNewNode(NULL, BAD_CAST "qmcsystem"); + { + //wavefunction + xmlNodePtr wfPtr = xmlNewNode(NULL, (const xmlChar*)"wavefunction"); + xmlNewProp(wfPtr, (const xmlChar*)"name", (const xmlChar*)psi_tag.c_str()); + xmlNewProp(wfPtr, (const xmlChar*)"target", (const xmlChar*)"e"); + { + xmlNodePtr detPtr = xmlNewNode(NULL, (const xmlChar*)"determinantset"); xmlNewProp(detPtr, (const xmlChar*)"type", (const xmlChar*)"MolecularOrbital"); xmlNewProp(detPtr, (const xmlChar*)"name", (const xmlChar*)"LCAOBSet"); @@ -2037,7 +2318,171 @@ void QMCGaussianParserBase::dumpPBC(const std::string& psi_tag, const std::strin void QMCGaussianParserBase::dumpStdInputProd(const std::string& psi_tag, const std::string& ion_tag) { - std::cout << " Generating production input file designed for large calculations." << std::endl; + std::cout << " Generating production input file designed for large calculations in the Batched Code Style." << std::endl; + std::cout << " Modify according to the accuracy you would like to achieve. Make sure to adjust the number of Walkers per rank to your machine" << std::endl; + + std::string fname = Title + ".qmc.in-wf" + WFS_name + ".xml"; + + xmlDocPtr doc_input = xmlNewDoc((const xmlChar*)"1.0"); + xmlNodePtr qm_root_input = xmlNewNode(NULL, BAD_CAST "simulation"); + + ///Adding Project id + { + xmlNodePtr project = xmlNewNode(NULL, (const xmlChar*)"project"); + xmlNewProp(project, (const xmlChar*)"id", (const xmlChar*)Title.c_str()); + xmlNewProp(project, (const xmlChar*)"series", (const xmlChar*)"0"); + xmlAddChild(project, parameter(project, "driver_version", "batch")); + xmlAddChild(qm_root_input, project); + } + ///Adding Link to Partcle Set and Wave function + { + std::string Ptclname = Title + ".structure.xml"; + xmlNodePtr ptcl = xmlNewNode(NULL, (const xmlChar*)"include"); + xmlNewProp(ptcl, (const xmlChar*)"href", (const xmlChar*)Ptclname.c_str()); + xmlAddChild(qm_root_input, ptcl); + + std::string Wfsname = Title + ".wf" + WFS_name + ".xml"; + xmlNodePtr wfs = xmlNewNode(NULL, (const xmlChar*)"include"); + xmlNewProp(wfs, (const xmlChar*)"href", (const xmlChar*)Wfsname.c_str()); + xmlAddChild(qm_root_input, wfs); + } + + ///Adding Hamiltonian + { + xmlAddChild(qm_root_input, createHamiltonian(ion_tag, psi_tag)); + } + ///Adding Optimization Block based on One Shift Only + if (addJastrow) + { + ///Adding a VMC Block to help equilibrate + xmlNodePtr initvmc = xmlNewNode(NULL, (const xmlChar*)"qmc"); + xmlNewProp(initvmc, (const xmlChar*)"method", (const xmlChar*)"vmc"); + xmlNewProp(initvmc, (const xmlChar*)"move", (const xmlChar*)"pbyp"); + //xmlNewProp(initvmc, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); + { + xmlAddChild(initvmc, parameter(initvmc, "walkers_per_rank", "100")); + xmlAddChild(initvmc, parameter(initvmc, "warmupSteps", "10")); + xmlAddChild(initvmc, parameter(initvmc, "blocks", "10")); + xmlAddChild(initvmc, parameter(initvmc, "steps", "5")); + xmlAddChild(initvmc, parameter(initvmc, "substeps", "2")); + xmlAddChild(initvmc, parameter(initvmc, "timestep", "0.1")); + xmlAddChild(initvmc, parameter(initvmc, "usedrift", "no")); + } + xmlAddChild(qm_root_input, initvmc); + + + ///Adding First loop of Cheap optimization blocks + xmlNodePtr loopopt1 = xmlNewNode(NULL, (const xmlChar*)"loop"); + xmlNewProp(loopopt1, (const xmlChar*)"max", (const xmlChar*)"4"); + { + xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc"); + xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear"); + xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp"); + xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); + //xmlNewProp(initopt,(const xmlChar*)"gpu", (const xmlChar*)"no"); + { + xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator"); + xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy"); + xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no"); + xmlAddChild(initopt, estimator); + + xmlAddChild(initopt, parameter(initopt, "blocks", "20")); + xmlAddChild(initopt, parameter(initopt, "warmupSteps", "10")); + xmlAddChild(initopt, parameter(initopt, "timestep", "0.5")); + xmlAddChild(initopt, parameter(initopt, "walkers_per_rank", "100")); + xmlAddChild(initopt, parameter(initopt, "samples", "80000")); + xmlAddChild(initopt, parameter(initopt, "substeps", "5")); + xmlAddChild(initopt, parameter(initopt, "usedrift", "no")); + xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly")); + xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.1")); + } + xmlAddChild(loopopt1, initopt); + } + xmlAddChild(qm_root_input, loopopt1); + + ///Adding loop for optimization blocks + xmlNodePtr loopopt = xmlNewNode(NULL, (const xmlChar*)"loop"); + xmlNewProp(loopopt, (const xmlChar*)"max", (const xmlChar*)"10"); + { + xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc"); + xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear"); + xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp"); + xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); + //xmlNewProp(initopt,(const xmlChar*)"gpu", (const xmlChar*)"no"); + { + xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator"); + xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy"); + xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no"); + xmlAddChild(initopt, estimator); + + xmlAddChild(initopt, parameter(initopt, "blocks", "40 ")); + xmlAddChild(initopt, parameter(initopt, "warmupSteps", "10")); + xmlAddChild(initopt, parameter(initopt, "timestep", "0.5")); + xmlAddChild(initopt, parameter(initopt, "walkers_per_rank", "100")); + xmlAddChild(initopt, parameter(initopt, "samples", "160000")); + xmlAddChild(initopt, parameter(initopt, "substeps", "5")); + xmlAddChild(initopt, parameter(initopt, "usedrift", "no")); + xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly")); + xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.5")); + } + xmlAddChild(loopopt, initopt); + } + xmlAddChild(qm_root_input, loopopt); + } + + + ///Adding a VMC Block to the Input + xmlNodePtr vmc = xmlNewNode(NULL, (const xmlChar*)"qmc"); + xmlNewProp(vmc, (const xmlChar*)"method", (const xmlChar*)"vmc"); + xmlNewProp(vmc, (const xmlChar*)"move", (const xmlChar*)"pbyp"); + xmlNewProp(vmc, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); + //xmlNewProp(vmc,(const xmlChar*)"gpu", (const xmlChar*)"no"); + { + xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator"); + xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy"); + xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no"); + xmlAddChild(vmc, estimator); + + xmlAddChild(vmc, parameter(vmc, "walkers_per_rank", "100")); + xmlAddChild(vmc, parameter(vmc, "stepsbetweensamples", "10")); + xmlAddChild(vmc, parameter(vmc, "substeps", "30")); + xmlAddChild(vmc, parameter(vmc, "warmupSteps", "10")); + xmlAddChild(vmc, parameter(vmc, "blocks", "20")); + xmlAddChild(vmc, parameter(vmc, "timestep", "0.1")); + xmlAddChild(vmc, parameter(vmc, "usedrift", "no")); + } + xmlAddChild(qm_root_input, vmc); + + ///Adding a DMC Block to the Input + xmlNodePtr dmc = xmlNewNode(NULL, (const xmlChar*)"qmc"); + xmlNewProp(dmc, (const xmlChar*)"method", (const xmlChar*)"dmc"); + xmlNewProp(dmc, (const xmlChar*)"move", (const xmlChar*)"pbyp"); + xmlNewProp(dmc, (const xmlChar*)"checkpoint", (const xmlChar*)"20"); + //xmlNewProp(dmc,(const xmlChar*)"gpu", (const xmlChar*)"no"); + { + xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator"); + xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy"); + xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no"); + xmlAddChild(dmc, estimator); + + xmlAddChild(dmc, parameter(dmc, "walkers_per_rank", "1i00")); + xmlAddChild(dmc, parameter(dmc, "warmupSteps", "100")); + xmlAddChild(dmc, parameter(dmc, "timestep", "0.0005")); + xmlAddChild(dmc, parameter(dmc, "steps", "30")); + xmlAddChild(dmc, parameter(dmc, "blocks", "1000")); + if (ECP == true) + xmlAddChild(dmc, parameter(dmc, "nonlocalmoves", "v3")); + } + xmlAddChild(qm_root_input, dmc); + + xmlDocSetRootElement(doc_input, qm_root_input); + xmlSaveFormatFile(fname.c_str(), doc_input, 1); + xmlFreeDoc(doc_input); +} + +void QMCGaussianParserBase::dumpStdInputProdLegacy(const std::string& psi_tag, const std::string& ion_tag) +{ + std::cout << " Generating production input file designed for large calculations in the legacy Code Style." << std::endl; std::cout << " Modify according to the accuracy you would like to achieve. " << std::endl; std::string fname = Title + ".qmc.in-wf" + WFS_name + ".xml"; @@ -2779,7 +3224,7 @@ xmlNodePtr QMCGaussianParserBase::createHamiltonian(const std::string& ion_tag, for (int iat = 0; iat < AtomNames.size(); iat++) { - std::string PPname = AtomNames[iat] + ".qmcpp.xml"; + std::string PPname = AtomNames[iat] + ".ccECP.xml"; xmlNodePtr a = xmlNewNode(NULL, (const xmlChar*)"pseudo"); xmlNewProp(a, (const xmlChar*)"elementType", (const xmlChar*)AtomNames[iat].c_str()); xmlNewProp(a, (const xmlChar*)"href", (const xmlChar*)PPname.c_str()); diff --git a/src/QMCTools/QMCGaussianParserBase.h b/src/QMCTools/QMCGaussianParserBase.h index 4bd145bed4..dcba28fc76 100644 --- a/src/QMCTools/QMCGaussianParserBase.h +++ b/src/QMCTools/QMCGaussianParserBase.h @@ -42,6 +42,7 @@ struct QMCGaussianParserBase bool Periodicity; bool UseHDF5; bool PBC; + bool legacy; bool production; bool batched; bool optJStaged; @@ -162,10 +163,12 @@ struct QMCGaussianParserBase virtual void dumpPBC(const std::string& psi_tag, const std::string& ion_tag); + virtual void dump_Legacy(const std::string& psi_tag, const std::string& ion_tag); virtual void dump(const std::string& psi_tag, const std::string& ion_tag); void dumpStdInput(const std::string& psi_tag, const std::string& ion_tag); + void dumpStdInputProdLegacy(const std::string& psi_tag, const std::string& ion_tag); void dumpStdInputProd(const std::string& psi_tag, const std::string& ion_tag); void dumpStdInputBatch(const std::string& psi_tag, const std::string& ion_tag); diff --git a/src/QMCTools/convert4qmc.cpp b/src/QMCTools/convert4qmc.cpp index fb17ca3f7e..21443053d4 100644 --- a/src/QMCTools/convert4qmc.cpp +++ b/src/QMCTools/convert4qmc.cpp @@ -40,7 +40,7 @@ int main(int argc, char** argv) std::cout << "[-nojastrow -hdf5 -prefix title -addCusp -production -batched -optJStaged -NbImages NimageX NimageY NimageZ]" << std::endl; std::cout << "[-psi_tag psi0 -ion_tag ion0 -gridtype log|log0|linear -first ri -last rf]" << std::endl; std::cout << "[-size npts -multidet multidet.h5 -ci file.out -threshold cimin -TargetState state_number " - "-NaturalOrbitals NumToRead -optDetCoeffs -batched]" + "-NaturalOrbitals NumToRead -optDetCoeffs -legacy]" << std::endl; std::cout << "Defaults : -gridtype log -first 1e-6 -last 100 -size 1001 -ci required -threshold 0.01 -TargetState " "0 -prefix sample" @@ -75,6 +75,7 @@ int main(int argc, char** argv) std::string prefix; int TargetState = 0; + bool legacy = false; bool addJastrow = true; bool batched = false; // Will become true by default in version 4. bool optJStaged = false; //Selecting Staged optimization of J1+J2 the J3 @@ -124,6 +125,10 @@ int main(int argc, char** argv) { usehdf5 = true; } + else if (a == "-legacy") + { + legacy = true; + } else if (a == "-psi_tag") { psi_tag = argv[++iargc]; @@ -270,6 +275,7 @@ int main(int argc, char** argv) parser->debug = debug; parser->DoCusp = addCusp; parser->UseHDF5 = usehdf5; + parser->legacy = legacy; parser->singledetH5 = h5; if (h5) { @@ -317,11 +323,24 @@ int main(int argc, char** argv) parser->dumpPBC(psi_tag, ion_tag); } else +<<<<<<< HEAD parser->dump(psi_tag, ion_tag); if(batched) parser->dumpStdInputBatch(psi_tag, ion_tag); else parser->dumpStdInputProd(psi_tag, ion_tag); +======= + { + if (parser->legacy) + parser->dump_Legacy(psi_tag, ion_tag); + else + parser->dump(psi_tag, ion_tag); + } + if (parser->legacy) + parser->dumpStdInputProdLegacy(psi_tag, ion_tag); + else + parser->dumpStdInputProd(psi_tag, ion_tag); +>>>>>>> 8e255cc80 (Making batched version of the code the default version) } else { From 5cd6953cd68585449b033421b5ba5c42990bd537 Mon Sep 17 00:00:00 2001 From: Anouar Benali Date: Fri, 15 Nov 2024 00:25:27 -0600 Subject: [PATCH 4/5] fix --- src/QMCTools/convert4qmc.cpp | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/QMCTools/convert4qmc.cpp b/src/QMCTools/convert4qmc.cpp index 21443053d4..5311f47129 100644 --- a/src/QMCTools/convert4qmc.cpp +++ b/src/QMCTools/convert4qmc.cpp @@ -37,7 +37,7 @@ int main(int argc, char** argv) if (argc < 2) { std::cout << "Usage: convert [-gaussian|-gamess|-orbitals|-dirac|-rmg] filename " << std::endl; - std::cout << "[-nojastrow -hdf5 -prefix title -addCusp -production -batched -optJStaged -NbImages NimageX NimageY NimageZ]" << std::endl; + std::cout << "[-nojastrow -hdf5 -prefix title -addCusp -production -NbImages NimageX NimageY NimageZ]" << std::endl; std::cout << "[-psi_tag psi0 -ion_tag ion0 -gridtype log|log0|linear -first ri -last rf]" << std::endl; std::cout << "[-size npts -multidet multidet.h5 -ci file.out -threshold cimin -TargetState state_number " "-NaturalOrbitals NumToRead -optDetCoeffs -legacy]" @@ -77,8 +77,6 @@ int main(int argc, char** argv) int TargetState = 0; bool legacy = false; bool addJastrow = true; - bool batched = false; // Will become true by default in version 4. - bool optJStaged = false; //Selecting Staged optimization of J1+J2 the J3 bool usehdf5 = false; bool h5 = false; bool useprefix = false; @@ -133,14 +131,6 @@ int main(int argc, char** argv) { psi_tag = argv[++iargc]; } - else if (a == "-batched") - { - batched = true; - } - else if (a == "-optJStaged") - { - optJStaged = true; - } else if (a == "-production") { prod = true; @@ -314,8 +304,6 @@ int main(int argc, char** argv) { parser->addJastrow = addJastrow; parser->WFS_name = jastrow; - parser->batched = batched; - parser->optJStaged = optJStaged; if (parser->PBC) { std::cout << "Generating Inputs for Supertwist with coordinates:" << parser->STwist_Coord[0] << " " @@ -323,13 +311,6 @@ int main(int argc, char** argv) parser->dumpPBC(psi_tag, ion_tag); } else -<<<<<<< HEAD - parser->dump(psi_tag, ion_tag); - if(batched) - parser->dumpStdInputBatch(psi_tag, ion_tag); - else - parser->dumpStdInputProd(psi_tag, ion_tag); -======= { if (parser->legacy) parser->dump_Legacy(psi_tag, ion_tag); @@ -340,7 +321,6 @@ int main(int argc, char** argv) parser->dumpStdInputProdLegacy(psi_tag, ion_tag); else parser->dumpStdInputProd(psi_tag, ion_tag); ->>>>>>> 8e255cc80 (Making batched version of the code the default version) } else { @@ -354,10 +334,7 @@ int main(int argc, char** argv) } else parser->dump(psi_tag, ion_tag); - if(batched) - parser->dumpStdInputBatch(psi_tag, ion_tag); - else - parser->dumpStdInputProd(psi_tag, ion_tag); + parser->dumpStdInput(psi_tag, ion_tag); } } catch (const std::exception& e) From bc50d3893df6fe19458a3e823f0113bb2f148b5f Mon Sep 17 00:00:00 2001 From: Anouar Benali Date: Fri, 15 Nov 2024 00:40:17 -0600 Subject: [PATCH 5/5] fixing conflicts --- src/QMCTools/PyscfToQmcpack.py | 1 + src/QMCTools/QMCGaussianParserBase.cpp | 372 ------------------------- src/QMCTools/QMCGaussianParserBase.h | 4 - 3 files changed, 1 insertion(+), 376 deletions(-) diff --git a/src/QMCTools/PyscfToQmcpack.py b/src/QMCTools/PyscfToQmcpack.py index 481262507b..9d0150ea36 100644 --- a/src/QMCTools/PyscfToQmcpack.py +++ b/src/QMCTools/PyscfToQmcpack.py @@ -534,6 +534,7 @@ def order_mo_coef(ll): mf.mo_energy = ensure_numpy(mf.mo_energy) eigenvalue=GroupDet.create_dataset("eigenval_0",(1,NbMO),dtype="f8",data=mf.mo_energy) else: + NbAO, NbMO =mo_coeff[0].shape mo_coeff0 = [ensure_numpy(coeff) for coeff in mo_coeff[0]] mo_coeff1 = [ensure_numpy(coeff) for coeff in mo_coeff[1]] diff --git a/src/QMCTools/QMCGaussianParserBase.cpp b/src/QMCTools/QMCGaussianParserBase.cpp index 2f50613631..974a9a2a2e 100644 --- a/src/QMCTools/QMCGaussianParserBase.cpp +++ b/src/QMCTools/QMCGaussianParserBase.cpp @@ -60,8 +60,6 @@ QMCGaussianParserBase::QMCGaussianParserBase() PBC(false), legacy(false), production(false), - batched(false), - optJStaged(false), zeroCI(false), orderByExcitation(false), addJastrow(true), @@ -1806,7 +1804,6 @@ void QMCGaussianParserBase::dump(const std::string& psi_tag, const std::string& } xmlDocPtr doc = xmlNewDoc((const xmlChar*)"1.0"); xmlNodePtr qm_root = xmlNewNode(NULL, BAD_CAST "qmcsystem"); - /* { //wavefunction xmlNodePtr wfPtr = xmlNewNode(NULL, (const xmlChar*)"wavefunction"); @@ -1920,81 +1917,6 @@ void QMCGaussianParserBase::dump(const std::string& psi_tag, const std::string& } } xmlAddChild(qm_root, wfPtr); - }*/ -// Function to create sposet nodes with common properties -xmlNodePtr createSposetNode(const std::string &name, const std::string &size, bool doCusp, const std::string &cuspInfoPath) { - xmlNodePtr sposet = xmlNewNode(NULL, (const xmlChar*)"sposet"); - xmlNewProp(sposet, (const xmlChar*)"name", (const xmlChar*)name.c_str()); - xmlNewProp(sposet, (const xmlChar*)"size", (const xmlChar*)size.c_str()); - if (doCusp) { - xmlNewProp(sposet, (const xmlChar*)"cuspInfo", (const xmlChar*)cuspInfoPath.c_str()); - } - - // Add occupation - xmlNodePtr occ_data = xmlNewNode(NULL, (const xmlChar*)"occupation"); - xmlNewProp(occ_data, (const xmlChar*)"mode", (const xmlChar*)"ground"); - xmlAddChild(sposet, occ_data); - - // Add coefficients - xmlNodePtr coeff_data = xmlNewNode(NULL, (const xmlChar*)"coefficient"); - xmlNewProp(coeff_data, (const xmlChar*)"size", (const xmlChar*)size.c_str()); - xmlAddChild(sposet, coeff_data); - - return sposet; -} - -xmlNodePtr createDeterminantNode(const std::string &id) { - xmlNodePtr det = xmlNewNode(NULL, (const xmlChar*)"determinant"); - xmlNewProp(det, (const xmlChar*)"id", (const xmlChar*)id.c_str()); - return det; -} - -{ - // Wavefunction - xmlNodePtr wfPtr = xmlNewNode(NULL, (const xmlChar*)"wavefunction"); - xmlNewProp(wfPtr, (const xmlChar*)"name", (const xmlChar*)psi_tag.c_str()); - xmlNewProp(wfPtr, (const xmlChar*)"target", (const xmlChar*)"e"); - - // Determinant set - xmlNodePtr detset = xmlNewNode(NULL, (const xmlChar*)"determinantset"); - xmlNodePtr sposetCollPtr = xmlNewNode(NULL, (const xmlChar*)"sposet_collection"); - - xmlNewProp(sposetCollPtr, (const xmlChar*)"type", (const xmlChar*)"MolecularOrbital"); - xmlNewProp(sposetCollPtr, (const xmlChar*)"name", (const xmlChar*)"LCAOBSet"); - xmlNewProp(sposetCollPtr, (const xmlChar*)"source", (const xmlChar*)ion_tag.c_str()); - xmlNewProp(sposetCollPtr, (const xmlChar*)"transform", (const xmlChar*)"yes"); - - if (DoCusp) { - xmlNewProp(sposetCollPtr, (const xmlChar*)"cuspCorrection", (const xmlChar*)"yes"); - } - if (UseHDF5 || singledetH5) { - xmlNewProp(sposetCollPtr, (const xmlChar*)"href", (const xmlChar*)h5file.c_str()); - } - - // Create sposet nodes - std::ostringstream up_size, down_size, b_size; - up_size << NumberOfAlpha; - down_size << NumberOfBeta; - b_size << numMO; - - xmlAddChild(sposetCollPtr, createSposetNode("spo-up", multideterminant ? b_size.str() : up_size.str(), DoCusp, "../spo-up.cuspInfo.xml")); - xmlAddChild(sposetCollPtr, createSposetNode("spo-dn", multideterminant ? b_size.str() : down_size.str(), DoCusp, "../spo-dn.cuspInfo.xml")); - - xmlAddChild(wfPtr, sposetCollPtr); - - // Slater determinant - xmlNodePtr slaterdet = xmlNewNode(NULL, (const xmlChar*)"slaterdeterminant"); - - if (multideterminant) { - xmlNodePtr multislaterdetPtr = createMultiDeterminantSetFromH5(); - xmlAddChild(slaterdet, multislaterdetPtr); - } else { - xmlAddChild(slaterdet, createDeterminantNode("spo-up")); - xmlAddChild(slaterdet, createDeterminantNode("spo-dn")); - } - - xmlAddChild(detset, slaterdet); - xmlAddChild(wfPtr, detset); // Add Jastrow factors if needed if (addJastrow) { @@ -2652,300 +2574,6 @@ void QMCGaussianParserBase::dumpStdInputProdLegacy(const std::string& psi_tag, c xmlFreeDoc(doc_input); } -void QMCGaussianParserBase::dumpStdInputBatch(const std::string& psi_tag, const std::string& ion_tag) -{ - std::cout << " Generating production input file designed for large calculations using Batched drivers." << std::endl; - std::cout << " Modify according to the accuracy you would like to achieve. Focus on the walkers_per_rank tag. It should be adjusted based on the number of electron and the type of CPU" << std::endl; - - std::string fname = Title + ".qmc.in-wf" + WFS_name + ".xml"; - - xmlDocPtr doc_input = xmlNewDoc((const xmlChar*)"1.0"); - xmlNodePtr qm_root_input = xmlNewNode(NULL, BAD_CAST "simulation"); - - ///Adding Project id - { - xmlNodePtr project = xmlNewNode(NULL, (const xmlChar*)"project"); - xmlNewProp(project, (const xmlChar*)"id", (const xmlChar*)Title.c_str()); - xmlNewProp(project, (const xmlChar*)"series", (const xmlChar*)"0"); - xmlAddChild(project, parameter(project, "driver_version", "batched")); - xmlAddChild(qm_root_input, project); - } - - ///Adding Link to Partcle Set and Wave function - { - std::string Ptclname = Title + ".structure.xml"; - xmlNodePtr ptcl = xmlNewNode(NULL, (const xmlChar*)"include"); - xmlNewProp(ptcl, (const xmlChar*)"href", (const xmlChar*)Ptclname.c_str()); - xmlAddChild(qm_root_input, ptcl); - - std::string Wfsname = Title + ".wf" + WFS_name + ".xml"; - xmlNodePtr wfs = xmlNewNode(NULL, (const xmlChar*)"include"); - xmlNewProp(wfs, (const xmlChar*)"href", (const xmlChar*)Wfsname.c_str()); - xmlAddChild(qm_root_input, wfs); - } - - ///Adding Hamiltonian - { - xmlAddChild(qm_root_input, createHamiltonian(ion_tag, psi_tag)); - } - ///Adding Optimization Block based on One Shift Only - if (addJastrow) - { - ///Adding a VMC Block to help equilibrate - xmlNodePtr initvmc = xmlNewNode(NULL, (const xmlChar*)"qmc"); - xmlNewProp(initvmc, (const xmlChar*)"method", (const xmlChar*)"vmc_batch"); - xmlNewProp(initvmc, (const xmlChar*)"move", (const xmlChar*)"pbyp"); - xmlNewProp(initvmc, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); - { - xmlAddChild(initvmc, parameter(initvmc, "walkers_per_rank", "100")); - xmlAddChild(initvmc, parameter(initvmc, "substeps", "3")); - xmlAddChild(initvmc, parameter(initvmc, "steps", "20")); - xmlAddChild(initvmc, parameter(initvmc, "warmupSteps", "5")); - xmlAddChild(initvmc, parameter(initvmc, "blocks", "10")); - xmlAddChild(initvmc, parameter(initvmc, "timestep", "0.5")); - xmlAddChild(initvmc, parameter(initvmc, "usedrift", "no")); - } - xmlAddChild(qm_root_input, initvmc); - - if(!optJStaged) - { - ///Adding First loop of Cheap optimization blocks - xmlNodePtr loopopt1 = xmlNewNode(NULL, (const xmlChar*)"loop"); - xmlNewProp(loopopt1, (const xmlChar*)"max", (const xmlChar*)"4"); - { - xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc"); - xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear_batch"); - xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp"); - xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); - //xmlNewProp(initopt,(const xmlChar*)"gpu", (const xmlChar*)"no"); - { - xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator"); - xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy"); - xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no"); - xmlAddChild(initopt, estimator); - - xmlAddChild(initopt, parameter(initopt, "blocks", "20")); - xmlAddChild(initopt, parameter(initopt, "warmupSteps", "10")); - xmlAddChild(initopt, parameter(initopt, "timestep", "0.5")); - xmlAddChild(initopt, parameter(initopt, "walkers_per_rank", "600")); - xmlAddChild(initopt, parameter(initopt, "substeps", "2")); - xmlAddChild(initopt, parameter(initopt, "usedrift", "no")); - xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly")); - xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.1")); - } - xmlAddChild(loopopt1, initopt); - } - xmlAddChild(qm_root_input, loopopt1); - - ///Adding loop for optimization blocks - xmlNodePtr loopopt = xmlNewNode(NULL, (const xmlChar*)"loop"); - xmlNewProp(loopopt, (const xmlChar*)"max", (const xmlChar*)"10"); - { - xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc"); - xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear_batch"); - xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp"); - xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); - //xmlNewProp(initopt,(const xmlChar*)"gpu", (const xmlChar*)"no"); - { - xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator"); - xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy"); - xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no"); - xmlAddChild(initopt, estimator); - - xmlAddChild(initopt, parameter(initopt, "blocks", "20")); - xmlAddChild(initopt, parameter(initopt, "warmupSteps", "10")); - xmlAddChild(initopt, parameter(initopt, "timestep", "0.5")); - xmlAddChild(initopt, parameter(initopt, "walkers_per_rank", "600")); - xmlAddChild(initopt, parameter(initopt, "substeps", "2")); - xmlAddChild(initopt, parameter(initopt, "usedrift", "no")); - xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly")); - xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.5")); - } - xmlAddChild(loopopt, initopt); - } - xmlAddChild(qm_root_input, loopopt); - } - else - { - - ///Adding First loop of Cheap optimization blocks - { - xmlNodePtr loopopt1 = xmlNewNode(NULL, (const xmlChar*)"loop"); - xmlNewProp(loopopt1, (const xmlChar*)"max", (const xmlChar*)"4"); - { - xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc"); - xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear_batch"); - xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp"); - xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); - //xmlNewProp(initopt,(const xmlChar*)"gpu", (const xmlChar*)"no"); - { - xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator"); - xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy"); - xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no"); - xmlAddChild(initopt, estimator); - - xmlAddChild(initopt, parameter(initopt, "variational_subset", "uu ud")); - xmlAddChild(initopt, parameter(initopt, "blocks", "20")); - xmlAddChild(initopt, parameter(initopt, "warmupSteps", "10")); - xmlAddChild(initopt, parameter(initopt, "timestep", "0.5")); - xmlAddChild(initopt, parameter(initopt, "walkers_per_rank", "600")); - xmlAddChild(initopt, parameter(initopt, "substeps", "2")); - xmlAddChild(initopt, parameter(initopt, "usedrift", "no")); - xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly")); - xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.1")); - } - xmlAddChild(loopopt1, initopt); - } - xmlAddChild(qm_root_input, loopopt1); - - ///Adding loop for optimization blocks - xmlNodePtr loopopt = xmlNewNode(NULL, (const xmlChar*)"loop"); - xmlNewProp(loopopt, (const xmlChar*)"max", (const xmlChar*)"10"); - { - xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc"); - xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear_batch"); - xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp"); - xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); - //xmlNewProp(initopt,(const xmlChar*)"gpu", (const xmlChar*)"no"); - { - xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator"); - xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy"); - xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no"); - xmlAddChild(initopt, estimator); - - xmlAddChild(initopt, parameter(initopt, "variational_subset", "uu ud")); - xmlAddChild(initopt, parameter(initopt, "blocks", "20")); - xmlAddChild(initopt, parameter(initopt, "warmupSteps", "10")); - xmlAddChild(initopt, parameter(initopt, "timestep", "0.5")); - xmlAddChild(initopt, parameter(initopt, "walkers_per_rank", "600")); - xmlAddChild(initopt, parameter(initopt, "substeps", "2")); - xmlAddChild(initopt, parameter(initopt, "usedrift", "no")); - xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly")); - xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.5")); - } - xmlAddChild(loopopt, initopt); - } - xmlAddChild(qm_root_input, loopopt); - } - { - - ///Optimizing for 3Body Jastrow - ///Adding First loop of Cheap optimization blocks - - std::vector AtomNames(GroupName); - sort(AtomNames.begin(), AtomNames.end()); - AtomNames.erase(unique(AtomNames.begin(), AtomNames.end()), AtomNames.end()); - - std::string o3("uu ud "); - for (int iat = 0; iat < AtomNames.size(); iat++) - { - std::string o1 = "uu" + AtomNames[iat]; - std::string o2 = "ud" + AtomNames[iat]; - o3=o3+" "+o1+" "+o2; - } - xmlNodePtr loopopt1 = xmlNewNode(NULL, (const xmlChar*)"loop"); - xmlNewProp(loopopt1, (const xmlChar*)"max", (const xmlChar*)"4"); - { - xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc"); - xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear_batch"); - xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp"); - xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); - //xmlNewProp(initopt,(const xmlChar*)"gpu", (const xmlChar*)"no"); - { - xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator"); - xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy"); - xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no"); - xmlAddChild(initopt, estimator); - - - - xmlAddChild(initopt, parameter(initopt, "variational_subset", o3)); - xmlAddChild(initopt, parameter(initopt, "blocks", "20")); - xmlAddChild(initopt, parameter(initopt, "warmupSteps", "10")); - xmlAddChild(initopt, parameter(initopt, "timestep", "0.5")); - xmlAddChild(initopt, parameter(initopt, "walkers_per_rank", "600")); - xmlAddChild(initopt, parameter(initopt, "substeps", "2")); - xmlAddChild(initopt, parameter(initopt, "usedrift", "no")); - xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly")); - xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.1")); - } - xmlAddChild(loopopt1, initopt); - } - xmlAddChild(qm_root_input, loopopt1); - - ///Adding loop for optimization blocks - xmlNodePtr loopopt = xmlNewNode(NULL, (const xmlChar*)"loop"); - xmlNewProp(loopopt, (const xmlChar*)"max", (const xmlChar*)"10"); - { - xmlNodePtr initopt = xmlNewNode(NULL, (const xmlChar*)"qmc"); - xmlNewProp(initopt, (const xmlChar*)"method", (const xmlChar*)"linear_batch"); - xmlNewProp(initopt, (const xmlChar*)"move", (const xmlChar*)"pbyp"); - xmlNewProp(initopt, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); - //xmlNewProp(initopt,(const xmlChar*)"gpu", (const xmlChar*)"no"); - { - xmlNodePtr estimator = xmlNewNode(NULL, (const xmlChar*)"estimator"); - xmlNewProp(estimator, (const xmlChar*)"name", (const xmlChar*)"LocalEnergy"); - xmlNewProp(estimator, (const xmlChar*)"hdf5", (const xmlChar*)"no"); - xmlAddChild(initopt, estimator); - - xmlAddChild(initopt, parameter(initopt, "variational_subset", o3)); - xmlAddChild(initopt, parameter(initopt, "blocks", "20")); - xmlAddChild(initopt, parameter(initopt, "warmupSteps", "10")); - xmlAddChild(initopt, parameter(initopt, "timestep", "0.5")); - xmlAddChild(initopt, parameter(initopt, "walkers_per_rank", "600")); - xmlAddChild(initopt, parameter(initopt, "substeps", "2")); - xmlAddChild(initopt, parameter(initopt, "usedrift", "no")); - xmlAddChild(initopt, parameter(initopt, "MinMethod", "OneShiftOnly")); - xmlAddChild(initopt, parameter(initopt, "minwalkers", "0.5")); - } - xmlAddChild(loopopt, initopt); - } - xmlAddChild(qm_root_input, loopopt); - } - } - } - - - ///Adding a VMC Block to the Input - xmlNodePtr vmc = xmlNewNode(NULL, (const xmlChar*)"qmc"); - xmlNewProp(vmc, (const xmlChar*)"method", (const xmlChar*)"vmc_batch"); - xmlNewProp(vmc, (const xmlChar*)"move", (const xmlChar*)"pbyp"); - xmlNewProp(vmc, (const xmlChar*)"checkpoint", (const xmlChar*)"-1"); - //xmlNewProp(vmc,(const xmlChar*)"gpu", (const xmlChar*)"no"); - { - - xmlAddChild(vmc, parameter(vmc, "walkers_per_rank", "100")); - xmlAddChild(vmc, parameter(vmc, "warmupSteps", "20")); - xmlAddChild(vmc, parameter(vmc, "blocks", "20")); - xmlAddChild(vmc, parameter(vmc, "step", "20")); - xmlAddChild(vmc, parameter(vmc, "substeps", "3")); - xmlAddChild(vmc, parameter(vmc, "timestep", "0.1")); - xmlAddChild(vmc, parameter(vmc, "usedrift", "no")); - } - xmlAddChild(qm_root_input, vmc); - - ///Adding a DMC Block to the Input - xmlNodePtr dmc = xmlNewNode(NULL, (const xmlChar*)"qmc"); - xmlNewProp(dmc, (const xmlChar*)"method", (const xmlChar*)"dmc_batch"); - xmlNewProp(dmc, (const xmlChar*)"move", (const xmlChar*)"pbyp"); - xmlNewProp(dmc, (const xmlChar*)"checkpoint", (const xmlChar*)"20"); - //xmlNewProp(dmc,(const xmlChar*)"gpu", (const xmlChar*)"no"); - { - - xmlAddChild(dmc, parameter(dmc, "walkers_per_rank", "200")); - xmlAddChild(dmc, parameter(dmc, "warmupSteps", "50")); - xmlAddChild(dmc, parameter(dmc, "timestep", "0.001")); - xmlAddChild(dmc, parameter(dmc, "steps", "40")); - xmlAddChild(dmc, parameter(dmc, "blocks", "1000")); - if(ECP) - xmlAddChild(dmc, parameter(dmc, "nonlocalmoves", "v3")); - } - xmlAddChild(qm_root_input, dmc); - - xmlDocSetRootElement(doc_input, qm_root_input); - xmlSaveFormatFile(fname.c_str(), doc_input, 1); - xmlFreeDoc(doc_input); -} void QMCGaussianParserBase::dumpStdInput(const std::string& psi_tag, const std::string& ion_tag) { std::cout << " Generating Standard Input file containing VMC, standard optmization, and DMC blocks." << std::endl; diff --git a/src/QMCTools/QMCGaussianParserBase.h b/src/QMCTools/QMCGaussianParserBase.h index dcba28fc76..3a21487b1c 100644 --- a/src/QMCTools/QMCGaussianParserBase.h +++ b/src/QMCTools/QMCGaussianParserBase.h @@ -44,8 +44,6 @@ struct QMCGaussianParserBase bool PBC; bool legacy; bool production; - bool batched; - bool optJStaged; bool zeroCI; bool orderByExcitation; bool addJastrow; @@ -171,8 +169,6 @@ struct QMCGaussianParserBase void dumpStdInputProdLegacy(const std::string& psi_tag, const std::string& ion_tag); void dumpStdInputProd(const std::string& psi_tag, const std::string& ion_tag); - void dumpStdInputBatch(const std::string& psi_tag, const std::string& ion_tag); - //static std::vector IonName; static std::map IonName;