
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "examples_generated/tutorials/md.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_examples_generated_tutorials_md.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_examples_generated_tutorials_md.py:

.. _md_tutorial:

==================
Molecular dynamics
==================

.. note::

  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.

Goal
====

In this tutorial, we will learn how to perform basic molecular dynamics (MD)
simulations using ASE.

The key objectives are:

- Understand how to set up a crystal structure (Cu atoms on an FCC lattice).
- Initialize velocities from Maxwell–Boltzmann distribution corresponding to a
  chosen temperature.
- Integrate Newton’s equations of motion using Velocity-Verlet algorithm and we
  monitor the temperature using Langevin thermostat.
- Monitor and analyze thermodynamic quantities (potential energy, kinetic
  energy, total energy, temperature).
- Save trajectories and visualize atomic motion with ASE’s GUI.
- Explore MD in different scenarios:
  - Constant energy MD (NVE ensemble)
  - Constant temperature MD (NVT ensemble)
  - Isolated nanoparticle simulations

By the end of this tutorial, you should be able to set up your own MD
simulations, monitor energy conservation, and visualize system evolution.

Part 1: Basic Molecular Dynamics Simulation
===========================================

We start by creating a copper crystal, assigning random velocities
corresponding to Maxwell Boltzmann Distribution at 300 K, and running dynamics
in the NVE ensemble (constant energy).

.. GENERATED FROM PYTHON SOURCE LINES 47-79

.. code-block:: Python

    import matplotlib.pyplot as plt
    import numpy as np

    # choose one of the following implementations of EMT:
    # included in ase
    from ase.calculators.emt import EMT
    # faster performance
    #from asap3 import EMT

    from ase import units
    from ase.cluster.cubic import FaceCenteredCubic as ClusterFCC
    from ase.io.trajectory import Trajectory
    from ase.lattice.cubic import FaceCenteredCubic as LatticeFCC
    from ase.md.langevin import Langevin  # for later NPT simulations
    from ase.md.velocitydistribution import (
        MaxwellBoltzmannDistribution,
        Stationary,
        ZeroRotation,
    )
    from ase.md.verlet import VelocityVerlet
    from ase.optimize import QuasiNewton
    from ase.visualize.plot import plot_atoms

    # Set up initial positions of Cu atoms on Fcc crystal lattice
    size = 10
    atoms = LatticeFCC(
        directions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
        symbol='Cu',
        size=(size, size, size),
        pbc=True,
    )








.. GENERATED FROM PYTHON SOURCE LINES 80-81

Before setting up the MD simulation, we take a look at the initial structure:

.. GENERATED FROM PYTHON SOURCE LINES 83-89

.. code-block:: Python

    fig, ax = plt.subplots(figsize=(5, 5))
    plot_atoms(atoms, ax, rotation=('45x,45y,0z'), show_unit_cell=2, radii=0.75)
    ax.set_axis_off()
    plt.tight_layout()
    plt.show()




.. image-sg:: /examples_generated/tutorials/images/sphx_glr_md_001.png
   :alt: md
   :srcset: /examples_generated/tutorials/images/sphx_glr_md_001.png
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 90-92

Now let's run the MD simulation and monitor the kinetic and potential energy
of the whole system:

.. GENERATED FROM PYTHON SOURCE LINES 92-149

.. code-block:: Python


    # Describe the interatomic interactions with the Effective Medium Theory (EMT)
    atoms.calc = EMT()

    # Set the initial velocities corresponding to T=300K from Maxwell Boltzmann
    # Distribution
    MaxwellBoltzmannDistribution(atoms, temperature_K=300)

    # We use Velocity Verlet algorithm to integrate the Newton's equations.
    timestep_fs = 5
    dyn = VelocityVerlet(atoms, timestep_fs * units.fs)  # 5 fs time step.


    def printenergy(a):
        """
        Function to print the thermodynamical properties i.e potential energy,
        kinetic energy and total energy
        """
        epot = a.get_potential_energy()
        ekin = a.get_kinetic_energy()
        temp = a.get_temperature()
        print(
            f'Energy per atom: Epot ={epot:6.3f}eV  Ekin = {ekin:.3f}eV '
            f'(T={temp:.3f}K) Etot = {epot + ekin:.3f}eV'
        )


    # Now run the dynamics
    print('running a NVE simulation of fcc Cu')
    printenergy(atoms)
    # init lists to for energy vs time data
    time_ps, epot, ekin = [], [], []
    mdind = 0
    steps_per_block = 10
    for i in range(20):
        dyn.run(steps_per_block)
        mdind += steps_per_block
        printenergy(atoms)
        # save the energies of the current MD step
        time_ps.append(mdind * timestep_fs / 1000.0)
        epot.append(atoms.get_potential_energy())
        ekin.append(atoms.get_kinetic_energy())

    etot = np.array(epot) + np.array(ekin)

    # Plot energies vs time
    fig, ax = plt.subplots(figsize=(6, 4))
    ax.plot(time_ps, epot, label='Potential energy')
    ax.plot(time_ps, ekin, label='Kinetic energy')
    ax.plot(time_ps, etot, label='Total energy')
    ax.set_xlabel('Time (ps)')
    ax.set_ylabel('Energy (eV)')
    ax.legend(loc='best')
    ax.grid(True, linewidth=0.5, alpha=0.5)
    plt.tight_layout()
    plt.show()




.. image-sg:: /examples_generated/tutorials/images/sphx_glr_md_002.png
   :alt: md
   :srcset: /examples_generated/tutorials/images/sphx_glr_md_002.png
   :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    running a NVE simulation of fcc Cu
    Energy per atom: Epot =-22.726eV  Ekin = 154.735eV (T=299.270K) Etot = 132.009eV
    Energy per atom: Epot =97.116eV  Ekin = 35.682eV (T=69.013K) Etot = 132.799eV
    Energy per atom: Epot =58.092eV  Ekin = 74.565eV (T=144.215K) Etot = 132.657eV
    Energy per atom: Epot =49.717eV  Ekin = 82.796eV (T=160.134K) Etot = 132.512eV
    Energy per atom: Epot =49.224eV  Ekin = 83.234eV (T=160.982K) Etot = 132.458eV
    Energy per atom: Epot =59.520eV  Ekin = 73.092eV (T=141.366K) Etot = 132.612eV
    Energy per atom: Epot =58.423eV  Ekin = 74.190eV (T=143.490K) Etot = 132.613eV
    Energy per atom: Epot =52.388eV  Ekin = 80.125eV (T=154.969K) Etot = 132.513eV
    Energy per atom: Epot =51.639eV  Ekin = 80.882eV (T=156.433K) Etot = 132.521eV
    Energy per atom: Epot =59.018eV  Ekin = 73.584eV (T=142.318K) Etot = 132.602eV
    Energy per atom: Epot =54.708eV  Ekin = 77.851eV (T=150.570K) Etot = 132.559eV
    Energy per atom: Epot =53.818eV  Ekin = 78.720eV (T=152.251K) Etot = 132.538eV
    Energy per atom: Epot =55.395eV  Ekin = 77.167eV (T=149.248K) Etot = 132.563eV
    Energy per atom: Epot =56.226eV  Ekin = 76.340eV (T=147.648K) Etot = 132.565eV
    Energy per atom: Epot =53.901eV  Ekin = 78.647eV (T=152.109K) Etot = 132.548eV
    Energy per atom: Epot =54.480eV  Ekin = 78.084eV (T=151.021K) Etot = 132.564eV
    Energy per atom: Epot =54.155eV  Ekin = 78.398eV (T=151.629K) Etot = 132.553eV
    Energy per atom: Epot =58.343eV  Ekin = 74.225eV (T=143.558K) Etot = 132.568eV
    Energy per atom: Epot =53.124eV  Ekin = 79.425eV (T=153.615K) Etot = 132.549eV
    Energy per atom: Epot =53.178eV  Ekin = 79.362eV (T=153.494K) Etot = 132.541eV
    Energy per atom: Epot =59.192eV  Ekin = 73.385eV (T=141.933K) Etot = 132.577eV




.. GENERATED FROM PYTHON SOURCE LINES 150-162

