:orphan:

.. _tutorials:

Tutorials
=========

This directory contains examples of how to use ASE.

For running the examples install ase.

.. code-block:: bash

    pip install ase

Some more advanced examples might need additional packages.
Most of the tutorials will use the :mod:`EMT <ase.calculators.emt>` potential,
but any other :mod:`Calculator <ase.calculators>` could be plugged in instead.

We are still porting old tutorials to the current tutorial format.
Many tutorials are available here, but some may not have been ported
yet.  Tutorials still in legacy format can be found under
:ref:`gettingstarted`.

.. note::

   You can also take a look at tutorials from previous :ref:`events`.

.. note::

  The :mod:`ase.ga` package has moved to
  `ase-ga <https://dtu-energy.github.io/ase-ga/>`_
  including tutorials.



.. raw:: html

  <div id='sg-tag-list' class='sphx-glr-tag-list'></div>


.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. thumbnail-parent-div-close

.. raw:: html

    </div>


============
Gallery
============





.. raw:: html

  <div id='sg-tag-list' class='sphx-glr-tag-list'></div>


.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Periodic Table">

.. only:: html

  .. image:: /examples_generated/gallery/images/thumb/sphx_glr_ptable_thumb.png
    :alt:

  :doc:`/examples_generated/gallery/ptable`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Periodic Table</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


Introduction Examples
---------------------

This is a collection of starting examples.
It contains the introduction example of ase, including an introduction to the aoms object, how to read and write structures, adding a calculator, relax structures, visualize and run molecular dynamics.




.. raw:: html

  <div id='sg-tag-list' class='sphx-glr-tag-list'></div>


.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This section gives a quick (and incomplete) overview of what ASE can do. You can download the code shown in this tutorial (and others in the same style) as python scripts or jupyter notebooks at the bottom of this page.">

.. only:: html

  .. image:: /examples_generated/gettingstarted/images/thumb/sphx_glr_00-n2cu_thumb.png
    :alt:

  :doc:`/examples_generated/gettingstarted/00-n2cu`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">ASE Introduction: Nitrogen on copper</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="ASE allows atomistic calculations to be scripted with different computational codes. In this introductory exercise, we go through the basic concepts and workflow of ASE and will eventually calculate the binding curve of N_2.">

.. only:: html

  .. image:: /examples_generated/gettingstarted/images/thumb/sphx_glr_01-atoms-and-calculators_thumb.png
    :alt:

  :doc:`/examples_generated/gettingstarted/01-atoms-and-calculators`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Atoms and calculators</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Let&#x27;s calculate the structure of the H_2O molecule. Part of this tutorial is exercise-based, so refer back to what you learnt from introductionexample and atomscalculators. Suggested solutions to the exercises are found after each exercise, but try solving them youself first!">

.. only:: html

  .. image:: /examples_generated/gettingstarted/images/thumb/sphx_glr_02-h2o-structure_thumb.png
    :alt:

  :doc:`/examples_generated/gettingstarted/02-h2o-structure`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Structure optimization: H_2O</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Manipulating Atoms">

.. only:: html

  .. image:: /examples_generated/gettingstarted/images/thumb/sphx_glr_03-manipulating-atoms_thumb.png
    :alt:

  :doc:`/examples_generated/gettingstarted/03-manipulating-atoms`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Manipulating Atoms</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Nanoparticle">

.. only:: html

  .. image:: /examples_generated/gettingstarted/images/thumb/sphx_glr_06-nanoparticle_thumb.png
    :alt:

  :doc:`/examples_generated/gettingstarted/06-nanoparticle`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Nanoparticle</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


Python Examples
---------------

This is a collection of python examples.




.. raw:: html

  <div id='sg-tag-list' class='sphx-glr-tag-list'></div>


.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This section will give a very brief introduction to the Python language.">

.. only:: html

  .. image:: /examples_generated/python/images/thumb/sphx_glr_01_whatispython_thumb.png
    :alt:

  :doc:`/examples_generated/python/01_whatispython`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">What is Python?</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Examples demonstrating NumPy usage in ASE documentation.">

.. only:: html

  .. image:: /examples_generated/python/images/thumb/sphx_glr_02_numeric-arrays_thumb.png
    :alt:

  :doc:`/examples_generated/python/02_numeric-arrays`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Numeric arrays in Python</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


ASE Tutorials
-------------

This is a collection of more advanced tutorials for ASE.




.. raw:: html

  <div id='sg-tag-list' class='sphx-glr-tag-list'></div>


