[Draft] ENH: Proper restarting during optimisations/MDs
Related to #1454 @AndrewRosen @flokno
There are probably a lot of things to say about the current code in this MR but it fixes problems that I would say are important:
-
Current restarting mechanisms do not allow for complete results reproducibility, this is especially true for Dynamics
types that are stochastic; the state of the random number generator has to be kept between restarts. This is fixed here by printing a pickleRestartFile
which is put as an observer. -
The current restart mechanism always performs one more calculation (at the beginning of each restart), resulting in increased computational cost, we fix it by introducing a restart
method in theDynamics
classes
Andersen MD, first a run with a restart mid-way, then the complete run, this was not possible before:
Time[ps] Etot[eV] Epot[eV] Ekin[eV] T[K]
0.0000 2.0024 2.0024 0.0000 0.0
0.0010 2.0419 1.9718 0.0701 180.8
0.0020 2.0374 1.9085 0.1289 332.5
0.0030 2.0065 1.8813 0.1252 322.9
0.0040 1.9986 1.8932 0.1053 271.6
0.0050 1.9847 1.9197 0.0650 167.6
Time[ps] Etot[eV] Epot[eV] Ekin[eV] T[K]
0.0060 1.9848 1.9210 0.0638 164.5
0.0070 1.9782 1.8992 0.0790 203.7
0.0080 1.9330 1.8822 0.0508 130.9
0.0090 1.9415 1.8868 0.0547 141.0
0.0100 1.9438 1.9156 0.0282 72.6
Time[ps] Etot[eV] Epot[eV] Ekin[eV] T[K]
0.0000 2.0024 2.0024 0.0000 0.0
0.0010 2.0419 1.9718 0.0701 180.8
0.0020 2.0374 1.9085 0.1289 332.5
0.0030 2.0065 1.8813 0.1252 322.9
0.0040 1.9986 1.8932 0.1053 271.6
0.0050 1.9847 1.9197 0.0650 167.6
0.0060 1.9848 1.9210 0.0638 164.5
0.0070 1.9782 1.8992 0.0790 203.7
0.0080 1.9330 1.8822 0.0508 130.9
0.0090 1.9415 1.8868 0.0547 141.0
0.0100 1.9438 1.9156 0.0282 72.6
Other, less important problems that would be nice to address:
-
Be compatible with the new Numpy random Generator's class, this is done here by changing from random_sample()
torandom()
for generating random numbers -
There should be only one correct way to do things: if there is an attach
mechanism for observers, we should delete thetrajectory
andlogfile
keywords in the constructors, especially since they do not allow as much flexibility -
Similarly, fixcm
orfix_com
should probably be discarded since there is already a whole module to deal with constraints?
I think this is a nice introduction to discuss these issues, it does not have to be using the current code
Checklist
-
I am familiar with ASE's contribution guidelines. -
Doc strings in code changed in this MR are up to date. -
Unit tests have been added for new or changed code. -
Issue is resolved via "closes #XXXX" if applicable.