Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seniority number in jj-coupling #64

Merged
merged 9 commits into from
Jun 13, 2020
Merged
Show file tree
Hide file tree
Changes from 7 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
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ os:
- linux
- osx
julia:
- 1.0
- 1.1
- 1.2
- 1.3
- 1.4
- 1.5
- nightly
notifications:
email: false
Expand Down Expand Up @@ -44,7 +44,7 @@ after_success:
jobs:
include:
- stage: "Documentation"
julia: 1.0
julia: 1.4
os: linux
script:
- julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd()));
Expand Down
133 changes: 49 additions & 84 deletions Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,49 +1,42 @@
# This file is machine-generated - editing it directly is not advised

[[ArrayLayouts]]
deps = ["FillArrays", "LinearAlgebra"]
git-tree-sha1 = "89182776a99b69964e995cc2f1e37b5fc3476d56"
uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
version = "0.3.4"

[[BandedMatrices]]
deps = ["FillArrays", "LazyArrays", "LinearAlgebra", "MatrixFactorizations", "Random", "SparseArrays"]
git-tree-sha1 = "5a9e887a119842c033622d5fab67968516e2746f"
deps = ["ArrayLayouts", "FillArrays", "LinearAlgebra", "Random", "SparseArrays"]
git-tree-sha1 = "ab0e98974a74abf7b2b3a89946d28695133a8ae7"
uuid = "aae01518-5342-5314-be14-df237901396f"
version = "0.12.3"
version = "0.15.11"

[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[BlockArrays]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "87b72cb71d7306b767d175ece832bf8a7f3b6dc8"
deps = ["ArrayLayouts", "Compat", "LinearAlgebra"]
git-tree-sha1 = "5e157c81f1321f2338e1e2b71389c7783d3f59e6"
uuid = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
version = "0.10.0"
version = "0.12.8"

[[BlockBandedMatrices]]
deps = ["BandedMatrices", "BlockArrays", "Distributed", "FillArrays", "LazyArrays", "LinearAlgebra", "MatrixFactorizations", "Pkg", "Profile", "Random", "SharedArrays", "SparseArrays", "Statistics", "Test"]
git-tree-sha1 = "160fc541f01304ab823d1aff1959e84f28a63faf"
deps = ["ArrayLayouts", "BandedMatrices", "BlockArrays", "Distributed", "FillArrays", "LinearAlgebra", "MatrixFactorizations", "Pkg", "Random", "SharedArrays", "SparseArrays", "Statistics", "Test"]
git-tree-sha1 = "1caed9949c3077a8af9fa45739c094fefd8b33b6"
uuid = "ffab5731-97b5-5995-9138-79e8c1846df0"
version = "0.5.1"

[[CSTParser]]
deps = ["Tokenize"]
git-tree-sha1 = "c69698c3d4a7255bc1b4bc2afc09f59db910243b"
uuid = "00ebfdb7-1f24-5e51-bd34-a7502290713f"
version = "0.6.2"
version = "0.8.5"

[[Combinatorics]]
deps = ["LinearAlgebra", "Polynomials", "Test"]
git-tree-sha1 = "50b3ae4d643dc27eaff69fb6be06ee094d5500c9"
git-tree-sha1 = "08c8b6831dc00bfea825826be0bc8336fc369860"
uuid = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
version = "0.7.0"
version = "1.0.2"

[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "ed2c4abadf84c53d9e58510b5fc48912c2336fbb"
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "054993b6611376ddb40203e973e954fd9d1d1902"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "2.2.0"

[[DataStructures]]
deps = ["InteractiveUtils", "OrderedCollections"]
git-tree-sha1 = "f94423c68f2e47db0d6f626a26d4872266e0ec3d"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.17.2"
version = "3.12.0"

[[Dates]]
deps = ["Printf"]
Expand All @@ -59,9 +52,9 @@ uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[FillArrays]]
deps = ["LinearAlgebra", "Random", "SparseArrays"]
git-tree-sha1 = "16974065d5bfa867446d3228bc63f05a440e910b"
git-tree-sha1 = "44f561e293987ffc84272cd3d2b14b0b93123d63"
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
version = "0.7.2"
version = "0.8.10"

[[Formatting]]
deps = ["Printf"]
Expand All @@ -70,21 +63,16 @@ uuid = "59287772-0a20-5a39-b81b-1366585eb4c0"
version = "0.4.1"

[[HalfIntegers]]
git-tree-sha1 = "46026f5138d0458abbeaa60ddd700580f009e291"
git-tree-sha1 = "4c2671229adff0a42b3999f4255904959472de8f"
uuid = "f0d1745a-41c9-11e9-1dd9-e5d34d218721"
version = "0.1.3"
version = "1.1.1"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[LazyArrays]]
deps = ["FillArrays", "LinearAlgebra", "MacroTools", "StaticArrays"]
git-tree-sha1 = "576081d32ef488a03a8cebcc63fdb23d52b466e5"
uuid = "5078a376-72f3-5289-bfd5-ec5146d43c02"
version = "0.12.2"

