SSCHAcode / python-sscha

The python implementation of the Stochastic Self-Consistent Harmonic Approximation (SSCHA).
GNU General Public License v3.0
55 stars 21 forks source link

Restoring the sscha.Relax.SSCHA object from the saved data #105

Open Kurufinve opened 1 year ago

Kurufinve commented 1 year ago

Dear developers,

Is it possible to restore the sscha.Relax.SSCHA object from the data saved during the relaxation? I have run the sscha relaxation in the jupyter notebook for 1 month (with remote cluster). However, when the relaxation have finished (or not finished, I'm not sure), the sscha.Relax.SSCHA object was gone from memory. I would like to restore it to look on the results of relaxation and check if it was converged. The part of the script with defining the sscha.Relax.SSCHA object is following:

relax = sscha.Relax.SSCHA(minim, ase_calculator = espresso_calc, N_configs = N_CONFIGS, max_pop = MAX_ITERATIONS, save_ensemble = True, cluster =my_hpc)

ioinfo = sscha.Utilities.IOInfo() ioinfo.SetupSaving("minim_info") relax.setup_custom_functions(custom_function_post = ioinfo.CFP_SaveAll)

relax.vc_relax(target_press = 170, static_bulk_modulus = 150, restart_from_ens = True, ensemble_loc = "ensembles")

mesonepigreco commented 1 year ago

Hi, Of course, To check convergence, the minimization info are stored into minim_info.freq and minim_info.dat that you saved. You can plot the history of the frequencies, free energy and gradients executing from the terminal

sscha-plot-frequencies.py minim_info

from the same directory as the jupyter lab was executing (where the minim_info.freq and minim_info.dat are stored)

You have all the ensemble computed and generated into the directory "ensembles", you can restore the lastone with

import sscha, sscha.Ensemble

POPULATION = POPULATION_INDEX
NQIRR = THE_IRREDUCIBLE_Q_POINTS_OR_YOUR_MATRIX
dyn = CC.Phonons.Phonons("ensembles/dyn_gen_pop{}_".format(POPULATION), NQIRR)
ensemble = sscha.Ensemble.Ensemble(dyn, TEMPERATURE)
ensemble.load_bin("ensembles", POPULATION)

You can check POPULATION_INDEX by looking at the files stored in the "ensembles" directory (the biggest number after pop is the last one). You can use this ensemble to compute the free energy hessian or the quantity you prefer.

If you want to continue the optimization, you can simply redefine the relax object as you did with your code, initializing using the last ensemble.

Since for this ensemble you have already the forces and energy computed, you can run directly the minimization without recomputing them adding to the relax (or vc_relax) the key restart_from_ens as

relax.setup_custom_functions(custom_function_post = ioinfo.CFP_SaveAll, restart_from_ens = True)

Moreover, in the same directory as the Jupyter notebook, you have all the dynamical matrices at the end of each step, saved as dyn_popXX_YY (XX is the index of the population, YY the id of the q points) Let me know if you need something else, Bests, Lorenzo

Kurufinve commented 1 year ago

Dear Lorenzo,

Thank you very much for your answer!

Sincerely, Daniil Poletaev