Skip to main content
v2026.11,986 entries · CC-BY 4.0

ASE Python: Atomic Simulation Environment Install and First Relaxation

How to install ASE, the Atomic Simulation Environment, build a structure, relax it with BFGS and read the energy and force output, with a tested script.

Written and maintained by CASRAI Editorial Board

Published · Last updated

On this page

ASE is the Atomic Simulation Environment, a free, open source Python package for setting up, manipulating, running, visualizing and analyzing atomistic simulations. You install it with pip install --upgrade ase in a Python 3.11 or newer environment, build structures with ase.build, attach a calculator to an Atoms object, and read energies and forces from it. This guide takes you from a clean install to a relaxed copper cell with a logged trajectory.

What ASE is used for in research

The ASE community site describes the package as a Python-based platform for the whole lifecycle of an atomistic simulation: building a structure, running a calculation, visualizing it and analyzing the result. It is developed by a large international community and governed by the ASE Steering Committee, with code hosted on GitLab and documentation at docs.ase-lib.org.

ASE itself is a toolkit and a common interface, not a single engine. The central object is Atoms: a set of atoms with positions, a cell and a calculator. Once a calculator is attached with atoms.calc = calc, the methods get_potential_energy(), get_forces() and get_potential_energies() ask that calculator for results. Because many different calculators in ase.calculators sit behind the same interface, a script that builds, relaxes and records a structure can be written once and pointed at a different energy model later.

Typical research uses that follow from the documented modules are structure building (ase.build), geometry optimization (ase.optimize), molecular dynamics (ase.md), file conversion (ase.io) and storing many calculations in a searchable database (ase.db). The ASE ecosystem page lists dozens of third-party packages that use ASE, from workflow tools to machine-learned potentials; the table further down names a few.

How to install or access it

The official installation page states that ASE requires Python 3.11 or newer, plus NumPy, SciPy and Matplotlib, which pip installs for you. Optional packages add features: Tkinter for the graphical interface (ase gui), Flask for the ase.db web interface, pytest, pytest-mock and pytest-xdist for the test suite, and spglib for symmetry features. The data table below sets these out with the role of each.

  1. Create and activate an isolated environment. A python -m venv environment works; so does a conda environment, as described in the conda new-environment guide.
  2. Install the current release: pip install --upgrade ase.
  3. To run the test suite as well: pip install --upgrade ase[test].
  4. Without administrator rights: pip install --upgrade --user ase. The command-line tools then land in ~/.local/bin on Unix and macOS, or %APPDATA%/Python/Scripts on Windows, which must be on your PATH.
  5. Check the install: python -c "import ase; print(ase.__version__)".

Other routes exist. Debian, Ubuntu, Fedora and RHEL package ASE as python3-ase and Arch as python-ase; the docs warn that a distribution package may not be the latest release, and Red Hat needs the EPEL repository. On Homebrew, brew install python-tk supplies Tkinter for ase gui, and Homebrew’s pip installs only into virtual environments. You can also install from a source tarball or clone the repository from GitLab; the docs give a command that checks out a tagged release, which is the right choice if you need an exact version.

At the time of reading, PyPI lists 3.29.0 as the latest release and the install page names the same 3.29.0 source tarball. Record the version you use in any methods section or script header, because defaults in optimizers and I/O can change between releases.

Step-by-step: build, calculate and relax a structure

The script below uses only calls documented in the ASE build, atoms, calculator, optimizer and I/O pages. It builds a face-centred cubic copper cell, repeats it, perturbs the atoms so there is something to relax, attaches the EMT calculator, relaxes with BFGS and writes the result. It is an illustration of the workflow, not a production calculation: the EMT calculator is described in the docs as a simple calculator for quick demonstrations and tests.

from ase.build import bulkfrom ase.calculators.emt import EMTfrom ase.optimize import BFGSfrom ase.io import read, writeatoms = bulk('Cu', 'fcc', a=3.6, cubic=True).repeat((2, 2, 2))atoms.rattle(stdev=0.05, seed=42)atoms.calc = EMT()print('initial energy', atoms.get_potential_energy())print('initial max force', abs(atoms.get_forces()).max())opt = BFGS(atoms, trajectory='relax.traj', logfile='-')opt.run(fmax=0.05)print('final energy', atoms.get_potential_energy())write('relaxed.xyz', atoms)frames = read('relax.traj', index=':')

Step 1: build the structure

