Skip to content

Commit dd96bc3

Browse files
committed
Add test of bosonic exp within auto fermion
1 parent efed80e commit dd96bc3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/base/test_fermions.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,29 @@ using ITensors.SiteTypes: op, siteind, siteinds
802802

803803
# Check wrong index ordering fails (i.e. we are actually paying attention to it)
804804
@test norm(id_tensor - exp(0.0 * id_tensor, (dag(s[1]), dag(s[2])), (s[2]', s[1]'))) > 1
805+
806+
# Test a different, random tensor
807+
T = random_itensor(s[1]', dag(s[1]))
808+
T = 1/2*(T+swapprime(dag(T), 0=>1))
809+
t = 0.01
810+
eT = exp(t*T)
811+
eT_taylor = (op("I", s[1])+t*T+t^2*apply(T, T)/2)
812+
@test norm(eT - eT_taylor) < 1E-5
813+
814+
#
815+
# Test that bosonic tensor exp works with auto fermion enabled
816+
#
817+
j1 = Index([QN("Nb", 0)=>2, QN("Nb", 1)=>2])
818+
j2 = Index([QN("Nb", 0)=>2, QN("Nb", 1)=>2])
819+
id_tensor = op("I", j1) * op("I", j2)
820+
@test id_tensor exp(0.0 * id_tensor)
821+
822+
T = random_itensor(j1', dag(j1))
823+
T = 1/2*(T+swapprime(dag(T), 0=>1))
824+
t = 0.01
825+
eT = exp(t*T)
826+
eT_taylor = (op("I", j1)+t*T+t^2*apply(T, T)/2)
827+
@test norm(eT - eT_taylor) < 1E-5
805828
end
806829

807830
ITensors.disable_auto_fermion()

0 commit comments

Comments
 (0)