Pressure and Strain Transformations in the Crystal¶
This notebook demonstrates how to use the scale_unit_cell
function to apply pressure and strain transformations to a material’s unit cell, modifying its lattice parameters in various ways, including:
Pressure-Based Scaling: Uses pressure and bulk modulus to calculate uniform strain
UniforStrainng: Appliestrainor uniformly across all lattice directionsn.
Anisotropic Strain: Applies strain along each lattice axis individually.
Strain and Shear Transformations: Utilizes a strain tensor to apply anisotrotrain and sh)._
Loading a Structure¶
Crystals or molecules can be easily read from file and initiated as Structure
object:
[1]:
from aim2dat.strct import Structure
strct = Structure.from_file("files/strc/Zn_MOF5_H_conv.xyz", label="Zn_MOF5_H")
Example 1: Pressure-Based Scaling¶
Applies 10 GPa pressure to strct
using a bulk modulus of 1600 GPa. The resulting lattice parameters show the effect of the applied pressure.s.
[2]:
pressure_applied_structure = strct.scale_unit_cell(
pressure= 1, # Pressure in GPa.
bulk_modulus=16.0, # Bulk modulus in GPa, MOF-5
change_label=True
)
Create a pandas DataFrame
to compare original and pressure-applied lattice parameters.
[3]:
import pandas as pd
pressure_lattice_comparison = pd.DataFrame({
"Original": strct.cell,
"Pressure Applied (10 GPa)": pressure_applied_structure.cell
}, index=["x", "y", "z"])
display(pressure_lattice_comparison)
Original | Pressure Applied (10 GPa) | |
---|---|---|
x | (26.076570788092, 0.0, 0.0) | (24.44678511383625, 0.0, 0.0) |
y | (0.0, 26.076570788092, 0.0) | (0.0, 24.44678511383625, 0.0) |
z | (0.0, 0.0, 26.076570788092) | (0.0, 0.0, 24.44678511383625) |
Example 2: Uniform Strain¶
In this simpst example, we apply uniform scaling t````strct` using a scaling factor of 1.1:
scale_unit_cell
scales all lattice parameters uniformly by 1.1.change_label=True
updates the label to reflect the transformatiation. cling.
[4]:
uniform_scaled_structure = strct.scale_unit_cell(
scaling_factors=1.1, # Uniform scaling factor
change_label=True
)
Create a pandas DataFrame
to compare original and scaled lattice parameters.
[5]:
lattice_comparison = pd.DataFrame({
"Original": strct.cell,
"Uniform Scaled (1.1)": uniform_scaled_structure.cell
}, index=["x", "y", "z"])
display(lattice_comparison)
Original | Uniform Scaled (1.1) | |
---|---|---|
x | (26.076570788092, 0.0, 0.0) | (28.6842278669012, 0.0, 0.0) |
y | (0.0, 26.076570788092, 0.0) | (0.0, 28.6842278669012, 0.0) |
z | (0.0, 0.0, 26.076570788092) | (0.0, 0.0, 28.6842278669012) |
Example 3: Anisotropic Strain¶
Applies anisotropic strain to str0]
with specified strains along each axis: 2% along x, -1% along y, and 3% along z. The updated lattice parameters are printed to show the effect.
[6]:
anisotropic_strain_structure = strct.scale_unit_cell(
scaling_factors=[1.02, 0.99, 1.03],
change_label=True
)
Create a pandas DataFrame
to compare original and anisotropically strained lattice parameters.
[7]:
anisotropic_lattice_comparison = pd.DataFrame({
"Original": strct.cell,
"Anisotropic Strain [1.02, 0.99, 1.03]": anisotropic_strain_structure.cell
}, index=["x", "y", "z"])
display(anisotropic_lattice_comparison)
Original | Anisotropic Strain [1.02, 0.99, 1.03] | |
---|---|---|
x | (26.076570788092, 0.0, 0.0) | (26.598102203853838, 0.0, 0.0) |
y | (0.0, 26.076570788092, 0.0) | (0.0, 25.815805080211078, 0.0) |
z | (0.0, 0.0, 26.076570788092) | (0.0, 0.0, 26.85886791173476) |
Example 4: Anisotropic Strain and Shear Transformation¶
Applies a 3x3 strain tensor to str0]
, introducing both anisotropic strain and shear:
The strain matrix specifies 2% strain along x, -1% along y, 3% along z, and shear components between x, y, and z axes.
The
scale_unit_cell
function applies these transformations, andchange_label=True
updates the label.
The initial and transformed lattice parameters are printed to display the effects.
[8]:
strain_matrix = [
[1.02, 0.01, 0.0], # 2% strain along x, 0.01 shear strain between x and y.
[0.01, 0.99, 0.0], # -1% strain along y, 0.01 shear strain between y and x.
[0.0, 0.02, 1.03] # 3% strain along z, 0.02 shear strain between z and y.
]
anisotropic_strain_structure = strct.scale_unit_cell(
scaling_factors=strain_matrix,
change_label=True
)
Create a pandas DataFrame
to compare original and strained lattice parameters.
[9]:
tensor_lattice_comparison = pd.DataFrame({
"Original": strct.cell,
"3x3 Strain Tensor Applied": anisotropic_strain_structure.cell
}, index=["x", "y", "z"])
display(tensor_lattice_comparison)
Original | 3x3 Strain Tensor Applied | |
---|---|---|
x | (26.076570788092, 0.0, 0.0) | (26.598102203853838, 0.26076570788092, 0.0) |
y | (0.0, 26.076570788092, 0.0) | (0.26076570788092, 25.815805080211078, 0.0) |
z | (0.0, 0.0, 26.076570788092) | (0.0, 0.52153141576184, 26.85886791173476) |
It is also possible to save the new structure as a .xyz file.
[10]:
anisotropic_strain_structure.to_file("files/strc/annisotropic_strain.xyz")