Closed Sourin-chatterjee closed 2 years ago
Hi, The python tools are indeed only designed to conventiently extract the spin correlations from the *.obs files, but they don't allow for extra processing. However, you can easily perform post-processing with a few lines of python. Below, I'm attaching exemplary code on how you could implement the computation of spin flip and non spin-flip structure factors. I hope this helps!
import numpy as np
from spinparser.obs import getLatticeBasis, getLatticeSites, getCorrelation
file = "test.obs" # Input file
cutoff = 0.0 # Cutoff to compute structure factor at
k = np.array([1.0, 0.0, 0.0]) # Momentum to compute structure factor at
# Get the basis sites of the lattice
basis = getLatticeBasis(file)
# Create 3x3 matrix to store structure factor in global basis
sf = np.zeros([3,3])
for site1 in basis:
# Get lattice sites within truncation range of basis site `site1`
sites = getLatticeSites(file, reference=site1, verbose=False)
for site2 in sites:
# Create a 3x3 matrix and fill with correlations in the local basis
correlation = np.zeros([3,3])
correlation[0,0] = getCorrelation(file, cutoff=cutoff, site=site2, reference=site1, component="XX", verbose=False)[0,0]
correlation[1,1] = getCorrelation(file, cutoff=cutoff, site=site2, reference=site1, component="YY", verbose=False)[0,0]
correlation[2,2] = getCorrelation(file, cutoff=cutoff, site=site2, reference=site1, component="ZZ", verbose=False)[0,0]
# Define your transformation from local basis to global basis
# In this example, we simply use the identity matrix. In your example, these would be the basis dependent matrices R_0, ..., R_3
# Unfortunately, the lattice sites `site1` and `site2` are only available in real-space coordinates (not basis site index), so you need to manually determine from the coordinates what basis index the sites belong to
transformation = np.eye(3)
# Apply transformation
correlation = np.dot(transformation, correlation)
# Add term to structure factor
sf += correlation * np.cos(np.dot(k, site2 - site1))
# Normalize structure factor
sf /= len(basis)
# You can now further process the result with additional prefactors for spin flip and non-spin flip channels
print("The structure factor in the transformed basis is:\n", sf)
Hi Finn,
Thanks again. This is really helpful. Let me work with this code, I will let you know if I face any further issues.
Hi,
I am facing some issues while plotting structure factor plots in spin-flip and non-spin-flip channels. Primarily I want to plot them with the weight factor on the global basis.
But when I am performing the transformation, the components are no longer just strings they are picking some pre-factors, but in getStructureFactor, the components can only take strings.
For reference, I am attaching the transformation equation and the transformation matrix. It will be of great help if you let me know if there is some better way to post-process the data file.