Energy volume curve

Theory

Fitting the energy volume curve allows to calculate the equilibrium energy $E_0$, the equilirbium volume $V_0$, the equilibrium bulk modulus $B_0$ and its derivative $B^{'}_0$. These quantities can then be used as part of the Einstein model to get an initial prediction for the thermodynamik properties, the heat capacity $C_v$ and the free energy $F$.

Initialisation

We start by importing matplotlib, numpy and the pyiron project class.

In [1]:
%matplotlib inline 
import matplotlib.pyplot as plt
import numpy as np
from pyiron import Project

In the next step we create a project, by specifying the name of the project. In addition we remove all jobs which might exist in the project before to have a clean project for our example.

In [2]:
pr = Project(path='thermo')
# pr.remove_jobs(recursive=True)

Atomistic structure

To analyse the energy volume dependence a single super cell is sufficient, so we create an iron super cell as an example.

In [3]:
basis = pr.create_structure(element='Fe', bravais_basis='bcc', lattice_constant=2.75)
basis.plot3d()

Calculation

Energy volume curves are commonly calculated with ab initio codes, so we use VASP in this example. But we focus on the generic commands so the same example works with any DFT code. We choose 'vasp' as job name prefix, select an energy cut off of $320 eV$ and assign the basis to the job. Afterwards we apply the corresponding strain.

In [4]:
for strain in np.linspace(0.97, 1.03, 7):
    strain_str = str(strain).replace('.', '_')
    job_vasp_strain = pr.create_job(job_type=pr.job_type.GpawJob, job_name='gpaw_' + strain_str)
    job_vasp_strain.set_encut(320.0)
    job_vasp_strain.structure = basis.copy()
    job_vasp_strain.structure.set_cell(cell=basis.cell * strain ** (1/3), scale_atoms=True)
    job_vasp_strain.run()

As these are simple calculation, there is no need to submit them to the queuing sytem. We can confirm the status of the calculation with the job_table. If the status of each job is marked as finished, then we can continue with the next step.

In [5]:
pr.job_table()
Out[5]:
id status chemicalformula job subjob projectpath project timestart timestop totalcputime computer hamilton hamversion parentid masterid
6 3601535 finished None gpaw_0_97 /gpaw_0_97 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/ 2019-09-04 13:50:31.285688 None None [email protected]#1 GpawJob None None None
38 3601804 finished None gpaw_0_98 /gpaw_0_98 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/ 2019-09-04 13:50:42.970024 None None [email protected]#1 GpawJob None None None
45 3602090 finished None gpaw_0_99 /gpaw_0_99 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/ 2019-09-04 13:50:52.350144 None None [email protected]#1 GpawJob None None None
8 3602359 finished None gpaw_1_0 /gpaw_1_0 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/ 2019-09-04 13:51:01.413156 None None [email protected]#1 GpawJob None None None
39 3602595 finished None gpaw_1_01 /gpaw_1_01 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/ 2019-09-04 13:51:10.251511 None None [email protected]#1 GpawJob None None None
0 3602869 finished None gpaw_1_02 /gpaw_1_02 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/ 2019-09-04 13:51:20.041600 None None [email protected]#1 GpawJob None None None
4 3603146 finished None gpaw_1_03 /gpaw_1_03 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/ 2019-09-04 13:51:29.741836 None None [email protected]#1 GpawJob None None None
37 3603487 finished None gpaw_0_97 /gpaw_0_97 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_270/ 2019-09-04 13:51:42.796905 None None [email protected]#1 GpawJob None None None
5 3603765 finished None gpaw_0_98 /gpaw_0_98 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_270/ 2019-09-04 13:51:53.088836 None None [email protected]#1 GpawJob None None None
44 3604021 finished None gpaw_0_99 /gpaw_0_99 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_270/ 2019-09-04 13:52:02.979283 None None [email protected]#1 GpawJob None None None
2 3604219 finished None gpaw_1_0 /gpaw_1_0 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_270/ 2019-09-04 13:52:11.921097 None None [email protected]#1 GpawJob None None None
7 3604443 finished None gpaw_1_01 /gpaw_1_01 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_270/ 2019-09-04 13:52:21.335934 None None [email protected]#1 GpawJob None None None
3 3604655 finished None gpaw_1_02 /gpaw_1_02 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_270/ 2019-09-04 13:52:31.009130 None None [email protected]#1 GpawJob None None None
1 3604768 finished None gpaw_1_03 /gpaw_1_03 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_270/ 2019-09-04 13:52:40.320534 None None [email protected]#1 GpawJob None None None
40 3604824 finished None gpaw_0_97 /gpaw_0_97 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_280/ 2019-09-04 13:52:50.470563 None None [email protected]#1 GpawJob None None None
42 3604871 finished None gpaw_0_98 /gpaw_0_98 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_280/ 2019-09-04 13:52:59.954797 None None [email protected]#1 GpawJob None None None
43 3604875 finished None gpaw_0_99 /gpaw_0_99 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_280/ 2019-09-04 13:53:09.963464 None None [email protected]#1 GpawJob None None None
48 3604880 finished None gpaw_1_0 /gpaw_1_0 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_280/ 2019-09-04 13:53:20.141701 None None [email protected]#1 GpawJob None None None
9 3604884 finished None gpaw_1_01 /gpaw_1_01 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_280/ 2019-09-04 13:53:29.324131 None None [email protected]#1 GpawJob None None None
10 3604887 finished None gpaw_1_02 /gpaw_1_02 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_280/ 2019-09-04 13:53:38.550641 None None [email protected]#1 GpawJob None None None
19 3604890 finished None gpaw_1_03 /gpaw_1_03 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_280/ 2019-09-04 13:53:48.099532 None None [email protected]#1 GpawJob None None None
41 3604896 finished None gpaw_0_97 /gpaw_0_97 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_290/ 2019-09-04 13:53:59.152323 None None [email protected]#1 GpawJob None None None
46 3604899 finished None gpaw_0_98 /gpaw_0_98 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_290/ 2019-09-04 13:54:08.057464 None None [email protected]#1 GpawJob None None None
47 3604903 finished None gpaw_0_99 /gpaw_0_99 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_290/ 2019-09-04 13:54:17.516512 None None [email protected]#1 GpawJob None None None
11 3604907 finished None gpaw_1_0 /gpaw_1_0 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_290/ 2019-09-04 13:54:26.874849 None None [email protected]#1 GpawJob None None None
12 3604910 finished None gpaw_1_01 /gpaw_1_01 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_290/ 2019-09-04 13:54:37.345194 None None [email protected]#1 GpawJob None None None
13 3604911 finished None gpaw_1_02 /gpaw_1_02 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_290/ 2019-09-04 13:54:48.785761 None None [email protected]#1 GpawJob None None None
14 3604913 finished None gpaw_1_03 /gpaw_1_03 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_290/ 2019-09-04 13:55:00.556380 None None [email protected]#1 GpawJob None None None
15 3604914 finished None gpaw_0_97 /gpaw_0_97 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_300/ 2019-09-04 13:55:10.828970 None None [email protected]#1 GpawJob None None None
16 3604915 finished None gpaw_0_98 /gpaw_0_98 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_300/ 2019-09-04 13:55:19.451476 None None [email protected]#1 GpawJob None None None
17 3604916 finished None gpaw_0_99 /gpaw_0_99 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_300/ 2019-09-04 13:55:28.235999 None None [email protected]#1 GpawJob None None None
18 3604917 finished None gpaw_1_0 /gpaw_1_0 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_300/ 2019-09-04 13:55:36.912405 None None [email protected]#1 GpawJob None None None
20 3604918 finished None gpaw_1_01 /gpaw_1_01 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_300/ 2019-09-04 13:55:46.777440 None None [email protected]#1 GpawJob None None None
21 3604919 finished None gpaw_1_02 /gpaw_1_02 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_300/ 2019-09-04 13:55:55.186420 None None [email protected]#1 GpawJob None None None
22 3604920 finished None gpaw_1_03 /gpaw_1_03 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_300/ 2019-09-04 13:56:05.185718 None None [email protected]#1 GpawJob None None None
23 3604921 finished None gpaw_0_97 /gpaw_0_97 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_310/ 2019-09-04 13:56:14.138209 None None [email protected]#1 GpawJob None None None
24 3604922 finished None gpaw_0_98 /gpaw_0_98 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_310/ 2019-09-04 13:56:22.072544 None None [email protected]#1 GpawJob None None None
25 3604923 finished None gpaw_0_99 /gpaw_0_99 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_310/ 2019-09-04 13:56:30.773140 None None [email protected]#1 GpawJob None None None
26 3604924 finished None gpaw_1_0 /gpaw_1_0 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_310/ 2019-09-04 13:56:38.738514 None None [email protected]#1 GpawJob None None None
27 3604925 finished None gpaw_1_01 /gpaw_1_01 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_310/ 2019-09-04 13:56:46.853680 None None [email protected]#1 GpawJob None None None
28 3604926 finished None gpaw_1_02 /gpaw_1_02 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_310/ 2019-09-04 13:56:55.404483 None None [email protected]#1 GpawJob None None None
29 3604927 finished None gpaw_1_03 /gpaw_1_03 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_310/ 2019-09-04 13:57:03.940368 None None [email protected]#1 GpawJob None None None
30 3604928 finished None gpaw_0_97 /gpaw_0_97 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_320/ 2019-09-04 13:57:13.347542 None None [email protected]mc001#1 GpawJob None None None
31 3604929 finished None gpaw_0_98 /gpaw_0_98 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_320/ 2019-09-04 13:57:21.459612 None None [email protected]#1 GpawJob None None None
32 3604930 finished None gpaw_0_99 /gpaw_0_99 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_320/ 2019-09-04 13:57:29.623085 None None [email protected]#1 GpawJob None None None
33 3604931 finished None gpaw_1_0 /gpaw_1_0 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_320/ 2019-09-04 13:57:37.903535 None None [email protected]#1 GpawJob None None None
34 3604933 finished None gpaw_1_01 /gpaw_1_01 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_320/ 2019-09-04 13:57:46.032614 None None [email protected]#1 GpawJob None None None
35 3604934 finished None gpaw_1_02 /gpaw_1_02 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_320/ 2019-09-04 13:57:54.280901 None None [email protected]#1 GpawJob None None None
36 3604935 finished None gpaw_1_03 /gpaw_1_03 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_320/ 2019-09-04 13:58:02.411374 None None [email protected]#1 GpawJob None None None

Analysis

We aggregate the data for further processing in two separated lists, one for the volumes and one for the energies. To do so we iterate over the jobs within the project, filter the job names which contain the string 'vasp' and from those extract the final volume and the final energy.

In [6]:
volume_lst, energy_lst = zip(*[[job['output/generic/volume'][-1], job['output/generic/energy_pot'][-1]] 
                               for job in pr.iter_jobs(convert_to_object=False) if 'gpaw' in job.job_name])   

We plot the aggregated data using matplotlib.

In [7]:
plt.plot(volume_lst, energy_lst, 'x-')
plt.xlabel('Volume ($\AA ^ 3$)')
plt.ylabel('Energy (eV)')
Out[7]:
Text(0, 0.5, 'Energy (eV)')

Encut Dependence

To extend the complexity of our simulation protocol we can not only iterate over different strains but also different energy cutoffs. For this we use multiple sub projects to structure the data. And we summarize the previous code in multiple functions to maintain a high level of readability. The first function calculates a specific strained configuration for an specifc energy cut off, while the second function analyses the different strained calculations for a specific energy cutoff and returns the list of energy volume pairs.

Functions

In [8]:
def vasp_calculation_for_strain(pr, basis, strain, encut):
    strain_str = str(strain).replace('.', '_')
    job_vasp_strain = pr.create_job(job_type=pr.job_type.GpawJob, job_name='gpaw_' + strain_str)
    job_vasp_strain.set_encut(encut)
    job_vasp_strain.structure = basis.copy()
    job_vasp_strain.structure.set_cell(cell=basis.cell * strain ** (1/3), scale_atoms=True)
    job_vasp_strain.run()
In [9]:
def energy_volume_pairs(pr):
    volume_lst, energy_lst = zip(*[[job['output/generic/volume'][-1], job['output/generic/energy_pot'][-1]] 
                               for job in pr.iter_jobs(convert_to_object=False) if 'gpaw' in job.job_name])
    return volume_lst, energy_lst

Calculation

With these functions we can structure our code and implement the additional for loop to include multiple energy cutoffs.

In [10]:
for encut in np.linspace(270, 320, 6):
    encut_str = 'encut_' + str(int(encut))
    pr_encut = pr.open(encut_str)
    for strain in np.linspace(0.97, 1.03, 7):
        vasp_calculation_for_strain(pr=pr_encut, 
                                    basis=basis, 
                                    strain=strain, 
                                    encut=encut)

Analysis

The analysis is structured in a similar way. Here we use iter_groups() to iterate over the existing subprojects within our project and plot the individual energy volume curves using the functions defined above.

In [11]:
for pr_encut in pr.iter_groups():
    volume_lst, energy_lst = energy_volume_pairs(pr_encut)
    plt.plot(volume_lst, energy_lst, 'x-', label=pr_encut.base_name)
plt.xlabel('Volume ($\AA ^ 3$)')
plt.ylabel('Energy (eV)')
plt.legend()
Out[11]:
<matplotlib.legend.Legend at 0x2b8836c94470>

Fitting

After we created multiple datasets we can now start to fit the converged results. While it is possible to fit the results using a simple polynomial fit we prefer to use the phyiscally motivated birch murnaghan equation or the vinet equation. For this we create the Murnaghan object and use it is fitting functionality:

In [12]:
murn = pr.create_job(job_type=pr.job_type.Murnaghan, job_name='murn')

Birch Marnaghan

In [13]:
[e0, b0, bP, v0], [e0_error, b0_error, bP_error, v0_error] = murn._fit_leastsq(volume_lst=volume_lst,
                                                                               energy_lst=energy_lst,
                                                                               fittype='birchmurnaghan')
[e0, b0, bP, v0] 
Out[13]:
[-10938046483227.81, -160.21766207685127, 4.0, -21876092966476.383]

Vinet

In [14]:
[e0, b0, bP, v0], [e0_error, b0_error, bP_error, v0_error] = murn._fit_leastsq(volume_lst=volume_lst,
                                                                               energy_lst=energy_lst,
                                                                               fittype='vinet')
[e0, b0, bP, v0] 
Out[14]:
[-16.62393775939236,
 361.18208413366904,
 -8.873197550150648,
 21.173041264923626]

We see that both equation of states give slightly different results, with overall good agreement. To validate the agreement we plot the with with the original data.

In [15]:
vol_lst = np.linspace(np.min(volume_lst), np.max(volume_lst), 1000)
plt.plot(volume_lst, energy_lst, label='dft')
plt.plot(vol_lst, murn.fit_module.vinet_energy(vol_lst, e0, b0/ 160.21766208, bP, v0), label='vinet')
plt.xlabel('Volume ($\AA ^ 3$)')
plt.ylabel('Energy (eV)')
plt.legend()
Out[15]:
<matplotlib.legend.Legend at 0x2b8836cf24a8>

Murnaghan Module

Besides the fitting capabilities the Murnaghan module can also be used to run a set of calculations. For this we define a reference job, which can be either a Vasp calculation or any other pyiron job type and then specify the input parameters for the Murnaghan job.

In [16]:
job_vasp_strain = pr.create_job(job_type=pr.job_type.GpawJob, job_name='gpaw')
job_vasp_strain.set_encut(320)
job_vasp_strain.structure = basis.copy()
In [17]:
murn = pr.create_job(job_type=pr.job_type.Murnaghan, job_name='murn')
murn.ref_job = job_vasp_strain
murn.input
Out[17]:
Parameter Value Comment
0 num_points 11 number of sample points
1 fit_type polynomial ['polynomial', 'birch', 'birchmurnaghan', 'murnaghan', 'pouriertarantola', 'vinet']
2 fit_order 3 order of the fit polynom
3 vol_range 0.1 relative volume variation around volume defined by ref_ham

We modify the input parameters to agree with the settings used in the examples above and execute the simulation by calling the run command on the murnaghan job object.

In [18]:
murn.input['num_points'] = 7
murn.input['vol_range'] = 0.03
In [19]:
type(murn.structure)
Out[19]:
ase.atoms.Atoms
In [20]:
pr.job_table()
Out[20]:
id status chemicalformula job subjob projectpath project timestart timestop totalcputime computer hamilton hamversion parentid masterid
6 3601535 finished None gpaw_0_97 /gpaw_0_97 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/ 2019-09-04 13:50:31.285688 None None [email protected]#1 GpawJob None None None
38 3601804 finished None gpaw_0_98 /gpaw_0_98 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/ 2019-09-04 13:50:42.970024 None None [email protected]#1 GpawJob None None None
45 3602090 finished None gpaw_0_99 /gpaw_0_99 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/ 2019-09-04 13:50:52.350144 None None [email protected]#1 GpawJob None None None
8 3602359 finished None gpaw_1_0 /gpaw_1_0 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/ 2019-09-04 13:51:01.413156 None None [email protected]#1 GpawJob None None None
39 3602595 finished None gpaw_1_01 /gpaw_1_01 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/ 2019-09-04 13:51:10.251511 None None [email protected]#1 GpawJob None None None
0 3602869 finished None gpaw_1_02 /gpaw_1_02 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/ 2019-09-04 13:51:20.041600 None None [email protected]#1 GpawJob None None None
4 3603146 finished None gpaw_1_03 /gpaw_1_03 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/ 2019-09-04 13:51:29.741836 None None [email protected]#1 GpawJob None None None
37 3603487 finished None gpaw_0_97 /gpaw_0_97 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_270/ 2019-09-04 13:51:42.796905 None None [email protected]#1 GpawJob None None None
5 3603765 finished None gpaw_0_98 /gpaw_0_98 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_270/ 2019-09-04 13:51:53.088836 None None [email protected]#1 GpawJob None None None
44 3604021 finished None gpaw_0_99 /gpaw_0_99 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_270/ 2019-09-04 13:52:02.979283 None None [email protected]#1 GpawJob None None None
2 3604219 finished None gpaw_1_0 /gpaw_1_0 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_270/ 2019-09-04 13:52:11.921097 None None [email protected]#1 GpawJob None None None
7 3604443 finished None gpaw_1_01 /gpaw_1_01 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_270/ 2019-09-04 13:52:21.335934 None None [email protected]#1 GpawJob None None None
3 3604655 finished None gpaw_1_02 /gpaw_1_02 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_270/ 2019-09-04 13:52:31.009130 None None [email protected]#1 GpawJob None None None
1 3604768 finished None gpaw_1_03 /gpaw_1_03 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_270/ 2019-09-04 13:52:40.320534 None None [email protected]#1 GpawJob None None None
40 3604824 finished None gpaw_0_97 /gpaw_0_97 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_280/ 2019-09-04 13:52:50.470563 None None [email protected]#1 GpawJob None None None
42 3604871 finished None gpaw_0_98 /gpaw_0_98 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_280/ 2019-09-04 13:52:59.954797 None None [email protected]#1 GpawJob None None None
43 3604875 finished None gpaw_0_99 /gpaw_0_99 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_280/ 2019-09-04 13:53:09.963464 None None [email protected]#1 GpawJob None None None
48 3604880 finished None gpaw_1_0 /gpaw_1_0 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_280/ 2019-09-04 13:53:20.141701 None None [email protected]#1 GpawJob None None None
9 3604884 finished None gpaw_1_01 /gpaw_1_01 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_280/ 2019-09-04 13:53:29.324131 None None [email protected]#1 GpawJob None None None
10 3604887 finished None gpaw_1_02 /gpaw_1_02 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_280/ 2019-09-04 13:53:38.550641 None None [email protected]#1 GpawJob None None None
19 3604890 finished None gpaw_1_03 /gpaw_1_03 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_280/ 2019-09-04 13:53:48.099532 None None [email protected]#1 GpawJob None None None
41 3604896 finished None gpaw_0_97 /gpaw_0_97 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_290/ 2019-09-04 13:53:59.152323 None None [email protected]#1 GpawJob None None None
46 3604899 finished None gpaw_0_98 /gpaw_0_98 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_290/ 2019-09-04 13:54:08.057464 None None [email protected]#1 GpawJob None None None
47 3604903 finished None gpaw_0_99 /gpaw_0_99 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_290/ 2019-09-04 13:54:17.516512 None None [email protected]#1 GpawJob None None None
11 3604907 finished None gpaw_1_0 /gpaw_1_0 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_290/ 2019-09-04 13:54:26.874849 None None [email protected]#1 GpawJob None None None
12 3604910 finished None gpaw_1_01 /gpaw_1_01 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_290/ 2019-09-04 13:54:37.345194 None None [email protected]#1 GpawJob None None None
13 3604911 finished None gpaw_1_02 /gpaw_1_02 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_290/ 2019-09-04 13:54:48.785761 None None [email protected]#1 GpawJob None None None
14 3604913 finished None gpaw_1_03 /gpaw_1_03 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_290/ 2019-09-04 13:55:00.556380 None None [email protected]#1 GpawJob None None None
15 3604914 finished None gpaw_0_97 /gpaw_0_97 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_300/ 2019-09-04 13:55:10.828970 None None [email protected]#1 GpawJob None None None
16 3604915 finished None gpaw_0_98 /gpaw_0_98 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_300/ 2019-09-04 13:55:19.451476 None None [email protected]#1 GpawJob None None None
17 3604916 finished None gpaw_0_99 /gpaw_0_99 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_300/ 2019-09-04 13:55:28.235999 None None [email protected]#1 GpawJob None None None
18 3604917 finished None gpaw_1_0 /gpaw_1_0 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_300/ 2019-09-04 13:55:36.912405 None None [email protected]#1 GpawJob None None None
20 3604918 finished None gpaw_1_01 /gpaw_1_01 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_300/ 2019-09-04 13:55:46.777440 None None [email protected]#1 GpawJob None None None
21 3604919 finished None gpaw_1_02 /gpaw_1_02 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_300/ 2019-09-04 13:55:55.186420 None None [email protected]#1 GpawJob None None None
22 3604920 finished None gpaw_1_03 /gpaw_1_03 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_300/ 2019-09-04 13:56:05.185718 None None [email protected]#1 GpawJob None None None
23 3604921 finished None gpaw_0_97 /gpaw_0_97 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_310/ 2019-09-04 13:56:14.138209 None None [email protected]#1 GpawJob None None None
24 3604922 finished None gpaw_0_98 /gpaw_0_98 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_310/ 2019-09-04 13:56:22.072544 None None [email protected]#1 GpawJob None None None
25 3604923 finished None gpaw_0_99 /gpaw_0_99 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_310/ 2019-09-04 13:56:30.773140 None None [email protected]#1 GpawJob None None None
26 3604924 finished None gpaw_1_0 /gpaw_1_0 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_310/ 2019-09-04 13:56:38.738514 None None [email protected]#1 GpawJob None None None
27 3604925 finished None gpaw_1_01 /gpaw_1_01 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_310/ 2019-09-04 13:56:46.853680 None None [email protected]#1 GpawJob None None None
28 3604926 finished None gpaw_1_02 /gpaw_1_02 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_310/ 2019-09-04 13:56:55.404483 None None [email protected]#1 GpawJob None None None
29 3604927 finished None gpaw_1_03 /gpaw_1_03 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_310/ 2019-09-04 13:57:03.940368 None None [email protected]#1 GpawJob None None None
30 3604928 finished None gpaw_0_97 /gpaw_0_97 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_320/ 2019-09-04 13:57:13.347542 None None [email protected]#1 GpawJob None None None
31 3604929 finished None gpaw_0_98 /gpaw_0_98 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_320/ 2019-09-04 13:57:21.459612 None None [email protected]#1 GpawJob None None None
32 3604930 finished None gpaw_0_99 /gpaw_0_99 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_320/ 2019-09-04 13:57:29.623085 None None [email protected]#1 GpawJob None None None
33 3604931 finished None gpaw_1_0 /gpaw_1_0 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_320/ 2019-09-04 13:57:37.903535 None None [email protected]#1 GpawJob None None None
34 3604933 finished None gpaw_1_01 /gpaw_1_01 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_320/ 2019-09-04 13:57:46.032614 None None [email protected]#1 GpawJob None None None
35 3604934 finished None gpaw_1_02 /gpaw_1_02 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_320/ 2019-09-04 13:57:54.280901 None None [email protected]#1 GpawJob None None None
36 3604935 finished None gpaw_1_03 /gpaw_1_03 /cmmc/u/ janj/pyiron/projects/2019/2019-09-04-website-examples/thermo/encut_320/ 2019-09-04 13:58:02.411374 None None [email protected]#1 GpawJob None None None
In [21]:
murn.run()
The job murn was saved and received the ID: 3606074
The job strain_0_97 was saved and received the ID: 3606075
The job strain_0_98 was saved and received the ID: 3606084
The job strain_0_99 was saved and received the ID: 3606089
The job strain_1_0 was saved and received the ID: 3606092
The job strain_1_01 was saved and received the ID: 3606099
The job strain_1_02 was saved and received the ID: 3606106
The job strain_1_03 was saved and received the ID: 3606112
job_id:  3606075 finished
job_id:  3606084 finished
job_id:  3606089 finished
job_id:  3606092 finished
job_id:  3606099 finished
job_id:  3606106 finished
job_id:  3606112 finished

Afterwards we can use the build in capabilites to plot the resulting energy volume curve and fit different equations of state to the calculated energy volume pairs.

In [22]:
murn.output_to_pandas()
Out[22]:
volume energy error id equilibrium_b_prime equilibrium_bulk_modulus equilibrium_energy equilibrium_volume
0 20.172969 -16.576797 0.0 3606075 -8.102283 359.180621 -16.623924 21.172823
1 20.380937 -16.593942 0.0 3606084 -8.102283 359.180621 -16.623924 21.172823
2 20.588906 -16.607049 0.0 3606089 -8.102283 359.180621 -16.623924 21.172823
3 20.796875 -16.616336 0.0 3606092 -8.102283 359.180621 -16.623924 21.172823
4 21.004844 -16.622714 0.0 3606099 -8.102283 359.180621 -16.623924 21.172823
5 21.212813 -16.623909 0.0 3606106 -8.102283 359.180621 -16.623924 21.172823
6 21.420781 -16.620513 0.0 3606112 -8.102283 359.180621 -16.623924 21.172823
In [23]:
murn.plot()
In [24]:
murn.fit_vinet()
Out[24]:
{'fit_type': 'vinet',
 'volume_eq': 21.173041264923626,
 'energy_eq': -16.62393775939236,
 'bulkmodul_eq': 361.18208413366904,
 'b_prime_eq': -8.873197550150648,
 'least_square_error': array([2.35206844e-04, 2.03161020e+01, 3.15362473e+00, 7.39621643e-03])}

Common mistakes

Not copying the basis

It is important to copy the basis before applying the strain, as the strain has to be applied on the initial structure, not the previous structure:

In [25]:
volume_lst_with_copy = []
for strain in np.linspace(0.97, 1.03, 7):
    basis_copy = basis.copy()
    basis_copy.set_cell(cell=basis.cell * strain ** (1/3), scale_atoms=True)
    volume_lst_with_copy.append(basis_copy.get_volume())
In [26]:
basis_copy = basis.copy()
volume_lst_without_copy = []
for strain in np.linspace(0.97, 1.03, 7):
    basis_copy.set_cell(cell=basis_copy.cell * strain ** (1/3), scale_atoms=True)
    volume_lst_without_copy.append(basis_copy.get_volume())
In [27]:
volume_lst_with_copy, volume_lst_without_copy
Out[27]:
([20.17296874999999,
  20.380937499999995,
  20.588906250000004,
  20.796874999999996,
  21.004843749999992,
  21.212812500000016,
  21.42078124999999],
 [20.17296874999999,
  19.769509374999995,
  19.571814281250003,
  19.571814281250003,
  19.76753242406251,
  20.162883072543767,
  20.767769564720073])

Rescaling the cell

Another common issue is the rescaling of the supercell, there are multiple options to choose from. We used the option to scale the atoms with the supercell.

In [28]:
basis_copy = basis.copy()
strain = 0.5
basis_copy.set_cell(cell=basis_copy.cell * strain ** (1/3), scale_atoms=True)
basis_copy.plot3d()

A nother typical case is rescaling the cell to increase the distance between the atoms or add vacuum. But that is not what we want to fit an energy volume curve.

In [29]:
basis_copy = basis.copy()
strain = 0.5
basis_copy.set_cell(cell=basis_copy.cell * strain ** (1/3), scale_atoms=False)
basis_copy.plot3d()

The same can be achieved by setting the basis to relative coordinates.

In [30]:
basis_copy = basis.copy()
strain = 0.5
basis_copy.set_relative()
basis_copy.cell *= strain ** (1/3)
basis_copy.plot3d()
In [31]:
basis_copy = basis.copy()
strain = 0.5
basis_copy.cell *= strain ** (1/3)
basis_copy.plot3d()
In [ ]: