Make free energy analysis using EHMs more convenient
Description
Currently constructing free energies using EHMs (TDEPs) is a bit annoying.
It is easier thanks to the fact that StructureContainer
s can now store potential energy values but it is still messy.
For illustration:
sc = StructureContainer.read('my_sc.sc')
opt = ...
opt.train()
fcp = ForceConstantPotential(cs, opt.parameters)
Fvib = get_fvib(fcp)
All good so far but now the correction U_A-U_B
needs to be handled and it feels rather clumsy doing this.
I have FitStructure
s (with displacements and fit matrices) and parameters yet no good way to compute the energy.
It would be nice to avoid having to set up a ForceConstantCalculator
for reasons of cleanliness and performance.
This would also help with energy calculations for static structures. For example, at the moment computing the potential energy surface (PES) of a specific phonon mode with an ensemble of models takes a substantial effort/time. Instead it could be something like
E = np.dot(np.dot(fs.fit_matrix, parameters), fs.displacements)
which would take a second (as opposed to hours).
Note
I have no real good suggestion how this should be made available to users though.
- Add a method
FitStructure.predict(parameters)
- Add a helper function somewhere
predict(fs.fit_matrix, fs.displacements, parameters)
FROM IRL discussion solution 1. seemed preferred. (This method could also support force calculation.)
Demo
- tests pass
- new code fully tested
- usage of feature illustrated in tutorial