.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Setting up a database --------------------- To construct a database we first need some atomic structures so let&#x27;s quickly create some. As you have seen the ASE command line tool provides many convenient commands and in particular we can use the build command to create some atomic structures. Remember, if you are unsure how to use a particular command you can always append -h to the particular command (ie. ase build -h) to see the help for that particular command.">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_ase_database_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/ase_database`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">ASE Databases: An Introduction</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In this tutorial we will adsorb C, N and O on 7 different FCC(111) surfaces with 1, 2 and 3 layers and we will use database files to store the results.">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_ase_db_adsorbate_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/ase_db_adsorbate`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">ASE Databases: Surface adsorption study</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The following script will calculate the atomization energy of a nitrogen molecule.">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_atomization_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/atomization`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Atomization energy</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Here, we calculate the band structure of relaxed bulk crystal structures.">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_band_structure_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/band_structure`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Band Structures of Bulk Structures</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Here, we create bulk structures and optimize them to their ideal bulk properties">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_bulk_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/bulk`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Bulk Structures and Relaxations</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In this tutorial, we will calculate the energy barrier that was found using the ase.mep.neb method in the diffusion tutorial tutorial.  Here, we use a simple FixedPlane constraint that forces the Au atom to relax in the yz-plane only:">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_constraint_diffusion_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/constraint_diffusion`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Constrained Calculations - Surface diffusion energy barriers</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This section gives an (incomplete) overview of features in ASE that help in the preparation and analysis of supercell calculations as most commonly employed in the computation of defect properties.">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_defects_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/defects`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Defect calculations: ASE Tools</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Surface diffusion energy barriers using the Nudged Elastic Band  (NEB) method">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_diffusion_neb_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/diffusion_neb`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Surface diffusion energy barriers using the Nudged Elastic Band  (NEB) method</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This is a example of analysis of the dimensionality of a structure using the ase.geometry.dimensionality.analyze_dimensionality function. This is useful for finding low-dimensional materials, such as 1D chain-like structures, 2D layered structures, or structures with multiple dimensionality types, such as 1D+3D.">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_dimensionality_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/dimensionality`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Dimensionality analysis</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="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.">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_eos_01_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/eos_01`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">EOS: Introduction to the Equation of state</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="EOS: Calculating Delta-values">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_eos_delta_values_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/eos_delta_values`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">EOS: Calculating Delta-values</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Goals -----">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_equil_acn_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/equil_acn`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Equilibrating a box of acetonitrile with MD</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to use the TIP3P and TIP4P force fields in ASE.">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_equil_tipnp_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/equil_tipnp`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Equilibrating a TIPnP Water Box</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This is an example of a search for a global optimum geometric configuration using the minima hopping algorithm, along with the Hookean class of constraints. This type of approach is useful in searching for the global optimum position of adsorbates on a surface while enforcing that the adsorbates&#x27; identity is preserved. In short, this example searches for a global optimum configuration using the minima hopping algorithm together with Hookean constraints to preserve molecular identity of an adsorbate.">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_global_optimization_constrained_minima_hopping_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/global_optimization_constrained_minima_hopping`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Global optimization: Constrained minima hopping</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Lattice constants using EOS and the stress tensor">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_lattice_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/lattice`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Lattice constants using EOS and the stress tensor</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="  These examples can be run without asap3 installed. In that case,   ASE’s Python implementation of the EMT calculator can be used instead, but it   is much slower.">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_md_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/md`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Molecular dynamics</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In this tutorial we provide an illustrative example of a nudged-elastic band (NEB) calculation. For more information on the NEB technique, see ase.mep.neb.">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_neb_dissociation_thumb.gif
    :alt:

  :doc:`/examples_generated/tutorials/neb_dissociation`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">NEB: Dissociation of a molecule using the NEB method</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Reference: S. Smidstrup, A. Pedersen, K. Stokbro and H. Jonsson, Improved initial guess for minimum energy path calculations &lt;10.1063/1.4878664&gt;, J. Chem. Phys. 140, 214106 (2014).">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_neb_idpp_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/neb_idpp`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">NEB with IDPP: |subst|</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="NEB and Dimer method for Self-diffusion on the Al(110) surface">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_neb_selfdiffusion_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/neb_selfdiffusion`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">NEB and Dimer method for Self-diffusion on the Al(110) surface</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="QM/MM Simulations couple two (or, in principle, more) descriptions to get total energy and forces for the entire system in an efficient manner. ASE has a native Explicit Interaction calculator, EIQMMM, that uses an electrostatic embedding model to couple the subsystems explicitly. See the method paper for more info &lt;10.1021/acs.jctc.7b00621&gt;.">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_qmmm_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/qmmm`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">QM/MM Simulations with ASE</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Let&#x27;s calculate the vibrational modes of H_2O.">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_vibrational_modes_thumb.gif
    :alt:

  :doc:`/examples_generated/tutorials/vibrational_modes`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Vibrational Modes of a Molecule</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This tutorial walks through building partly occupied Wannier functions with the ase.dft.wannier module and the GPAW electronic structure code. For more information on the details of the method and the implementation, see">

.. only:: html

  .. image:: /examples_generated/tutorials/images/thumb/sphx_glr_wannier_thumb.png
    :alt:

  :doc:`/examples_generated/tutorials/wannier`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Partly occupied Wannier Functions</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


.. toctree::
   :hidden:
   :includehidden:


   /examples_generated/gallery/index.rst
   /examples_generated/gettingstarted/index.rst
   /examples_generated/python/index.rst
   /examples_generated/tutorials/index.rst


.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-gallery

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download all examples in Python source code: examples_generated_python.zip </examples_generated/examples_generated_python.zip>`

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download all examples in Jupyter notebooks: examples_generated_jupyter.zip </examples_generated/examples_generated_jupyter.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
