stfc / janus-core

Tools for machine learnt interatomic potentials
https://stfc.github.io/janus-core/
BSD 3-Clause "New" or "Revised" License
9 stars 7 forks source link

Add on-the-fly correlations of MD observables? #185

Closed harveydevereux closed 1 month ago

harveydevereux commented 2 months ago

It might be useful to include an online correlation algorithm that can hook into the simulation statistics, computing correlations at runtime.

I'd propose to work out the machinery/interface by supporting viscosity (stress correlations) to begin, unless there are objections. The correlator code is reasonably compact so it is just a case of working out user I/O and hooking into MD.


Some details:

The use case is that calculation of these correlations is decoupled from saving/storing the data that is correlated. Depending on parameters we can correlate more frequently than we save in stats etc. It could also mean, for example, a viscosity measurement $\sim~\int{t=0}^{T}dt\langle\sigma{xy}(0)\sigma_{xy}(t)\rangle$ can be observed as (subject to calculating the integral of the correlation) "easily" as a stress. All at the users option of course.

VAF can be done, so all the velocity data does not have to be stored, but the balance is then updating all those correlations (per atom) at runtime vs. storing and doing FFTs. If the I/O penalty is strong enough the fact the FFTs are fast can become moot. Plus if you chose parameters poorly you may have to restart if you did not store the data correlated as well.

Was talking with @alinelena about how to do it perhaps we can achieve this by attaching a correlator(s?) to dyn

self.dyn.attach(self._correlate_something, interval=self.correlation_frequency)

Here the correlator supplies an update(X, Y) method to attach and obviously a way to get the resultant correlation.

Here is a paper on the algorithm which we also used in DL_POLY