File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -82,10 +82,19 @@ function deduce_pspaces(opps::SumOfLocalOperators)
8282 end
8383 end
8484
85- non_deduced = map (ismissing, pspaces)
86- any (non_deduced) &&
87- error (" cannot automatically deduce physical spaces at $(findall (non_deduced)) " )
85+ not_missing = filter (! ismissing, pspaces)
8886
87+ if length (not_missing) != length (pspaces) # Some spaces were not defined / not able to be deduced
88+ if allequal (not_missing) # all non-missing spaces are equal
89+ # fill in the missing spaces with the unique non-missing space
90+ uniquespace = first (not_missing)
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 (map (ismissing, pspaces))) " )
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