This repository was archived by the owner on Jun 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerateXiXjSpinOperators.m
More file actions
80 lines (63 loc) · 1.96 KB
/
Copy pathgenerateXiXjSpinOperators.m
File metadata and controls
80 lines (63 loc) · 1.96 KB
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
% IiIjop = generateXiXjSpinOperators(S,maxClusterSize)
% S = spin.
% maxClusterSize = the maximum number of spins to be accounted for.
%
% IiIjop{clusterSize}}(:,:, x + 9n) is the spin opererator that acts as IiIj
% for the nth spin in a cluster of size clusterSize, and as the identity for all
% other spins in the cluster; n in [0, maxClusterSize -1].
%
% The number x gives the operator IiIj as shown below.
%
% ENUM for spin-operator indices.
% XX = 1; XY = 4; XZ = 7;
% YX = 2; YY = 5; YZ = 8;
% ZX = 3; ZY = 6; ZZ = 9;
function IiIjop = generateXiXjSpinOperators(S,maxClusterSize)
% Generate spin operators.
Iop{1} = spinX(S);
Iop{2} = spinY(S);
Iop{3} = spinZ(S);
% Form all 9 IiIj operators, in the order XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ
IiIj = cell(3,3);
for ii = 1:3
for jj = 1:3
IiIj{ii,jj} = Iop{ii}*Iop{jj};
end
end
% Get the identity operator.
E = eye(2*S+1);
% Initialize output.
IiIjop = cell(maxClusterSize,1);
% Loop of cluster sizes.
for clusterSize = 1:maxClusterSize
% Determine cluster Hilbert space dimensionality.
N = (2*S+1)^clusterSize;
% Initialize the set of cluster operators of order clusterSize.
IiIjop{clusterSize} = zeros(N,N,clusterSize*9);
% Define an index.
idx = 1;
% Loop over nuclei within a the cluster.
for iNuc = 1:clusterSize
% Loop over the 9 IiIj operators.
for iOp = 1:9
% Initilize cluster spin-operator.
Iop = 1;
% Loop over cluster positions.
for j = 1:clusterSize
if j==iNuc % spin position == cluster position
% Use IiIj operator.
op_ = IiIj{iOp};
else
% Use identity.
op_ = E;
end
% Build up cluster spin-operator with the appropriate spin operator.
Iop = kron(Iop,op_);
end
% Add cluster spin-operator to the output.
IiIjop{clusterSize}(:,:,idx) = Iop;
% Increment index.
idx = idx + 1;
end
end
end