QMCPACK / qmcpack

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
http://www.qmcpack.org
Other
302 stars 139 forks source link

Improve the xsf format data precision #5233

Closed aannabe closed 1 week ago

aannabe commented 1 week ago

Proposed changes

A common way to analyze charge/spin densities in qmcpack is to generate the *.xsf data files via qdens that reads the data from the native stat.h5 files. The xsf files can then be further analyzed via qdens-radial or other tools. Currently, the data (such as charge density) in the xsf files are written as floats with 8 significant digits (12.8f). I think scientific notation is better for this type of data. For example, QE (v7.0) uses scientific notation with 6 significant digits (12.6E). In a simple test I did, the integrated charge (norm) has improved significantly using the 12.6E style for CH4 molecules in a 16^3 Ang box. Here the correct norm is 5.

Old code:

Max Density: 0.00069445
Norm: 4.999454429999994
File Size: 111 MB

New code:

Max Density: 0.0006944463
Norm: 5.000000002221036
File Size: 111 MB

The accuracy can be further improved at the expense of a larger file size.

What type(s) of changes does this code introduce?

Does this introduce a breaking change?

What systems has this change been tested on?

Checklist

aannabe commented 1 week ago

Just want to add that the reason I looked at this is to rule out any possible bugs. Having the norm close to the correct value provides a good sanity check.

prckent commented 1 week ago

Thanks Gani. Big improvement. Happy to merge this. Are there any arguments against using an even higher precision? Using the same format as QE is one argument, but why not choose bigger files?... Does a couple of extra digits gain much?

aannabe commented 1 week ago

I just tried to improve the accuracy while maintaining the same file size. Slightly increasing further to 14.8E shows even better norm:

Max Density: 0.000694446266
Norm: 5.000000000032804
File Size: 126 MB

This is with a [200x200x200] grid (the increase in file size with denser grids will be steeper). But overall the file size is still acceptable I think, and I have now pushed it to 14.8E.

ye-luo commented 1 week ago

Test this please