-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with post processing data #9
Comments
Hi, 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. |
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.
The text was updated successfully, but these errors were encountered: