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

Issues encountered with manually submitting works #152

Closed woyolo990422 closed 10 months ago

woyolo990422 commented 1 year ago

The manual submission task in the manual does not have the ability to achieve vc-relax. I am curious that if I want to know the accurate Gibbs free energy, I need to calculate vc-relax. However, due to the difficulty of applying for multi-core on the server and our server being an LSF operating system, cluster mode cannot be directly called. I would like to know how to achieve vc-relax by manually submitting tasks and calculating Gibbs free energy under high temperature and pressure

mesonepigreco commented 1 year ago

Hi, yes, it is possible. You can still use the SSCHA class from the Relax module by initializing it with a minimizer (SSCHA_Minimizer) initialized with the ensemble computed manually. Then you can call vc_relax, as if it was an automatic calculation, setting the max_population to 1 and the flag restart_from_ensemble = True.

A minimal example:

# Load the dynamical matrix as dyn
ensemble = sscha.Ensemble.Ensemble(dyn, temperature)
ensemble.load("data_dir",  population_id, n_configs)

minim = sscha.SchaMinimizer.SSCHA_Minimizer(ensemble)

relax = sscha.Relax.SSCHA(minim, max_pop = 1)
relax.vc_relax(target_press = 0, static_bulk_modulus = 100, restart_from_ensemble= True)
relax.minim.dyn.save_qe("final_dyn_sscha_pop{}".format(population_id))

Unfortunately, the algorithm will do 1 step at a time. This means that you need to guess a good value for the static_bulk_modulus. If you see that in the following population the cell changed too much (you overshot the target pressure), increase the static_bulk_modulus (it will reduce the step of the cell in the vc-relax). If the pressure change barely, then reduce it to speed up. This is usually done automatically by the vc_relax across different populations, but it must be done manually.

woyolo990422 commented 1 year ago

Thank you for the answer, but during this process, I encountered other issues. I was studying the free energy of structures under extreme pressure and temperature. I wrote some simple scripts to solve my problem, but encountered the following error:

Traceback (most recent call last): File "/bbfs/fs09/home/js_wangyl/CO-Gibbs/SSCHA/C/60/total.py", line 126, in relax.vc_relax(target_press = 60000, static_bulk_modulus = 10000, restart_from_ens= True) File "/fs08/home/js_wangyl/.conda/envs/magus/lib/python3.9/site-packages/sscha/Relax.py", line 568, in vc_relax self.minim.ensemble.generate(self.N_configs, sobol=sobol, sobol_scramble = sobol_scramble, sobol_scatter = sobol_scatter) File "/fs08/home/js_wangyl/.conda/envs/magus/lib/python3.9/site-packages/sscha/Ensemble.py", line 1124, in generate raise ValueError("Error, evenodd allowed only with an even number of random structures") ValueError: Error, evenodd allowed only with an even number of random structures

But the structures I actually gave were even, not odd

Here is my attachment

mesonepigreco commented 1 year ago

You are right! It is a bug (very easy to fix). Thanks for the report For now, the workaround is to call vc_relax with start_pop=1.

relax.vc_relax(target_press = 0, static_bulk_modulus = 100, restart_from_ensemble= True, start_pop=1)

By the way, target_press and static_bulk_modulus are both in GPa, are you sure of your units? They seem quite big.

woyolo990422 commented 1 year ago

Thank you for your reply. I am studying the state of matter under very high pressure, and it is very difficult to explain it in MD. Therefore, I am using SSCHA to solve the problem.