Skip to content

Commit

Permalink
Functional only stores identifier symbolically
Browse files Browse the repository at this point in the history
Extend tests

new patched version
  • Loading branch information
mfherbst authored and unkcpz committed Aug 24, 2019
1 parent f58e8a2 commit db751a7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Libxc"
uuid = "66e17ffc-8502-11e9-23b5-c9248d0eb96d"
authors = ["Jason Eu <[email protected]>"]
version = "0.1.2"
version = "0.1.3"

[compat]
julia = "1"
Expand Down
8 changes: 4 additions & 4 deletions src/Functional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ end

mutable struct Functional
number::Int
name::String
identifier::Symbol
kind::FunctionalKind
family::FunctionalFamily
n_spin::Int
Expand All @@ -42,12 +42,12 @@ end


"""
Functional(identifier; n_spin::Integer = 1)
Functional(identifier::Symbol; n_spin::Integer = 1)
Construct a Functional from a libxc `identifier` and the number
of spins `n_spin` to consider. `
"""
function Functional(identifier; n_spin::Integer = 1)
function Functional(identifier::Symbol; n_spin::Integer = 1)
if n_spin != 1 && n_spin != 2
error("n_spin needs to be 1 or 2")
end
Expand Down Expand Up @@ -79,7 +79,7 @@ function Functional(identifier; n_spin::Integer = 1)
# TODO Extract references ....

# Make functional and attach finalizer for cleaning up the pointer
func = Functional(number, string(identifier), FunctionalKind(kind),
func = Functional(number, identifier, FunctionalKind(kind),
FunctionalFamily(family), n_spin, pointer)
finalizer(cls -> pointer_cleanup(cls.pointer), func)
return func
Expand Down
12 changes: 12 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,23 @@ end
sigma = [0.2, 0.3, 0.4, 0.5, 0.6]
result = zeros(Float64, 5)

# LDA
func = Libxc.Functional(:lda_x)
@test func.identifier == :lda_x
@test func.number == 1
@test func.family == Libxc.family_lda
@test func.n_spin == 1

Libxc.evaluate_lda!(func, rho, E=result)
@test result [-0.342809, -0.431912, -0.494416, -0.544175, -0.586194] atol=1e-5

# GGA
func = Libxc.Functional(:gga_x_pbe)
@test func.identifier == :gga_x_pbe
@test func.number == 101
@test func.family == Libxc.family_gga
@test func.n_spin == 1

Libxc.evaluate_gga!(func, rho, sigma, E=result)
@test result [-0.452598, -0.478878, -0.520674, -0.561428, -0.598661] atol=1e-5
end

2 comments on commit db751a7

@unkcpz
Copy link
Member

@unkcpz unkcpz commented on db751a7 Aug 24, 2019

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/2916

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 Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.3 -m "<description of version>" db751a74084aa4e71cf86528efa6f599a4532181
git push origin v0.1.3

Please sign in to comment.