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

Out-source n!/k! to Combinatorics.jl #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ version = "0.1.0"
[deps]
AngularMomentumAlgebra = "0bb1b1ac-0216-11e9-361b-bb110c659ce1"
AtomicLevels = "10933b4c-d60f-11e8-1fc6-bd9035a249a1"
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
EnergyExpressions = "f4b57a2e-27c7-11e9-0cb0-edd185b706f6"
HypergeometricFunctions = "34004b35-14d8-5ef3-9330-4cdb6864b03a"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand All @@ -15,6 +16,7 @@ SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
SpecialPolynomials = "a25cea48-d430-424a-8ee7-0d3ad3742e9e"

[compat]
Combinatorics = "1.0"
HypergeometricFunctions = "0.2, 0.3"
Polynomials = "1"
SpecialFunctions = "0.10"
Expand Down
2 changes: 1 addition & 1 deletion src/Hydrogen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Hydrogen

using LinearAlgebra
using SparseArrays
using Combinatorics

using AtomicLevels
using AngularMomentumAlgebra
Expand All @@ -13,7 +14,6 @@ using SpecialPolynomials: Laguerre
using SpecialFunctions: gamma

include("sparse_builder.jl")
include("factorial_ratio.jl")

include("constants.jl")
include("energies.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/dipoles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function radial_dipole_moment(a::Orbital, b::Orbital)
n == n′ && return 3/2*n*√(n^2-ℓ^2)

A = powneg1(n′-ℓ)/(4*factorial(2ℓ-1))
B = √(factorial_ratio(n+ℓ,n-ℓ-1)*factorial_ratio(n′+ℓ-1,n′-ℓ))
B = √(factorial(n+ℓ,n-ℓ-1)*factorial(n′+ℓ-1,n′-ℓ))
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't the gamma function from SpecialFunctions be better here, for the high n/ell cases?

Copy link
Member Author

Choose a reason for hiding this comment

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

I am actually unsure, when talking about ratios of factorials. Should be investigated. This is of course related to #2, however, a numerically stable evaluation of the formula will not help for arbitrarily large values of n/ell, anyway, since the dipole moments (in the length gauge) are analytically divergent. This is physically reasonable, since the matrix element is ~ <n' ell' | r | n ell>, which of course will increase, the larger the values of the quantum numbers are.

C = (4*n*n′)^(ℓ+1)*(n-n′)^(n+n′-2ℓ-2)/((n+n′)^(n+n′))

nᵣ = n-ℓ-1
Expand Down
25 changes: 0 additions & 25 deletions src/factorial_ratio.jl

This file was deleted.

8 changes: 0 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ function lyman_balmer²(o, n, ℓ)
end

@testset "Hydrogen.jl" begin
@testset "Factorial ratios" begin
for a = 1:6
for b = 1:6
@test Hydrogen.factorial_ratio(a,b) == factorial(a)/factorial(b)
end
end
end

@testset "Radial dipole moments" begin
# We cannot compare with Table 13 of Bethe and Salpeter 1977,
# since it provides so few figures and some of the values
Expand Down