Exercise 1: Atomistic Structures

Authors: Jan Janssen, Tilmann Hickel, Jörg Neugebauer (Max-Planck-Institut für Eisenforschung)

The scope of this first exercise is to become familar with:

  • the jupyter notebook environment,

  • the pyiron project object and

  • the creation of atomistic structures.


Keyboard Shortcuts used in this tutorial

  • <tab> - auto completion

  • <tab> + <shift> - documentation

  • <shift> + <enter> - execute cell

  • <esc> + <a> - new cell above

  • <esc> + <b> - new cell below

Getting Started

Let’s start by creating the first pyiron Project:

# Import the Project object
from pyiron import ____
# Create a Project object instance for a project 
# named atomistics
pr = ____("atomistics")
# The Project object instance, or Project for short 
# created a new folder in your current directory: 

The Project Object

The project object is the central object of the workflow management in pyiron. It can be used to:

  • create atomistic structure objects

  • create different kinds of atomistic simulation jobs

  • track the execution of job objects locally and on remote HPC clusters.

All these features are discussed in the following. For now we focus on the creation of atomistic structures from the project object.

Atomistic Structures

We start by creating a primitive fcc aluminium lattice using the ASE interface:

# Create a primitive aluminium (Al) fcc lattice: 
al_fcc = pr.create_ase_bulk(____)
# Create a cubic aluminium (Al) fcc lattice: 
al_fcc_cubic = pr.create_ase_bulk(____, cubic=True)

# Visualise the cubic aluminium structure using NGLview: 

Based on the atomistic simulation environment (ASE) pyiron can create atomistic structures with minimal inputs. Still it is also possible to define all details manually:

# Create a cubic aluminium (Al) bcc lattice:
al_bcc_cubic = pr.create_ase_bulk(_____, crystalstructure=_____, a=3.2, cubic=True)

# Compare the number of atoms (length of the structure object)
# in the bcc lattice (2) and the fcc lattice (4):
____(al_bcc_cubic), ____(al_fcc_cubic)

Replacing atoms

While unary systems are still interesting from an academic perspective, the goal of this workshop is to calculate phase diagrams, so we are interested in alloys.

# Create a copy of the cubic aluminium fcc structure:
al_ni_fcc_cubic = al_fcc_cubic._____
# Replace the first aluminium atom with an nickle (Ni) atom: 
al_ni_fcc_cubic[0] = ____

# Visualise the updated structure: 

Beyond ASE - Atomic Neighbors

https://wiki.fysik.dtu.dk/ase/ase/build/build.html While the ASE atoms class already provides extensive functionality to build complex structures. pyiron extends the atoms class for example by adding specialized functionality like analysing the neighbour environment:

# Repeat the cubic aluminium structure 5 times in each direction: 
al_large = al_fcc_cubic.repeat(___)
# Create the neighbor environment for the cubic aluminium structure, 
# by limiting the number of neighbors to 1000: 
al_large_neighbors = al_large.get_neighbors(num_neighbors=_____)
# Import the matplotlib library for plotting.
import matplotlib.pyplot as plt

# Visualise the per atom neighbour distances as historgram 
# with 100 bins: 
plt.hist(al_large_neighbors.distances.flatten(), bins=____);

Special Quasi-random Structures

Rather than replacing individual atoms one by one special quasi-random structures are used to have the most random configuration for a given concentration. More details about this method are available in the literature: https://doi.org/10.1103/PhysRevLett.65.353

# Create an SQS calculation job from the project object 
# named "sqscalculation" : 
job_sqs = pr.create_job(
# assign the large cubic aluminium fcc structure to the job object: 
job_sqs.structure = _____
# Print the input
# Set the Aluminium Nickel concentration to 50:50: 
job_sqs.input.mole_fractions = {_____: 0.5, _____:0.5}

# Limit the number of iterations to 1000
job_sqs.input.iterations = ____
# Execute the SQS calculation by calling the run function 
# of the job object: 
# Display the first resulting structure 

Managing your pyiron project

In contrast to the ASE functions which can be executed nearly instantaneous the calculation of the SQS structure requires multiple iterations and is therefore implemented as pyiron job. The same create_job() function is used in the following to create other atomistic simulations. Still before doing so we want to use the projecct object to inspect the calculation in the project:

# Display the table of all jobs in the current 
# project by calling the job_table function: 
# Reload the job once based on it's database ID 
# using the job_id property:
job_reload_job_id = pr.load(_____)

# and once using the job_name property of the job object: 
job_reload_job_name = pr.load(____)
# Compare the job name of both jobs: 
job_reload_job_id._____ == job_reload_job_name._____

Modify SQS-calculation job

By default pyiron is reloading existing calculations, rather than executing the same calculation again. Therefore to change the concentration of the SQS structure we set the delete_existing_job parameter for the run() function.

# Set the Aluminium Nickel concentration to 80:20. 
# The concentrations have to be given as floats ranging from 0 to 1: 
job_sqs.input.mole_fractions = {"Al": _____, "Ni": ____}
# Execute the SQS calculation by calling the run function 
# with the delete_existing parameter set to true: 
# Display the first resulting structure 


Finally using an integrated framework like pyiron also allows us to collect all the publications of the tools we used in a given project, to keep track of the methods in use:

# List publications used in the current project


At the end of this section you should be able to create pyiron projects, atomistic structures and calculation jobs.

Additional exercises:

  • Create a vacancy using the del method.

  • Identify the coordinates of the vacancy automatically by calculating the nearest neighbor distance of all atoms.

  • Replace the nearest neighbor atoms of the vacancy with a different element and visualise the structure using plot3d().