Skip to content

Commit

Permalink
Merge 63cbda7 into 957f2af
Browse files Browse the repository at this point in the history
  • Loading branch information
emstoudenmire authored Mar 22, 2024
2 parents 957f2af + 63cbda7 commit 54a636b
Show file tree
Hide file tree
Showing 88 changed files with 483 additions and 532 deletions.
27 changes: 0 additions & 27 deletions ITensorGPU/test/test_cuiterativesolvers.jl

This file was deleted.

1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
SerializedElementArrays = "d3ce8812-9567-47e9-a7b5-65a6d70a3065"
SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d"
Expand Down
26 changes: 26 additions & 0 deletions src/ITensorMPS/ITensorMPS.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module ITensorMPS

include("usings.jl")
include("imports.jl")
include("exports.jl")
include("abstractmps.jl")
include("mps.jl")
include("mpo.jl")
include("sweeps.jl")
include("abstractprojmpo/abstractprojmpo.jl")
include("abstractprojmpo/projmpo.jl")
include("abstractprojmpo/diskprojmpo.jl")
include("abstractprojmpo/projmposum.jl")
include("abstractprojmpo/projmps.jl")
include("abstractprojmpo/projmpo_mps.jl")
include("observer.jl")
include("dmrg.jl")
include("adapt.jl")
include("autompo/matelem.jl")
include("autompo/qnmatelem.jl")
include("autompo/opsum_to_mpo_generic.jl")
include("autompo/opsum_to_mpo.jl")
include("autompo/opsum_to_mpo_qn.jl")
include("deprecated.jl")

