File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -83,9 +83,18 @@ function deduce_pspaces(opps::SumOfLocalOperators)
8383 end
8484
8585 non_deduced = map(ismissing, pspaces)
86- any(non_deduced) &&
87- error(" cannot automatically deduce physical spaces at $(findall(non_deduced)) " )
8886
87+ if any(non_deduced) # Some spaces were not defined / not able to be deduced
88+ if allequal(filter(! ismissing, pspaces)) # all non-missing spaces are equal
89+ # fill in the missing spaces with the unique non-missing space
90+ uniquespace = first(filter(! ismissing, pspaces))
91+ for i in eachindex(pspaces)
92+ pspaces[i] = uniquespace
93+ end
94+ else # Not all non-missing spaces are equal
95+ error(" cannot automatically deduce physical spaces at $(findall(non_deduced)) " )
96+ end
97+ end
8998 return collect(S, pspaces)
9099end
91100
Original file line number Diff line number Diff line change 1- using MPSKitModels
1+ using MPSKitModels, MPSKit, TensorKit
22
33lattice = InfiniteChain(1 )
44H1 = @mpoham begin
2020 H = @mpoham sum(ZZ{i,j} for (i, j) in nearest_neighbours(lattice))
2121 @test length(H) == length(lattice)
2222end
23+
24+ @testset " deduce_pspaces" begin
25+ # Not fully defining the pspaces should still work
26+ lattice = FiniteChain(5 )
27+ H = @mpoham S_zz(){lattice[2 ],lattice[3 ]}
28+
29+ @test unique(MPSKit. physicalspace(H))[1 ] == ComplexSpace(2 )
30+
31+ @test_throws Exception @mpoham σˣ(){lattice[1 ]} + σˣ(; spin= 3 // 2 ){lattice[2 ]}
32+ end
You can’t perform that action at this time.
0 commit comments