Skip to content

Create a Custom Perturbation in a Material

1. Introduction

Perturb a supercell of a material with a custom function of the coordinates, written as a SymPy expression.

2. Open the notebook

In JupyterLite, the notebook is made/create_perturbation_custom.ipynb, entry 5.2.2 "Perturbation using custom function" of made/Introduction.ipynb.

3. Set the parameters

Cell 1.2 holds the parameters:

1
2
3
4
5
6
7
8
# Set whether to preserve geodesic distance and scale the cell accordingly to match PBC
PRESERVE_GEODESIC_DISTANCE = True

# Set the supercell matrix to apply to original material
SUPERCELL_MATRIX = [[30, 0, 0], [0, 30, 0], [0, 0, 1]]

# Set whether to use Cartesian coordinates for the perturbation function
USE_CARTESIAN_COORDINATES = False

PRESERVE_GEODESIC_DISTANCE = True keeps the distances between the atoms along the perturbed surface and scales the cell to match the periodic boundary conditions.

SUPERCELL_MATRIX builds the supercell of the first of the input materials that is perturbed.

The overview explains USE_CARTESIAN_COORDINATES.

Cell 1.3 holds the perturbation function:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
import sympy as sp

# Variables for the perturbation function (for SymPy)
variable_names = ["x", "y", "z"]
x, y, z = sp.symbols(variable_names)

# Set the parameters for your perturbation function
AMPLITUDE = 0.05
WAVELENGTH = 1.0
PHASE = 0.0

# Define the perturbation function
custom_sympy_function = AMPLITUDE * sp.sin(2 * sp.pi * x / WAVELENGTH + PHASE) * sp.sin(
    2 * sp.pi * y / WAVELENGTH)

custom_sympy_function is the displacement as a SymPy expression of x, y and z. The default is a product of sine waves along x and y, set by AMPLITUDE, WAVELENGTH and PHASE.

4. Run and read the result

Run the notebook with Run > Run All. The notebook shows the perturbed material from the top and from the side and passes it back with set_materials, as in Structure Notebooks.

5. Interactive JupyterLite notebook

The interactive JupyterLite notebook for creating a custom perturbation can be accessed below.

The specific example Ripple Perturbation in Graphene uses this notebook.