Note how the total energy is conserved, but the kinetic energy quickly
drops to half the expected value. Why?

What you learned here:

- How to set up a basic MD run.
- How to monitor the energy over time.
- That total energy is approximately conserved in NVE simulations, what is
  the error in total energy?

Exercise: Tune the time step from 5fs to 10fs and 50fs, what changes do you
observe in total energy?

.. GENERATED FROM PYTHON SOURCE LINES 165-196

Part 2: Constant temperature MD
===============================

In many cases, you want to control temperature (NVT ensemble). This
can be done using a thermostat, like -- in this tutorial -- Langevin
thermostat.
Compared to the previous example, we replace the line
``dyn = VelocityVerlet(...)`` with

::

  dyn = Langevin(atoms, timestep=5 * units.fs, temperature_K=T,
  friction=0.02)

where ``T`` is the desired temperature in Kelvin. For that we also imported
the Langevin in the beginning.

The Langevin dynamics will then slowly adjust the total energy of the
system so the temperature approaches the desired one.

As a slightly less boring example, let us use this to melt a chunk of
copper by starting the simulation without any momentum of the atoms
(no kinetic energy), and with a desired temperature above the melting
point. We will also save information about the atoms in a trajectory
file called ``moldyn3.traj``.

.. note::

  It is recommended to use the ``asap3`` implementation of the ``EMT``
  calculator here, because its performance benefits over the ``ase``
  implementation.

.. GENERATED FROM PYTHON SOURCE LINES 198-246

.. code-block:: Python

    size = 10
    T = 1500  # Kelvin

    # Set up a crystal
    atoms = LatticeFCC(
        directions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
        symbol='Cu',
        size=(size, size, size),
        pbc=False,
    )

    # Describe the interatomic interactions with the Effective Medium Theory
    atoms.calc = EMT()

    # We want to run MD with constant energy using the Langevin algorithm
    # with a time step of 5 fs, the temperature T and the friction
    # coefficient to 0.02 atomic units.
    timestep_fs = 5
    dyn = Langevin(
        atoms, timestep=timestep_fs * units.fs, temperature_K=T, friction=0.02
    )

    # We also want to save the positions of all atoms after every 100th time step.
    traj = Trajectory('fccCu_NPT.traj', 'w', atoms)

    # Now run the dynamics
    print('running a NVT simulation of fcc Cu')
    printenergy(atoms)
    time_ps, temperature = [], []
    mdind = 0
    steps_per_block = 10
    for i in range(200):
        dyn.run(steps_per_block)
        mdind += steps_per_block
        printenergy(atoms)
        # save the temperature of the current MD step
        time_ps.append(mdind * timestep_fs / 1000.0)
        temperature.append(atoms.get_temperature())

    # Plot temperatures vs time
    fig, ax = plt.subplots(figsize=(6, 4))
    ax.plot(time_ps, temperature)
    ax.set_xlabel('Time (ps)')
    ax.set_ylabel('Temperature (K)')
    ax.grid(True, linewidth=0.5, alpha=0.5)
    plt.tight_layout()
    plt.show()