[[LibGit2]]
deps = ["Printf"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[Libdl]]
Expand All @@ -97,47 +85,34 @@ uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[MacroTools]]
deps = ["CSTParser", "Compat", "DataStructures", "Test", "Tokenize"]
git-tree-sha1 = "d6e9dedb8c92c3465575442da456aec15a89ff76"
uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
version = "0.5.1"

[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[MatrixFactorizations]]
deps = ["LinearAlgebra", "Random", "Test"]
git-tree-sha1 = "42f7931fac4068709a8412d3766e9a2bfc91e451"
deps = ["ArrayLayouts", "LinearAlgebra", "Random"]
git-tree-sha1 = "69454f168628adeff74264837fc4c9d258dcc444"
uuid = "a3b82374-2e81-5b9e-98ce-41277c0e4c87"
version = "0.2.0"
version = "0.4.1"

[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[OrderedCollections]]
deps = ["Random", "Serialization", "Test"]
git-tree-sha1 = "c4c13474d23c60d20a67b217f1d7f22a40edf8f1"
git-tree-sha1 = "12ce190210d278e12644bcadf5b21cbdcf225cd3"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.1.0"
version = "1.2.0"

[[Parameters]]
deps = ["OrderedCollections"]
git-tree-sha1 = "b62b2558efb1eef1fa44e4be5ff58a515c287e38"
deps = ["OrderedCollections", "UnPack"]
git-tree-sha1 = "38b2e970043613c187bd56a995fe2e551821eb4a"
uuid = "d96e819e-fc66-5662-9728-84c9c7592b0a"
version = "0.12.0"
version = "0.12.1"

[[Pkg]]
deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[Polynomials]]
deps = ["LinearAlgebra", "RecipesBase"]
git-tree-sha1 = "f7c0c07e82798aef542d60a6e6e85e39f4590750"
uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
version = "0.5.3"

[[Primes]]
deps = ["Test"]
git-tree-sha1 = "ff1a2323cb468ec5f201838fcbe3c232266b1f95"
Expand All @@ -148,10 +123,6 @@ version = "0.4.0"
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[Profile]]
deps = ["Printf"]
uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"

[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Expand All @@ -160,10 +131,10 @@ uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[RecipesBase]]
git-tree-sha1 = "7bdce29bc9b2f5660a6e5e64d64d91ec941f6aa2"
uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
version = "0.7.0"
[[RationalRoots]]
git-tree-sha1 = "4165f49c451e6fc4bc0a2eeb1250abdf8c6e550e"
uuid = "308eb6b3-cc68-5ff3-9e97-c3c4da4fa681"
version = "0.1.0"

