Skip to content

Commit

Permalink
1) Remove the reciprocals field in Lattice; 2) Remove `@translati…
Browse files Browse the repository at this point in the history
…ons_str`, add support of unit ranges for `Translations`; 3) Add support of construction of concrete `Momentum`s by reciprocal vectors; 4) Add support of `update!` the `expression` field of `AnalyticalExpressions.`
  • Loading branch information
waltergu committed Nov 2, 2022
1 parent 8b26775 commit bcc2d50
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 130 deletions.
4 changes: 2 additions & 2 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[deps.RecipesBase]]
deps = ["SnoopPrecompile"]
git-tree-sha1 = "612a4d76ad98e9722c8ba387614539155a59e30c"
git-tree-sha1 = "d12e612bba40d189cead6ff857ddb67bd2e6a387"
uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
version = "1.3.0"
version = "1.3.1"

[[deps.Requires]]
deps = ["UUIDs"]
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "QuantumLattices"
uuid = "78ae1a1f-1d5d-5174-b61c-66e31b2346dc"
authors = ["waltergu <[email protected]>"]
version = "0.9.2"
version = "0.9.3"

[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Expand Down
54 changes: 27 additions & 27 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ uuid = "a4c015fc-c6ff-483c-b24f-f7ea428134e9"
version = "0.0.1"

[[deps.AbstractTrees]]
git-tree-sha1 = "5c0b629df8a5566a06f5fef5100b53ea56e465a0"
git-tree-sha1 = "52b3b436f8f73133d7bc3a6c71ee7ed6ab2ab754"
uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
version = "0.4.2"
version = "0.4.3"

[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
Expand Down Expand Up @@ -95,9 +95,9 @@ uuid = "3709ef60-1bee-4518-9f2f-acd86f176c50"
version = "0.2.0"

[[deps.CommonSolve]]
git-tree-sha1 = "332a332c97c7071600984b3c31d9067e1a4e6e25"
git-tree-sha1 = "9441451ee712d1aec22edad62db1a9af3dc8d852"
uuid = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"
version = "0.2.1"
version = "0.2.3"

[[deps.Compat]]
deps = ["Dates", "LinearAlgebra", "UUIDs"]
Expand Down Expand Up @@ -142,9 +142,9 @@ uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"

[[deps.DocStringExtensions]]
deps = ["LibGit2"]
git-tree-sha1 = "5158c2b41018c5f7eb1470d558127ac274eca0c9"
git-tree-sha1 = "c36550cb29cbe373e95b3f40486b9a4148f89ffd"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.9.1"
version = "0.9.2"

[[deps.Documenter]]
deps = ["ANSIColoredPrinters", "Base64", "Dates", "DocStringExtensions", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
Expand Down Expand Up @@ -222,9 +222,9 @@ version = "3.3.8+0"

[[deps.GR]]
deps = ["Base64", "DelimitedFiles", "GR_jll", "HTTP", "JSON", "Libdl", "LinearAlgebra", "Pkg", "Preferences", "Printf", "Random", "Serialization", "Sockets", "Test", "UUIDs"]
git-tree-sha1 = "a9ec6a35bc5ddc3aeb8938f800dc599e652d0029"
git-tree-sha1 = "00a9d4abadc05b9476e937a5557fcce476b9e547"
uuid = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
version = "0.69.3"
version = "0.69.5"

[[deps.GR_jll]]
deps = ["Artifacts", "Bzip2_jll", "Cairo_jll", "FFMPEG_jll", "Fontconfig_jll", "GLFW_jll", "JLLWrappers", "JpegTurbo_jll", "Libdl", "Libtiff_jll", "Pixman_jll", "Pkg", "Qt5Base_jll", "Zlib_jll", "libpng_jll"]
Expand Down Expand Up @@ -257,9 +257,9 @@ version = "1.0.2"

[[deps.Gumbo]]
deps = ["AbstractTrees", "Gumbo_jll", "Libdl"]
git-tree-sha1 = "a4b03190a8d79e95b2f418df44f74cbc34289920"
git-tree-sha1 = "a1a138dfbf9df5bace489c7a9d5196d6afdfa140"
uuid = "708ec375-b3d6-5a57-a7ce-8257bf98657a"
version = "0.8.1"
version = "0.8.2"

[[deps.Gumbo_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
Expand All @@ -269,9 +269,9 @@ version = "0.10.2+0"

[[deps.HTTP]]
deps = ["Base64", "CodecZlib", "Dates", "IniFile", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"]
git-tree-sha1 = "4abede886fcba15cd5fd041fef776b230d004cee"
git-tree-sha1 = "a97d47758e933cd5fe5ea181d178936a9fc60427"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "1.4.0"
version = "1.5.1"

[[deps.HarfBuzz_jll]]
deps = ["Artifacts", "Cairo_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "Graphite2_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Pkg"]
Expand Down Expand Up @@ -459,9 +459,9 @@ uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[deps.MbedTLS]]
deps = ["Dates", "MbedTLS_jll", "MozillaCACerts_jll", "Random", "Sockets"]
git-tree-sha1 = "6872f9594ff273da6d13c7c1a1545d5a8c7d0c1c"
git-tree-sha1 = "03a9b9718f5682ecb107ac9f7308991db4ce395b"
uuid = "739be429-bea8-5141-9913-cc70e7f3736d"
version = "1.1.6"
version = "1.1.7"

[[deps.MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
Expand Down Expand Up @@ -520,9 +520,9 @@ version = "8.9.0+1"

[[deps.OpenSSL]]
deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"]
git-tree-sha1 = "ebe81469e9d7b471d7ddb611d9e147ea16de0add"
git-tree-sha1 = "3c3c4a401d267b04942545b1e964a20279587fd7"
uuid = "4d8831e6-92b7-49fb-bdf8-b643e874388c"
version = "1.2.1"
version = "1.3.0"

[[deps.OpenSSL_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
Expand Down Expand Up @@ -554,9 +554,9 @@ version = "10.40.0+0"

[[deps.Parsers]]
deps = ["Dates"]
git-tree-sha1 = "3d5bf43e3e8b412656404ed9466f1dcbf7c50269"
git-tree-sha1 = "6c01a9b494f6d2a9fc180a08b182fcb06f0958a0"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.4.0"
version = "2.4.2"

[[deps.Pipe]]
git-tree-sha1 = "6842804e7867b115ca9de748a0cf6b364523c16d"
Expand All @@ -576,9 +576,9 @@ version = "1.8.0"

[[deps.PlotThemes]]
deps = ["PlotUtils", "Statistics"]
git-tree-sha1 = "8162b2f8547bc23876edd0c5181b27702ae58dce"
git-tree-sha1 = "1f03a2d339f42dca4a4da149c7e15e9b896ad899"
uuid = "ccf2f8ad-2431-5c83-bf29-c5338b663b6a"
version = "3.0.0"
version = "3.1.0"

[[deps.PlotUtils]]
deps = ["ColorSchemes", "Colors", "Dates", "Printf", "Random", "Reexport", "SnoopPrecompile", "Statistics"]
Expand All @@ -588,9 +588,9 @@ version = "1.3.1"

[[deps.Plots]]
deps = ["Base64", "Contour", "Dates", "Downloads", "FFMPEG", "FixedPointNumbers", "GR", "JLFzf", "JSON", "LaTeXStrings", "Latexify", "LinearAlgebra", "Measures", "NaNMath", "Pkg", "PlotThemes", "PlotUtils", "Printf", "REPL", "Random", "RecipesBase", "RecipesPipeline", "Reexport", "RelocatableFolders", "Requires", "Scratch", "Showoff", "SnoopPrecompile", "SparseArrays", "Statistics", "StatsBase", "UUIDs", "UnicodeFun", "Unzip"]
git-tree-sha1 = "65451f70d8d71bd9d06821c7a53adbed162454c9"
git-tree-sha1 = "8c5643a30c97e02f4e80b9fff99544f64292eb6f"
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
version = "1.35.2"
version = "1.35.7"

[[deps.Preferences]]
deps = ["TOML"]
Expand Down Expand Up @@ -628,15 +628,15 @@ uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[deps.RecipesBase]]
deps = ["SnoopPrecompile"]
git-tree-sha1 = "612a4d76ad98e9722c8ba387614539155a59e30c"
git-tree-sha1 = "d12e612bba40d189cead6ff857ddb67bd2e6a387"
uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
version = "1.3.0"
version = "1.3.1"

[[deps.RecipesPipeline]]
deps = ["Dates", "NaNMath", "PlotUtils", "RecipesBase"]
git-tree-sha1 = "017f217e647cf20b0081b9be938b78c3443356a0"
deps = ["Dates", "NaNMath", "PlotUtils", "RecipesBase", "SnoopPrecompile"]
git-tree-sha1 = "249df6fb3520492092ccebe921829920215ab205"
uuid = "01d81517-befc-4cb6-b9ec-a95719d0359c"
version = "0.6.6"
version = "0.6.9"

[[deps.Reexport]]
git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
Expand Down
15 changes: 12 additions & 3 deletions docs/src/unitcell description framework/SpatialInfoOfAUnitcell.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ The first step toward the complete description of a quantum lattice system is th

In general, a lattice has translation symmetry. This symmetry introduces an equivalence relation for the points in a lattice when they can be translated into each other by multiple times of the translation vectors. This observation sets the mathematical foundation of the unitcell construction. As a result, it is enough for a lattice to restrict all points within the origin unitcell together with the translation vectors.

[`Lattice`](@ref) is the simplest structure to encode all the spatial information within the origin unitcell. Apparently, it must contain all the coordinates of the points in the origin unitcell and the translation vectors of the lattice. Other stuff appears to be useful as well, such as the name of the lattice and the reciprocals dual to the translation vectors. Therefore, in this package, [`Lattice`](@ref) has four attributes:
[`Lattice`](@ref) is the simplest structure to encode all the spatial information within the origin unitcell. Apparently, it must contain all the coordinates of the points in the origin unitcell and the translation vectors of the lattice. It also appears to be useful to associate a lattice with a name. Therefore, in this package, [`Lattice`](@ref) has three attributes:
* `name::Symbol`: the name of the lattice
* `coordinates::Matrix{<:Number}`: the coordinates of the points within the origin unitcell
* `vectors::Vector{<:StaticArraysCore.SVector}`: the translation vectors of the lattice
* `reciprocals::Vector{<:StaticArraysCore.SVector}`: the reciprocals dual to the translation vectors

[`Lattice`](@ref) can be constructed by offering the coordinates, with optional keyword arguments to specify its name and translation vectors:
```jldoctest unitcell
Expand Down Expand Up @@ -49,7 +48,7 @@ Lattice(Cube)
[0.0, 1.0, 0.0]
[0.0, 0.0, 1.0]
```
The coordinates could be specified by vectors or tuples. It is noted that the `reciprocals` attribute need not be assigned because it can be deduced from the input `vectors`.
The coordinates could be specified by vectors or tuples.

Iteration over a lattice will get the coordinates of the points in it:
```jldoctest unitcell
Expand All @@ -69,6 +68,16 @@ julia> collect(lattice)
[0.5, 0.5]
```

The reciprocal translation vectors of the dual lattice can be obtained by [`reciprocals`](@ref):
```jldoctest unitcell
julia> lattice = Lattice((0.0, 0.0); vectors=[[1.0, 0.0], [0.0, 1.0]]);
julia> reciprocals(lattice)
2-element Vector{StaticArraysCore.SVector{2, Float64}}:
[6.283185307179586, -0.0]
[-0.0, 6.283185307179586]
```

## Request for the bonds of a lattice

Before the introduction of how to obtain the bonds of a lattice, let's discuss more about the unitcell construction to clarify the logic behind the definitions of the [`Point`](@ref) type and the [`Bond`](@ref) type in this package.
Expand Down
2 changes: 2 additions & 0 deletions src/Frameworks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ mutable struct AnalyticalExpression{F<:Function, P<:Parameters} <: Representatio
end
@inline function update!(expression::AnalyticalExpression; parameters...)
expression.parameters = update(expression.parameters; parameters...)
update!(expression.expression; parameters...)
return expression
end
@inline update!(expression::Function; parameters...) = expression
@inline Parameters(expression::AnalyticalExpression) = expression.parameters
@inline (expression::AnalyticalExpression)(; kwargs...) = expression.expression(values(expression.parameters)...; kwargs...)

Expand Down
2 changes: 1 addition & 1 deletion src/QuantumLattices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export particlenumbers, periods, spinfulparticles, spinzs, @abeliannumber
include("Spatials.jl")
using .Spatials
export azimuth, azimuthd, distance, isintratriangle, isonline, isparallel, issubordinate, interlinks, minimumlengths, polar, polard, reciprocals, rotate, translate, tile, volume
export AbstractLattice, Bond, BrillouinZone, Lattice, Neighbors, Point, ReciprocalSpace, ReciprocalZone, ReciprocalPath, Segment, Translations, bonds!, bonds, icoordinate, isintracell, rcoordinate, @translations_str
export AbstractLattice, Bond, BrillouinZone, Lattice, Neighbors, Point, ReciprocalSpace, ReciprocalZone, ReciprocalPath, Segment, Translations, bonds!, bonds, icoordinate, isintracell, rcoordinate
export @hexagon_str, @line_str, @rectangle_str

# DegreesOfFreedom
Expand Down
15 changes: 0 additions & 15 deletions src/QuantumNumbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -701,21 +701,6 @@ Abstract type for momentum.
"""
abstract type Momentum <: AbelianNumber end

"""
expand(momentum::Momentum, reciprocals::AbstractVector{<:AbstractVector}) -> eltype(reciprocals)
Expand the momentum from integral values to real values with the given reciprocals.
"""
@inline function expand(momentum::Momentum, reciprocals::AbstractVector{<:AbstractVector})
p = periods(momentum)
@assert length(p)==length(reciprocals) "expand error: mismatched momentum and reciprocals."
result = zero(first(reciprocals))
for i = 1:length(p)
result += reciprocals[i]*(Int(momentum[i])//p[i])
end
return result
end

"""
Momentum₁{N}(k::Real) where N
Expand Down
Loading

0 comments on commit bcc2d50

Please sign in to comment.