Skip to content

Commit c84fe25

Browse files
committed
The guide goes on
1 parent e59f768 commit c84fe25

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

UserGuide/start.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ We prepared an input file in the form of a python script (tested with python-ssc
112112
relax.minim.dyn.save_qe("sscha_T{}_dyn".format(TEMPERATURE))
113113
114114
115+
Now save the file as `sscha_gold.py` and execute it with:
116+
117+
.. code-block:: bash
118+
119+
$ python sscha_gold.py > output.log
120+
121+
And that's it.
122+
**Congratulations!**
123+
115124

116125
While the input may seem long, it is heavily commented, but lets go through it step by step.
117126
At the very beginning, we simply import the sscha libraries, cellconstructor, the math libraries and the force field. This is done in python with the `import` statemets.
@@ -169,6 +178,49 @@ These parameters are almost self-explaining. However, we give a brief overview o
169178
While MD or MC calculation represent the equilibrium probability distribution over time of the system by updating a single structure, the SSCHA encodes the whole probability distribution as an analytical function. Therefore, to compute properties, we can generate on the fly the ionic configurations that represent the equilibrium distributions.
170179
The number of random configuration is exactly how many ionic configuration we generate to compute the properties (Free energy and Stress tensors)
171180

181+
The code that sets up and perform the SSCHA is the following:
182+
183+
.. code-block:: python
184+
185+
TEMPERATURE = 300
186+
N_CONFIGS = 50
187+
MAX_ITERATIONS = 20
188+
189+
# Initialize the random ionic ensemble
190+
ensemble = sscha.Ensemble.Ensemble(gold_harmonic_dyn, TEMPERATURE)
191+
192+
# Initialize the free energy minimizer
193+
minim = sscha.SchaMinimizer.SSCHA_Minimizer(ensemble)
194+
minim.set_minimization_step(0.01)
195+
196+
# Initialize the NVT simulation
197+
relax = sscha.Relax.SSCHA(minim, calculator, N_configs = N_CONFIGS,
198+
max_pop = MAX_ITERATIONS)
199+
200+
# Define the I/O operations
201+
# To save info about the free energy minimization after each step
202+
ioinfo = sscha.Utilities.IOInfo()
203+
ioinfo.SetupSaving("minim_info")
204+
relax.setup_custom_functions(custom_function_post = ioinfo.CFP_SaveAll)
205+
206+
# Run the NVT simulation
207+
relax.relax(get_stress = True)
208+
209+
210+
211+
212+
So you see many classes. `ensemble` represent the ensemble of ionic configurations. We initialize it with the dynamical matrix (which represent how much atoms fluctuate around the centroids) and the temperature.
213+
`minim` is a `SSCHA_Minimizer` object, which performs the free energy minimization. It contains all the info regarding the minimization algorithm, as the initial timestep (that here we set to 0.01). You can avoid setting the time-step, as the code will automatically guess the best value.
214+
The `relax` is a `SSCHA` object: the class that takes care about the simulation and automatizes all the steps to perform a NVT or NPT calculation.
215+
We pass the minimizer (which contains the ensemble with the temperature), the force-field (`calculator`), the number of configurations `N_configs` and the maximum number of iterations.
216+
217+
In this example, most of the time is spent in the minimization, however, if we replace the force-field with ab-initio DFT, the time tu run the minimization is negligible with respect to the time to compute energies and forces on the ensemble configurations.
218+
The total (maximum) number of energy/forces calculations is equal to the number of configurations times the number of iterations (passed through the `max_pop` argument).
219+
220+
The calculation is submitted with `relax.relax()`. However, before running the calculation we introduce another object, the `IOInfo`.
221+
This tells the `relax` to save information of the free energy, its gradient and the anharmonic phonon frequencies during the minimization in the files *minim_info.dat° and *minim_info.freqs*. It is not mandatory to introduce them, but it is very usefull as it allows to visualize the minimization while it is running.
222+
223+
172224

173225

174226

0 commit comments

Comments
 (0)