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

Bug in the input parser of nwxc functional #1073

Open
iswhy opened this issue Feb 1, 2025 · 2 comments
Open

Bug in the input parser of nwxc functional #1073

iswhy opened this issue Feb 1, 2025 · 2 comments

Comments

@iswhy
Copy link

iswhy commented Feb 1, 2025

Describe the bug
When nwxc functional is used and range-separated functionals are specified, NWChem cannot recognize user-defined cam parameters.

Describe settings used
OS: Manjaro Linux 24.2.1
NWCHEM_MODULES="smallqm nwxc"

To Reproduce
Prepare the following input file:

start H2O
geometry units angstrom
  O  0.00000000  0.00000000  0.11726921
  H  0.75698224  0.00000000 -0.46907685
  H -0.75698224  0.00000000 -0.46907685
end
basis spherical
  * library cc-pvdz
end
dft
  xc xcampbe96 1.0 cpbe96 1.0 HFexch 1.0
  cam 0.30 cam_alpha 0.25 cam_beta 0.75
  iterations 100
end
task dft energy

and run. Next, prepare another input file that is the same as above except that the dft block above is replaced with

set dft:gonwxc .true.
dft
  xc new xcampbe96 1.0 cpbe96 1.0 #HFexch 1.0
  cam 0.30 cam_alpha 0.25 cam_beta 0.75
  iterations 100
end

This will trigger NWChem to use nwxc functionals. If you compare the output, they produce different results.

Note that it is not because of the commented-out hfexch keyword in the later input file. In fact, you need to ignore this keyword when nwxc is used to produce the same result as the old XC functional library. This undesired behavior appears to be caused by nwxc inability to allow user-defined cam parameters---it only allows the pre-defined set of cam parameters. In the output of the job above using nwxc, go to "Range-Separation Parameters" section, and you will see that the listed values of the cam parameters are different than what are specified in the input

           Range-Separation Parameters        
           ---------------------------
           Alpha           :  0.00
           Beta            :  1.00
           Gamma           :  0.33
           Short-Range HF  :     F

Now, try running this input file with a different functional:

start H2O
geometry units angstrom
  O  0.00000000  0.00000000  0.11726921
  H  0.75698224  0.00000000 -0.46907685
  H -0.75698224  0.00000000 -0.46907685
end
basis spherical
  * library cc-pvdz
end
dft
  xc xcamb88 1.00 lyp 0.81 vwn_5 0.19 hfexch 1.00
  cam 0.33 cam_alpha 0.19 cam_beta 0.46
  iterations 100
end
task dft energy

then rerun using the nwxc version of the functional, namely, with the dft section replaced with

set dft:gonwxc .true.
dft
  xc new xcamb88 1.00 lyp 0.81 vwn_5 0.19    #hfexch 1.00
  cam 0.33 cam_alpha 0.19 cam_beta 0.46
  iterations 100
end

You will see that this time the two XC libraries produce the same results. This is most likely because the specified combination of functionals and cam parameters belongs to a pre-defined set (I took those values from NWChem user manual).

I have the fix in my repo branch https://github.com/iswhy/nwchem/tree/fix_nwxc in case some reference might be helpful. I am sorry though for the loads of changes, they are mostly due to the files that are not git-tracked in the upstream but are git-tracked in my repo. (like some compile-time-generated *.fh files) The actual debugger modifications are found in src/nwdft/input_dft/dft_input.F and src/nwxc/nwxc/nwxc_nwchem.F.

PS: At the moment I consider the need of the hfexch to be absent when nwxc is used as a feature instead of a bug. If it is a bug, however, it would be independent from the one currently addressed.

@edoapra
Copy link
Collaborator

edoapra commented Feb 2, 2025

@iswhy Thank you for this detailed bug report.

Please keep in mind that that, as your own experience clearly show, that the nwxc has not reached production quality yet.
We recommend the use of either builtin XC functionals input or, as a more recent alternative, the libxc library functionals.
https://nwchemgit.github.io/Density-Functional-Theory-for-Molecules.html#libxc-interface-new-in-nwchem-720
https://nwchemgit.github.io/Density-Functional-Theory-for-Molecules.html#xc-functionals-summary

PS The nwxc module is not part of the default build since version 6.8 for the above mentioned reasons
https://nwchemgit.github.io/Density-Functional-Theory-for-Molecules.html#xc-functionals-summary

@iswhy
Copy link
Author

iswhy commented Feb 3, 2025

@edoapra, thanks for your response.
Does that mean that the development of the nwxc module has stopped?
Despite the bugs, looking at the codes, the library looks extensive enough to be removed from the development line.
Mind telling us why it was developed to such an extent in the first place?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants