.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples_generated/eos/plot_ag_eos.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_eos_plot_ag_eos.py: .. _eos_example: ======================= Equation of state (EOS) ======================= First, do a bulk calculation for different lattice constants: .. GENERATED FROM PYTHON SOURCE LINES 13-34 .. 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 35-38 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 38-48 .. 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/eos/images/sphx_glr_plot_ag_eos_001.png :alt: sj: E: -0.000 eV, V: 16.781 Å$^3$, B: 100.142 GPa :srcset: /examples_generated/eos/images/sphx_glr_plot_ag_eos_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 100.14189241973199 GPa .. GENERATED FROM PYTHON SOURCE LINES 49-52 A quicker way to do this analysis is to use the :mod:`ase.gui` tool:: $ ase gui Ag.traj .. GENERATED FROM PYTHON SOURCE LINES 54-55 And then choose :menuselection:`Tools --> Bulk modulus`. .. _sphx_glr_download_examples_generated_eos_plot_ag_eos.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_ag_eos.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_ag_eos.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_ag_eos.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_