Powder Patterns¶
In [2]:
Copied!
import numpy as np
import matplotlib.pyplot as plt
np.set_printoptions(precision=2, suppress=True)
import numpy as np
import matplotlib.pyplot as plt
np.set_printoptions(precision=2, suppress=True)
In [4]:
Copied!
def Rx(theta):
return np.array(
[
[1, 0, 0,],
[0, np.cos(theta), -np.sin(theta),],
[0, np.sin(theta), np.cos(theta),],
])
def Rx(theta):
return np.array(
[
[1, 0, 0,],
[0, np.cos(theta), -np.sin(theta),],
[0, np.sin(theta), np.cos(theta),],
])
In [5]:
Copied!
def Ry(theta):
return np.array(
[
[np.cos(theta), 0, np.sin(theta),],
[0, 1, 0,],
[-np.sin(theta), 0, np.cos(theta),],
])
def Ry(theta):
return np.array(
[
[np.cos(theta), 0, np.sin(theta),],
[0, 1, 0,],
[-np.sin(theta), 0, np.cos(theta),],
])
In [6]:
Copied!
def Rz(theta):
return np.array(
[
[np.cos(theta), -np.sin(theta), 0],
[np.sin(theta), np.cos(theta), 0,],
[0, 0, 1],
])
def Rz(theta):
return np.array(
[
[np.cos(theta), -np.sin(theta), 0],
[np.sin(theta), np.cos(theta), 0,],
[0, 0, 1],
])
In [7]:
Copied!
def euler_rotate(tensor, alpha, beta, gamma):
return (
Rz(alpha)
@ Ry(beta)
@ Rz(gamma)
@ tensor
@ Rz(-gamma)
@ Ry(-beta)
@ Rz(-alpha)
)
def euler_rotate(tensor, alpha, beta, gamma):
return (
Rz(alpha)
@ Ry(beta)
@ Rz(gamma)
@ tensor
@ Rz(-gamma)
@ Ry(-beta)
@ Rz(-alpha)
)
In [8]:
Copied!
csa = 2 * np.pi * np.diag([30, 0, -30])
xscale = list(range(-200, 200))
powder = np.zeros(len(xscale))
for i, beta in enumerate(np.linspace(0, np.pi, 512)):
intensity = abs(np.sin(beta))
for gamma in np.linspace(0, 2*np.pi, 512):
freq = euler_rotate(csa, 0, beta, gamma)[2, 2]
place = int(np.floor(freq) - 200)
powder[place] += intensity
csa = 2 * np.pi * np.diag([30, 0, -30])
xscale = list(range(-200, 200))
powder = np.zeros(len(xscale))
for i, beta in enumerate(np.linspace(0, np.pi, 512)):
intensity = abs(np.sin(beta))
for gamma in np.linspace(0, 2*np.pi, 512):
freq = euler_rotate(csa, 0, beta, gamma)[2, 2]
place = int(np.floor(freq) - 200)
powder[place] += intensity
In [9]:
Copied!
fig, ax = plt.subplots()
ax.plot(np.array(xscale), powder.real)
plt.show()
fig, ax = plt.subplots()
ax.plot(np.array(xscale), powder.real)
plt.show()
Q1¶
- Make csa patterns for different anisotropies and asymmetries
In [11]:
Copied!
# your answer here
# your answer here
Q2¶
- Make the Pake pattern for dipole-dipole coupling. What is the difference between the calculation you do for CSA and dipole-dipole coupling?
In [10]:
Copied!
dipole = 2 * np.pi * np.diag([10, 10, -20])
xscale = list(range(-150, 150))
powder = np.zeros(len(xscale))
# continue here
dipole = 2 * np.pi * np.diag([10, 10, -20])
xscale = list(range(-150, 150))
powder = np.zeros(len(xscale))
# continue here
In [ ]:
Copied!