Skip to content

Commit

Permalink
[ITensors] Start organizing into submodules (#1400)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman committed Apr 29, 2024
1 parent 7329ffe commit ff6a871
Show file tree
Hide file tree
Showing 110 changed files with 1,661 additions and 1,478 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ITensors"
uuid = "9136182c-28ba-11e9-034c-db9fb085ebd5"
authors = ["Matthew Fishman <mfishman@flatironinstitute.org>", "Miles Stoudenmire <mstoudenmire@flatironinstitute.org>"]
version = "0.4.0"
version = "0.4.1"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
2 changes: 0 additions & 2 deletions ext/ITensorsHDF5Ext/ITensorsHDF5Ext.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module ITensorsHDF5Ext

include("index.jl")
include("itensor.jl")
include("qnindex.jl")
Expand All @@ -8,5 +7,4 @@ include("qn.jl")
include("tagset.jl")
include("ITensorMPS/mps.jl")
include("ITensorMPS/mpo.jl")

end
2 changes: 1 addition & 1 deletion ext/ITensorsHDF5Ext/tagset.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using HDF5: HDF5, attributes, create_group, open_group, read, write
using ITensors: TagSet, tagstring
using ITensors.TagSets: TagSet, tagstring

function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, T::TagSet)
g = create_group(parent, name)
Expand Down
125 changes: 98 additions & 27 deletions src/ITensors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,65 +51,136 @@ Documentation: https://itensor.github.io/ITensors.jl/stable/
module ITensors
include("usings.jl")
include("utils.jl")
include("lib/ContractionSequenceOptimization/ContractionSequenceOptimization.jl")
include("lib/ContractionSequenceOptimization/src/ContractionSequenceOptimization.jl")
# TODO: `using .ContractionSequenceOptimization: ContractionSequenceOptimization, ...`.
using .ContractionSequenceOptimization
include("lib/LazyApply/LazyApply.jl")
include("lib/LazyApply/src/LazyApply.jl")
# TODO: `using .LazyApply: LazyApply, ...`.
using .LazyApply
include("lib/Ops/Ops.jl")
using .LazyApply: Prod, Scaled, Sum, coefficient
export Prod, Scaled, Sum, coefficient
include("lib/Ops/src/Ops.jl")
# TODO: `using .Ops: Ops, ...`.
using .Ops
using .Ops: Ops, Op, Trotter
import .Ops: sites, name
export Ops, Op, Trotter
include("exports.jl")
include("imports.jl")
include("global_variables.jl")
# TODO: Move to `lib/LastVals/src/LastVals.jl`.
include("lastval.jl")
include("smallstring.jl")
include("lib/SmallStrings/src/SmallStrings.jl")
using .SmallStrings: SmallStrings, IntChar, SmallString, Tag, isint, isnull
include("readwrite.jl")
export readcpp
# TODO: Move to `lib/Nots/src/Nots.jl`.
include("not.jl")
include("tagset.jl")
include("arrow.jl")
export not
include("lib/TagSets/src/TagSets.jl")
using .TagSets: TagSets, set_strict_tags!, using_strict_tags
# TODO: Move to `lib/Names/src/Names.jl`.
include("name.jl")
# TODO: Move to `lib/Vals/src/Vals.jl`.
include("val.jl")
export val
include("lib/QuantumNumbers/src/QuantumNumbers.jl")
using .QuantumNumbers:
Arrow,
In,
Neither,
Out,
QN,
QNVal,
hasname,
have_same_mods,
have_same_qns,
isactive,
maxQNs,
modulus,
nactive
export QN, isactive, modulus
include("symmetrystyle.jl")
include("index.jl")
include("set_operations.jl")
include("indexset.jl")
include("itensor.jl")
include("qn/flux.jl")
include("oneitensor.jl")
include("tensor_operations/tensor_algebra.jl")
include("tensor_operations/matrix_algebra.jl")
include("tensor_operations/permutations.jl")
include("lib/SiteTypes/src/SiteTypes.jl")
using .SiteTypes:
SiteTypes,
OpName,
SiteType,
StateName,
TagType,
ValName,
@OpName_str,
@SiteType_str,
@StateName_str,
@TagType_str,
@ValName_str,
alias,
has_fermion_string,
op,
op!,
ops,
state
export OpName,
SiteType,
StateName,
TagType,
ValName,
@OpName_str,
@SiteType_str,
@StateName_str,
@TagType_str,
@ValName_str,
has_fermion_string,
op,
ops,
state,
val
include("lib/ITensorsSiteTypesExt/src/ITensorsSiteTypesExt.jl")
include("broadcast.jl")
include("tensor_operations/matrix_decomposition.jl")
include("adapt.jl")
include("set_types.jl")
include("tensor_operations/itensor_combiner.jl")
include("qn/flux.jl")
include("qn/qn.jl")
include("qn/qnindex.jl")
include("qn/qnindexset.jl")
include("qn/qnitensor.jl")
include("nullspace.jl")
include("lib/Ops/ops_itensor.jl")
include("physics/sitetype.jl")
include("physics/lattices.jl")
include("physics/site_types/aliases.jl")
include("physics/site_types/generic_sites.jl")
include("physics/site_types/qubit.jl")
include("physics/site_types/spinhalf.jl")
include("physics/site_types/spinone.jl")
include("physics/site_types/fermion.jl")
include("physics/site_types/electron.jl")
include("physics/site_types/tj.jl")
include("physics/site_types/qudit.jl")
include("physics/site_types/boson.jl")
include("physics/fermions.jl")
include("lib/ITensorMPS/ITensorMPS.jl")
include("lib/ITensorsOpsExt/src/ITensorsOpsExt.jl")
include("fermions/fermions.jl")
export fparity, isfermionic
include("lib/ITensorMPS/src/ITensorMPS.jl")
# TODO: `using .ITensorMPS: ITensorMPS, ...` and
# explicit export list.
@reexport using .ITensorMPS
include("lib/ITensorsNamedDimsArraysExt/src/ITensorsNamedDimsArraysExt.jl")
using .ITensorsNamedDimsArraysExt: ITensorsNamedDimsArraysExt
include("lib/Ops/trotter.jl")
include("lib/ITensorChainRules/ITensorChainRules.jl")
include("lib/ITensorNetworkMaps/ITensorNetworkMaps.jl")
include("lib/ITensorVisualizationCore/ITensorVisualizationCore.jl")
include("lib/ITensorChainRules/src/ITensorChainRules.jl")
include("lib/ITensorNetworkMaps/src/ITensorNetworkMaps.jl")
include("lib/ITensorVisualizationCore/src/ITensorVisualizationCore.jl")
# TODO: `using .ITensorVisualizationCore: ITensorVisualizationCore, ...`.
using .ITensorVisualizationCore
using .ITensorVisualizationCore:
@visualize,
@visualize!,
@visualize_noeval,
@visualize_noeval!,
@visualize_sequence,
@visualize_sequence_noeval
export @visualize,
@visualize!,
@visualize_noeval,
@visualize_noeval!,
@visualize_sequence,
@visualize_sequence_noeval
include("deprecated.jl")
include("argsdict/argsdict.jl")
include("packagecompile/compile.jl")
Expand Down
78 changes: 0 additions & 78 deletions src/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ export
# LinearAlgebra
nullspace,
tr,

