Skip to content

Commit 821b17a

Browse files
authored
Merge aea2af3 into 3c20776
2 parents 3c20776 + aea2af3 commit 821b17a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+283
-288
lines changed

NDTensors/test/ITensors/TestITensorDMRG/dmrg.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using ITensors: MPO, OpSum, dmrg, randomMPS, siteinds
1+
using ITensors: MPO, OpSum, dmrg, random_mps, siteinds
22
using Random: Random
33
using Test: @test
44
include("../../NDTensorsTestUtils/NDTensorsTestUtils.jl")
@@ -19,7 +19,7 @@ function test_dmrg(
1919

2020
Random.seed!(1234)
2121
init = j -> isodd(j) ? "" : ""
22-
psi0 = dev(randomMPS(elt, sites, init; linkdims=4))
22+
psi0 = dev(random_mps(elt, sites, init; linkdims=4))
2323
H = dev(MPO(elt, os, sites))
2424

2525
nsweeps = 3

docs/src/MPSandMPO.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ MPO
1212
```@docs
1313
MPS(::Int)
1414
MPS(::Type{<:Number}, ::Vector{<:Index})
15-
randomMPS(sites::Vector{<:Index})
16-
randomMPS(::Type{<:Number}, sites::Vector{<:Index})
17-
randomMPS(::Vector{<:Index}, ::Any)
15+
random_mps(sites::Vector{<:Index})
16+
random_mps(::Type{<:Number}, sites::Vector{<:Index})
17+
random_mps(::Vector{<:Index}, ::Any)
1818
MPS(::Vector{<:Index}, ::Any)
1919
MPS(::Type{<:Number}, ::Vector{<:Index}, ::Any)
2020
MPS(::Vector{<:Pair{<:Index}})

docs/src/Observer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ let
184184
a += 0.5,"S-",n,"S+",n+1
185185
end
186186
H = MPO(a,s)
187-
psi0 = randomMPS(s;linkdims=4)
187+
psi0 = random_mps(s;linkdims=4)
188188

189189
nsweeps = 5
190190
cutoff = 1E-8

docs/src/examples/DMRG.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ The random starting wavefunction `psi0` must be defined in the same Hilbert spac
4747
as the Hamiltonian, so we construct it using the same collection of site indices:
4848

4949
```julia
50-
psi0 = randomMPS(sites;linkdims=2)
50+
psi0 = random_mps(sites;linkdims=2)
5151
```
5252

5353
Here we have made a random MPS of bond dimension 2. We could have used a random product
@@ -85,7 +85,7 @@ let
8585
maxdim = [10,20,100,100,200] # gradually increase states kept
8686
cutoff = [1E-10] # desired truncation error
8787

88-
psi0 = randomMPS(sites;linkdims=2)
88+
psi0 = random_mps(sites;linkdims=2)
8989

9090
energy,psi = dmrg(H,psi0;nsweeps,maxdim,cutoff)
9191

@@ -158,7 +158,7 @@ let
158158
maxdim = [10,10,20,40,80,100,140,180,200]
159159
cutoff = [1E-8]
160160

161-
psi0 = randomMPS(sites;linkdims=4)
161+
psi0 = random_mps(sites;linkdims=4)
162162

163163
energy,psi = dmrg(H,psi0;nsweeps,maxdim,cutoff)
164164

@@ -238,7 +238,7 @@ let
238238
# Initialize wavefunction to a random MPS
239239
# of bond-dimension 10 with same quantum
240240
# numbers as `state`
241-
psi0 = randomMPS(sites,state;linkdims=20)
241+
psi0 = random_mps(sites,state;linkdims=20)
242242

243243
nsweeps = 10
244244
maxdim = [20,60,100,100,200,400,800]
@@ -328,15 +328,15 @@ let
328328
#
329329
# Compute the ground state psi0
330330
#
331-
psi0_init = randomMPS(sites;linkdims=2)
331+
psi0_init = random_mps(sites;linkdims=2)
332332
energy0,psi0 = dmrg(H,psi0_init;nsweeps,maxdim,cutoff,noise)
333333

334334
println()
335335

336336
#
337337
# Compute the first excited state psi1
338338
#
339-
psi1_init = randomMPS(sites;linkdims=2)
339+
psi1_init = random_mps(sites;linkdims=2)
340340
energy1,psi1 = dmrg(H,[psi0],psi1_init;nsweeps,maxdim,cutoff,noise,weight)
341341

342342
# Check psi1 is orthogonal to psi0
@@ -357,7 +357,7 @@ let
357357
#
358358
# Compute the second excited state psi2
359359
#
360-
psi2_init = randomMPS(sites;linkdims=2)
360+
psi2_init = random_mps(sites;linkdims=2)
361361
energy2,psi2 = dmrg(H,[psi0,psi1],psi2_init;nsweeps,maxdim,cutoff,noise,weight)
362362

363363
# Check psi2 is orthogonal to psi0 and psi1
@@ -429,7 +429,7 @@ let
429429
a += 0.5,"S-",n,"S+",n+1
430430
end
431431
H = MPO(a,s)
432-
psi0 = randomMPS(s;linkdims=4)
432+
psi0 = random_mps(s;linkdims=4)
433433

434434
nsweeps = 5
435435
maxdim = [10,20,80,160]
@@ -523,7 +523,7 @@ let
523523
a += 0.5,"S-",n,"S+",n+1
524524
end
525525
H = MPO(a,s)
526-
psi0 = randomMPS(s;linkdims=4)
526+
psi0 = random_mps(s;linkdims=4)
527527

528528
nsweeps = 5
529529
maxdim = [10,20,80,160]

docs/src/examples/MPSandMPO.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ let # hide
8888
N = 10
8989
s = siteinds(2,N)
9090
chi = 4
91-
psi = randomMPS(s;linkdims=chi)
91+
psi = random_mps(s;linkdims=chi)
9292
9393
# Make an array of integers of the element we
9494
# want to obtain
@@ -143,7 +143,7 @@ using ITensors, ITensorMPS
143143
N = 10
144144
chi = 4
145145
sites = siteinds("S=1/2",N)
146-
psi = randomMPS(sites;linkdims=chi)
146+
psi = random_mps(sites;linkdims=chi)
147147
magz = expect(psi,"Sz")
148148
for (j,mz) in enumerate(magz)
149149
println("$j $mz")
@@ -362,7 +362,7 @@ N = 10 # number of sites
362362
d = 3 # dimension of each site
363363
chi = 16 # bond dimension of the MPS
364364
s = siteinds(d,N)
365-
psi = randomMPS(s;linkdims=chi)
365+
psi = random_mps(s;linkdims=chi)
366366
```
367367

368368
We can now draw some samples from this MPS as

docs/src/faq/DMRG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ When DMRG is failing to converge, here are some of the steps you can take to imp
9191
up on the left-hand side only, it can take DMRG a very long time to converge.
9292

9393
* Try using a random MPS with a modestly large bond dimension. ITensor offers a function
94-
called [`randomMPS`](@ref) which can be used to make random MPS in both the quantum number (QN)
94+
called [`random_mps`](@ref) which can be used to make random MPS in both the quantum number (QN)
9595
conserving and non-QN conserving cases. Because random MPS have properties
9696
which are "typical" of most ground states, they can be good initial states for DMRG.
9797

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ let
294294
H = MPO(os,sites)
295295

296296
# Create an initial random matrix product state
297-
psi0 = randomMPS(sites)
297+
psi0 = random_mps(sites)
298298

299299
# Plan to do 5 passes or 'sweeps' of DMRG,
300300
# setting maximum MPS internal dimensions

docs/src/tutorials/DMRG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ let
3838
end
3939
H = MPO(os,sites)
4040

41-
psi0 = randomMPS(sites;linkdims=10)
41+
psi0 = random_mps(sites;linkdims=10)
4242

4343
nsweeps = 5
4444
maxdim = [10,20,100,100,200]
@@ -92,7 +92,7 @@ physical indices given by the array `sites`.
9292
The line
9393

9494
```julia
95-
psi0 = randomMPS(sites;linkdims=10)
95+
psi0 = random_mps(sites;linkdims=10)
9696
```
9797

9898
constructs an MPS `psi0` which has the physical indices `sites` and a bond dimension of 10.

docs/src/tutorials/QN_DMRG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ To make change (2), instead of constructing the initial MPS `psi0` to be an arbi
8181
So we will replace the line
8282

8383
```julia
84-
psi0 = randomMPS(sites;linkdims=10)
84+
psi0 = random_mps(sites;linkdims=10)
8585
```
8686

8787
by the lines

ext/ITensorsPackageCompilerExt/precompile_itensors.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using ITensors.ITensorMPS: MPO, OpSum, dmrg, randomMPS, siteinds
1+
using ITensors.ITensorMPS: MPO, OpSum, dmrg, random_mps, siteinds
22

33
# TODO: This uses all of the tests to make
44
# precompile statements, but takes a long time
@@ -19,7 +19,7 @@ function main(; N, dmrg_kwargs)
1919
for conserve_qns in (false, true)
2020
sites = siteinds("S=1", N; conserve_qns)
2121
H = MPO(opsum, sites)
22-
ψ0 = randomMPS(sites, j -> isodd(j) ? "" : ""; linkdims=2)
22+
ψ0 = random_mps(sites, j -> isodd(j) ? "" : ""; linkdims=2)
2323
dmrg(H, ψ0; outputlevel=0, dmrg_kwargs...)
2424
end
2525
return nothing

src/lib/ITensorMPS/examples/autodiff/mps_autodiff.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ h = 0.5
3131

3232
# Loss function only works with `Vector{ITensor}`,
3333
# extract with `ITensors.data`.
34-
ψ0 = ITensors.data(randomMPS(s; linkdims=10))
34+
ψ0 = ITensors.data(random_mps(s; linkdims=10))
3535
H = ITensors.data(MPO(ising(n; J, h), s))
3636

3737
loss(ψ) = loss(H, ψ)

src/lib/ITensorMPS/examples/dmrg/1d_heisenberg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let
2323
H = MPO(os, sites)
2424

2525
# Create an initial random matrix product state
26-
psi0 = randomMPS(sites; linkdims=10)
26+
psi0 = random_mps(sites; linkdims=10)
2727

2828
# Plan to do 5 DMRG sweeps:
2929
nsweeps = 5

src/lib/ITensorMPS/examples/dmrg/1d_heisenberg_conserve_spin.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let
2424
H = MPO(os, sites)
2525

2626
state = [isodd(n) ? "Up" : "Dn" for n in 1:N]
27-
psi0 = randomMPS(sites, state; linkdims=10)
27+
psi0 = random_mps(sites, state; linkdims=10)
2828

2929
# Plan to do 5 DMRG sweeps:
3030
nsweeps = 5

src/lib/ITensorMPS/examples/dmrg/1d_hubbard_extended.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ let
5454
# Initialize wavefunction to be bond
5555
# dimension 10 random MPS with number
5656
# of particles the same as `state`
57-
psi0 = randomMPS(sites, state; linkdims=10)
57+
psi0 = random_mps(sites, state; linkdims=10)
5858

5959
# Check total number of particles:
6060
@show flux(psi0)

src/lib/ITensorMPS/examples/dmrg/1d_ising_with_observer.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ end
2323
let
2424
N = 100
2525
sites = siteinds("S=1/2", N)
26-
psi0 = randomMPS(sites; linkdims=10)
26+
psi0 = random_mps(sites; linkdims=10)
2727

2828
# define parameters for DMRG sweeps
2929
nsweeps = 15

src/lib/ITensorMPS/examples/dmrg/2d_heisenberg_conserve_spin.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let
2222
# Initialize wavefunction to a random MPS
2323
# of bond-dimension 10 with same quantum
2424
# numbers as `state`
25-
psi0 = randomMPS(sites, state; linkdims=20)
25+
psi0 = random_mps(sites, state; linkdims=20)
2626

2727
nsweeps = 10
2828
maxdim = [20, 60, 100, 100, 200, 400, 800]

src/lib/ITensorMPS/examples/dmrg/2d_hubbard_conserve_momentum.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function main(;
7979
display(state)
8080

8181
psi0 = if random_init
82-
randomMPS(itensor_rng, sites, state; linkdims=2)
82+
random_mps(itensor_rng, sites, state; linkdims=2)
8383
else
8484
MPS(sites, state)
8585
end

src/lib/ITensorMPS/examples/dmrg/2d_hubbard_conserve_particles.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function main(; Nx=6, Ny=3, U=4.0, t=1.0)
3030
# Initialize wavefunction to a random MPS
3131
# of bond-dimension 10 with same quantum
3232
# numbers as `state`
33-
psi0 = randomMPS(sites, state)
33+
psi0 = random_mps(sites, state)
3434

3535
energy, psi = dmrg(H, psi0; nsweeps, maxdim, cutoff, noise)
3636
@show t, U

src/lib/ITensorMPS/examples/dmrg/threaded_blocksparse/2d_hubbard_conserve_momentum.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function main(;
5858
end
5959
display(state)
6060

61-
psi0 = randomMPS(sites, state; linkdims=10)
61+
psi0 = random_mps(sites, state; linkdims=10)
6262

6363
energy, psi = @time dmrg(H, psi0; nsweeps, maxdim, cutoff, noise, outputlevel)
6464

src/lib/ITensorMPS/examples/dmrg/write_to_disk/1d_heisenberg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let
2121
H = MPO(os, sites)
2222

2323
state = [isodd(n) ? "Up" : "Dn" for n in 1:N]
24-
psi0 = randomMPS(sites, state; linkdims=10)
24+
psi0 = random_mps(sites, state; linkdims=10)
2525

2626
# Plan to do 5 DMRG sweeps:
2727
nsweeps = 5

src/lib/ITensorMPS/examples/exact_diagonalization/exact_diagonalization.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function main(n; blas_num_threads=Sys.CPU_THREADS, fuse=true, binary=true)
3030
s = siteinds("S=1/2", n; conserve_qns=true)
3131
H = MPO(heisenberg(n), s)
3232
initstate(j) = isodd(j) ? "" : ""
33-
ψ0 = randomMPS(s, initstate; linkdims=10)
33+
ψ0 = random_mps(s, initstate; linkdims=10)
3434

3535
edmrg, ψdmrg = dmrg(H, ψ0; nsweeps=10, cutoff=1e-6)
3636

src/lib/ITensorMPS/examples/finite_temperature/metts.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function main(; N=10, cutoff=1E-8, δτ=0.1, beta=2.0, NMETTS=3000, Nwarm=10)
5151
Ry_gates = ops([("Ry", n, (θ=π / 2,)) for n in 1:N], s)
5252

5353
# Arbitrary initial state
54-
psi = randomMPS(s)
54+
psi = random_mps(s)
5555

5656
# Make H for measuring the energy
5757
terms = OpSum()

src/lib/ITensorMPS/examples/mps_mpo_algebra/mps_density_matrix.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ N = 4
44
nmps = 3
55
cutoff = 1e-8
66
s = siteinds("S=1/2", N)
7-
ψs = [randomMPS(s; linkdims=2) for _ in 1:nmps]
7+
ψs = [random_mps(s; linkdims=2) for _ in 1:nmps]
88
ρs = [outer(ψ, ψ; cutoff) for ψ in ψs]
99
ρ = sum(ρs; cutoff)
1010

0 commit comments

Comments
 (0)