What is ASE?
Overview
Teaching: 10 min
Exercises: 0 minQuestions
How can ASE help me in my research?
In what way is the ASE code structured?
Objectives
List the key features of ASE
Identify and describe the core ASE classes
Describe how ASE fits within the larger atomistic modelling software ecosystem
Understand the difference between class, instance and method in object oriented programming
ASE is a Python library for atomistic modelling
- The atomic simulation environment (ASE) is Python library for atomistic modelling; it allows you to set up, run and analyse atomistic simulations using Python scripts.
- Systems are described by a set of atomic positions, and calculations are derived from these.
- There are two core classes in ASE:
Atoms
andCalculator
.
NumPy
ASE makes strong use of NumPy arrays. NumPy arrays have a host of useful features such as array slicing, and ensure that there is efficient performance even for thousands or millions of atoms. If you are unfamiliar with NumPy arrays there is a brief overview on the ASE website.
ASE uses several design patterns from object oriented programming (OOP).
- You do not need to be familiar with the intricacies of OOP to start coding with
ASE, however some basic terminology is useful.
- An object is an combination of data alongside operations for manipulating and returning information on that data.
- A class is a category of objects - for example,
Composer()
. - An instance is an object that belongs to a class - for example, the instance
beethoven
belongs to the classComposer
. - A method is a fuction that belongs to an object - for example, the class
Composer
contains the functioncount_symphonies()
.
- To use ASE you will need to create an instance of a pre-defined class.
- To take an example most will be familiar with, lets assume you have a class called
Composer()
. - We can create an instance of that class called
beethoven
.
beethoven = Composer(birth_year=1770)
- This then allows us to access the methods and data associated with
beethoven
and theComposer
class more generally:
print(beethoven.count_symphonies()) print(beethoven.birth_year)
9 1770
The Atoms
class is used to represent molecules and materials
- When working with ASE, molecules and materials are represented by an
Atoms
object. Atoms
represents (at minimum) a collection of atoms of any chemical species and associated positions
The Calculator
class calculates basic properties of an Atoms
object
- A
Calculator
object can be attached to anAtoms
object. - The
Calculator
takes the atomic numbers and positions fromAtoms
and calculates basic properties such as energy or forces. Calculator
objects can themselves be split into three types:- in-built calculators that run the simulation within the same Python interpreter process. - file-based calculators that run the simulation as a sub-process, with communication mediated through input and output files.
- calculators that run the simulation as a sub-process, with communication via pipes. Each approach has its own advantages and limitations which will be outlined later in the course.
Further information
For further information about code structure, implementation and features we recommend reading this topical review from Larsen et al.
ASE plays nicely with a variety of atomistic modelling tools
- The modular design of ASE allows it to play nicely with (“interoperate”) with many different atomistic simulation codes.
- This includes codes implementing density functional theory, (semi-)empirical methods, tight-binding models and classical interatomic potentials.
- For a full list of supported codes please see the ASE documentation.
Course structure
The structure of this course is designed to reflect the structure of ASE. First we introduce the
Atoms
object (episodes 2-4) andCalculators
object (episodes 5-7). We then outline how to simulate more complex and computationally demanding systems by parallelising over multiple compute cores (episode 8). Finally we apply our understanding to three common tasks: molecular dynamics, geometry optimisation and electronic structure calculations (episodes 9-11). As the course progresses we move from smaller code snippets introducing the core ASE objects, to extended pieces of code for more complex tasks. Throughout the course you will see boxes like this. They will provide Python hints, signposting to other resources, discussion prompts or exercises for you to complete.
Key Points
ASE is a Python library for atomistic modelling
ASE uses several design patterns from object oriented programming (OOP)
The
Atoms
class is used to represent molecules and materialsThe
Calculator
class calculates basic properties of anAtoms
objectASE plays nicely with a variety of atomistic modelling tools