-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdiffDensity.m
More file actions
28 lines (24 loc) · 895 Bytes
/
Copy pathdiffDensity.m
File metadata and controls
28 lines (24 loc) · 895 Bytes
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
function res = diffDensity(obj, istate)
% diffDensity(indo, state_number)
% Calculate change in density matrix (in atomic orbitals) for
% state istate of an indo object (1= ground state)
norb = obj.norb;
nfilled = obj.nfilled;
nempty = obj.norb-obj.nfilled;
% convert wavefunction into format wf(a,r)
wf = zeros(nfilled,nempty);
for isci = 1:obj.nscibasis
a = obj.ehsci(isci,1); % hole label
r = obj.ehsci(isci,2)-nfilled; % elec label (LUMO = 1)
wf(a,r) = obj.wfsci(isci,istate);
end
% First get the change in density in molecular orbitals
rhomo = zeros(norb,norb);
% the filled portion is: -sum_s wf(a,s) wf(b,s) = -wf*wf'
rhomo(1:nfilled,1:nfilled) = -wf*(wf');
rempty = (nfilled+1):norb;
% the empty portion is: +sum_a wf(a,r) wf(a,s) = +wf'*wf
rhomo(rempty,rempty) = +wf'*wf
% now transfrom to atomic orbitals orb(atomic, molecular)
res = orb * (rhomo*(orb'));
end