{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n# Equation of state (EOS)\n\nFirst, do a bulk calculation for different lattice constants:\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\n\nfrom ase import Atoms\nfrom ase.calculators.emt import EMT\nfrom ase.eos import EquationOfState\nfrom ase.io import read\nfrom ase.io.trajectory import Trajectory\nfrom ase.units import kJ\n\na = 4.0 # approximate lattice constant\nb = a / 2\nag = Atoms(\n 'Ag', cell=[(0, b, b), (b, 0, b), (b, b, 0)], pbc=1, calculator=EMT()\n) # use EMT potential\ncell = ag.get_cell()\ntraj = Trajectory('Ag.traj', 'w')\nfor x in np.linspace(0.95, 1.05, 5):\n ag.set_cell(cell * x, scale_atoms=True)\n ag.get_potential_energy()\n traj.write(ag)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This writes a trajectory file containing five configurations of FCC silver\nfor five different lattice constants. Now, analyse the result with\nthe :class:`~ase.eos.EquationOfState` class:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "configs = read('Ag.traj@0:5') # read 5 configurations\n# Extract volumes and energies:\nvolumes = [ag.get_volume() for ag in configs]\nenergies = [ag.get_potential_energy() for ag in configs]\neos = EquationOfState(volumes, energies)\nv0, e0, B = eos.fit()\nprint(B / kJ * 1.0e24, 'GPa')\neos.plot('Ag-eos.png')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A quicker way to do this analysis is to use the :mod:`ase.gui` tool::\n\n $ ase gui Ag.traj\n\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And then choose :menuselection:`Tools --> Bulk modulus`.\n\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.7" } }, "nbformat": 4, "nbformat_minor": 0 }