-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathunitarytransform.py
320 lines (224 loc) · 9.77 KB
/
unitarytransform.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#!/usr/bin/env python3
r"""
Unitary Tranformation
=====================
This module contains functions which are useful for
unitary transformations.
Unitary transformation of spherical to cubic harmonics.
Transform observables, e.g. the crystal field operator, from the spherical harmonics to cubic harmonics basis.
d-orbitals.
The d-cubic harmonics expressed in 3-d spherical harmonics:
.. math:: 0: d_{z^2} = Y_2^{0}
.. math:: 1: d_{x^2-y^2} = \frac{1}{\sqrt{2}}Y_2^{-2} + \frac{1}{\sqrt{2}}Y_2^{2}
.. math:: 2: d_{yz} = \frac{-i}{\sqrt{2}}Y_2^{-1} + \frac{-i}{\sqrt{2}}Y_2^{1}
.. math:: 3: d_{xz} = \frac{1}{\sqrt{2}}Y_2^{-1} + \frac{-1}{\sqrt{2}}Y_2^{1}
.. math:: 4: d_{xy} = \frac{i}{\sqrt{2}}Y_2^{-2} + \frac{-i}{\sqrt{2}}Y_2^{2}
This is the ordering used in RSPt.
Let's order also the spherical harmonic orbitals (in the order it's done in RSPt):
.. math:: 0: Y_{2}^{-2}
.. math:: 1: Y_{2}^{-1}
.. math:: 2: Y_{2}^{0}
.. math:: 3: Y_{2}^{1}
.. math:: 4: Y_{2}^{2}
Now we define for convienience the notation: :math:`d_i` and :math:`Y_{d,i}` for the :math:`i` cubic and
spherical harmonic d-orbital respectively.
This makes it easy to write down a transformation matrix :math:`u_d`, with element :math:`u_{d,(i,j)}` representing
the contribution of spherical harmonic :math:`i` to the cubic harmonic :math:`j`:
.. math:: \lvert d_j \rangle = \sum_{i=0}^4 u_{d,(i,j)} \lvert Y_{d,i} \rangle, \; \mathrm{for} \; j \in \{0,1,2,3,4\},
with
.. math:: u_d = \begin{bmatrix} 0 & \frac{1}{\sqrt{2}} & 0 & 0 & \frac{i}{\sqrt{2}} \\ 0 & 0 & \frac{-i}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0 \\ 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & \frac{-i}{\sqrt{2}} & \frac{-1}{\sqrt{2}} & 0 \\ 0 & \frac{1}{\sqrt{2}} & 0 & 0 & \frac{-i}{\sqrt{2}} \end{bmatrix}
Note: :math:`u_d` is a unitary matrix, hence:
.. math:: u_d^\dagger u_d = I
.. math:: u_d u_d^\dagger = I
Orthogonality of spherical harmonics:
.. math:: \delta_{i,j} = \langle Y_{d,i} \lvert Y_{d,j} \rangle
Orthogonality of cubic harmonics:
.. math:: \delta_{i,j} = \langle d_i \lvert d_j \rangle = \sum_{k=0}^4 \bar{u}_{d,(k,i)} \langle Y_{d,k} \lvert \sum_{n=0}^4 u_{d,(n,j)} \lvert Y_{d,n} \rangle \\ = \sum_{k,n} \bar{u}_{d,(k,i)} u_{d,(n,j)} \delta_{k,n} = \sum_{k=0}^4 \bar{u}_{d,(k,i)} u_{d,(k,j)} \\ = \sum_{k=0}^4 (u_d^\dagger)_{(i,k)} u_{d,(k,j)},
which in matrix form reads:
.. math:: I = u_d^\dagger u_d.
An observable, expressed in cubic harmonics basis is:
.. math:: \tilde{A}_{i,j} = \langle d_i \lvert \hat{A} \rvert d_j \rangle = \sum_{k=0}^4 \bar{u}_{d,(k,i)} \langle Y_{d,k} \lvert \hat{A} \sum_{n=0}^4 u_{d,(n,j)} \lvert Y_{d,n} \rangle \\ = \sum_{k,n} \bar{u}_{d,(k,i)} u_{d,(n,j)} \langle Y_{d,k} \lvert \hat{A} \rvert Y_{d,n} \rangle = \sum_{k,n} \bar{u}_{d,(k,i)} A_{k,n} u_{d,(n,j)} \\ = \sum_{k=0}^4 (u_d^\dagger)_{(i,k)} \sum_{n=0}^4 A_{k,n} u_{d,(n,j)},
which in matrix form becomes:
.. math:: \tilde{A} = u_d^\dagger A u_d.
Thus, transforming an observable from spherical to cubic harmonic basis is
simple done by multiplying its matrix representation in the spherical
harmonics basis from left :math:`u_d^\dagger` and from the right
with :math:`u_d`.
Due to the orthogonality of the columns and the rows in :math:`u_d`, we can also easily transform back:
.. math:: A = u_d \tilde{A} u_d^\dagger.
p-orbitals.
The p-cubic harmonics expressed in 3-d spherical harmonics:
.. math:: 0: p_y = \frac{i}{\sqrt{2}}Y_1^{-1} + \frac{i}{\sqrt{2}}Y_1^{1}
.. math:: 1: p_x = \frac{1}{\sqrt{2}}Y_1^{-1} - \frac{1}{\sqrt{2}}Y_1^{1}
.. math:: 2: p_z = Y_1^{0}
The ordering is the same as in RSPt.
Let's order also the spherical harmonic orbitals (in the order it's done in RSPt):
.. math:: 0: Y_1^{-1}
.. math:: 1: Y_1^{0}
.. math:: 2: Y_1^{1}
Now we define for convienience the notation: :math:`p_i` and :math:`Y_{p,i}`
for the :math:`i` cubic and spherical harmonic respectively.
This makes it easy to write down a transformation matrix :math:`u_p`,
with element :math:`u_{p,(i,j)}` representing the contribution of
spherical harmonics :math:`i` to the cubic harmonic :math:`j`:
.. math:: \lvert d_j \rangle = \sum_{i=0}^4 u_{p,(i,j)} \lvert Y_{p,i} \rangle, \; \mathrm{for} \; j \in \{0,1,2,3,4\},
with
.. math:: u_p = \begin{bmatrix} \frac{i}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0 \\ 0 & 0 & 1 \\ \frac{i}{\sqrt{2}} & \frac{-1}{\sqrt{2}} & 0 \end{bmatrix}
We can define a transformation matrix between cubic and spherical harmonics,
as we did for the d-orbitals.
Thus a observable in cubic harmonics becomes:
:math:`\tilde{A} = u_p^\dagger A u_p`, where :math:`u_p`
is the transformation matrix for p-orbitals.
p- and d-orbitals.
An observable with a d-oribtal as bra and a p-orbital as a ket can be
expressed in cubic harmonics:
.. math:: \tilde{A}_{i,j} = \langle d_i \lvert \hat{A} \rvert p_j \rangle = \sum_{k=0}^4 \bar{u}_{d,(k,i)} \langle Y_{d,k} \lvert \hat{A} \sum_{n=0}^2 u_{p,(n,j)} \lvert Y_{p,n} \rangle \\ = \sum_{k,n} \bar{u}_{d,(k,i)} u_{p,(n,j)} \langle Y_{d,k} \lvert \hat{A} \rvert Y_{p,n} \rangle = \sum_{k,n} \bar{u}_{d,(k,i)} A_{k,n} u_{p,(n,j)} \\ = \sum_{k=0}^4 (u_d^\dagger)_{(i,k)} \sum_{n=0}^2 A_{k,n} u_{p,(n,j)},
which in matrix form becomes:
.. math:: \tilde{A} = u_d^\dagger A u_p.
Thus, transforming an observable from spherical to cubic harmonic basis
is simple done by multiplying its matrix representation in the
spherical harmonics basis from left
:math:`u_d^\dagger` and from the right with :math:`u_p`.
Due to the orthogonality of the columns and the rows in
:math:`u_d` and :math:`u_p`, we can also easily transform back:
.. math:: A = u_d \tilde{A} u_p^\dagger.
"""
import numpy as np
import sys
def rotate(d, r_left, r_right):
r"""
Return matrix rotated from left and right.
Assumptions:
- Variable `d` to contain both spin channels
but with no spin off-diagonal elements.
- Variables `r_left` and `r_right` contain only one spin channel.
The other spin channel has to be the same.
Parameters
----------
d : (N,M) array
Spin-orbitals are ordered: 0dn, 0up, 1dn, 1up, ...
r_left : (N/2,N/2) array
r_right : (M/2,M/2) array
Returns
-------
dp : (N,M) ndarray
Spin-orbitals are ordered: 0dn, 0up, 1dn, 1up, ...
"""
# Remove spin
dm = d[::2, ::2]
# Rotate to spherical harmonics basis
# in the rotated coordinate system
dmp = np.dot(np.transpose(np.conj(r_left)), np.dot(dm, r_right))
# Add spin
dp = np.zeros(2*np.array(np.shape(dmp)), dtype=np.complex)
dp[::2, ::2] = dmp
dp[1::2, 1::2] = dmp
return dp
def get_spherical_2_cubic_matrix(spinpol=False, l=2):
r"""
Return unitary ndarray for transforming from spherical
to cubic harmonics.
Parameters
----------
spinpol : boolean
If transformation involves spin.
l : integer
Angular momentum number. p: l=1, d: l=2.
Returns
-------
u : (M,M) ndarray
The unitary matrix from spherical to cubic harmonics.
Notes
-----
Element :math:`u_{i,j}` represents the contribution of spherical
harmonics :math:`i` to the cubic harmonic :math:`j`:
.. math:: \lvert l_j \rangle = \sum_{i=0}^4 u_{d,(i,j)} \lvert Y_{d,i} \rangle.
"""
if l == 1:
u = np.zeros((3, 3), dtype=np.complex)
u[0, 0] = 1j/np.sqrt(2)
u[2, 0] = 1j/np.sqrt(2)
u[0, 1] = 1/np.sqrt(2)
u[2, 1] = -1/np.sqrt(2)
u[1, 2] = 1
elif l == 2:
u = np.zeros((5, 5), dtype=np.complex)
u[2, 0] = 1
u[[0, -1], 1] = 1/np.sqrt(2)
u[1, 2] = -1j/np.sqrt(2)
u[-2, 2] = -1j/np.sqrt(2)
u[1, 3] = 1/np.sqrt(2)
u[-2, 3] = -1/np.sqrt(2)
u[0, 4] = 1j/np.sqrt(2)
u[-1, 4] = -1j/np.sqrt(2)
else:
sys.exit('This angular momentum is not implemented yet')
if spinpol:
n, m = np.shape(u)
uSpin = np.zeros((2*n, 2*m), dtype=np.complex)
uSpin[:n, :m] = u
uSpin[n:, m:] = u
u = uSpin
return u
def get_spinpol_and_ls(n, m):
r"""
Calculate if spinpolarized and which angular momentum
the matrix dimensions n,m corresponds to.
Parameters
----------
n : integer
Number of elements in the first dimension.
m : integer
Number of elements in the second dimension.
Returns
-------
spinpol : boolean
if matrix is spinpolarized
ls : list of two integers
angular momentum numbers
"""
if n % 2 == 0:
spinpol = True
ls = [(n/2-1)/2, (m/2-1)/2]
else:
spinpol = False
ls = [(n-1)/2, (m-1)/2]
return spinpol, ls
def spherical_2_cubic(a):
r"""
Create the observable matrix expressed in cubic harmonics
instead of spherical harmonics.
.. math:: \tilde{a} = u^\dagger a u.
Parameters
----------
a : matrix
Observable, expressed in spherical harmonics.
Returns
-------
at : matrix
Observable, expressed in cubic harmonics.
"""
spinpol, ls = get_spinpol_and_ls(*np.shape(a))
u_bra = get_spherical_2_cubic_matrix(spinpol=spinpol, l=ls[0])
u_ket = get_spherical_2_cubic_matrix(spinpol=spinpol, l=ls[1])
at = np.dot(np.transpose(np.conj(u_bra)),np.dot(a, u_ket))
return at
def cubic_2_spherical(at):
r"""
Create the observable matrix expressed in spherical
harmonics instead of cubic harmonics.
.. math:: a = u \tilde{a} u^\dagger.
Parameters
----------
at : matrix
Observable, expressed in cubic harmonics.
Returns
-------
a : matrix
Observable, expressed in spherical harmonics.
"""
spinpol, ls = get_spinpol_and_ls(*np.shape(at))
u_bra = get_spherical_2_cubic_matrix(spinpol=spinpol, l=ls[0])
u_ket = get_spherical_2_cubic_matrix(spinpol=spinpol, l=ls[1])
a = np.dot(u_bra, np.dot(at,np.transpose(np.conj(u_ket))))
return a