Finding the Transformation and Scaling Matrices from Super Cell to Conventional Cell. #3717
Replies: 2 comments 1 reply
-
I tried to solve the problem like this: The following script incorporates the actual variable names initial_lattice_matrix and conventional_lattice_matrix from the pymatgen structure objects directly into the calculation of the transformation matrix and its singular value decomposition (SVD): import numpy as np
from pymatgen.io.vasp import Poscar
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
# Step 1: Load the structure from the POSCAR file
poscar_path = "5MD/POSCAR" # Adjust the path as necessary
structure = Poscar.from_file(poscar_path).structure
# Extract the initial lattice matrix
A = structure.lattice.matrix
print("Initial lattice matrix (A):")
print(A)
# Step 2: Convert to conventional cell and get its lattice matrix
analyzer = SpacegroupAnalyzer(structure)
conventional_structure = analyzer.get_conventional_standard_structure()
B = conventional_structure.lattice.matrix
print("\nConventional cell lattice matrix (B):")
print(B)
# Calculate the transformation matrix T that relates A to B
# Since A * T = B, then T = A_inv * B
A_inv = np.linalg.inv(A) # Inverse of A
T = np.dot(A_inv, B) # Transformation matrix
print("\nTransformation matrix (T):")
print(T)
# Step 3: Perform Singular Value Decomposition (SVD) on the transformation matrix T
U, S, VT = np.linalg.svd(T)
print("\nU matrix from SVD of T:")
print(U)
print("\nSingular values (S) from SVD of T:")
print(S)
print("\nVT matrix from SVD of T:")
print(VT)
# Interpretation:
# U and VT matrices describe the rotations and reflections involved in the transformation.
# Singular values in S represent the scaling along principal axes, indicating a uniform
# scaling if all values are the same. This reflects how the supercell is transformed
# to the conventional cell, including any rotations, reflections, and scaling. This script: 1. Reads the structure from a POSCAR file. 2. Extracts the initial and conventional cell lattice matrices. 3. Calculates the transformation matrix T that maps the initial lattice matrix A to the conventional lattice matrix B. 4. Performs the SVD on T to dissect the transformation into rotations, reflections, and scaling components. 5. Prints out the matrices involved in these steps and the singular values that indicate scaling factors. The results of the above script are as follows:
So, the scaling transformation matrix which used to make the supercell should be the following:
Any better methods or corrections to my methods would be appreciated. Regards, |
Beta Was this translation helpful? Give feedback.
-
Hi Hongsheng, Well, if I understand your question correctly... I don't think people could find an "transformation matrix" like you mentioned:
from a "conventional cell" to a "supercell" just by scaling the lattice itself. Making a supercell involves operation not only on the lattice but replicate the atoms. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm working with a POSCAR file for a supercell structure generated by VASPKIT and need some help determining the transformation matrix to convert it back to its conventional cell form. The POSCAR file details are as follows:
Given this supercell, how can I identify or calculate the transformation matrix that converts this supercell back to the conventional cell? Is there a function or method in pymatgen that could assist me with this process?
Thank you for your assistance.
Regards,
Zhao
Beta Was this translation helpful? Give feedback.
All reactions