bulk('Cu', 'fcc', a=3.6) returns an Atoms object. The documented signature is bulk(name, crystalstructure=None, a=None, b=None, c=None, *, alpha=None, covera=None, u=None, orthorhombic=False, cubic=False, basis=None). Passing cubic=True gives the conventional four-atom cubic cell instead of the one-atom primitive cell; orthorhombic=True is the corresponding option for an orthorhombic cell. .repeat((2, 2, 2)) makes a 2 × 2 × 2 supercell of 32 atoms. For isolated molecules use molecule('H2O'), whose signature is molecule(name, vacuum=None, **kwargs). The same module also provides surface-building tools.

Step 2: attach a calculator

Assigning atoms.calc = EMT() connects the Effective Medium Theory potential. The docs state it is a pure Python implementation for the metals Al, Cu, Ag, Au, Ni, Pd and Pt, and that for real applications you should use the ASAP calculator instead. Swapping in a different calculator later changes only this line.

Step 3: relax with an optimizer

Every optimizer takes the form Optimizer(atoms, restart=None, logfile=None, trajectory=None, append_trajectory=False) and is started with run(fmax=0.05, steps=100000000). The run stops when the largest force on any atom falls below fmax, or when it reaches steps. Setting logfile='-' prints the progress to the screen, and trajectory='relax.traj' saves every step. BFGS is one of several local optimizers in the docs (BFGSLineSearch, LBFGS, LBFGSLineSearch, GoodOldQuasiNewton, CellAwareBFGS, RFO, GPMin, MDMin, FIRE and FIRE2/ABC-FIRE); QuasiNewton is a synonym for BFGSLineSearch. The BFGS defaults are a maximum step of 0.2 Å and alpha of 70.0.

Step 4: write and re-read the result

write('relaxed.xyz', atoms) infers the format from the file type. read(filename, index=None, format=None, parallel=True, ...) returns the last configuration by default; index=0 returns the first, ':' returns all, and '-3:' returns the last three. The function iread iterates over configurations without loading them all at once.

Output and how to read it

The log has one line per optimizer step with the step number, a timestamp, the energy and fmax, the largest force magnitude on any atom, which is the quantity the convergence test uses. Running the script above with ASE 3.29.0 gave this energy and force trace (timestamps omitted). Your digits may differ slightly with other NumPy or ASE versions, because the starting positions come from a random number generator.

  • Step 0: energy 0.567 eV, fmax 1.328 eV/Å (before any movement).
  • Step 5: energy −0.187 eV, fmax 0.169 eV/Å.
  • Step 10: energy −0.2123 eV, fmax 0.0518 eV/Å, still above the 0.05 threshold.
  • Step 11: energy −0.2130 eV, fmax 0.0441 eV/Å, below the threshold, so the run stops.

The trajectory therefore holds 12 frames, and read('relax.traj') without an index returns the final 32-atom structure. One reading is worth making. A converged result means only that forces are below your fmax for this calculator. A relaxation with EMT says nothing about whether the physics is right, which is why the calculator choice, not the optimizer, is the scientific decision.

Optimizers move atomic positions only. To relax the cell volume or shape you wrap the Atoms object in one of the Filter classes described in the optimizer docs before passing it to the optimizer; read that section of the documentation for the current class names and parameters before relying on a cell relaxation.

Troubleshooting

These are the failures most likely at install and in a first script, each tied to a statement in the official docs or reproduced when testing the script above.

Symptom Likely cause What the docs or test show
pip refuses to install ase, or reports no matching version Python older than the supported version The install page requires Python 3.11 or newer. Check python --version inside the active environment.
NotImplementedError: No EMT-potential for Si The element is outside EMT’s coverage Reproduced with bulk('Si', 'diamond', a=5.43). EMT supports Al, Cu, Ag, Au, Ni, Pd and Pt; use a calculator that covers your elements.
Version is older than expected after a system install A distribution package (python3-ase, python-ase) was installed The docs say distribution packages may not be the latest release; use pip in a virtual environment.
ase gui fails to start on macOS Tkinter is missing The docs give brew install python-tk for Homebrew Python.
pip fails on Homebrew Python outside an environment Homebrew’s pip installs only into virtual environments Create a virtual environment first, then install.
The ase command is not found after a --user install The scripts folder is not on PATH The docs place scripts in ~/.local/bin (Unix, macOS) or %APPDATA%/Python/Scripts (Windows).
read() returns one structure when you wanted all The default index is the last configuration Use index=':' for every frame.
Relaxation never reaches fmax Few steps allowed, wrong calculator, or cell degrees of freedom you did not free Pass a finite steps to bound the run, watch the log, and remember that optimizers move atoms only.