end # module ITensorMPS
8 changes: 4 additions & 4 deletions src/mps/abstractmps.jl → src/ITensorMPS/abstractmps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ function deprecate_make_inds_match!(
make_inds_match = false
end
if !hassameinds(siteinds, M1dag, M2) && make_inds_match
warn_once(inner_mps_mpo_mps_deprecation_warning(), :inner_mps_mps)
ITensors.warn_once(inner_mps_mpo_mps_deprecation_warning(), :inner_mps_mps)
replace_siteinds!(M1dag, siteindsM2)
end
return M1dag, M2
Expand Down Expand Up @@ -1776,7 +1776,7 @@ function _fermionic_swap(s1::Index, s2::Index)
if _isodd_fermionic_parity(s1, n1) && _isodd_fermionic_parity(s2, n2)
dval = -1.0
end
Tb = blockview(tensor(T), b)
Tb = ITensors.blockview(tensor(T), b)
mat_dim = prod(dims(Tb)[1:2])
Tbr = reshape(Tb, mat_dim, mat_dim)
for i in diagind(Tbr)
Expand Down Expand Up @@ -1847,9 +1847,9 @@ function setindex!(
sites = sites0[[perm...]]
# Check if the site indices
# are fermionic
if !using_auto_fermion() && any(anyfermionic, sites)
if !using_auto_fermion() && any(ITensors.anyfermionic, sites)
if length(sites) == 2 && ψ isa MPS
if all(allfermionic, sites)
if all(ITensors.allfermionic, sites)
s0 = Index.(sites0)

# TODO: the Fermionic swap is could be diagonal,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ subtract!(os::OpSum, o::Tuple) = add!(os, -Ops.op_term(o))
function isfermionic(t::Vector{Op}, sites)
p = +1
for op in t
if has_fermion_string(name(op), sites[site(op)])
if has_fermion_string(ITensors.name(op), sites[site(op)])
p *= -1
end
end
Expand Down Expand Up @@ -207,7 +207,7 @@ function sorteachterm(os::OpSum, sites)
filter!(!iszero, perm)
# and account for anti-commuting, fermionic operators
# during above sort; put resulting sign into coef
t *= parity_sign(perm)
t *= ITensors.parity_sign(perm)
terms(os)[j] = t
end

Expand Down Expand Up @@ -299,8 +299,8 @@ function MPO(os::OpSum, sites::Vector{<:Index}; splitblocks=true, kwargs...)::MP
return M
end

function MPO(eltype::Type{<:Number}, os::OpSum, sites::Vector{<:Index}; kwargs...)
return NDTensors.convert_scalartype(eltype, MPO(os, sites; kwargs...))
function MPO(elt::Type{<:Number}, os::OpSum, sites::Vector{<:Index}; kwargs...)
return NDTensors.convert_scalartype(elt, MPO(os, sites; kwargs...))
end

# Conversion from other formats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function qn_svdMPO(
llinks = Vector{QNIndex}(undef, N + 1)
# Set dir=In for fermionic ordering, avoid arrow sign
# <fermions>:
linkdir = using_auto_fermion() ? In : Out
linkdir = using_auto_fermion() ? ITensors.In : ITensors.Out
llinks[1] = Index([QN() => 1, Hflux => 1]; tags="Link,l=0", dir=linkdir)
for n in 1:N
qi = Vector{Pair{QN,Int}}()
Expand Down Expand Up @@ -220,7 +220,7 @@ function qn_svdMPO(
end

b = loc(rq, cq)
T = BlockSparseTensor(ValType, [b], (dag(ll), rl))
T = ITensors.NDTensors.BlockSparseTensor(ValType, [b], (dag(ll), rl))
T[b] .= M

H[n] += (itensor(T) * Op)
Expand All @@ -230,13 +230,13 @@ function qn_svdMPO(
# Put in ending identity operator
Id = op("Id", sites[n])
b = Block(1, 1)
T = BlockSparseTensor(ValType, [b], (dag(ll), rl))
T = ITensors.NDTensors.BlockSparseTensor(ValType, [b], (dag(ll), rl))
T[b] = 1
H[n] += (itensor(T) * Id)

# Put in starting identity operator
b = Block(nblocks(ll), nblocks(rl))
T = BlockSparseTensor(ValType, [b], (dag(ll), rl))
T = ITensors.NDTensors.BlockSparseTensor(ValType, [b], (dag(ll), rl))
T[b] = 1
H[n] += (itensor(T) * Id)
end # for n in 1:N
Expand Down
File renamed without changes.
34 changes: 34 additions & 0 deletions src/mps/deprecated.jl → src/ITensorMPS/deprecated.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
# mps/abstractmps.jl
@deprecate orthoCenter(args...; kwargs...) orthocenter(args...; kwargs...)
@deprecate store(m::AbstractMPS) data(m)
@deprecate replacesites!(args...; kwargs...) ITensors.replace_siteinds!(args...; kwargs...)
@deprecate applyMPO(args...; kwargs...) contract(args...; kwargs...)
@deprecate applympo(args...; kwargs...) contract(args...; kwargs...)
@deprecate errorMPOprod(args...; kwargs...) error_contract(args...; kwargs...)
@deprecate error_mpoprod(args...; kwargs...) error_contract(args...; kwargs...)
@deprecate error_mul(args...; kwargs...) error_contract(args...; kwargs...)
@deprecate multMPO(args...; kwargs...) contract(args...; kwargs...)
@deprecate sum(A::AbstractMPS, B::AbstractMPS; kwargs...) add(A, B; kwargs...)
@deprecate multmpo(args...; kwargs...) contract(args...; kwargs...)
@deprecate set_leftlim!(args...; kwargs...) ITensors.setleftlim!(args...; kwargs...)
@deprecate set_rightlim!(args...; kwargs...) ITensors.setrightlim!(args...; kwargs...)
@deprecate tensors(args...; kwargs...) ITensors.data(args...; kwargs...)
@deprecate primelinks!(args...; kwargs...) ITensors.prime_linkinds!(args...; kwargs...)
@deprecate simlinks!(args...; kwargs...) ITensors.sim_linkinds!(args...; kwargs...)
@deprecate mul(A::AbstractMPS, B::AbstractMPS; kwargs...) contract(A, B; kwargs...)

# mps/mpo.jl
@deprecate MPO(A::MPS; kwargs...) outer(A', A; kwargs...)

# mps/mps.jl
@deprecate randomMPS(sites::Vector{<:Index}, linkdims::Integer) randomMPS(
sites; linkdims=linkdims
)
@deprecate randomMPS(ElType::Type, sites::Vector{<:Index}, linkdims::Integer) randomMPS(
ElType, sites; linkdims=linkdims
)
@deprecate randomMPS(sites::Vector{<:Index}, state, linkdims::Integer) randomMPS(
sites, state; linkdims=linkdims
)

# Pass throughs of old name to new name:

unique_siteind(A::AbstractMPS, B::AbstractMPS, j::Integer) = siteinds(uniqueind, A, B, j)

Expand Down
5 changes: 1 addition & 4 deletions src/mps/dmrg.jl → src/ITensorMPS/dmrg.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@

#function IndexSet_ignore_missing(is::Union{Index,Nothing}...)
# return IndexSet(filter(i -> i isa Index, is))
#end
using KrylovKit: eigsolve

function permute(
M::AbstractMPS, ::Tuple{typeof(linkind),typeof(siteinds),typeof(linkind)}
Expand Down
128 changes: 128 additions & 0 deletions src/ITensorMPS/exports.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
export
# dmrg.jl
dmrg,

# abstractmps.jl
# Macros
@preserve_ortho,
# Methods
AbstractMPS,
add,
common_siteind,
common_siteinds,
findfirstsiteind,
findfirstsiteinds,
findsite,
findsites,
firstsiteind,
firstsiteinds,
logdot,
loginner,
lognorm,
movesite,
movesites,
normalize,
ortho_lims,
orthocenter,
promote_itensor_eltype,
reset_ortho_lims!,
set_ortho_lims!,
siteinds,
sim!,

# autompo/
AutoMPO,
add!,

# mpo.jl
# Types
MPO,
# Methods
error_contract,
maxlinkdim,
orthogonalize,
orthogonalize!,
outer,
projector,
randomMPO,
truncate,
truncate!,
unique_siteind,
unique_siteinds,

# mps.jl
# Types
MPS,
# Methods
,
correlation_matrix,
expect,
inner,
isortho,
linkdim,
linkdims,
linkind,
linkinds,
productMPS,
randomMPS,
replacebond,
replacebond!,
sample,
sample!,
siteind,
siteinds,
replace_siteinds!,
replace_siteinds,
swapbondsites,
totalqn,

# observer.jl
# Types
AbstractObserver,
DMRGObserver,
DMRGMeasurement,
NoObserver,
# Methods
checkdone!,
energies,
measure!,
measurements,
truncerrors,

# projmpo.jl
checkflux,
disk,
ProjMPO,
lproj,
product,
rproj,
noiseterm,
nsite,
position!,

# projmposum.jl
ProjMPOSum,

# projmpo_mps.jl
ProjMPO_MPS,

# sweeps.jl
Sweeps,
cutoff,
cutoff!,
get_cutoffs,
get_maxdims,
get_mindims,
get_noises,
maxdim,
maxdim!,
mindim,
mindim!,
noise,
noise!,
nsweep,
setmaxdim!,
setmindim!,
setcutoff!,
setnoise!,
sweepnext
Loading

0 comments on commit 54a636b

Please sign in to comment.