Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .JuliaFormatter.toml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "CompatHelper"

on:
schedule:
- cron: 0 0 * * *
- cron: '0 0 * * *'
workflow_dispatch:
permissions:
contents: write
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: "Format Check"

on:
push:
branches:
- 'main'
tags: '*'
pull_request:
pull_request_target:
paths: ['**/*.jl']
types: [opened, synchronize, reopened, ready_for_review]

permissions:
contents: read
actions: write
pull-requests: write

jobs:
format-check:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
.vscode/
Manifest.toml
benchmark/*.json
dev/
docs/LocalPreferences.toml
docs/Manifest.toml
docs/build/
docs/src/index.md
examples/LocalPreferences.toml
test/LocalPreferences.toml
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ci:
skip: [julia-formatter]
skip: [runic]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -11,7 +11,7 @@ repos:
- id: end-of-file-fixer
exclude_types: [markdown] # incompatible with Literate.jl

- repo: "https://github.com/domluna/JuliaFormatter.jl"
rev: v2.1.6
- repo: https://github.com/fredrikekre/runic-pre-commit
rev: v2.0.1
hooks:
- id: "julia-formatter"
- id: runic
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ITensorMPS"
uuid = "0d1a4710-d33b-49a5-8f18-73bdf49b47e2"
authors = ["Matthew Fishman <[email protected]>", "Miles Stoudenmire <[email protected]>"]
version = "0.3.21"
version = "0.3.22"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
66 changes: 33 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,39 +52,39 @@ the behavior of quantum systems.
````julia
using ITensors, ITensorMPS
let
# Create 100 spin-one indices
N = 100
sites = siteinds("S=1", N)

# Input operator terms which define
# a Hamiltonian matrix, and convert
# these terms to an MPO tensor network
# (here we make the 1D Heisenberg model)
os = OpSum()
for j in 1:(N - 1)
os += "Sz", j, "Sz", j + 1
os += 0.5, "S+", j, "S-", j + 1
os += 0.5, "S-", j, "S+", j + 1
end
H = MPO(os, sites)

# Create an initial random matrix product state
psi0 = random_mps(sites)

# Plan to do 5 passes or 'sweeps' of DMRG,
# setting maximum MPS internal dimensions
# for each sweep and maximum truncation cutoff
# used when adapting internal dimensions:
nsweeps = 5
maxdim = [10, 20, 100, 100, 200]
cutoff = 1E-10

# Run the DMRG algorithm, returning energy
# (dominant eigenvalue) and optimized MPS
energy, psi = dmrg(H, psi0; nsweeps, maxdim, cutoff)
println("Final energy = $energy")

nothing
# Create 100 spin-one indices
N = 100
sites = siteinds("S=1", N)

# Input operator terms which define
# a Hamiltonian matrix, and convert
# these terms to an MPO tensor network
# (here we make the 1D Heisenberg model)
os = OpSum()
for j in 1:(N - 1)
os += "Sz", j, "Sz", j + 1
os += 0.5, "S+", j, "S-", j + 1
os += 0.5, "S-", j, "S+", j + 1
end
H = MPO(os, sites)

# Create an initial random matrix product state
psi0 = random_mps(sites)

# Plan to do 5 passes or 'sweeps' of DMRG,
# setting maximum MPS internal dimensions
# for each sweep and maximum truncation cutoff
# used when adapting internal dimensions:
nsweeps = 5
maxdim = [10, 20, 100, 100, 200]
cutoff = 1.0e-10

# Run the DMRG algorithm, returning energy
# (dominant eigenvalue) and optimized MPS
energy, psi = dmrg(H, psi0; nsweeps, maxdim, cutoff)
println("Final energy = $energy")

nothing
end

# output
Expand Down
88 changes: 44 additions & 44 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,54 @@ using ITensorMPS
using ITensors
using Documenter: Documenter, DocMeta, deploydocs, makedocs

DocMeta.setdocmeta!(ITensorMPS, :DocTestSetup, :(using ITensorMPS); recursive=true)
DocMeta.setdocmeta!(ITensors, :DocTestSetup, :(using ITensors); recursive=true)
DocMeta.setdocmeta!(ITensorMPS, :DocTestSetup, :(using ITensorMPS); recursive = true)
DocMeta.setdocmeta!(ITensors, :DocTestSetup, :(using ITensors); recursive = true)

include("make_index.jl")

makedocs(;
# Allows using ITensors.jl docstrings in ITensorMPS.jl documentation:
# https://github.com/JuliaDocs/Documenter.jl/issues/1734
modules=[ITensorMPS, ITensors],
authors="ITensor developers <[email protected]> and contributors",
sitename="ITensorMPS.jl",
format=Documenter.HTML(;
canonical="https://itensor.github.io/ITensorMPS.jl",
edit_link="main",
assets=["assets/favicon.ico", "assets/extras.css"],
prettyurls=false,
),
pages=[
"Home" => "index.md",
"Tutorials" => [
"DMRG" => "tutorials/DMRG.md",
"Quantum Number Conserving DMRG" => "tutorials/QN_DMRG.md",
"MPS Time Evolution" => "tutorials/MPSTimeEvolution.md",
# Allows using ITensors.jl docstrings in ITensorMPS.jl documentation:
# https://github.com/JuliaDocs/Documenter.jl/issues/1734
modules = [ITensorMPS, ITensors],
authors = "ITensor developers <[email protected]> and contributors",
sitename = "ITensorMPS.jl",
format = Documenter.HTML(;
canonical = "https://itensor.github.io/ITensorMPS.jl",
edit_link = "main",
assets = ["assets/favicon.ico", "assets/extras.css"],
prettyurls = false,
),
pages = [
"Home" => "index.md",
"Tutorials" => [
"DMRG" => "tutorials/DMRG.md",
"Quantum Number Conserving DMRG" => "tutorials/QN_DMRG.md",
"MPS Time Evolution" => "tutorials/MPSTimeEvolution.md",
],
"Code Examples" => [
"MPS and MPO Examples" => "examples/MPSandMPO.md",
"DMRG Examples" => "examples/DMRG.md",
"Physics (SiteType) System Examples" => "examples/Physics.md",
],
"Documentation" => [
"MPS and MPO" => "MPSandMPO.md",
"SiteType and op, state, val functions" => "SiteType.md",
"SiteTypes Included with ITensor" => "IncludedSiteTypes.md",
"DMRG" => [
"DMRG.md",
"Sweeps.md",
"ProjMPO.md",
"ProjMPOSum.md",
"Observer.md",
"DMRGObserver.md",
],
"OpSum" => "OpSum.md",
],
"Frequently Asked Questions" =>
["DMRG FAQs" => "faq/DMRG.md", "Quantum Number (QN) FAQs" => "faq/QN.md"],
"HDF5 File Formats" => "HDF5FileFormats.md",
],
"Code Examples" => [
"MPS and MPO Examples" => "examples/MPSandMPO.md",
"DMRG Examples" => "examples/DMRG.md",
"Physics (SiteType) System Examples" => "examples/Physics.md",
],
"Documentation" => [
"MPS and MPO" => "MPSandMPO.md",
"SiteType and op, state, val functions" => "SiteType.md",
"SiteTypes Included with ITensor" => "IncludedSiteTypes.md",
"DMRG" => [
"DMRG.md",
"Sweeps.md",
"ProjMPO.md",
"ProjMPOSum.md",
"Observer.md",
"DMRGObserver.md",
],
"OpSum" => "OpSum.md",
],
"Frequently Asked Questions" =>
["DMRG FAQs" => "faq/DMRG.md", "Quantum Number (QN) FAQs" => "faq/QN.md"],
"HDF5 File Formats" => "HDF5FileFormats.md",
],
warnonly=true,
warnonly = true,
)

deploydocs(; repo="github.com/ITensor/ITensorMPS.jl", devbranch="main", push_preview=true)
deploydocs(; repo = "github.com/ITensor/ITensorMPS.jl", devbranch = "main", push_preview = true)
16 changes: 8 additions & 8 deletions docs/make_index.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ using Literate: Literate
using ITensorMPS: ITensorMPS

function ccq_logo(content)
include_ccq_logo = """
include_ccq_logo = """
```@raw html
<img class="display-light-only" src="assets/CCQ.png" width="20%" alt="Flatiron Center for Computational Quantum Physics logo."/>
<img class="display-dark-only" src="assets/CCQ-dark.png" width="20%" alt="Flatiron Center for Computational Quantum Physics logo."/>
```
"""
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
return content
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
return content
end

Literate.markdown(
joinpath(pkgdir(ITensorMPS), "examples", "README.jl"),
joinpath(pkgdir(ITensorMPS), "docs", "src");
flavor=Literate.DocumenterFlavor(),
name="index",
postprocess=ccq_logo,
joinpath(pkgdir(ITensorMPS), "examples", "README.jl"),
joinpath(pkgdir(ITensorMPS), "docs", "src");
flavor = Literate.DocumenterFlavor(),
name = "index",
postprocess = ccq_logo,
)
16 changes: 8 additions & 8 deletions docs/make_readme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ using Literate: Literate
using ITensorMPS: ITensorMPS

function ccq_logo(content)
include_ccq_logo = """
include_ccq_logo = """
<picture>
<source media="(prefers-color-scheme: dark)" width="20%" srcset="docs/src/assets/CCQ-dark.png">
<img alt="Flatiron Center for Computational Quantum Physics logo." width="20%" src="docs/src/assets/CCQ.png">
</picture>
"""
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
return content
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
return content
end

Literate.markdown(
joinpath(pkgdir(ITensorMPS), "examples", "README.jl"),
joinpath(pkgdir(ITensorMPS));
flavor=Literate.CommonMarkFlavor(),
name="README",
postprocess=ccq_logo,
joinpath(pkgdir(ITensorMPS), "examples", "README.jl"),
joinpath(pkgdir(ITensorMPS));
flavor = Literate.CommonMarkFlavor(),
name = "README",
postprocess = ccq_logo,
)
84 changes: 42 additions & 42 deletions docs/src/tutorials/tebd.jl
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
using ITensors, ITensorMPS

let
N = 100
cutoff = 1E-8
tau = 0.1
ttotal = 5.0

# Make an array of 'site' indices
s = siteinds("S=1/2", N; conserve_qns=true)

# Make gates (1,2),(2,3),(3,4),...
gates = ITensor[]
for j in 1:(N - 1)
s1 = s[j]
s2 = s[j + 1]
hj =
op("Sz", s1) * op("Sz", s2) +
1 / 2 * op("S+", s1) * op("S-", s2) +
1 / 2 * op("S-", s1) * op("S+", s2)
Gj = exp(-1.0im * tau / 2 * hj)
push!(gates, Gj)
end
# Include gates in reverse order too
# (N,N-1),(N-1,N-2),...
append!(gates, reverse(gates))

# Initialize psi to be a product state (alternating up and down)
psi = MPS(s, n -> isodd(n) ? "Up" : "Dn")

c = div(N, 2) # center site

# Compute and print <Sz> at each time step
# then apply the gates to go to the next time
for t in 0.0:tau:ttotal
Sz = expect(psi, "Sz"; sites=c)
println("$t $Sz")

t ≈ ttotal && break

psi = apply(gates, psi; cutoff)
normalize!(psi)
end

return nothing
N = 100
cutoff = 1.0e-8
tau = 0.1
ttotal = 5.0

# Make an array of 'site' indices
s = siteinds("S=1/2", N; conserve_qns = true)

# Make gates (1,2),(2,3),(3,4),...
gates = ITensor[]
for j in 1:(N - 1)
s1 = s[j]
s2 = s[j + 1]
hj =
op("Sz", s1) * op("Sz", s2) +
1 / 2 * op("S+", s1) * op("S-", s2) +
1 / 2 * op("S-", s1) * op("S+", s2)
Gj = exp(-1.0im * tau / 2 * hj)
push!(gates, Gj)
end
# Include gates in reverse order too
# (N,N-1),(N-1,N-2),...
append!(gates, reverse(gates))

# Initialize psi to be a product state (alternating up and down)
psi = MPS(s, n -> isodd(n) ? "Up" : "Dn")

c = div(N, 2) # center site

# Compute and print <Sz> at each time step
# then apply the gates to go to the next time
for t in 0.0:tau:ttotal
Sz = expect(psi, "Sz"; sites = c)
println("$t $Sz")

t ≈ ttotal && break

psi = apply(gates, psi; cutoff)
normalize!(psi)
end

return nothing
end
Loading
Loading