.. image-sg:: /examples_generated/tutorials/images/sphx_glr_md_003.png
   :alt: md
   :srcset: /examples_generated/tutorials/images/sphx_glr_md_003.png
   :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    /build/python-ase-iXAd1o/python-ase-3.28.0/ase/md/langevin.py:110: FutureWarning: The implementation of `fixcm=True` in `Langevin` does not strictly sample the correct NVT distributions. The deviations are typically small for large systems but can be more pronounced for small systems. Use `fixcm=False` together with `ase.constraints.FixCom`. `fixcm` is deprecated since ASE 3.28.0 and will be removed in a future release.
      warnings.warn(msg, FutureWarning)
    running a NVT simulation of fcc Cu
    Energy per atom: Epot =524.308eV  Ekin = 0.000eV (T=0.000K) Etot = 524.308eV
    Energy per atom: Epot =583.831eV  Ekin = 83.126eV (T=160.773K) Etot = 666.957eV
    Energy per atom: Epot =655.913eV  Ekin = 139.146eV (T=269.121K) Etot = 795.060eV
    Energy per atom: Epot =709.843eV  Ekin = 203.074eV (T=392.762K) Etot = 912.917eV
    Energy per atom: Epot =765.844eV  Ekin = 251.635eV (T=486.683K) Etot = 1017.479eV
    Energy per atom: Epot =815.815eV  Ekin = 304.454eV (T=588.840K) Etot = 1120.269eV
    Energy per atom: Epot =868.858eV  Ekin = 344.221eV (T=665.754K) Etot = 1213.079eV
    Energy per atom: Epot =911.849eV  Ekin = 383.358eV (T=741.448K) Etot = 1295.207eV
    Energy per atom: Epot =948.326eV  Ekin = 419.637eV (T=811.615K) Etot = 1367.964eV
    Energy per atom: Epot =994.381eV  Ekin = 447.941eV (T=866.357K) Etot = 1442.322eV
    Energy per atom: Epot =1038.986eV  Ekin = 462.646eV (T=894.797K) Etot = 1501.632eV
    Energy per atom: Epot =1059.946eV  Ekin = 496.696eV (T=960.653K) Etot = 1556.642eV
    Energy per atom: Epot =1085.524eV  Ekin = 522.719eV (T=1010.984K) Etot = 1608.243eV
    Energy per atom: Epot =1131.302eV  Ekin = 526.530eV (T=1018.354K) Etot = 1657.832eV
    Energy per atom: Epot =1160.231eV  Ekin = 543.356eV (T=1050.898K) Etot = 1703.588eV
    Energy per atom: Epot =1195.355eV  Ekin = 549.810eV (T=1063.380K) Etot = 1745.165eV
    Energy per atom: Epot =1209.893eV  Ekin = 585.485eV (T=1132.378K) Etot = 1795.377eV
    Energy per atom: Epot =1244.645eV  Ekin = 590.263eV (T=1141.620K) Etot = 1834.908eV
    Energy per atom: Epot =1266.446eV  Ekin = 599.480eV (T=1159.446K) Etot = 1865.926eV
    Energy per atom: Epot =1305.678eV  Ekin = 586.006eV (T=1133.386K) Etot = 1891.684eV
    Energy per atom: Epot =1300.437eV  Ekin = 619.944eV (T=1199.026K) Etot = 1920.381eV
    Energy per atom: Epot =1323.756eV  Ekin = 627.396eV (T=1213.439K) Etot = 1951.152eV
    Energy per atom: Epot =1368.640eV  Ekin = 618.995eV (T=1197.189K) Etot = 1987.634eV
    Energy per atom: Epot =1372.696eV  Ekin = 639.238eV (T=1236.341K) Etot = 2011.933eV
    Energy per atom: Epot =1389.899eV  Ekin = 653.819eV (T=1264.544K) Etot = 2043.718eV
    Energy per atom: Epot =1411.765eV  Ekin = 654.450eV (T=1265.763K) Etot = 2066.215eV
    Energy per atom: Epot =1419.535eV  Ekin = 664.751eV (T=1285.686K) Etot = 2084.286eV
    Energy per atom: Epot =1431.228eV  Ekin = 669.973eV (T=1295.786K) Etot = 2101.201eV
    Energy per atom: Epot =1446.585eV  Ekin = 676.204eV (T=1307.837K) Etot = 2122.789eV
    Energy per atom: Epot =1468.491eV  Ekin = 664.280eV (T=1284.775K) Etot = 2132.771eV
    Energy per atom: Epot =1475.573eV  Ekin = 676.883eV (T=1309.151K) Etot = 2152.456eV
    Energy per atom: Epot =1493.922eV  Ekin = 679.556eV (T=1314.321K) Etot = 2173.478eV
    Energy per atom: Epot =1502.443eV  Ekin = 676.967eV (T=1309.314K) Etot = 2179.411eV
    Energy per atom: Epot =1522.361eV  Ekin = 680.687eV (T=1316.508K) Etot = 2203.048eV
    Energy per atom: Epot =1517.798eV  Ekin = 701.809eV (T=1357.359K) Etot = 2219.607eV
    Energy per atom: Epot =1537.932eV  Ekin = 697.804eV (T=1349.613K) Etot = 2235.736eV
    Energy per atom: Epot =1550.851eV  Ekin = 700.000eV (T=1353.861K) Etot = 2250.851eV
    Energy per atom: Epot =1558.387eV  Ekin = 703.932eV (T=1361.465K) Etot = 2262.318eV
    Energy per atom: Epot =1565.601eV  Ekin = 702.904eV (T=1359.477K) Etot = 2268.504eV
    Energy per atom: Epot =1576.251eV  Ekin = 696.574eV (T=1347.235K) Etot = 2272.825eV
    Energy per atom: Epot =1583.663eV  Ekin = 703.167eV (T=1359.986K) Etot = 2286.830eV
    Energy per atom: Epot =1597.352eV  Ekin = 705.419eV (T=1364.341K) Etot = 2302.771eV
    Energy per atom: Epot =1618.554eV  Ekin = 704.160eV (T=1361.907K) Etot = 2322.714eV
    Energy per atom: Epot =1621.288eV  Ekin = 715.254eV (T=1383.364K) Etot = 2336.543eV
    Energy per atom: Epot =1633.529eV  Ekin = 717.968eV (T=1388.613K) Etot = 2351.497eV
    Energy per atom: Epot =1642.149eV  Ekin = 720.743eV (T=1393.979K) Etot = 2362.892eV
    Energy per atom: Epot =1634.937eV  Ekin = 740.914eV (T=1432.992K) Etot = 2375.851eV
    Energy per atom: Epot =1640.830eV  Ekin = 728.875eV (T=1409.707K) Etot = 2369.705eV
    Energy per atom: Epot =1646.536eV  Ekin = 736.102eV (T=1423.686K) Etot = 2382.638eV
    Energy per atom: Epot =1656.319eV  Ekin = 738.978eV (T=1429.247K) Etot = 2395.296eV
    Energy per atom: Epot =1671.672eV  Ekin = 731.872eV (T=1415.504K) Etot = 2403.544eV
    Energy per atom: Epot =1676.989eV  Ekin = 746.044eV (T=1442.914K) Etot = 2423.033eV
    Energy per atom: Epot =1680.764eV  Ekin = 746.430eV (T=1443.661K) Etot = 2427.194eV
    Energy per atom: Epot =1690.062eV  Ekin = 738.169eV (T=1427.684K) Etot = 2428.232eV
    Energy per atom: Epot =1691.026eV  Ekin = 753.179eV (T=1456.713K) Etot = 2444.204eV
    Energy per atom: Epot =1710.270eV  Ekin = 735.005eV (T=1421.563K) Etot = 2445.275eV
    Energy per atom: Epot =1708.370eV  Ekin = 747.184eV (T=1445.120K) Etot = 2455.554eV
    Energy per atom: Epot =1721.619eV  Ekin = 731.115eV (T=1414.040K) Etot = 2452.734eV
    Energy per atom: Epot =1731.635eV  Ekin = 726.739eV (T=1405.577K) Etot = 2458.374eV
    Energy per atom: Epot =1742.322eV  Ekin = 725.316eV (T=1402.824K) Etot = 2467.638eV
    Energy per atom: Epot =1743.457eV  Ekin = 745.614eV (T=1442.081K) Etot = 2489.071eV
    Energy per atom: Epot =1752.894eV  Ekin = 746.069eV (T=1442.963K) Etot = 2498.963eV
    Energy per atom: Epot =1776.179eV  Ekin = 728.269eV (T=1408.535K) Etot = 2504.448eV
    Energy per atom: Epot =1777.562eV  Ekin = 740.310eV (T=1431.823K) Etot = 2517.871eV
    Energy per atom: Epot =1795.843eV  Ekin = 732.955eV (T=1417.599K) Etot = 2528.798eV
    Energy per atom: Epot =1797.125eV  Ekin = 745.230eV (T=1441.339K) Etot = 2542.355eV
    Energy per atom: Epot =1806.583eV  Ekin = 744.067eV (T=1439.090K) Etot = 2550.650eV
    Energy per atom: Epot =1813.774eV  Ekin = 740.621eV (T=1432.426K) Etot = 2554.395eV
    Energy per atom: Epot =1822.430eV  Ekin = 738.993eV (T=1429.277K) Etot = 2561.423eV
    Energy per atom: Epot =1830.856eV  Ekin = 734.329eV (T=1420.256K) Etot = 2565.185eV
    Energy per atom: Epot =1815.263eV  Ekin = 755.709eV (T=1461.606K) Etot = 2570.972eV
    Energy per atom: Epot =1826.088eV  Ekin = 748.511eV (T=1447.686K) Etot = 2574.599eV
    Energy per atom: Epot =1834.275eV  Ekin = 751.724eV (T=1453.900K) Etot = 2585.999eV
    Energy per atom: Epot =1832.771eV  Ekin = 768.375eV (T=1486.104K) Etot = 2601.147eV
    Energy per atom: Epot =1852.780eV  Ekin = 756.516eV (T=1463.167K) Etot = 2609.295eV
    Energy per atom: Epot =1851.403eV  Ekin = 745.881eV (T=1442.599K) Etot = 2597.284eV
    Energy per atom: Epot =1843.426eV  Ekin = 753.699eV (T=1457.719K) Etot = 2597.125eV
    Energy per atom: Epot =1848.740eV  Ekin = 749.779eV (T=1450.138K) Etot = 2598.519eV
    Energy per atom: Epot =1847.237eV  Ekin = 761.405eV (T=1472.623K) Etot = 2608.642eV
    Energy per atom: Epot =1855.542eV  Ekin = 754.391eV (T=1459.058K) Etot = 2609.934eV
    Energy per atom: Epot =1866.641eV  Ekin = 744.718eV (T=1440.350K) Etot = 2611.359eV
    Energy per atom: Epot =1863.151eV  Ekin = 746.420eV (T=1443.641K) Etot = 2609.570eV
    Energy per atom: Epot =1859.110eV  Ekin = 757.494eV (T=1465.060K) Etot = 2616.604eV
    Energy per atom: Epot =1866.110eV  Ekin = 740.873eV (T=1432.914K) Etot = 2606.983eV
    Energy per atom: Epot =1855.404eV  Ekin = 749.264eV (T=1449.142K) Etot = 2604.668eV
    Energy per atom: Epot =1879.670eV  Ekin = 737.672eV (T=1426.722K) Etot = 2617.342eV
    Energy per atom: Epot =1864.292eV  Ekin = 749.510eV (T=1449.617K) Etot = 2613.802eV
    Energy per atom: Epot =1868.562eV  Ekin = 745.260eV (T=1441.398K) Etot = 2613.822eV
    Energy per atom: Epot =1872.910eV  Ekin = 737.522eV (T=1426.432K) Etot = 2610.433eV
    Energy per atom: Epot =1876.806eV  Ekin = 744.791eV (T=1440.491K) Etot = 2621.597eV
    Energy per atom: Epot =1880.542eV  Ekin = 748.020eV (T=1446.736K) Etot = 2628.562eV
    Energy per atom: Epot =1882.903eV  Ekin = 743.511eV (T=1438.014K) Etot = 2626.413eV
    Energy per atom: Epot =1886.989eV  Ekin = 752.870eV (T=1456.116K) Etot = 2639.859eV
    Energy per atom: Epot =1899.033eV  Ekin = 733.070eV (T=1417.821K) Etot = 2632.102eV
    Energy per atom: Epot =1895.819eV  Ekin = 747.467eV (T=1445.666K) Etot = 2643.285eV
    Energy per atom: Epot =1901.266eV  Ekin = 739.184eV (T=1429.646K) Etot = 2640.450eV
    Energy per atom: Epot =1891.517eV  Ekin = 740.516eV (T=1432.222K) Etot = 2632.033eV
    Energy per atom: Epot =1891.438eV  Ekin = 754.113eV (T=1458.519K) Etot = 2645.550eV
    Energy per atom: Epot =1909.637eV  Ekin = 738.467eV (T=1428.260K) Etot = 2648.104eV
    Energy per atom: Epot =1902.465eV  Ekin = 754.758eV (T=1459.767K) Etot = 2657.222eV
    Energy per atom: Epot =1903.818eV  Ekin = 762.659eV (T=1475.049K) Etot = 2666.477eV
    Energy per atom: Epot =1924.411eV  Ekin = 743.738eV (T=1438.453K) Etot = 2668.149eV
    Energy per atom: Epot =1908.331eV  Ekin = 751.115eV (T=1452.721K) Etot = 2659.445eV
    Energy per atom: Epot =1911.931eV  Ekin = 751.685eV (T=1453.824K) Etot = 2663.616eV
    Energy per atom: Epot =1917.107eV  Ekin = 752.634eV (T=1455.659K) Etot = 2669.740eV
    Energy per atom: Epot =1923.693eV  Ekin = 754.316eV (T=1458.912K) Etot = 2678.009eV
    Energy per atom: Epot =1928.459eV  Ekin = 760.770eV (T=1471.396K) Etot = 2689.229eV
    Energy per atom: Epot =1935.562eV  Ekin = 758.765eV (T=1467.518K) Etot = 2694.327eV
    Energy per atom: Epot =1927.115eV  Ekin = 767.791eV (T=1484.975K) Etot = 2694.906eV
    Energy per atom: Epot =1924.319eV  Ekin = 770.806eV (T=1490.806K) Etot = 2695.125eV
    Energy per atom: Epot =1942.100eV  Ekin = 749.193eV (T=1449.004K) Etot = 2691.292eV
    Energy per atom: Epot =1950.168eV  Ekin = 748.199eV (T=1447.082K) Etot = 2698.367eV
    Energy per atom: Epot =1936.817eV  Ekin = 779.411eV (T=1507.448K) Etot = 2716.228eV
    Energy per atom: Epot =1946.643eV  Ekin = 769.352eV (T=1487.993K) Etot = 2715.995eV
    Energy per atom: Epot =1944.567eV  Ekin = 778.263eV (T=1505.229K) Etot = 2722.831eV
    Energy per atom: Epot =1952.321eV  Ekin = 772.742eV (T=1494.550K) Etot = 2725.063eV
    Energy per atom: Epot =1946.029eV  Ekin = 773.217eV (T=1495.469K) Etot = 2719.246eV
    Energy per atom: Epot =1952.292eV  Ekin = 771.946eV (T=1493.011K) Etot = 2724.238eV
    Energy per atom: Epot =1948.736eV  Ekin = 775.795eV (T=1500.456K) Etot = 2724.531eV
    Energy per atom: Epot =1948.492eV  Ekin = 767.421eV (T=1484.260K) Etot = 2715.913eV
    Energy per atom: Epot =1952.355eV  Ekin = 767.711eV (T=1484.820K) Etot = 2720.066eV
    Energy per atom: Epot =1949.245eV  Ekin = 774.964eV (T=1498.847K) Etot = 2724.209eV
    Energy per atom: Epot =1956.562eV  Ekin = 767.216eV (T=1483.863K) Etot = 2723.778eV
    Energy per atom: Epot =1947.675eV  Ekin = 774.126eV (T=1497.226K) Etot = 2721.800eV
    Energy per atom: Epot =1951.398eV  Ekin = 761.147eV (T=1472.124K) Etot = 2712.545eV
    Energy per atom: Epot =1953.175eV  Ekin = 758.745eV (T=1467.479K) Etot = 2711.920eV
    Energy per atom: Epot =1941.606eV  Ekin = 778.034eV (T=1504.786K) Etot = 2719.640eV
    Energy per atom: Epot =1953.607eV  Ekin = 760.927eV (T=1471.700K) Etot = 2714.535eV
    Energy per atom: Epot =1959.499eV  Ekin = 754.473eV (T=1459.216K) Etot = 2713.972eV
    Energy per atom: Epot =1960.586eV  Ekin = 750.187eV (T=1450.927K) Etot = 2710.773eV
    Energy per atom: Epot =1942.229eV  Ekin = 786.026eV (T=1520.242K) Etot = 2728.255eV
    Energy per atom: Epot =1970.746eV  Ekin = 756.311eV (T=1462.772K) Etot = 2727.057eV
    Energy per atom: Epot =1950.458eV  Ekin = 778.469eV (T=1505.627K) Etot = 2728.927eV
    Energy per atom: Epot =1968.119eV  Ekin = 757.873eV (T=1465.793K) Etot = 2725.993eV
    Energy per atom: Epot =1957.832eV  Ekin = 768.485eV (T=1486.317K) Etot = 2726.317eV
    Energy per atom: Epot =1968.391eV  Ekin = 765.097eV (T=1479.763K) Etot = 2733.488eV
    Energy per atom: Epot =1968.308eV  Ekin = 776.148eV (T=1501.137K) Etot = 2744.456eV
    Energy per atom: Epot =1957.569eV  Ekin = 773.739eV (T=1496.478K) Etot = 2731.308eV
    Energy per atom: Epot =1949.430eV  Ekin = 773.284eV (T=1495.599K) Etot = 2722.714eV
    Energy per atom: Epot =1942.908eV  Ekin = 774.907eV (T=1498.738K) Etot = 2717.815eV
    Energy per atom: Epot =1960.045eV  Ekin = 763.887eV (T=1477.424K) Etot = 2723.932eV
    Energy per atom: Epot =1963.270eV  Ekin = 762.636eV (T=1475.005K) Etot = 2725.907eV
    Energy per atom: Epot =1957.068eV  Ekin = 768.673eV (T=1486.681K) Etot = 2725.741eV
    Energy per atom: Epot =1962.697eV  Ekin = 760.692eV (T=1471.245K) Etot = 2723.390eV
    Energy per atom: Epot =1965.579eV  Ekin = 770.905eV (T=1490.997K) Etot = 2736.484eV
    Energy per atom: Epot =1957.724eV  Ekin = 778.707eV (T=1506.088K) Etot = 2736.431eV
    Energy per atom: Epot =1963.811eV  Ekin = 778.493eV (T=1505.674K) Etot = 2742.304eV
    Energy per atom: Epot =1966.816eV  Ekin = 774.432eV (T=1497.819K) Etot = 2741.248eV
    Energy per atom: Epot =1967.656eV  Ekin = 773.335eV (T=1495.698K) Etot = 2740.991eV
    Energy per atom: Epot =1971.635eV  Ekin = 771.368eV (T=1491.893K) Etot = 2743.004eV
    Energy per atom: Epot =1963.662eV  Ekin = 767.538eV (T=1484.485K) Etot = 2731.200eV
    Energy per atom: Epot =1956.001eV  Ekin = 781.821eV (T=1512.109K) Etot = 2737.822eV
    Energy per atom: Epot =1969.901eV  Ekin = 773.544eV (T=1496.101K) Etot = 2743.445eV
    Energy per atom: Epot =1986.557eV  Ekin = 766.756eV (T=1482.973K) Etot = 2753.313eV
    Energy per atom: Epot =1985.282eV  Ekin = 779.628eV (T=1507.868K) Etot = 2764.910eV
    Energy per atom: Epot =1990.194eV  Ekin = 763.462eV (T=1476.601K) Etot = 2753.656eV
    Energy per atom: Epot =1985.309eV  Ekin = 768.807eV (T=1486.940K) Etot = 2754.117eV
    Energy per atom: Epot =1974.901eV  Ekin = 768.599eV (T=1486.537K) Etot = 2743.500eV
    Energy per atom: Epot =1973.865eV  Ekin = 767.412eV (T=1484.241K) Etot = 2741.276eV
    Energy per atom: Epot =1977.862eV  Ekin = 755.229eV (T=1460.678K) Etot = 2733.091eV
    Energy per atom: Epot =1964.412eV  Ekin = 775.678eV (T=1500.229K) Etot = 2740.090eV
    Energy per atom: Epot =1971.545eV  Ekin = 767.063eV (T=1483.566K) Etot = 2738.608eV
    Energy per atom: Epot =1968.264eV  Ekin = 773.580eV (T=1496.170K) Etot = 2741.844eV
    Energy per atom: Epot =1978.637eV  Ekin = 766.040eV (T=1481.588K) Etot = 2744.677eV
    Energy per atom: Epot =1955.480eV  Ekin = 781.258eV (T=1511.020K) Etot = 2736.737eV
    Energy per atom: Epot =1977.343eV  Ekin = 761.934eV (T=1473.646K) Etot = 2739.277eV
    Energy per atom: Epot =1965.834eV  Ekin = 764.212eV (T=1478.053K) Etot = 2730.046eV
    Energy per atom: Epot =1967.297eV  Ekin = 763.984eV (T=1477.611K) Etot = 2731.281eV
    Energy per atom: Epot =1968.592eV  Ekin = 766.970eV (T=1483.387K) Etot = 2735.562eV
    Energy per atom: Epot =1955.033eV  Ekin = 783.829eV (T=1515.994K) Etot = 2738.862eV
    Energy per atom: Epot =1960.288eV  Ekin = 773.493eV (T=1496.002K) Etot = 2733.781eV
    Energy per atom: Epot =1958.800eV  Ekin = 763.996eV (T=1477.634K) Etot = 2722.795eV
    Energy per atom: Epot =1932.372eV  Ekin = 789.159eV (T=1526.302K) Etot = 2721.531eV
    Energy per atom: Epot =1948.731eV  Ekin = 775.585eV (T=1500.049K) Etot = 2724.316eV
    Energy per atom: Epot =1949.784eV  Ekin = 773.829eV (T=1496.653K) Etot = 2723.613eV
    Energy per atom: Epot =1949.861eV  Ekin = 758.258eV (T=1466.537K) Etot = 2708.119eV
    Energy per atom: Epot =1944.261eV  Ekin = 762.751eV (T=1475.226K) Etot = 2707.011eV
    Energy per atom: Epot =1950.473eV  Ekin = 759.564eV (T=1469.064K) Etot = 2710.038eV
    Energy per atom: Epot =1951.962eV  Ekin = 761.121eV (T=1472.073K) Etot = 2713.083eV
    Energy per atom: Epot =1932.696eV  Ekin = 776.351eV (T=1501.531K) Etot = 2709.048eV
    Energy per atom: Epot =1944.883eV  Ekin = 765.847eV (T=1481.215K) Etot = 2710.730eV
    Energy per atom: Epot =1930.606eV  Ekin = 780.190eV (T=1508.956K) Etot = 2710.796eV
    Energy per atom: Epot =1944.083eV  Ekin = 763.224eV (T=1476.142K) Etot = 2707.307eV
    Energy per atom: Epot =1942.095eV  Ekin = 769.954eV (T=1489.158K) Etot = 2712.049eV
    Energy per atom: Epot =1937.518eV  Ekin = 768.525eV (T=1486.394K) Etot = 2706.043eV
    Energy per atom: Epot =1936.308eV  Ekin = 760.487eV (T=1470.847K) Etot = 2696.794eV
    Energy per atom: Epot =1929.387eV  Ekin = 779.354eV (T=1507.339K) Etot = 2708.741eV
    Energy per atom: Epot =1940.367eV  Ekin = 773.771eV (T=1496.540K) Etot = 2714.138eV
    Energy per atom: Epot =1946.645eV  Ekin = 770.109eV (T=1489.458K) Etot = 2716.754eV
    Energy per atom: Epot =1946.158eV  Ekin = 762.698eV (T=1475.124K) Etot = 2708.856eV
    Energy per atom: Epot =1954.406eV  Ekin = 767.305eV (T=1484.034K) Etot = 2721.710eV
    Energy per atom: Epot =1955.124eV  Ekin = 768.420eV (T=1486.192K) Etot = 2723.545eV
    Energy per atom: Epot =1953.078eV  Ekin = 772.364eV (T=1493.820K) Etot = 2725.442eV
    Energy per atom: Epot =1956.012eV  Ekin = 767.607eV (T=1484.619K) Etot = 2723.619eV
    Energy per atom: Epot =1953.705eV  Ekin = 769.642eV (T=1488.554K) Etot = 2723.346eV
    Energy per atom: Epot =1948.892eV  Ekin = 764.216eV (T=1478.060K) Etot = 2713.108eV
    Energy per atom: Epot =1943.752eV  Ekin = 762.823eV (T=1475.367K) Etot = 2706.575eV
    Energy per atom: Epot =1944.054eV  Ekin = 770.364eV (T=1489.951K) Etot = 2714.417eV
    Energy per atom: Epot =1949.179eV  Ekin = 769.134eV (T=1487.571K) Etot = 2718.312eV
    Energy per atom: Epot =1950.936eV  Ekin = 761.103eV (T=1472.039K) Etot = 2712.039eV
    Energy per atom: Epot =1949.228eV  Ekin = 760.952eV (T=1471.747K) Etot = 2710.180eV




