.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_qha.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_plot_qha.py: Quasi-harmonic approximation ============================ This example shows how to use the GSR.nc and PHDOS.nc files computed with different volumes to compute thermodynamic properties within the quasi-harmonic approximation. .. GENERATED FROM PYTHON SOURCE LINES 9-48 .. rst-class:: sphx-glr-horizontal * .. image:: /gallery/images/sphx_glr_plot_qha_001.png :alt: Energies as a function of volume for different T :class: sphx-glr-multi-img * .. image:: /gallery/images/sphx_glr_plot_qha_002.png :alt: Thermal expansion coefficient as a function of T :class: sphx-glr-multi-img * .. image:: /gallery/images/sphx_glr_plot_qha_003.png :alt: Volume as a function of T :class: sphx-glr-multi-img * .. image:: /gallery/images/sphx_glr_plot_qha_004.png :alt: Phonon band structures with color depending on T :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none WARNING combiblot: Bands have different number of k-points: [83, 81]
| .. code-block:: default import os import abipy.data as abidata from abipy.dfpt.phonons import PhononBands from abipy.dfpt.qha import QHA # We use a list of GSR.nc and PHDOS.nc files corresponding to different isotropic strains. # These files are shipped with AbiPy so that we don't need to run calculations from scratch. strains = [-4, -2, 0, 2, 4, 6] dirpath = os.path.join(abidata.dirpath, "refs", "si_qha") gsr_paths = [os.path.join(dirpath, "mp-149_{:+d}_GSR.nc".format(s)) for s in strains] dos_paths = [os.path.join(dirpath, "mp-149_{:+d}_PHDOS.nc".format(s)) for s in strains] # Initialize QHA object from files. # The PHDOS.nc files can be obtained from the DDB used ddb.anaget_phbst_and_phdos_files(...) qha = QHA.from_files(gsr_paths, dos_paths) # To change the default EOS (vinet), use #qha.set_eos("murnaghan") qha.plot_energies(title="Energies as a function of volume for different T") qha.plot_thermal_expansion_coeff(title="Thermal expansion coefficient as a function of T") qha.plot_vol_vs_t(title="Volume as a function of T") # Fake temperatures to test the plotting function. phbs_list = [PhononBands.from_file(os.path.join(dirpath, "mp-149_{:+d}_PHBST.nc".format(s))) for s in strains[2:4]] qha.plot_phbs(phbs_list, temperatures=[10, 20], title="Phonon band structures with color depending on T") # Here we build a Phonopy QHA object. # Cannot run this code because it breaks sphinx-gallery #qha_phonopy = qha.get_phonopy_qha(tstop=500, num=11) #qha_phonopy.run() #qha_phonopy.plot_bulk_modulus_temperature().show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.765 seconds) .. _sphx_glr_download_gallery_plot_qha.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/abinit/abipy/gh-pages?filepath=notebooks/gallery/plot_qha.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_qha.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_qha.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_