Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: ['1.8']
version: ['1.10']
os:
- ubuntu-latest
- macOS-latest
Expand Down
34 changes: 0 additions & 34 deletions .gitlab-ci.yml

This file was deleted.

30 changes: 14 additions & 16 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
authors = ["Jason Eu <[email protected]>", "Michael F. Herbst <[email protected]>"]
name = "Libxc"
uuid = "66e17ffc-8502-11e9-23b5-c9248d0eb96d"
version = "0.3.18"

[compat]
CUDA = "5"
Libxc_GPU_jll = "6"
Libxc_jll = "6"
Requires = "1"
julia = "1.8"
authors = ["Jason Eu <[email protected]>", "Michael F. Herbst <[email protected]>"]
version = "0.3.19"

[deps]
Libxc_GPU_jll = "25af9330-9b41-55d4-a324-1a83c0a0a1ac"
Libxc_jll = "a56a6d9d-ad03-58af-ab61-878bf78270d6"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

[weakdeps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"

[extensions]
LibxcCudaExt = "CUDA"

[compat]
CUDA = "5"
Libxc_GPU_jll = "7"
Libxc_jll = "7"
julia = "1.10"

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

[targets]
test = ["Test", "CUDA"]

[weakdeps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"

[extensions]
LibxcCudaExt = "CUDA"
18 changes: 5 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# Libxc.jl

| **Build Status** | **License** |
|:--------------------------------------------------------------------- |:-------------------------------- |
| ![][ci-img] [![][cigpu-img]][cigpu-url] [![][ccov-img]][ccov-url] | [![][license-img]][license-url] |
| **Build Status** | **License** |
|:-------------------------------------- |:-------------------------------- |
| ![][ci-img] [![][ccov-img]][ccov-url] | [![][license-img]][license-url] |

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

[cigpu-img]: https://git.uni-paderborn.de/herbstm/Libxc.jl/badges/master/pipeline.svg?key_text=GPU%20CI
[cigpu-url]: https://git.uni-paderborn.de/herbstm/Libxc.jl/-/pipelines

[ccov-img]: https://codecov.io/gh/JuliaMolSim/Libxc.jl/branch/master/graph/badge.svg?token=ZL7RUND4YE
[ccov-url]: https://codecov.io/gh/JuliaMolSim/Libxc.jl

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

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

## Status
Full support for evaluating LDA, GGA and meta-GGA functionals
Expand Down
22 changes: 2 additions & 20 deletions ext/LibxcCudaExt.jl
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
module LibxcCudaExt
import Libxc_GPU_jll

# Extension module compatibility
if isdefined(Base, :get_extension)
using Libxc: Libxc, xc_func_type, Functional
using CUDA
else
using ..Libxc: Libxc, xc_func_type, Functional
using ..CUDA
end

function __init__()
if CUDA.functional()
if !Libxc_GPU_jll.is_available() && CUDA.runtime_version() ≥ v"12"
@warn("Libxc_GPU_jll currently not available for CUDA 12. " *
"Please use CUDA 11 for GPU support " *
"""(i.e. `CUDA.set_runtime_version!(v"11.8")`)""")
end
end
end
using Libxc: Libxc, xc_func_type, Functional
using CUDA

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

pointer = allocate_gpufunctional(func)
@ccall libxc_gpu.xc_mgga(
Expand Down
5 changes: 5 additions & 0 deletions src/Functional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ is_global_hybrid(func::Functional) = is_hybrid(func) && !is_range_separated(func
"""Does the function need the laplacian of the density"""
needs_laplacian(func::Functional) = :needs_laplacian in func.flags

"""Does the function need the kinetic energy density"""
needs_tau(func::Functional) = :needs_tau in func.flags


# Supported properties:
# - density_threshold Density threshold below which functional will not be evaluated
Expand Down Expand Up @@ -214,6 +217,8 @@ const FLAGMAP = Dict(
XC_FLAGS_STABLE => :stable,
XC_FLAGS_DEVELOPMENT => :development,
XC_FLAGS_NEEDS_LAPLACIAN => :needs_laplacian,
XC_FLAGS_NEEDS_TAU => :needs_tau,
XC_FLAGS_ENFORCE_FHC => :enforce_fhc,
)


Expand Down
12 changes: 1 addition & 11 deletions src/Libxc.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Libxc
using Libxc_jll: libxc
import Libxc_GPU_jll
using Requires # Only needed in Julia < 1.9

include("gen/common.jl")
include("gen/api.jl")
Expand Down Expand Up @@ -31,15 +30,6 @@ end
export available_functionals
export Functional, evaluate, evaluate!, supported_derivatives
export is_lda, is_gga, is_mgga, is_hybrid, is_vv10, is_range_separated, is_global_hybrid
export needs_laplacian

# Requires-based dependency management for Julia < 1.9
if !isdefined(Base, :get_extension)
function __init__()
@require CUDA="052768ef-5323-5732-b1bb-66c8b64840ba" begin
include("../ext/LibxcCudaExt.jl")
end
end
end
export needs_laplacian, needs_tau

end # module
24 changes: 20 additions & 4 deletions src/gen/api.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Julia wrapper for header: xc.h
# Automatically generated using Clang.jl


function xc_reference()
ccall((:xc_reference, libxc), Ptr{Cchar}, ())
end
Expand Down Expand Up @@ -146,14 +142,30 @@ function xc_func_set_tau_threshold(p, t_tau)
ccall((:xc_func_set_tau_threshold, libxc), Cvoid, (Ptr{xc_func_type}, Cdouble), p, t_tau)
end

function xc_func_set_fhc_enforcement(p, on)
ccall((:xc_func_set_fhc_enforcement, libxc), Cvoid, (Ptr{xc_func_type}, Cint), p, on)
end

function xc_func_set_ext_params(p, ext_params)
ccall((:xc_func_set_ext_params, libxc), Cvoid, (Ptr{xc_func_type}, Ptr{Cdouble}), p, ext_params)
end

function xc_func_get_ext_params(p, ext_params)
ccall((:xc_func_get_ext_params, libxc), Cvoid, (Ptr{xc_func_type}, Ptr{Cdouble}), p, ext_params)
end

function xc_func_set_ext_params_name(p, name, par)
ccall((:xc_func_set_ext_params_name, libxc), Cvoid, (Ptr{xc_func_type}, Ptr{Cchar}, Cdouble), p, name, par)
end

function xc_func_get_ext_params_name(p, name)
ccall((:xc_func_get_ext_params_name, libxc), Cdouble, (Ptr{xc_func_type}, Ptr{Cchar}), p, name)
end

function xc_func_get_ext_params_value(p, number)
ccall((:xc_func_get_ext_params_value, libxc), Cdouble, (Ptr{xc_func_type}, Cint), p, number)
end

function xc_lda_new(p, order, np, rho, out)
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)
end
Expand All @@ -162,6 +174,10 @@ function xc_gga_new(p, order, np, rho, sigma, out)
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)
end

function xc_mgga_new(func, order, np, rho, sigma, lapl, tau, out)
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)
end

function xc_lda(p, np, rho, zk, vrho, v2rho2, v3rho3, v4rho4)
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)
end
Expand Down
Loading