.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "flow_gallery/run_phonopy_si.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_flow_gallery_run_phonopy_si.py: Phonopy with AbiPy Flow ======================= This example shows how to compute phonon frequencies with phonopy (supercells and finite-difference method). This approach could be useful to obtain vibrational properties with XC functionals for which DFPT is not yet implemented. .. warning: This example requires the `phonopy package `_ .. GENERATED FROM PYTHON SOURCE LINES 16-78 .. code-block:: default import sys import os import abipy.abilab as abilab import abipy.data as abidata import abipy.flowtk as flowtk from abipy.flowtk.abiphonopy import PhonopyWork def build_flow(options): """ Create a `Flow` for phonon calculations with phonopy: """ # Working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_") if not options.workdir: options.workdir = os.path.basename(sys.argv[0]).replace(".py", "").replace("run_", "flow_") # Initialize structure and pseudos structure = abilab.Structure.from_file(abidata.cif_file("si.cif")) pseudos = abidata.pseudos("14si.pspnc") # Build input for GS calculation. gsinp = abilab.AbinitInput(structure, pseudos) gsinp.set_vars(ecut=4, nband=4, toldff=1.e-6) # This gives ngkpt = 4x4x4 with 4 shifts for the initial unit cell. # The k-point sampling will be rescaled when we build the supercell in PhonopyWork. gsinp.set_autokmesh(nksmall=4) #gsinp.set_vars(ngkpt=[4, 4, 4]) flow = flowtk.Flow(workdir=options.workdir) # Use a 2x2x2 supercell to compute phonons with phonopy work = PhonopyWork.from_gs_input(gsinp, scdims=[2, 2, 2]) flow.register_work(work) return flow # This block generates the thumbnails in the AbiPy gallery. # You can safely REMOVE this part if you are using this script for production runs. if os.getenv("READTHEDOCS", False): __name__ = None import tempfile options = flowtk.build_flow_main_parser().parse_args(["-w", tempfile.mkdtemp()]) build_flow(options).graphviz_imshow() @flowtk.flow_main def main(options): """ This is our main function that will be invoked by the script. flow_main is a decorator implementing the command line interface. Command line args are stored in `options`. """ return build_flow(options) if __name__ == "__main__": sys.exit(main()) .. image:: /flow_gallery/images/sphx_glr_run_phonopy_si_001.png :alt: run phonopy si :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none self['nband'] 4 new['nband'] 32 new ngkpt: [2 2 2] .. GENERATED FROM PYTHON SOURCE LINES 79-110 Run the script with: run_phonopy_si.py -s the output results are produced in ``flow_phonopy_si/w0/outdata/`` Follow the instructions in the README file: .. code-block:: md To plot bands, use: phonopy -p band.conf To plot phonon dos, use: phonopy -p dos.conf To plot bands and dos, use: phonopy -p band-dos.conf See also: http://atztogo.github.io/phonopy/examples.html http://atztogo.github.io/phonopy/setting-tags.html#setting-tags The command: phonopy -p band-dos.conf will produce: .. image:: https://github.com/abinit/abipy_assets/blob/master/run_phonopy_si.png?raw=true :alt: Phonon Band structure computed with phonopy. .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.398 seconds) .. _sphx_glr_download_flow_gallery_run_phonopy_si.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/flow_gallery/run_phonopy_si.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: run_phonopy_si.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: run_phonopy_si.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_