Main repository for QMCPACK, an open-source production level many-body ab initio Quantum Monte Carlo code for computing the electronic structure of atoms, molecules, and solids with full performance portable GPU support
Describe the bug
qdens is not able to produce densities with the updated definition of estimators for the batched code.
To Reproduce
Steps to reproduce the behavior:
I think this is reproducable on any DMC or VMC batched input file you have available, but in case it fails, please let me know, I will provide the files to reproduce this error.
Add "estimators" block in "qmcsystem" block as below:
Instead of doing this by hand, one can use Nexus:
Using the attached nexus file (modified from /nexus/examples/rsqmc_misc/diamond_radial_density/diamond_spin.py), change driver between batched and legacy to observe how the input changes. With legacy option, the correct input file is produced (spindensity inside qmc blocks) , but with batched option, the estimators block is created inside the qmcsystem block (outside hamiltonian block) as above.
Depending on when Nexus is installed, the produced input file is also different.
Using Nexus pre Dec 8, 2023 the input file is written using this block of code:
if batched and d_estimators is not None and len(d_estimators)>0:
estimators = generate_estimators_batched(d_estimators)
for calc in kw.calculations:
if isinstance(calc,loop):
calc = calc.qmc
#end if
calc.estimators = estimators.copy()
#end for
#end if
Using the block of code above, nexus produces the input file with estimators block is created inside qmc blocks (thanks to kw.calculations loop).
In the latest version of Nexus, the loop over kw.calculations is removed and the estimator is added to qmcsystem based on the updated <estimator/> block definition:
if batched and d_estimators is not None and len(d_estimators)>0:
ests = generate_estimators_batched(d_estimators,wf_elem=wfn)
ests_elem = estimators()
ests_elem.estimators = ests
sim.qmcsystem.estimators = ests_elem
#end if
With estimator block defined as in (1), qdens complains that there is no density in h5 files, because qdens looks for the spindensity information from the in.xml files and can't find spindensity in hamiltonian or qmc blocks. Using the code below interactively one can load one of the h5 files:
import h5py
import numpy as np
f = h5py.File("dmc.g000.s002.stat.h5", "r")
ud=f['SpinDensity']['u']['value']
np.sum(ud[0])
>>> 104.00075659850167
ud.shape
>>> (1000, 235200)
This file has the correct grid density (dr=0.3, thus 40,40,147), and non-zero.
Expected behavior
Qdens should be able to work with the updated definition of <estimator/> element.
System:
Polaris
Additional context
Add any other context about the problem here.
diamond_spin.py.zip
Describe the bug qdens is not able to produce densities with the updated definition of estimators for the batched code.
To Reproduce Steps to reproduce the behavior: I think this is reproducable on any DMC or VMC batched input file you have available, but in case it fails, please let me know, I will provide the files to reproduce this error.
Add "estimators" block in "qmcsystem" block as below:
Instead of doing this by hand, one can use Nexus: Using the attached nexus file (modified from /nexus/examples/rsqmc_misc/diamond_radial_density/diamond_spin.py), change
driver
betweenbatched
andlegacy
to observe how the input changes. Withlegacy
option, the correct input file is produced (spindensity
insideqmc
blocks) , but withbatched
option, theestimators
block is created inside theqmcsystem
block (outsidehamiltonian
block) as above.Depending on when Nexus is installed, the produced input file is also different. Using Nexus pre Dec 8, 2023 the input file is written using this block of code:
Using the block of code above, nexus produces the input file with
estimators
block is created insideqmc
blocks (thanks to kw.calculations loop).In the latest version of Nexus, the loop over kw.calculations is removed and the estimator is added to
qmcsystem
based on the updated<estimator/>
block definition:qdens
complains that there is no density in h5 files, becauseqdens
looks for thespindensity
information from the in.xml files and can't findspindensity
inhamiltonian
orqmc
blocks. Using the code below interactively one can load one of the h5 files:This file has the correct grid density (dr=0.3, thus 40,40,147), and non-zero.
Expected behavior Qdens should be able to work with the updated definition of
<estimator/>
element.System:
Additional context Add any other context about the problem here. diamond_spin.py.zip