Input Needed: How to report optimizable parameters in opt.xml or vp.h5 files?
Is your feature request related to a problem? Please describe. For orbital rotations we need to report the total rotation at each step. I think this can be done entirely at the RotatedSPOs level, but what I don't understand is how wavefunction parameters are reported in the opt.xml and, more recently, the "vp.h5" files. I see methods like "checkInVariables", "checkOutVariables", and "resetParameters". These seem to be called in QMCCostFunctionBase. And the manual states that these functions handle variational parameter stuff. But looking around in the code, I can't seem to figure out where or how the parameters are reported at each stage of the optimization.
- Is opt.xml preferred over vp.h5? There seems to be both at the moment.
- In any case, how do I get the parameters to either of those files?
@markdewing @ye-luo Please help!
Short version: Once the variational parameter management functions are set up (checkInVariables, etc), storing the parameters to the vp.h5 file should be automatic, and you should need to do nothing more to get the parameter values saved and loaded.
The parameter management functions are described in TrialWaveFunction.h https://github.com/QMCPACK/qmcpack/blob/ea699798dc0c232d0d7427818f8d4dc364eaef3a/src/QMCWaveFunctions/TrialWaveFunction.h#L135-L167
The values are written out in QMCCostFunctionBase::reportParameters
https://github.com/QMCPACK/qmcpack/blob/ea699798dc0c232d0d7427818f8d4dc364eaef3a/src/QMCDrivers/WFOpt/QMCCostFunctionBase.cpp#L214-L232
Note that this function calls updateXmlNodes https://github.com/QMCPACK/qmcpack/blob/ea699798dc0c232d0d7427818f8d4dc364eaef3a/src/QMCDrivers/WFOpt/QMCCostFunctionBase.cpp#L512
One issue is that the wavefunction files contain the structure of the wavefunction and the variational parameters for the wavefunction. The updateXmlNodes function needs to understand the structure of the wavefunction in order to modify the variational parameters of the wavefunction. Which was getting difficult to modify. The intermediate solution is to separate the structure of the wavefunction from the values and just write the values to the vp.h5 file.
I think the multi-determinant coefficients and the LCAO orbital rotation parameters are only available in the vp.h5 file. The way forward is going be using the vp.h5 file (even though the opt.xml file is still present and some parts of it get updated).
The values of the parameters also get written to stdout/output file in QMCCostFunctionBase::Report.
The *.vp.h5 files are a simple HDF5 format. Should you want to look at or modify them, there's a script in the test directory to help with that
https://github.com/QMCPACK/qmcpack/blob/ea699798dc0c232d0d7427818f8d4dc364eaef3a/tests/molecules/He_param/convert_vp_format.py
Thanks, Mark. Your comments are very helpful! Based on this, it looks to me like the way to go is the vp.h5 route. Fortunately, it seems that the plumbing is already in place to write the rotations to the vp.h5 file. Looks like what is missing is loading the parameters back in. So I guess that's where I will start.
If the three functions for managing variational parameters are implemented (which needs to happen for optimization to work), then loading the parameters from a vp.h5 file should be automatic.
There is some code to read the rotation parameters from the input file, which was part of the original LCAO rotation code. Though there's nothing to write the parameters in this format. (If we had kept going following previous methods of updating the parameters, this would be written in the updateXmlNodes function.)
I wouldn't recommend depending on this code, but it is there and could be used for special cases.
https://github.com/QMCPACK/qmcpack/blob/687a2eeb0115b5ba17dbf6aea4e88bcdb2e572d6/src/QMCWaveFunctions/SPOSetBuilder.cpp#L105-L109