Skip to content

Commit c186122

Browse files
authored
Update to libxc 7 (#37)
1 parent 28403e0 commit c186122

File tree

11 files changed

+61
-1467
lines changed

11 files changed

+61
-1467
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
version: ['1.8']
21+
version: ['1.10']
2222
os:
2323
- ubuntu-latest
2424
- macOS-latest

.gitlab-ci.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

Project.toml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
authors = ["Jason Eu <morty.yu@yahoo.com>", "Michael F. Herbst <info@michael-herbst.com>"]
21
name = "Libxc"
32
uuid = "66e17ffc-8502-11e9-23b5-c9248d0eb96d"
4-
version = "0.3.18"
5-
6-
[compat]
7-
CUDA = "5"
8-
Libxc_GPU_jll = "6"
9-
Libxc_jll = "6"
10-
Requires = "1"
11-
julia = "1.8"
3+
authors = ["Jason Eu <morty.yu@yahoo.com>", "Michael F. Herbst <info@michael-herbst.com>"]
4+
version = "0.3.19"
125

136
[deps]
147
Libxc_GPU_jll = "25af9330-9b41-55d4-a324-1a83c0a0a1ac"
158
Libxc_jll = "a56a6d9d-ad03-58af-ab61-878bf78270d6"
16-
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
9+
10+
[weakdeps]
11+
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
12+
13+
[extensions]
14+
LibxcCudaExt = "CUDA"
15+
16+
[compat]
17+
CUDA = "5"
18+
Libxc_GPU_jll = "7"
19+
Libxc_jll = "7"
20+
julia = "1.10"
1721

1822
[extras]
1923
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
2024
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2125

2226
[targets]
2327
test = ["Test", "CUDA"]
24-
25-
[weakdeps]
26-
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
27-
28-
[extensions]
29-
LibxcCudaExt = "CUDA"

README.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
# Libxc.jl
22

3-
| **Build Status** | **License** |
4-
|:--------------------------------------------------------------------- |:-------------------------------- |
5-
| ![][ci-img] [![][cigpu-img]][cigpu-url] [![][ccov-img]][ccov-url] | [![][license-img]][license-url] |
3+
| **Build Status** | **License** |
4+
|:-------------------------------------- |:-------------------------------- |
5+
| ![][ci-img] [![][ccov-img]][ccov-url] | [![][license-img]][license-url] |
66

77
[ci-img]: https://github.com/JuliaMolSim/Libxc.jl/workflows/CI/badge.svg
88

9-
[cigpu-img]: https://git.uni-paderborn.de/herbstm/Libxc.jl/badges/master/pipeline.svg?key_text=GPU%20CI
10-
[cigpu-url]: https://git.uni-paderborn.de/herbstm/Libxc.jl/-/pipelines
11-
129
[ccov-img]: https://codecov.io/gh/JuliaMolSim/Libxc.jl/branch/master/graph/badge.svg?token=ZL7RUND4YE
1310
[ccov-url]: https://codecov.io/gh/JuliaMolSim/Libxc.jl
1411

@@ -18,7 +15,7 @@
1815
This package provides Julia bindings to the
1916
[libxc](https://libxc.gitlab.io/) library
2017
for common exchange-correlation functionals in density-functional theory.
21-
At least **Julia 1.8** is required.
18+
At least **Julia 1.10** is required.
2219

2320
## Usage
2421
Install the library from Julia as usual:
@@ -50,12 +47,7 @@ result = evaluate(gga_x, rho=rho, sigma=sigma, derivative=0)
5047
## GPU support
5148
Recently GPU support has been added. Whenever `evaluate` is called
5249
with `CuArray`s, the computation will automatically be done with the CUDA
53-
version of libxc. Currently only CUDA 11 is supported,
54-
so you need to enforce using CUDA 11 explicitly:
55-
```julia
56-
using CUDA
57-
CUDA.set_runtime_version!(v"11.8")
58-
```
50+
version of libxc.
5951

6052
## Status
6153
Full support for evaluating LDA, GGA and meta-GGA functionals

ext/LibxcCudaExt.jl

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
11
module LibxcCudaExt
22
import Libxc_GPU_jll
3-
4-
# Extension module compatibility
5-
if isdefined(Base, :get_extension)
6-
using Libxc: Libxc, xc_func_type, Functional
7-
using CUDA
8-
else
9-
using ..Libxc: Libxc, xc_func_type, Functional
10-
using ..CUDA
11-
end
12-
13-
function __init__()
14-
if CUDA.functional()
15-
if !Libxc_GPU_jll.is_available() && CUDA.runtime_version() v"12"
16-
@warn("Libxc_GPU_jll currently not available for CUDA 12. " *
17-
"Please use CUDA 11 for GPU support " *
18-
"""(i.e. `CUDA.set_runtime_version!(v"11.8")`)""")
19-
end
20-
end
21-
end
3+
using Libxc: Libxc, xc_func_type, Functional
4+
using CUDA
225

236
if Libxc_GPU_jll.is_available()
247
const libxc_gpu = Libxc_GPU_jll.libxc
@@ -164,7 +147,6 @@ function Libxc.evaluate!(func::Functional, ::Union{Val{:mgga},Val{:hyb_mgga}}, r
164147
v4lapltau3::OptCuArray=CU_NULL,
165148
v4tau4::OptCuArray=CU_NULL)
166149
np = Int(length(rho) / func.spin_dimensions.rho)
167-
@warn "meta-GGAs on GPU seem to be broken at least with Libxc 6.1.0"
168150

169151
pointer = allocate_gpufunctional(func)
170152
@ccall libxc_gpu.xc_mgga(

src/Functional.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ is_global_hybrid(func::Functional) = is_hybrid(func) && !is_range_separated(func
101101
"""Does the function need the laplacian of the density"""
102102
needs_laplacian(func::Functional) = :needs_laplacian in func.flags
103103

104+
"""Does the function need the kinetic energy density"""
105+
needs_tau(func::Functional) = :needs_tau in func.flags
106+
104107

105108
# Supported properties:
106109
# - density_threshold Density threshold below which functional will not be evaluated
@@ -214,6 +217,8 @@ const FLAGMAP = Dict(
214217
XC_FLAGS_STABLE => :stable,
215218
XC_FLAGS_DEVELOPMENT => :development,
216219
XC_FLAGS_NEEDS_LAPLACIAN => :needs_laplacian,
220+
XC_FLAGS_NEEDS_TAU => :needs_tau,
221+
XC_FLAGS_ENFORCE_FHC => :enforce_fhc,
217222
)
218223

219224

src/Libxc.jl

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module Libxc
22
using Libxc_jll: libxc
33
import Libxc_GPU_jll
4-
using Requires # Only needed in Julia < 1.9
54

65
include("gen/common.jl")
76
include("gen/api.jl")
@@ -31,15 +30,6 @@ end
3130
export available_functionals
3231
export Functional, evaluate, evaluate!, supported_derivatives
3332
export is_lda, is_gga, is_mgga, is_hybrid, is_vv10, is_range_separated, is_global_hybrid
34-
export needs_laplacian
35-
36-
# Requires-based dependency management for Julia < 1.9
37-
if !isdefined(Base, :get_extension)
38-
function __init__()
39-
@require CUDA="052768ef-5323-5732-b1bb-66c8b64840ba" begin
40-
include("../ext/LibxcCudaExt.jl")
41-
end
42-
end
43-
end
33+
export needs_laplacian, needs_tau
4434

4535
end # module

src/gen/api.jl

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# Julia wrapper for header: xc.h
2-
# Automatically generated using Clang.jl
3-
4-
51
function xc_reference()
62
ccall((:xc_reference, libxc), Ptr{Cchar}, ())
73
end
@@ -146,14 +142,30 @@ function xc_func_set_tau_threshold(p, t_tau)
146142
ccall((:xc_func_set_tau_threshold, libxc), Cvoid, (Ptr{xc_func_type}, Cdouble), p, t_tau)
147143
end
148144

145+
function xc_func_set_fhc_enforcement(p, on)
146+
ccall((:xc_func_set_fhc_enforcement, libxc), Cvoid, (Ptr{xc_func_type}, Cint), p, on)
147+
end
148+
149149
function xc_func_set_ext_params(p, ext_params)
150150
ccall((:xc_func_set_ext_params, libxc), Cvoid, (Ptr{xc_func_type}, Ptr{Cdouble}), p, ext_params)
151151
end
152152

153+
function xc_func_get_ext_params(p, ext_params)
154+
ccall((:xc_func_get_ext_params, libxc), Cvoid, (Ptr{xc_func_type}, Ptr{Cdouble}), p, ext_params)
155+
end
156+
153157
function xc_func_set_ext_params_name(p, name, par)
154158
ccall((:xc_func_set_ext_params_name, libxc), Cvoid, (Ptr{xc_func_type}, Ptr{Cchar}, Cdouble), p, name, par)
155159
end
156160

161+
function xc_func_get_ext_params_name(p, name)
162+
ccall((:xc_func_get_ext_params_name, libxc), Cdouble, (Ptr{xc_func_type}, Ptr{Cchar}), p, name)
163+
end
164+
165+
function xc_func_get_ext_params_value(p, number)
166+
ccall((:xc_func_get_ext_params_value, libxc), Cdouble, (Ptr{xc_func_type}, Cint), p, number)
167+
end
168+
157169
function xc_lda_new(p, order, np, rho, out)
158170
ccall((:xc_lda_new, libxc), Cvoid, (Ptr{xc_func_type}, Cint, Csize_t, Ptr{Cdouble}, Ptr{xc_lda_out_params}), p, order, np, rho, out)
159171
end
@@ -162,6 +174,10 @@ function xc_gga_new(p, order, np, rho, sigma, out)
162174
ccall((:xc_gga_new, libxc), Cvoid, (Ptr{xc_func_type}, Cint, Csize_t, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{xc_gga_out_params}), p, order, np, rho, sigma, out)
163175
end
164176

177+
function xc_mgga_new(func, order, np, rho, sigma, lapl, tau, out)
178+
ccall((:xc_mgga_new, libxc), Cvoid, (Ptr{xc_func_type}, Cint, Csize_t, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{xc_mgga_out_params}), func, order, np, rho, sigma, lapl, tau, out)
179+
end
180+
165181
function xc_lda(p, np, rho, zk, vrho, v2rho2, v3rho3, v4rho4)
166182
ccall((:xc_lda, libxc), Cvoid, (Ptr{xc_func_type}, Csize_t, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}), p, np, rho, zk, vrho, v2rho2, v3rho3, v4rho4)
167183
end

0 commit comments

Comments
 (0)