.. GENERATED FROM PYTHON SOURCE LINES 247-278

After running the simulation, you can study the result with the
command

::

  ase gui fccCu_NPT.traj

Try plotting the kinetic energy. Like in the temperature vs time plot you
will *not* see a well-defined melting point due to finite size effects
(including surface melting),
but you will probably see an almost flat region where the inside of
the system melts. The outermost layers melt at a lower temperature.

.. note::

  The Langevin dynamics will by default keep the position and momentum
  of the center of mass unperturbed. This is another improvement over
  just setting momenta corresponding to a temperature, as we did before.


Part 3: Isolated particle MD
============================

When simulating isolated particles with MD, it is sometimes preferable
to set random momenta corresponding to a specific temperature and let the
system evolve freely. With a relatively high temperature, the is however
a risk that the collection of atoms will drift out of the simulation box
because the randomized momenta gave the center of mass a small but
non-zero velocity too.

Let us see what happens when we propagate a nanoparticle:

.. GENERATED FROM PYTHON SOURCE LINES 280-313

.. code-block:: Python

    size = 4
    atoms = ClusterFCC(
        'Cu',
        surfaces=[[1, 0, 0], [1, 1, 0], [1, 1, 1]],
        layers=(size, size, size),
        vacuum=4,
    )
    # asap3 requires a non-zero cell even if pbc are not applied
    atoms.cell = [40] * 3
    atoms.set_pbc(False)  # isolated cluster (explicit, for clarity)

    # Describe the interatomic interactions with the Effective Medium Theory
    atoms.calc = EMT()

    # Quick relaxation of the cluster
    qn = QuasiNewton(atoms)
    qn.run(fmax=0.001, steps=10)

    # Set the momenta corresponding to T=1200 K
    MaxwellBoltzmannDistribution(atoms, temperature_K=1200)
    Stationary(atoms)  # zero linear momentum
    ZeroRotation(atoms)  # zero angular momentum

    # Run MD using the Velocity Verlet algorithm and save trajectory
    dyn = VelocityVerlet(atoms, 5 * units.fs, trajectory='nanoparticleCu_NVE.traj')

    print('running a NVE simulation of a Cu nanoparticle')
    printenergy(atoms)
    steps_per_block = 10
    for i in range(200):
        dyn.run(steps_per_block)
        printenergy(atoms)