[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
Expand All @@ -182,12 +153,6 @@ uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
deps = ["LinearAlgebra", "Random"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[[StaticArrays]]
deps = ["LinearAlgebra", "Random", "Statistics"]
git-tree-sha1 = "db23bbf50064c582b6f2b9b043c8e7e98ea8c0c6"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "0.11.0"

[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Expand All @@ -196,26 +161,26 @@ uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[Tokenize]]
git-tree-sha1 = "dfcdbbfb2d0370716c815cbd6f8a364efb6f42cf"
uuid = "0796e94c-ce3b-5d07-9a54-7f471281c624"
version = "0.5.6"

[[UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[UnPack]]
git-tree-sha1 = "d4bfa022cd30df012700cf380af2141961bb3bfb"
uuid = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
version = "1.0.1"

[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[[UnicodeFun]]
deps = ["Test"]
git-tree-sha1 = "63cbbd00217fc9aafedf055b60459c1ae7e01ecc"
deps = ["REPL"]
git-tree-sha1 = "53915e50200959667e78a92a418594b428dffddf"
uuid = "1cfade01-22cf-5700-b092-accc4b62d6e1"
version = "0.4.0"
version = "0.4.1"

[[WignerSymbols]]
deps = ["HalfIntegers", "Primes"]
git-tree-sha1 = "d89c807c3affcf48e31ca36378238f98429278a6"
deps = ["HalfIntegers", "Primes", "RationalRoots"]
git-tree-sha1 = "dfb49a51c4c8e205d1d7ddc7e6a1a29da871ef52"
uuid = "9f57e263-0b3d-5e2e-b1be-24f2bb48858b"
version = "1.0.0"
mortenpi marked this conversation as resolved.
Show resolved Hide resolved
version = "1.1.0"
3 changes: 3 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
UnicodeFun = "1cfade01-22cf-5700-b092-accc4b62d6e1"
WignerSymbols = "9f57e263-0b3d-5e2e-b1be-24f2bb48858b"

[compat]
julia = "1.2"

[extras]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
environment:
matrix:
- julia_version: 1.0
- julia_version: 1.1
- julia_version: 1.2
- julia_version: 1.3
- julia_version: 1.4
- julia_version: 1.5
- julia_version: nightly

platform:
Expand Down
1 change: 1 addition & 0 deletions src/AtomicLevels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ include("excited_configurations.jl")
include("terms.jl")
include("allchoices.jl")
include("jj_terms.jl")
include("intermediate_terms.jl")
include("couple_terms.jl")
include("csfs.jl")
include("jj2lsj.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/configurations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Base.copy(cfg::Configuration) =
Configuration(copy(cfg.orbitals), copy(cfg.occupancy), copy(cfg.states),
sorted=cfg.sorted)

const RelativisticConfiguration{N} = Configuration{RelativisticOrbital{N}}
const RelativisticConfiguration = Configuration{<:RelativisticOrbital}

"""
issorted(cfg::Configuration)
Expand Down
5 changes: 1 addition & 4 deletions src/couple_terms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ couple_terms(J1::T, J2::T) where {T <: Union{Integer,HalfInteger}} =
couple_terms(J1::Real, J2::Real) =
couple_terms(convert(HalfInteger, J1), convert(HalfInteger, J2))

term_type(::Type{IntermediateTerm}) = Term
term_type(::Type{T}) where {T<:Real} = T

function intermediate_couplings(its::Vector{T}, t₀::T=zero(T)) where {T<:Union{Term,Integer,HalfInteger}}
ts = Vector{Vector{T}}()
for t in couple_terms(t₀, its[1])
Expand Down Expand Up @@ -118,7 +115,7 @@ julia> intermediate_couplings([IntermediateTerm(T"2S", 1), IntermediateTerm(T"2D
[¹S, ²S, ³D]
```
"""
intermediate_couplings(its::Vector{IntermediateTerm}, t₀::Term=zero(Term)) =
intermediate_couplings(its::Vector{<:IntermediateTerm{T}}, t₀::T=zero(T)) where T =
intermediate_couplings(map(t -> t.term, its), t₀)

"""
Expand Down
40 changes: 20 additions & 20 deletions src/csfs.jl
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
struct CSF{O<:AbstractOrbital, IT<:Union{IntermediateTerm,HalfInteger}, T<:Union{Term,HalfInteger}}
struct CSF{O<:AbstractOrbital, T<:Union{Term,HalfInteger}, S}
config::Configuration{<:O}
subshell_terms::Vector{IT}
subshell_terms::Vector{IntermediateTerm{T,S}}
terms::Vector{T}
jagot marked this conversation as resolved.
Show resolved Hide resolved

function CSF(config::Configuration{<:Orbital},
subshell_terms::Vector{<:IntermediateTerm},
terms::Vector{<:Term})
length(subshell_terms) == length(peel(config)) ||
throw(ArgumentError("Need to provide $(length(peel(config))) subshell terms for $(config)"))
length(terms) == length(peel(config)) ||
throw(ArgumentError("Need to provide $(length(peel(config))) terms for $(config)"))
new{Orbital,IntermediateTerm,Term}(config, subshell_terms, terms)
end

function CSF(config::Configuration{O},
subshell_terms::Vector{R},
terms::Vector{R}) where {O <: RelativisticOrbital, R <: Real}
subshell_terms::Vector{IntermediateTerm{T,S}},
terms::Vector{T}) where {O<:Union{<:Orbital,<:RelativisticOrbital},
T<:Union{Term,HalfInt}, S}
length(subshell_terms) == length(peel(config)) ||
throw(ArgumentError("Need to provide $(length(peel(config))) subshell terms for $(config)"))
length(terms) == length(peel(config)) ||
throw(ArgumentError("Need to provide $(length(peel(config))) terms for $(config)"))
new{O,HalfInt,HalfInt}(config,
convert.(HalfInt, subshell_terms),
convert.(HalfInt, terms))

for (i,(orb,occ,_)) in enumerate(peel(config))
st = subshell_terms[i]
assert_unique_classification(orb, occ, st) ||
throw(ArgumentError("$(st) is not a unique classification of $(orb)$(to_superscript(occ))"))
end

new{O,T,S}(config, subshell_terms, terms)
end

CSF(config, subshell_terms, terms::Vector{<:Real}) =
CSF(config, subshell_terms, convert.(HalfInt, terms))
Copy link
Member

Choose a reason for hiding this comment

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

This causes stack overflows, e.g. with

julia> CSF(rc"1s2 2p- 2p", HalfInt.([0, 1//2, 3//2]), HalfInt.([0, 1//2, 1]))

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't know if it applies anymore, since the subshell terms need to be IntermediateTerm.

Copy link
Member

Choose a reason for hiding this comment

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

It does, since the constructor is still there. You're right in that the way I call it is not really valid, but it should fail with a missing method error then, not cause a stack overflow.

Copy link
Member Author

Choose a reason for hiding this comment

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

But I cannot reproduce anymore:

julia> CSF(rc"1s 2s", [IntermediateTerm(half(1), Seniority(1)), IntermediateTerm(half(1), Seniority(1))], HalfInt.([1/2, 1]))
1s   2s
  1/2  1/2
   1/2    1+

julia> CSF(rc"1s 2s", [IntermediateTerm(1/2, Seniority(1)), IntermediateTerm(1/2, Seniority(1))], [1/2, 1])
1s   2s
  1/2  1/2
   1/2    1+

Copy link
Member

@mortenpi mortenpi Jun 13, 2020

Choose a reason for hiding this comment

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

That's because the second argument is IntermediateTerms. It crashes with

julia> CSF(rc"1s2 2p- 2p", HalfInt.([0, 1//2, 3//2]), HalfInt.([0, 1//2, 1]))

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 4d8981a:

julia> CSF(rc"1s 2s", [IntermediateTerm(half(1), Seniority(1)), IntermediateTerm(half(1), Seniority(1))], HalfInt.([1/2, 1]))
1s   2s
  1/2  1/2
   1/2    1+

julia> CSF(rc"1s 2s", [IntermediateTerm(1/2, Seniority(1)), IntermediateTerm(1/2, Seniority(1))], [1/2, 1])
1s   2s
  1/2  1/2
   1/2    1+

julia> CSF(rc"1s2 2p- 2p", HalfInt.([0, 1//2, 3//2]), HalfInt.([0, 1//2, 1]))
ERROR: MethodError: no method matching CSF(::Configuration{RelativisticOrbital{Int64}}, ::Array{Half{Int64},1}, ::Array{Half{Int64},1})
Closest candidates are:
  CSF(::Configuration{O}, ::Array{IntermediateTerm{T,S},1}, ::Array{T,1}) where {O<:(Union{#s41, #s40} where #s40<:RelativisticOrbital where #s41<:Orbital), T<:Union{Term, Half{Int64}}, S} at /Users/jagot/.julia/dev/AtomicLevels/src/csfs.jl:10
  CSF(::Any, ::Array{#s19,1} where #s19<:IntermediateTerm, ::Array{#s18,1} where #s18<:Real) at /Users/jagot/.julia/dev/AtomicLevels/src/csfs.jl:24
Stacktrace:
 [1] top-level scope at REPL[5]:1
 [2] eval(::Module, ::Any) at ./boot.jl:331
 [3] eval_user_input(::Any, ::REPL.REPLBackend) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
 [4] run_backend(::REPL.REPLBackend) at /Users/jagot/.julia/packages/Revise/tV8FE/src/Revise.jl:1165
 [5] top-level scope at REPL[1]:0

end

const NonRelativisticCSF = CSF{<:Orbital,IntermediateTerm,Term}
const RelativisticCSF = CSF{<:RelativisticOrbital,HalfInt,HalfInt}
const NonRelativisticCSF = CSF{<:Orbital,Term}
const RelativisticCSF = CSF{<:RelativisticOrbital,HalfInt}

Base.:(==)(a::CSF{O,T}, b::CSF{O,T}) where {O,T} =
(a.config == b.config) && (a.subshell_terms == b.subshell_terms) && (a.terms == b.terms)
Expand Down Expand Up @@ -92,7 +91,8 @@ function Base.show(io::IO, ::MIME"text/plain", csf::RelativisticCSF)
println(io)

nc > 0 && printfmt(io, cfmt, "")
for j in csf.subshell_terms
for it in csf.subshell_terms
j = it.term
if denominator(j) == 1
printfmt(io, ifmt, numerator(j))
else
Expand Down
Loading