Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the xsf format data precision #5233

Merged
merged 2 commits into from
Nov 19, 2024
Merged

Conversation

aannabe
Copy link
Contributor

@aannabe aannabe commented Nov 18, 2024

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?

  • enhancement

Does this introduce a breaking change?

  • No

What systems has this change been tested on?

  • NERSC
  • Local Machine

Checklist

  • Yes. This PR is up to date with current the current state of 'develop'

@aannabe
Copy link
Contributor Author

aannabe commented Nov 18, 2024

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
Copy link
Contributor

prckent commented Nov 18, 2024

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
Copy link
Contributor Author

aannabe commented Nov 18, 2024

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
Copy link
Contributor

ye-luo commented Nov 19, 2024

Test this please

@ye-luo ye-luo enabled auto-merge November 19, 2024 00:11
@ye-luo ye-luo merged commit 3bc3c85 into QMCPACK:develop Nov 19, 2024
38 of 39 checks passed
@aannabe aannabe deleted the xsf_precision branch November 19, 2024 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants