Skip to content

Commit

Permalink
Make GenericLinearAlgebra an optional dependency (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfherbst authored Dec 14, 2020
1 parent ca6c8d8 commit 8855bea
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 8 deletions.
8 changes: 3 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
GenericLinearAlgebra = "14197337-ba66-59df-a3e3-ca00e7dcff7a"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153"
Expand Down Expand Up @@ -42,17 +41,15 @@ spglib_jll = "ac4a9f1e-bdb2-5204-990c-47c8b2f70d4e"
[compat]
AbstractFFTs = "0.5"
Conda = "1"
DoubleFloats = "1"
FFTW = "1"
ForwardDiff = "0.10"
GenericLinearAlgebra = "0.2"
Interpolations = "0.12, 0.13"
IterTools = "1"
IterativeSolvers = "0.8"
JSON = "0.21"
Libxc = "0.3"
LineSearches = "7"
LinearMaps = "2, 3.0"
LinearMaps = "2, 3"
MPI = "0.15, 0.16"
NCDatasets = "0.10, 0.11"
NLsolve = "4"
Expand All @@ -76,6 +73,7 @@ spglib_jll = "1.15"
[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
DoubleFloats = "497a8b3b-efae-58df-a0af-a86822472b78"
GenericLinearAlgebra = "14197337-ba66-59df-a3e3-ca00e7dcff7a"
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77"
Expand All @@ -84,4 +82,4 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Aqua", "DoubleFloats", "IntervalArithmetic", "Plots", "Random", "KrylovKit", "JLD2"]
test = ["Test", "Aqua", "DoubleFloats", "GenericLinearAlgebra", "IntervalArithmetic", "Plots", "Random", "KrylovKit", "JLD2"]
13 changes: 12 additions & 1 deletion examples/arbitrary_floattype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
# using double-precision arithmetic (i.e.`Float64`).
# Other floating-point types such as `Float32` (single precision)
# are readily supported as well.
# On top of that we already reported[^HLC2020] calculations
# On top of that we already reported[^HLC2020] calculations
# in DFTK using elevated precision
# from [DoubleFloats.jl](https://github.com/JuliaMath/DoubleFloats.jl)
# or interval arithmetic
# using [IntervalArithmetic.jl](https://github.com/JuliaIntervals/IntervalArithmetic.jl).
# In this example, however, we will concentrate on single-precision
# computations with `Float32`.
#
# The setup of such a reduced-precision calculation is basically identical
# to the regular case, since Julia automatically compiles all routines
# of DFTK at the precision, which is used for the lattice vectors.
Expand Down Expand Up @@ -47,3 +48,13 @@ scfres.energies
eltype(scfres.energies.total)
#-
eltype(scfres.ρ.real)

#
# !!! note "Generic linear algebra routines"
# For more unusual floating-point types (like IntervalArithmetic or DoubleFloats),
# which are not directly supported in the standard `LinearAlgebra` library of Julia
# one additional step is required: One needs to explicitly enable the generic versions
# of standard linear-algebra operations like `cholesky` or `qr`, which are needed
# inside DFTK by loading the `GenericLinearAlgebra` package in the user script
# (i.e. just add ad `using GenericLinearAlgebra` next to your `using DFTK` call).
#
1 change: 0 additions & 1 deletion src/eigen/lobpcg_hyper_impl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
vprintln(args...) = nothing

using LinearAlgebra
using GenericLinearAlgebra

# In the LOBPCG we deal with a subspace (X, R, P), where X, R and P are views
# into bigger arrays. We don't store these subspace vectors as a dense matrix
Expand Down
2 changes: 1 addition & 1 deletion src/external/etsf_nanoquanta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# ETSF Nanoquanta file format, for details see http://www.etsf.eu/fileformats/

using NCDatasets
using JSON
import JSON

struct EtsfFolder
folder
Expand Down
3 changes: 3 additions & 0 deletions src/fft_generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ include("FourierTransforms.jl/FourierTransforms.jl")
# This is needed to flag that the fft_generic.jl file has already been loaded
const GENERIC_FFT_LOADED = true

@info("Code paths for generic floating-point types activated in DFTK. Remember to add " *
"'using GenericLinearAlgebra' to your user script in case not yet done. " *
"See https://docs.dftk.org/stable/examples/arbitrary_floattype/ for details.")

# Utility functions to setup FFTs for DFTK. Most functions in here
# are needed to correct for the fact that FourierTransforms is not
Expand Down
1 change: 1 addition & 0 deletions test/interval_arithmetic.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Test
using DFTK
using IntervalArithmetic
using GenericLinearAlgebra

include("testcases.jl")

Expand Down
1 change: 1 addition & 0 deletions test/silicon_redHF.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include("run_scf_and_compare.jl")
include("testcases.jl")
using DoubleFloats
using GenericLinearAlgebra

# Silicon redHF (without xc) is a metal, so we add a bit of temperature to it
function run_silicon_redHF(T; Ecut=5, grid_size=15, spin_polarization=:none, kwargs...)
Expand Down

0 comments on commit 8855bea

Please sign in to comment.