# Modules
LinearAlgebra,
NDTensors,

# NDTensors module
# Types
Block,
Expand All @@ -19,22 +17,10 @@ export
truncerror,
# Deprecated
addblock!,

# ITensorVisualizationCore module
# Macros
@visualize,
@visualize!,
@visualize_noeval,
@visualize_noeval!,
@visualize_sequence,
@visualize_sequence_noeval,

# ITensors.jl
index_id_rng,

# argsdict/argsdict.jl
argsdict,

# tensor_operations/matrix_decomposition.jl
eigen,
factorize,
Expand All @@ -45,18 +31,14 @@ export
ql,
svd,
diag,

# tensor_operations/tensor_algebra.jl
contract,

# global_variables.jl
# Methods

# Macros
@disable_warn_order,
@reset_warn_order,
@set_warn_order,

# index.jl
# Types
Index,
Expand Down Expand Up @@ -90,8 +72,6 @@ export
space,
splitblocks,
tags,
val,

# indexset.jl
# Types
IndexSet,
Expand All @@ -118,7 +98,6 @@ export
swapinds,
swapprime,
swaptags,

# itensor.jl
# Types
ITensor,
Expand Down Expand Up @@ -199,13 +178,6 @@ export
unionind,
vector,
emptyITensor,

# not.jl
not,

# readwrite.jl
readcpp,

# tagset.jl
# Types
TagSet,
Expand All @@ -214,60 +186,10 @@ export
# Methods
addtags,
hastags,

# LazyApply/LazyApply.jl
Scaled,
Sum,
Prod,
coefficient,

# Ops/Ops.jl
Ops,
Op,

# Ops/trotter.jl
Trotter,

# physics/autompo.jl
AutoMPO,
OpSum,
add!,

# physics/fermions.jl
fparity,
isfermionic,

# physics/lattices.jl
Lattice,
LatticeBond,
square_lattice,
triangular_lattice,

# physics/sitetype.jl
SiteType,
@SiteType_str,
StateName,
@StateName_str,
op,
ops,
OpName,
@OpName_str,
ValName,
@ValName_str,
state,
TagType,
@TagType_str,
has_fermion_string,

# qn/qn.jl
# Types
QN,
# Methods
isactive,
isfermionic,
modulus,
val,

# qn/qnindex.jl
blockdim,
flux,
Expand Down
7 changes: 4 additions & 3 deletions src/physics/fermions.jl → src/fermions/fermions.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using .QuantumNumbers: QuantumNumbers, QN

"""
parity_sign(P)
Expand All @@ -19,7 +20,7 @@ function parity_sign(P)::Int
return s
end

isfermionic(qv::QNVal) = (modulus(qv) < 0)
isfermionic(qv::QuantumNumbers.QNVal) = (QuantumNumbers.modulus(qv) < 0)

isfermionic(qn::QN) = any(isfermionic, qn)

Expand Down Expand Up @@ -326,7 +327,7 @@ function NDTensors.before_combiner_signs(
end

return T
end #NDTensors.before_combiner_signs
end

function NDTensors.after_combiner_signs(
R, labelsR, indsR::NTuple{NR,QNIndex}, C, labelsC, indsC::NTuple{NC,QNIndex}
Expand Down Expand Up @@ -374,4 +375,4 @@ function NDTensors.after_combiner_signs(
end

return R
end #NDTensors.after_combiner_signs
end
Loading

2 comments on commit ff6a871

@mtfishman
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/105779

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.1 -m "<description of version>" ff6a871f760d8f335cee1aea01d8c103b5e23a01
git push origin v0.4.1

Please sign in to comment.