-
Notifications
You must be signed in to change notification settings - Fork 0
/
constructDensityEvolution.m
37 lines (31 loc) · 1.29 KB
/
constructDensityEvolution.m
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
function EvolutionMatrix = constructDensityEvolution(t,Hamfun,args,DecayMatrix)
H = Hamfun(t,args{:});
numofelements = size(H);
if numofelements(1) ~= numofelements(2);
error('Oh no!');
else
numofelements = numofelements(1);
end
EvolutionMatrix = zeros(numofelements.^2);
% Build in the arbitrary Hamiltonian:
for ii=1:numofelements
for jj=1:numofelements
for kk=1:numofelements
% First part of the commutator:
EvolutionMatrix(returnDensityEvInd(ii,jj,numofelements),...
returnDensityEvInd(ii,kk,numofelements)) = ...
EvolutionMatrix(returnDensityEvInd(ii,jj,numofelements),...
returnDensityEvInd(ii,kk,numofelements)) ...
+ 1i*H(kk,jj);
% Second part of the commutator:
EvolutionMatrix(returnDensityEvInd(ii,jj,numofelements),...
returnDensityEvInd(kk,jj,numofelements)) = ...
EvolutionMatrix(returnDensityEvInd(ii,jj,numofelements),...
returnDensityEvInd(kk,jj,numofelements)) ...
- 1i*H(ii,kk);
end
end
end
% Looks like we still need to build in the decay matrix:
EvolutionMatrix = EvolutionMatrix + DecayMatrix;
end