.. rst-class:: sphx-glr-script-out

 .. code-block:: none

                    Step[ FC]     Time          Energy          fmax
    BFGSLineSearch:    0[  0] 09:41:06       43.245239       1.0870
    BFGSLineSearch:    1[  1] 09:41:06       42.120661       0.2296
    BFGSLineSearch:    2[  2] 09:41:06       41.867789       0.1409
    BFGSLineSearch:    3[  3] 09:41:06       41.713030       0.1175
    BFGSLineSearch:    4[  4] 09:41:06       41.671285       0.0689
    BFGSLineSearch:    5[  5] 09:41:07       41.661506       0.0228
    BFGSLineSearch:    6[  6] 09:41:07       41.661063       0.0064
    BFGSLineSearch:    7[  7] 09:41:07       41.661007       0.0025
    BFGSLineSearch:    8[  8] 09:41:07       41.660988       0.0021
    BFGSLineSearch:    9[  9] 09:41:07       41.660979       0.0011
    BFGSLineSearch:   10[ 10] 09:41:07       41.660978       0.0004
    running a NVE simulation of a Cu nanoparticle
    Energy per atom: Epot =41.661eV  Ekin = 16.174eV (T=1345.477K) Etot = 57.835eV
    Energy per atom: Epot =50.449eV  Ekin = 7.433eV (T=618.367K) Etot = 57.882eV
    Energy per atom: Epot =51.315eV  Ekin = 6.585eV (T=547.817K) Etot = 57.900eV
    Energy per atom: Epot =51.347eV  Ekin = 6.544eV (T=544.378K) Etot = 57.891eV
    Energy per atom: Epot =50.607eV  Ekin = 7.280eV (T=605.633K) Etot = 57.887eV
    Energy per atom: Epot =50.135eV  Ekin = 7.752eV (T=644.830K) Etot = 57.886eV
    Energy per atom: Epot =49.863eV  Ekin = 8.023eV (T=667.427K) Etot = 57.887eV
    Energy per atom: Epot =49.957eV  Ekin = 7.930eV (T=659.640K) Etot = 57.886eV
    Energy per atom: Epot =49.866eV  Ekin = 8.024eV (T=667.475K) Etot = 57.890eV
    Energy per atom: Epot =50.903eV  Ekin = 6.988eV (T=581.310K) Etot = 57.891eV
    Energy per atom: Epot =51.080eV  Ekin = 6.810eV (T=566.497K) Etot = 57.890eV
    Energy per atom: Epot =49.835eV  Ekin = 8.051eV (T=669.744K) Etot = 57.886eV
    Energy per atom: Epot =50.396eV  Ekin = 7.494eV (T=623.380K) Etot = 57.890eV
    Energy per atom: Epot =49.414eV  Ekin = 8.472eV (T=704.717K) Etot = 57.885eV
    Energy per atom: Epot =49.587eV  Ekin = 8.297eV (T=690.235K) Etot = 57.884eV
    Energy per atom: Epot =50.575eV  Ekin = 7.319eV (T=608.804K) Etot = 57.893eV
    Energy per atom: Epot =51.134eV  Ekin = 6.759eV (T=562.234K) Etot = 57.893eV
    Energy per atom: Epot =50.820eV  Ekin = 7.068eV (T=587.997K) Etot = 57.888eV
    Energy per atom: Epot =50.421eV  Ekin = 7.470eV (T=621.419K) Etot = 57.892eV
    Energy per atom: Epot =50.693eV  Ekin = 7.194eV (T=598.485K) Etot = 57.887eV
    Energy per atom: Epot =49.716eV  Ekin = 8.169eV (T=679.543K) Etot = 57.885eV
    Energy per atom: Epot =50.313eV  Ekin = 7.579eV (T=630.461K) Etot = 57.892eV
    Energy per atom: Epot =50.996eV  Ekin = 6.902eV (T=574.148K) Etot = 57.898eV
    Energy per atom: Epot =50.623eV  Ekin = 7.266eV (T=604.410K) Etot = 57.889eV
    Energy per atom: Epot =50.775eV  Ekin = 7.111eV (T=591.526K) Etot = 57.886eV
    Energy per atom: Epot =50.413eV  Ekin = 7.474eV (T=621.732K) Etot = 57.887eV
    Energy per atom: Epot =50.755eV  Ekin = 7.131eV (T=593.232K) Etot = 57.886eV
    Energy per atom: Epot =50.131eV  Ekin = 7.754eV (T=644.987K) Etot = 57.885eV
    Energy per atom: Epot =50.055eV  Ekin = 7.831eV (T=651.422K) Etot = 57.886eV
    Energy per atom: Epot =50.449eV  Ekin = 7.443eV (T=619.187K) Etot = 57.892eV
    Energy per atom: Epot =51.090eV  Ekin = 6.804eV (T=565.980K) Etot = 57.894eV
    Energy per atom: Epot =50.434eV  Ekin = 7.456eV (T=620.210K) Etot = 57.890eV
    Energy per atom: Epot =50.804eV  Ekin = 7.090eV (T=589.768K) Etot = 57.894eV
    Energy per atom: Epot =49.890eV  Ekin = 7.997eV (T=665.246K) Etot = 57.887eV
    Energy per atom: Epot =51.431eV  Ekin = 6.462eV (T=537.578K) Etot = 57.894eV
    Energy per atom: Epot =50.133eV  Ekin = 7.755eV (T=645.115K) Etot = 57.888eV
    Energy per atom: Epot =50.842eV  Ekin = 7.050eV (T=586.436K) Etot = 57.892eV
    Energy per atom: Epot =49.913eV  Ekin = 7.972eV (T=663.188K) Etot = 57.885eV
    Energy per atom: Epot =51.160eV  Ekin = 6.733eV (T=560.090K) Etot = 57.893eV
    Energy per atom: Epot =51.481eV  Ekin = 6.413eV (T=533.505K) Etot = 57.894eV
    Energy per atom: Epot =50.638eV  Ekin = 7.250eV (T=603.124K) Etot = 57.888eV
    Energy per atom: Epot =50.466eV  Ekin = 7.421eV (T=617.335K) Etot = 57.887eV
    Energy per atom: Epot =51.082eV  Ekin = 6.816eV (T=566.971K) Etot = 57.898eV
    Energy per atom: Epot =50.328eV  Ekin = 7.562eV (T=629.047K) Etot = 57.890eV
    Energy per atom: Epot =50.209eV  Ekin = 7.684eV (T=639.173K) Etot = 57.893eV
    Energy per atom: Epot =50.198eV  Ekin = 7.692eV (T=639.834K) Etot = 57.889eV
    Energy per atom: Epot =50.324eV  Ekin = 7.557eV (T=628.618K) Etot = 57.880eV
    Energy per atom: Epot =50.835eV  Ekin = 7.050eV (T=586.489K) Etot = 57.885eV
    Energy per atom: Epot =50.702eV  Ekin = 7.187eV (T=597.829K) Etot = 57.889eV
    Energy per atom: Epot =50.708eV  Ekin = 7.184eV (T=597.583K) Etot = 57.891eV
    Energy per atom: Epot =51.151eV  Ekin = 6.739eV (T=560.582K) Etot = 57.890eV
    Energy per atom: Epot =51.138eV  Ekin = 6.757eV (T=562.128K) Etot = 57.895eV
    Energy per atom: Epot =50.639eV  Ekin = 7.252eV (T=603.265K) Etot = 57.891eV
    Energy per atom: Epot =50.581eV  Ekin = 7.304eV (T=607.566K) Etot = 57.885eV
    Energy per atom: Epot =50.443eV  Ekin = 7.444eV (T=619.211K) Etot = 57.887eV
    Energy per atom: Epot =50.742eV  Ekin = 7.149eV (T=594.678K) Etot = 57.891eV
    Energy per atom: Epot =51.128eV  Ekin = 6.764eV (T=562.669K) Etot = 57.892eV
    Energy per atom: Epot =51.102eV  Ekin = 6.796eV (T=565.373K) Etot = 57.899eV
    Energy per atom: Epot =49.681eV  Ekin = 8.208eV (T=682.818K) Etot = 57.889eV
    Energy per atom: Epot =50.540eV  Ekin = 7.349eV (T=611.364K) Etot = 57.889eV
    Energy per atom: Epot =49.703eV  Ekin = 8.182eV (T=680.670K) Etot = 57.885eV
    Energy per atom: Epot =50.565eV  Ekin = 7.325eV (T=609.311K) Etot = 57.890eV
    Energy per atom: Epot =50.897eV  Ekin = 6.990eV (T=581.456K) Etot = 57.887eV
    Energy per atom: Epot =49.846eV  Ekin = 8.034eV (T=668.328K) Etot = 57.880eV
    Energy per atom: Epot =50.471eV  Ekin = 7.415eV (T=616.809K) Etot = 57.886eV
    Energy per atom: Epot =51.164eV  Ekin = 6.732eV (T=559.986K) Etot = 57.896eV
    Energy per atom: Epot =50.413eV  Ekin = 7.480eV (T=622.208K) Etot = 57.893eV
    Energy per atom: Epot =50.470eV  Ekin = 7.422eV (T=617.436K) Etot = 57.893eV
    Energy per atom: Epot =50.220eV  Ekin = 7.673eV (T=638.311K) Etot = 57.894eV
    Energy per atom: Epot =50.555eV  Ekin = 7.337eV (T=610.368K) Etot = 57.893eV
    Energy per atom: Epot =50.905eV  Ekin = 6.989eV (T=581.392K) Etot = 57.894eV
    Energy per atom: Epot =50.529eV  Ekin = 7.361eV (T=612.309K) Etot = 57.890eV
    Energy per atom: Epot =50.202eV  Ekin = 7.686eV (T=639.334K) Etot = 57.888eV
    Energy per atom: Epot =50.425eV  Ekin = 7.462eV (T=620.712K) Etot = 57.886eV
    Energy per atom: Epot =50.524eV  Ekin = 7.365eV (T=612.706K) Etot = 57.890eV
    Energy per atom: Epot =51.345eV  Ekin = 6.552eV (T=545.008K) Etot = 57.897eV
    Energy per atom: Epot =51.949eV  Ekin = 5.951eV (T=495.039K) Etot = 57.900eV
    Energy per atom: Epot =50.555eV  Ekin = 7.334eV (T=610.125K) Etot = 57.889eV
    Energy per atom: Epot =50.034eV  Ekin = 7.847eV (T=652.761K) Etot = 57.881eV
    Energy per atom: Epot =51.056eV  Ekin = 6.829eV (T=568.062K) Etot = 57.885eV
    Energy per atom: Epot =51.031eV  Ekin = 6.859eV (T=570.567K) Etot = 57.890eV
    Energy per atom: Epot =51.726eV  Ekin = 6.174eV (T=513.552K) Etot = 57.900eV
    Energy per atom: Epot =50.866eV  Ekin = 7.027eV (T=584.526K) Etot = 57.893eV
    Energy per atom: Epot =50.417eV  Ekin = 7.475eV (T=621.833K) Etot = 57.892eV
    Energy per atom: Epot =50.654eV  Ekin = 7.236eV (T=601.916K) Etot = 57.890eV
    Energy per atom: Epot =49.923eV  Ekin = 7.959eV (T=662.082K) Etot = 57.882eV
    Energy per atom: Epot =50.553eV  Ekin = 7.336eV (T=610.237K) Etot = 57.889eV
    Energy per atom: Epot =50.105eV  Ekin = 7.785eV (T=647.584K) Etot = 57.890eV
    Energy per atom: Epot =50.453eV  Ekin = 7.441eV (T=618.981K) Etot = 57.894eV
    Energy per atom: Epot =51.217eV  Ekin = 6.681eV (T=555.801K) Etot = 57.899eV
    Energy per atom: Epot =50.276eV  Ekin = 7.614eV (T=633.424K) Etot = 57.890eV
    Energy per atom: Epot =49.876eV  Ekin = 8.014eV (T=666.627K) Etot = 57.890eV
    Energy per atom: Epot =50.286eV  Ekin = 7.607eV (T=632.778K) Etot = 57.892eV
    Energy per atom: Epot =50.150eV  Ekin = 7.743eV (T=644.132K) Etot = 57.893eV
    Energy per atom: Epot =50.724eV  Ekin = 7.165eV (T=596.013K) Etot = 57.888eV
    Energy per atom: Epot =50.439eV  Ekin = 7.452eV (T=619.920K) Etot = 57.891eV
    Energy per atom: Epot =50.651eV  Ekin = 7.240eV (T=602.245K) Etot = 57.891eV
    Energy per atom: Epot =49.498eV  Ekin = 8.386eV (T=697.641K) Etot = 57.884eV
    Energy per atom: Epot =51.074eV  Ekin = 6.823eV (T=567.554K) Etot = 57.897eV
    Energy per atom: Epot =50.406eV  Ekin = 7.482eV (T=622.440K) Etot = 57.889eV
    Energy per atom: Epot =49.947eV  Ekin = 7.934eV (T=660.037K) Etot = 57.881eV
    Energy per atom: Epot =51.031eV  Ekin = 6.860eV (T=570.629K) Etot = 57.891eV
    Energy per atom: Epot =50.990eV  Ekin = 6.910eV (T=574.799K) Etot = 57.900eV
    Energy per atom: Epot =49.833eV  Ekin = 8.056eV (T=670.158K) Etot = 57.889eV
    Energy per atom: Epot =51.025eV  Ekin = 6.868eV (T=571.339K) Etot = 57.893eV
    Energy per atom: Epot =50.245eV  Ekin = 7.646eV (T=636.038K) Etot = 57.891eV
    Energy per atom: Epot =50.690eV  Ekin = 7.205eV (T=599.355K) Etot = 57.894eV
    Energy per atom: Epot =50.390eV  Ekin = 7.504eV (T=624.272K) Etot = 57.894eV
    Energy per atom: Epot =49.452eV  Ekin = 8.433eV (T=701.493K) Etot = 57.885eV
    Energy per atom: Epot =50.613eV  Ekin = 7.279eV (T=605.534K) Etot = 57.892eV
    Energy per atom: Epot =49.803eV  Ekin = 8.080eV (T=672.183K) Etot = 57.884eV
    Energy per atom: Epot =50.167eV  Ekin = 7.717eV (T=641.980K) Etot = 57.884eV
    Energy per atom: Epot =50.094eV  Ekin = 7.790eV (T=648.029K) Etot = 57.884eV
    Energy per atom: Epot =49.281eV  Ekin = 8.607eV (T=715.946K) Etot = 57.888eV
    Energy per atom: Epot =49.867eV  Ekin = 8.024eV (T=667.502K) Etot = 57.891eV
    Energy per atom: Epot =49.456eV  Ekin = 8.427eV (T=701.038K) Etot = 57.883eV
    Energy per atom: Epot =50.837eV  Ekin = 7.052eV (T=586.666K) Etot = 57.889eV
    Energy per atom: Epot =50.788eV  Ekin = 7.101eV (T=590.699K) Etot = 57.889eV
    Energy per atom: Epot =51.305eV  Ekin = 6.592eV (T=548.378K) Etot = 57.897eV
    Energy per atom: Epot =50.076eV  Ekin = 7.813eV (T=649.950K) Etot = 57.889eV
    Energy per atom: Epot =50.877eV  Ekin = 7.013eV (T=583.392K) Etot = 57.890eV
    Energy per atom: Epot =49.975eV  Ekin = 7.913eV (T=658.229K) Etot = 57.888eV
    Energy per atom: Epot =49.238eV  Ekin = 8.649eV (T=719.451K) Etot = 57.887eV
    Energy per atom: Epot =49.904eV  Ekin = 7.988eV (T=664.461K) Etot = 57.892eV
    Energy per atom: Epot =50.381eV  Ekin = 7.517eV (T=625.292K) Etot = 57.898eV
    Energy per atom: Epot =49.840eV  Ekin = 8.050eV (T=669.624K) Etot = 57.890eV
    Energy per atom: Epot =50.632eV  Ekin = 7.259eV (T=603.887K) Etot = 57.892eV
    Energy per atom: Epot =49.389eV  Ekin = 8.498eV (T=706.929K) Etot = 57.887eV
    Energy per atom: Epot =50.937eV  Ekin = 6.959eV (T=578.929K) Etot = 57.897eV
    Energy per atom: Epot =50.221eV  Ekin = 7.665eV (T=637.610K) Etot = 57.886eV
    Energy per atom: Epot =50.166eV  Ekin = 7.719eV (T=642.154K) Etot = 57.886eV
    Energy per atom: Epot =50.283eV  Ekin = 7.605eV (T=632.675K) Etot = 57.889eV
    Energy per atom: Epot =51.045eV  Ekin = 6.842eV (T=569.162K) Etot = 57.887eV
    Energy per atom: Epot =50.449eV  Ekin = 7.436eV (T=618.590K) Etot = 57.885eV
    Energy per atom: Epot =50.118eV  Ekin = 7.772eV (T=646.538K) Etot = 57.890eV
    Energy per atom: Epot =49.514eV  Ekin = 8.377eV (T=696.894K) Etot = 57.891eV
    Energy per atom: Epot =49.965eV  Ekin = 7.929eV (T=659.600K) Etot = 57.894eV
    Energy per atom: Epot =49.859eV  Ekin = 8.034eV (T=668.352K) Etot = 57.893eV
    Energy per atom: Epot =49.554eV  Ekin = 8.335eV (T=693.329K) Etot = 57.889eV
    Energy per atom: Epot =50.102eV  Ekin = 7.792eV (T=648.154K) Etot = 57.894eV
    Energy per atom: Epot =49.733eV  Ekin = 8.162eV (T=678.984K) Etot = 57.896eV
    Energy per atom: Epot =50.356eV  Ekin = 7.541eV (T=627.295K) Etot = 57.896eV
    Energy per atom: Epot =50.028eV  Ekin = 7.867eV (T=654.391K) Etot = 57.895eV
    Energy per atom: Epot =50.380eV  Ekin = 7.511eV (T=624.830K) Etot = 57.891eV
    Energy per atom: Epot =50.246eV  Ekin = 7.641eV (T=635.615K) Etot = 57.887eV
    Energy per atom: Epot =49.367eV  Ekin = 8.515eV (T=708.302K) Etot = 57.881eV
    Energy per atom: Epot =49.688eV  Ekin = 8.199eV (T=682.041K) Etot = 57.887eV
    Energy per atom: Epot =49.462eV  Ekin = 8.421eV (T=700.480K) Etot = 57.882eV
    Energy per atom: Epot =49.983eV  Ekin = 7.903eV (T=657.383K) Etot = 57.886eV
    Energy per atom: Epot =50.049eV  Ekin = 7.838eV (T=651.981K) Etot = 57.887eV
    Energy per atom: Epot =49.943eV  Ekin = 7.945eV (T=660.887K) Etot = 57.888eV
    Energy per atom: Epot =51.500eV  Ekin = 6.403eV (T=532.616K) Etot = 57.902eV
    Energy per atom: Epot =50.346eV  Ekin = 7.545eV (T=627.607K) Etot = 57.890eV
    Energy per atom: Epot =49.041eV  Ekin = 8.838eV (T=735.239K) Etot = 57.879eV
    Energy per atom: Epot =50.259eV  Ekin = 7.628eV (T=634.519K) Etot = 57.887eV
    Energy per atom: Epot =51.096eV  Ekin = 6.799eV (T=565.559K) Etot = 57.895eV
    Energy per atom: Epot =49.058eV  Ekin = 8.823eV (T=733.958K) Etot = 57.882eV
    Energy per atom: Epot =49.444eV  Ekin = 8.443eV (T=702.378K) Etot = 57.887eV
    Energy per atom: Epot =50.591eV  Ekin = 7.300eV (T=607.262K) Etot = 57.891eV
    Energy per atom: Epot =49.968eV  Ekin = 7.919eV (T=658.773K) Etot = 57.888eV
    Energy per atom: Epot =50.786eV  Ekin = 7.110eV (T=591.476K) Etot = 57.897eV
    Energy per atom: Epot =50.008eV  Ekin = 7.879eV (T=655.407K) Etot = 57.886eV
    Energy per atom: Epot =50.375eV  Ekin = 7.507eV (T=624.515K) Etot = 57.882eV
    Energy per atom: Epot =50.662eV  Ekin = 7.230eV (T=601.452K) Etot = 57.892eV
    Energy per atom: Epot =49.887eV  Ekin = 8.009eV (T=666.251K) Etot = 57.896eV
    Energy per atom: Epot =49.617eV  Ekin = 8.273eV (T=688.177K) Etot = 57.889eV
    Energy per atom: Epot =50.558eV  Ekin = 7.326eV (T=609.438K) Etot = 57.884eV
    Energy per atom: Epot =50.258eV  Ekin = 7.626eV (T=634.394K) Etot = 57.884eV
    Energy per atom: Epot =50.322eV  Ekin = 7.570eV (T=629.741K) Etot = 57.892eV
    Energy per atom: Epot =50.402eV  Ekin = 7.492eV (T=623.194K) Etot = 57.893eV
    Energy per atom: Epot =49.629eV  Ekin = 8.258eV (T=686.928K) Etot = 57.887eV
    Energy per atom: Epot =49.570eV  Ekin = 8.320eV (T=692.090K) Etot = 57.890eV
    Energy per atom: Epot =49.755eV  Ekin = 8.134eV (T=676.665K) Etot = 57.889eV
    Energy per atom: Epot =50.369eV  Ekin = 7.525eV (T=625.963K) Etot = 57.894eV
    Energy per atom: Epot =49.654eV  Ekin = 8.235eV (T=685.077K) Etot = 57.889eV
    Energy per atom: Epot =49.249eV  Ekin = 8.638eV (T=718.537K) Etot = 57.887eV
    Energy per atom: Epot =49.348eV  Ekin = 8.544eV (T=710.719K) Etot = 57.891eV
    Energy per atom: Epot =49.642eV  Ekin = 8.247eV (T=686.057K) Etot = 57.889eV
    Energy per atom: Epot =49.130eV  Ekin = 8.754eV (T=728.218K) Etot = 57.884eV
    Energy per atom: Epot =50.508eV  Ekin = 7.388eV (T=614.578K) Etot = 57.896eV
    Energy per atom: Epot =49.475eV  Ekin = 8.413eV (T=699.838K) Etot = 57.888eV
    Energy per atom: Epot =50.260eV  Ekin = 7.633eV (T=634.973K) Etot = 57.893eV
    Energy per atom: Epot =49.703eV  Ekin = 8.189eV (T=681.230K) Etot = 57.892eV
    Energy per atom: Epot =49.813eV  Ekin = 8.074eV (T=671.610K) Etot = 57.887eV
    Energy per atom: Epot =50.362eV  Ekin = 7.527eV (T=626.174K) Etot = 57.889eV
    Energy per atom: Epot =49.923eV  Ekin = 7.966eV (T=662.631K) Etot = 57.889eV
    Energy per atom: Epot =50.742eV  Ekin = 7.149eV (T=594.735K) Etot = 57.892eV
    Energy per atom: Epot =49.908eV  Ekin = 7.979eV (T=663.765K) Etot = 57.887eV
    Energy per atom: Epot =49.971eV  Ekin = 7.915eV (T=658.434K) Etot = 57.886eV
    Energy per atom: Epot =50.130eV  Ekin = 7.757eV (T=645.260K) Etot = 57.887eV
    Energy per atom: Epot =49.316eV  Ekin = 8.568eV (T=712.701K) Etot = 57.883eV
    Energy per atom: Epot =49.095eV  Ekin = 8.791eV (T=731.283K) Etot = 57.886eV
    Energy per atom: Epot =50.797eV  Ekin = 7.097eV (T=590.414K) Etot = 57.894eV
    Energy per atom: Epot =50.050eV  Ekin = 7.844eV (T=652.536K) Etot = 57.894eV
    Energy per atom: Epot =50.145eV  Ekin = 7.747eV (T=644.438K) Etot = 57.892eV
    Energy per atom: Epot =49.408eV  Ekin = 8.483eV (T=705.703K) Etot = 57.892eV
    Energy per atom: Epot =50.097eV  Ekin = 7.793eV (T=648.250K) Etot = 57.890eV
    Energy per atom: Epot =48.575eV  Ekin = 9.300eV (T=773.599K) Etot = 57.875eV
    Energy per atom: Epot =49.932eV  Ekin = 7.952eV (T=661.539K) Etot = 57.885eV
    Energy per atom: Epot =50.508eV  Ekin = 7.379eV (T=613.843K) Etot = 57.888eV
    Energy per atom: Epot =49.713eV  Ekin = 8.169eV (T=679.517K) Etot = 57.881eV




.. GENERATED FROM PYTHON SOURCE LINES 314-324

After running the simulation, use :ref:`ase-gui` to compare the resulting
trajectory with how it looks if you comment out either the line that says
``Stationary(atoms)``, ``ZeroRotation(atoms)`` or both:

::

  ase gui nanoparticleCu_NVE.traj

Try playing the movie with a high frame rate and set frame skipping to a
low number. Can you spot the subtle difference?


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (22 minutes 45.278 seconds)


.. _sphx_glr_download_examples_generated_tutorials_md.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

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

      :download:`Download Jupyter notebook: md.ipynb <md.ipynb>`

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

      :download:`Download Python source code: md.py <md.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: md.zip <md.zip>`


.. only:: html

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

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