.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples_generated/tutorials/eos_01.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_generated_tutorials_eos_01.py: .. _eos_example: ========================================== EOS: Introduction to the Equation of state ========================================== The equation of states (EOS) can be used to compute the minimum lattice constants for a bulk material. In the following, we demonstrate how the ASE Equation of state function can be used to compute the minimum energy lattice constant and pressure for FCC silver. First, do a bulk calculation for different lattice constants: .. GENERATED FROM PYTHON SOURCE LINES 20-41 .. code-block:: Python import numpy as np from ase import Atoms from ase.calculators.emt import EMT from ase.eos import EquationOfState from ase.io import read from ase.io.trajectory import Trajectory from ase.units import kJ a = 4.0 # approximate lattice constant b = a / 2 ag = Atoms( 'Ag', cell=[(0, b, b), (b, 0, b), (b, b, 0)], pbc=1, calculator=EMT() ) # use EMT potential cell = ag.get_cell() traj = Trajectory('Ag.traj', 'w') for x in np.linspace(0.95, 1.05, 5): ag.set_cell(cell * x, scale_atoms=True) ag.get_potential_energy() traj.write(ag) .. GENERATED FROM PYTHON SOURCE LINES 42-45 This writes a trajectory file containing five configurations of FCC silver for five different lattice constants. Now, analyse the result with the :class:`~ase.eos.EquationOfState` class: .. GENERATED FROM PYTHON SOURCE LINES 45-55 .. code-block:: Python configs = read('Ag.traj@0:5') # read 5 configurations # Extract volumes and energies: volumes = [ag.get_volume() for ag in configs] energies = [ag.get_potential_energy() for ag in configs] eos = EquationOfState(volumes, energies) v0, e0, B = eos.fit() print(B / kJ * 1.0e24, 'GPa') eos.plot('Ag-eos.png') .. image-sg:: /examples_generated/tutorials/images/sphx_glr_eos_01_001.png :alt: sj: E: -0.000 eV, V: 16.781 Å$^3$, B: 100.142 GPa :srcset: /examples_generated/tutorials/images/sphx_glr_eos_01_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 100.14189241973199 GPa .. GENERATED FROM PYTHON SOURCE LINES 56-59 A quicker way to do this analysis is to use the :mod:`ase.gui` tool:: $ ase gui Ag.traj .. GENERATED FROM PYTHON SOURCE LINES 61-62 And then choose :menuselection:`Tools --> Bulk modulus`. .. _sphx_glr_download_examples_generated_tutorials_eos_01.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: eos_01.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: eos_01.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: eos_01.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_