If the same script must be rerun later, pin the version you used (pip install ase==3.29.0 for the release read here) and keep the .traj file: it records every optimizer step, so a reviewer can check the path to the final structure without rerunning it. For storing many calculations with metadata, the ase.db module provides a database and a web interface (which needs Flask). The Jupyter notebook debugging guide covers running such scripts interactively.

The ASE ecosystem page presents its list as packages related to ASE or using ASE, and does not describe any of them as a replacement for it. They are therefore complements for the next step in a workflow rather than competitors. A selection, using the page’s own descriptions:

Package Group on the ecosystem page Described as
Sella Workflow tools Minimization and refinement of arbitrary-order saddle points with constraints
QuAcc Workflow tools A platform for high-throughput, database-driven computational materials science and quantum chemistry workflows
AGOX Workflow tools Global optimization of atomistic structures using machine learning techniques
CHGNet MLIPs A pretrained universal neural network potential for charge-informed atomistic modeling
TorchANI MLIPs Accurate neural network potential on PyTorch
matscipy Analysis tools A generic materials science toolbox for plasticity, dislocations, fracture mechanics and electro-chemistry
texase Other A terminal user interface for the ASE database

For trajectory analysis and simulation engines outside ASE, see the CASRAI guides to MDTraj and OpenMM, which cover different tools for molecular dynamics work.

Frequently asked questions

What does ASE stand for in Python?

ASE stands for Atomic Simulation Environment, a free and open source Python package for setting up, manipulating, running, visualizing and analyzing atomistic simulations. It is unrelated to other uses of the letters “ASE”.

Which Python version does ASE need?

The official install page requires Python 3.11 or newer, with NumPy, SciPy and Matplotlib. The PyPI package metadata can list a slightly lower minimum than the prose on the install page, so create your environment with Python 3.11 or newer.

How do I install ASE?

Run pip install --upgrade ase inside a virtual or conda environment. Add [test] to also install the test dependencies, or --user if you lack permissions to install system-wide.

Can ASE run calculations by itself?

ASE includes the simple pure-Python EMT calculator for a handful of metals, which the docs describe as suitable for demonstrations and tests. For real applications the docs point to other calculators, and ASE’s ase.calculators modules provide the common interface to them.

How do I read the last or every structure from a trajectory?

read('file.traj') returns the last configuration. Use index=0 for the first and index=':' for all of them.

When does a relaxation stop?

When the largest force on any atom is below fmax (0.05 by default in run), or when the number of steps given by steps is reached.

Sources

Data: ASE calls used in a first relaxation, with documented signatures and defaults

Compiled from the official ASE documentation pages for build, atoms, EMT calculator, optimizers and I/O: each call used in the worked example, its module, what it does and the default or signature the docs state.

ASE calls used in a first relaxation, with documented signatures and defaults
CallModulePurposeSignature or default stated in the docs
bulkase.buildBuild a crystal cell as an Atoms objectbulk(name, crystalstructure=None, a=None, b=None, c=None, *, alpha=None, covera=None, u=None, orthorhombic=False, cubic=False, basis=None)
moleculease.buildBuild a named moleculemolecule(name, vacuum=None, **kwargs)
EMTase.calculators.emtPure Python Effective Medium Potential for quick tests; standard metals Al, Cu, Ag, Au, Ni, Pd, Ptatoms.calc = EMT()
get_potential_energy / get_forcesase.AtomsAsk the attached calculator for energy and forcesatoms.get_potential_energy(); atoms.get_forces()
BFGSase.optimizeLocal quasi-Newton optimizerOptimizer(atoms, restart=None, logfile=None, trajectory=None, append_trajectory=False); maxstep 0.2 Å; alpha 70.0
runase.optimizeRun until max force is below fmax or steps is reachedrun(fmax=0.05, steps=100000000)
readase.ioRead one or more configurations from a fileread(filename, index=None, format=None, parallel=True, ...); default index is the last configuration
writease.ioWrite configurations to a fileFormat guessed from the file type

Sources

Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · full access

Ask about ASE Python: Atomic Simulation Environment Install and First Relaxation

Full access: large monthly usage, up to 10 source passages behind each answer, and MCP and API access for Claude Code, Codex and other CLIs. Cancel any time.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →