From a84364998b2b9138449684e36303d9dd5cb365fa Mon Sep 17 00:00:00 2001 From: "Michael F. Herbst" Date: Fri, 10 Jan 2025 23:30:38 +0100 Subject: [PATCH] Remove mentions of bundled pseudopotentials from docs and tests (#1047) --- Project.toml | 21 ++- README.release_notes | 7 + docs/logo/.gitignore | 3 + docs/logo/DFTK_48.png | Bin 0 -> 2295 bytes docs/logo/DFTK_48.svg | 144 ++++++++++++++++++ docs/src/developer/data_structures.md | 5 +- docs/src/developer/symmetries.md | 4 +- docs/src/ecosystem/atomsbase.jl | 17 +-- docs/src/ecosystem/wannier.jl | 3 +- docs/src/tricks/achieving_convergence.md | 5 +- docs/src/tricks/parallelization.md | 4 +- docs/src/tricks/scf_checkpoints.jl | 4 +- examples/arbitrary_floattype.jl | 14 +- examples/collinear_magnetism.jl | 30 ++-- examples/convergence_study.jl | 4 +- examples/custom_solvers.jl | 16 +- examples/energy_cutoff_smearing.jl | 3 +- examples/error_estimates_forces.jl | 6 +- examples/forwarddiff.jl | 6 +- examples/gaas_surface.jl | 4 +- examples/gpu.jl | 3 +- examples/graphene.jl | 7 +- examples/metallic_systems.jl | 11 +- examples/polarizability.jl | 4 +- .../2020_silicon_scf_convergence.jl | 3 +- src/DFTK.jl | 3 +- src/elements.jl | 8 +- src/pseudo/list_psp.jl | 4 + src/pseudo/load_psp.jl | 99 +++++++----- src/scf/scfres.jl | 2 +- src/standard_models.jl | 4 +- src/terms/nonlocal.jl | 2 +- test/PspHgh.jl | 72 ++++++--- test/PspUpf.jl | 22 ++- test/aqua.jl | 15 +- test/elements.jl | 10 +- test/energy_nuclear.jl | 9 +- test/external/atomsbase.jl | 92 +++++------ test/external/spglib.jl | 5 +- test/forwarddiff.jl | 3 +- test/gth_pseudos/README.md | 3 + test/gth_pseudos/Si-q4.gth | 7 + .../Si.pbe-hgh.upf} | 0 test/gth_pseudos/Tl-q13.gth | 10 ++ .../Tl.pbe-d-hgh.upf} | 0 test/list_psp.jl | 11 +- test/lobpcg.jl | 9 +- test/silicon_lda.jl | 3 +- test/silicon_pbe.jl | 3 +- test/silicon_redHF.jl | 3 +- test/silicon_scan.jl | 6 +- test/symmetry_issues.jl | 4 +- 52 files changed, 518 insertions(+), 219 deletions(-) create mode 100644 README.release_notes create mode 100644 docs/logo/.gitignore create mode 100644 docs/logo/DFTK_48.png create mode 100644 docs/logo/DFTK_48.svg create mode 100644 test/gth_pseudos/README.md create mode 100644 test/gth_pseudos/Si-q4.gth rename test/{gth_pseudos_upf/Si.pbe-hgh.UPF => gth_pseudos/Si.pbe-hgh.upf} (100%) create mode 100644 test/gth_pseudos/Tl-q13.gth rename test/{gth_pseudos_upf/Tl.pbe-d-hgh.UPF => gth_pseudos/Tl.pbe-d-hgh.upf} (100%) diff --git a/Project.toml b/Project.toml index fe6295673c..6fcaa318a0 100644 --- a/Project.toml +++ b/Project.toml @@ -74,22 +74,30 @@ DFTKWriteVTKExt = "WriteVTK" [compat] AbstractFFTs = "1" +Aqua = "0.8.5" Artifacts = "1" +ASEconvert = "0.1" AtomsBase = "0.5" AtomsBuilder = "0.2" AtomsCalculators = "0.2.3" +AtomsIO = "0.3" +AtomsIOPython = "0.1" Brillouin = "0.5.14" -CUDA = "5" ChainRulesCore = "1.15" +ComponentArrays = "0.15" +CUDA = "5" Dates = "1" DftFunctionals = "0.3" DiffResults = "1.1" DocStringExtensions = "0.9" +DoubleFloats = "1" FFTW = "1.5" +FiniteDiff = "2" +FiniteDifferences = "0.12" ForwardDiff = "0.10" -GPUArraysCore = "0.1" GenericLinearAlgebra = "0.3" GeometryOptimization = "0.1" +GPUArraysCore = "0.1" Interpolations = "0.14, 0.15" IntervalArithmetic = "0.20" IterTools = "1" @@ -97,11 +105,12 @@ JLD2 = "0.4, 0.5" JSON3 = "1" KrylovKit = "0.8.3" Libxc = "0.3.17" -LineSearches = "7" LinearAlgebra = "1" LinearMaps = "3" -MPI = "0.20.22" +LineSearches = "7" +Logging = "1" Markdown = "1" +MPI = "0.20.22" Optim = "1" PeriodicTable = "1" PkgVersion = "0.3" @@ -113,6 +122,8 @@ Primes = "0.5" Printf = "1" PseudoPotentialData = "0.2.2" PseudoPotentialIO = "0.1" +PythonCall = "0.9" +QuadGK = "2" Random = "1" Roots = "2" SparseArrays = "1" @@ -120,6 +131,8 @@ SpecialFunctions = "2" Spglib = "0.9.4" StaticArrays = "1" Statistics = "1" +Test = "1" +TestItemRunner = "1" TimerOutputs = "0.5.12" Unitful = "1" UnitfulAtomic = "1" diff --git a/README.release_notes b/README.release_notes new file mode 100644 index 0000000000..dba972ba7d --- /dev/null +++ b/README.release_notes @@ -0,0 +1,7 @@ +@JuliaRegistrator register + +Release notes: + +Note that this release increases the minor version and contains a number of breaking changes: + +- The pseudopotential repository shipped with DFTK is now deprecated and slated for removal in a future version of DFTK. Please rely on the [PseudoPotentialData](https://github.com/JuliaMolSim/PseudoPotentialData.jl/) package for selecting pseudopotentials. Concretely this means that `list_psp` will be removed and `load_psp` will only be working with full paths to pseduopotential data files or e.g. combinations of `PseudoPotentialData.PseudoFamily` objects and an element symbol. diff --git a/docs/logo/.gitignore b/docs/logo/.gitignore new file mode 100644 index 0000000000..2d65ce2a9e --- /dev/null +++ b/docs/logo/.gitignore @@ -0,0 +1,3 @@ +DFTK.png +DFTK_100x50.png +DFTK_150x50.png diff --git a/docs/logo/DFTK_48.png b/docs/logo/DFTK_48.png new file mode 100644 index 0000000000000000000000000000000000000000..e5b89713ad3650b290ad612a53484e271b2d1a28 GIT binary patch literal 2295 zcmVpF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H12!u&Q zK~!jgy_tV-RMi#7Kj*#OkO2N5#UBBG%^--j1(i@muu3aaYlW(#Z5_+hcBTZw5C*D6 zO0qedq`)XugmK7H$7!{;1v*ZxRci~1MMFS?zXp_G)bR(2p(qjrlI*_IKXw-ub~n5G z68--7-aYr6@45G$bMLuVC=d+|4QE$ZSAPUpruHizKL506k9(I1-@$B%048$CV)m?O z!Idx1+0l`y-;yOuPK!pP=Y&F`mO}VQzJg1aE*;k0-5mz*0Ja13Rki7;fFYNy9#bR2 zEF8)(oD(d0g6;8Q^6=Km*4pH6RSf`@Ko~d$cnnyisvixA1FGtX$S=*T0T>Rv4V(|S zz*=CT*6N3oB4gGXd>vziVa>0AB|_0^R|x1`YxD0{5uuA>R(v z)zwY(JZ}|n8L&@8>dkDG>$;<3vDk9pdZ6dclefL{@!+;`V7bW0VRG=iL!)<%?JA!D z^Z<<|B_-7h7cT5l)oXwi38(fDpP7eL)yvxfRUH8=1AYobfz`#u#i6_JzWehN#&WCQ-y&&^&whs%#>vS_=Fc zm=6>I|8!lqs-~vqy)*|BQ@0Yh5NH#TMYXlH>vQqAJTm4vjHv~YKW2SHb4Ba4Tw?Y0 z^%tZrS)dW9QPl&Ys^F=tls=D*xFex(TRWmO30rl-P&BMFhm1UXoEKe{~R558?uDsMI^au94Ga|kFxbYB4$x%7RKHJx^;>$XOnJ< z`mssMsyR9XX69=K0JhHA^*kaWpfi`O!6%MT(>$wngI{~3a832zg zVFx0grU{6ADzGD1WIt@GXkF7ETdAA_^fLxhv1L|U6Yz~mYerpRo_q7~o-^k;xO5Ks zc!kAc>zgazY3{F$1dcADfQTd=>emdUBH>6=IDA{BnTe|YYM^vOJc!Ng_$%t z$Uy65po6#%SbsL^K5&$CAm1R~e#Ir{_KGvj6~1X$mq(z*dS&C~TelwQqnqU#nAI~M zKRp%=&JeS!K!yq4`!UbkP;_eNQx$6}db24_a!w86Q!)v^JgNK=bG(Qra+U*U8VCpu zvBL!U-^)`j-6X{_w|qm(akWB2L&L~uG+HDgj;daysykELAG~GVPzjX$-s`o=Vm1Q7 z1;Y@;b#IRzDBJtskDpjkxpu}%;pkq)x^?T^ojZ3X4}gx;)zwY*Jnz4WAAbx6gNqk0 zUfd3_ZOX(-%t9h|Mz#?Y@XUBuJf@d#X?Z(Q<3`Nv_C$;&gYKEq($ZV2s;UmG`pFX` zT$ATa?0k?u>IgfCIM45GA9|B+ni^HrZvzhi7X$6U3;|Hpi-7xp?~$lSuYKX)Z@SU$ zMvURv4WyV7-rYR$%KN%bK6M%Ky4ZmAz=viwPecMh)Um*tuk9K?73{)%^a^ss+~^Z~ zN59@fN`*+W9!M1qhr`p&?0zQ}8+CQl^U;#-!-0H^B++sDnY4_Xh={ypW;dv6D}bsF z6_H1P8-{d@l;Zuv5z9a6c}~etmK;i}5YqxI5{U#y{^!ZRo!;3oUA)3F(~+V< zwtZarta&R|K9s3_S>3YngIh;$bECncLi7T}f<13kJ$m!_6aS|TLq$bJ?-}iT$_gb9 zP~6k)O@8I2!P(kR+BtTJ8w(az{U_k|77aDhIc1zj6HfJG1aLj!TiF`LbH`z1%yzjT z$e>lXJd+lW86A*5GeZtTUiOPE6EA?}e;arL9M|nBPWzdW1RU{c1Vpl42|59JAK|bs zy=J|8J5Fg&)0t6L*zL;(bV2Oz**Q2bVWc0m^MSBWH%(0|fHKd3u^eGv;Wp@$!_EuY z+AIHj{bwL=6{^>SFCf;KsV$=eu-$G)C1HD}#T0)f~~2CZay2RI(mg~QY3n_Ds(Nk!G#8{6>YPJ~Z#>jgpDB+B*K zE_bs!aLK0E_Io|<6rf39e|7`52cvPq=9ZcH5CWL9ZpL3++?j^7S^TOn4F;bXvc+P~ zlsnc>&w5{#S4w;J$_YP+8jH+qWKVI)x#D@_>N+VUlziu-O^S5o2( zy4@4!XEC>T6i#fo6AQj4p0g{8ET8w+=^JzDC^#qAg+gCowk1?we~ll~*`TVwA%2~H znW}Efw_ibrH2}|XJo1W*g5d!;j#JQ}`l*9GpZ)rT-wQTBL<}EGFAsPCp67ifGvNEI zltV9k1vB6Q7l*^)xsgaD=%fFMkZ?GBo0-k`!^w{W3xI=Wwz9pw{q@AFi7%+?rK-Bw z%>D!n2Ic}yIl3JOUu#)a2aCvDGpihA(470*=PVQec9J%&)DjefG<+^M6I6f#Kq( R5M2NO002ovPDHLkV1g$^PDcO$ literal 0 HcmV?d00001 diff --git a/docs/logo/DFTK_48.svg b/docs/logo/DFTK_48.svg new file mode 100644 index 0000000000..2a4f6c384f --- /dev/null +++ b/docs/logo/DFTK_48.svg @@ -0,0 +1,144 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/docs/src/developer/data_structures.md b/docs/src/developer/data_structures.md index 52ee73ef1f..20698dee59 100644 --- a/docs/src/developer/data_structures.md +++ b/docs/src/developer/data_structures.md @@ -3,8 +3,9 @@ ```@setup data_structures using DFTK using AtomsBuilder -model = model_DFT(bulk(:Si); functionals=LDA(), - pseudopotentials=Dict(:Si => "hgh/lda/si-q4")) +using PseudoPotentialData +pseudopotentials = PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth") +model = model_DFT(bulk(:Si); functionals=LDA(), pseudopotentials) basis = PlaneWaveBasis(model; Ecut=15, kgrid=[4, 4, 4]) scfres = self_consistent_field(basis; tol=1e-4); ``` diff --git a/docs/src/developer/symmetries.md b/docs/src/developer/symmetries.md index f3fcc77b01..e4cb939600 100644 --- a/docs/src/developer/symmetries.md +++ b/docs/src/developer/symmetries.md @@ -87,11 +87,13 @@ reducible points, determines the weight of each irreducible ``k`` point. ## Example ```@setup symmetries using DFTK +using PseudoPotentialData a = 10.26 lattice = a / 2 * [[0 1 1.]; [1 0 1.]; [1 1 0.]] -Si = ElementPsp(:Si, load_psp("hgh/lda/Si-q4")) +pseudopotentials = PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth") +Si = ElementPsp(:Si, pseudopotentials) atoms = [Si, Si] positions = [ones(3)/8, -ones(3)/8] ``` diff --git a/docs/src/ecosystem/atomsbase.jl b/docs/src/ecosystem/atomsbase.jl index d7fc2280ca..e9113f6a00 100644 --- a/docs/src/ecosystem/atomsbase.jl +++ b/docs/src/ecosystem/atomsbase.jl @@ -27,19 +27,16 @@ system = bulk(:Si) using PseudoPotentialData # defines PseudoFamily pd_lda_family = PseudoFamily("dojo.nc.sr.lda.v0_4_1.standard.upf") -model = model_DFT(system; - functionals=LDA(), - temperature=1e-3, +model = model_DFT(system; functionals=LDA(), temperature=1e-3, pseudopotentials=pd_lda_family) # Alternatively the `pseudopotentials` object also accepts a `Dict{Symbol,String}`, # which provides for each element symbol the filename or identifier # of the pseudopotential to be employed, e.g. -model = model_DFT(system; - functionals=LDA(), - temperature=1e-3, - pseudopotentials=Dict(:Si => "hgh/lda/si-q4")) +path_to_pspfile = PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth")[:Si] +model = model_DFT(system; functionals=LDA(), temperature=1e-3, + pseudopotentials=Dict(:Si => path_to_pspfile)) # We can then discretise such a model and solve: basis = PlaneWaveBasis(model; Ecut=15, kgrid=[4, 4, 4]) @@ -59,7 +56,7 @@ using AtomsIO system = load_system("Si.extxyz"); # Run the LDA calculation: -pseudopotentials = Dict(:Si => "hgh/lda/si-q4") +pseudopotentials = PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth") model = model_DFT(system; pseudopotentials, functionals=LDA(), temperature=1e-3) basis = PlaneWaveBasis(model; Ecut=15, kgrid=[4, 4, 4]) scfres = self_consistent_field(basis, tol=1e-8); @@ -83,7 +80,7 @@ atoms = [:Si => ones(3)/8, :Si => -ones(3)/8] system = periodic_system(atoms, lattice; fractional=true) ## Now run the LDA calculation: -pseudopotentials = Dict(:Si => "hgh/lda/si-q4") +pseudopotentials = PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth") model = model_DFT(system; pseudopotentials, functionals=LDA(), temperature=1e-3) basis = PlaneWaveBasis(model; Ecut=15, kgrid=[4, 4, 4]) scfres = self_consistent_field(basis, tol=1e-4); @@ -100,7 +97,7 @@ second_system = atomic_system(model) lattice = 5.431u"Å" / 2 * [[0 1 1.]; [1 0 1.]; [1 1 0.]]; -Si = ElementPsp(:Si, load_psp("hgh/lda/Si-q4")) +Si = ElementPsp(:Si, pseudopotentials) atoms = [Si, Si] positions = [ones(3)/8, -ones(3)/8] diff --git a/docs/src/ecosystem/wannier.jl b/docs/src/ecosystem/wannier.jl index da58d5e536..c6b2256fa7 100644 --- a/docs/src/ecosystem/wannier.jl +++ b/docs/src/ecosystem/wannier.jl @@ -19,6 +19,7 @@ using DFTK using Plots using Unitful using UnitfulAtomic +using PseudoPotentialData d = 10u"Å" a = 2.641u"Å" # Graphene Lattice constant @@ -26,7 +27,7 @@ lattice = [a -a/2 0; 0 √3*a/2 0; 0 0 d] -C = ElementPsp(:C, load_psp("hgh/pbe/c-q4")) +C = ElementPsp(:C, PseudoFamily("cp2k.nc.sr.pbe.v0_1.semicore.gth")) atoms = [C, C] positions = [[0.0, 0.0, 0.0], [1//3, 2//3, 0.0]] model = model_DFT(lattice, atoms, positions; functionals=PBE()) diff --git a/docs/src/tricks/achieving_convergence.md b/docs/src/tricks/achieving_convergence.md index 74aa8adb78..3aba4839da 100644 --- a/docs/src/tricks/achieving_convergence.md +++ b/docs/src/tricks/achieving_convergence.md @@ -7,8 +7,9 @@ of inspiration for what you can try. Your mileage may vary. ```@setup convergence using DFTK using AtomsBuilder -model = model_DFT(bulk(:Si); functionals=LDA(), - pseudopotentials=Dict(:Si => "hgh/lda/si-q4")) +using PseudoPotentialData +pseudopotentials = PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth") +model = model_DFT(bulk(:Si); functionals=LDA(), pseudopotentials) basis = PlaneWaveBasis(model; Ecut=15, kgrid=(3, 3, 3)) ``` diff --git a/docs/src/tricks/parallelization.md b/docs/src/tricks/parallelization.md index 92a21215d0..15285aee3e 100644 --- a/docs/src/tricks/parallelization.md +++ b/docs/src/tricks/parallelization.md @@ -5,11 +5,13 @@ to monitor and influence performance of the code. ```@setup parallelization using DFTK +using PseudoPotentialData a = 10.26 # Silicon lattice constant in Bohr lattice = a / 2 * [[0 1 1.]; [1 0 1.]; [1 1 0.]] -Si = ElementPsp(:Si, load_psp("hgh/lda/Si-q4")) +pseudopotentials = PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth") +Si = ElementPsp(:Si, pseudopotentials) atoms = [Si, Si] positions = [ones(3)/8, -ones(3)/8] diff --git a/docs/src/tricks/scf_checkpoints.jl b/docs/src/tricks/scf_checkpoints.jl index c7e10c236c..95434c84b3 100644 --- a/docs/src/tricks/scf_checkpoints.jl +++ b/docs/src/tricks/scf_checkpoints.jl @@ -25,11 +25,13 @@ using DFTK using LinearAlgebra using JLD2 +using PseudoPotentialData d = 2.079 # oxygen-oxygen bondlength a = 9.0 # size of the simulation box lattice = a * I(3) -O = ElementPsp(:O, load_psp("hgh/pbe/O-q6.hgh")) +pseudopotentials = PseudoFamily("cp2k.nc.sr.pbe.v0_1.semicore.gth") +O = ElementPsp(:O, pseudopotentials) atoms = [O, O] positions = d / 2a * [[0, 0, 1], [0, 0, -1]] magnetic_moments = [1., 1.] diff --git a/examples/arbitrary_floattype.jl b/examples/arbitrary_floattype.jl index 2c1d036ac3..5a747b1580 100644 --- a/examples/arbitrary_floattype.jl +++ b/examples/arbitrary_floattype.jl @@ -25,16 +25,12 @@ # [ArXiv 2004.13549](https://arxiv.org/abs/2004.13549) using DFTK +using PseudoPotentialData +using AtomsBuilder -## Setup silicon lattice -a = 10.263141334305942 # lattice constant in Bohr -lattice = a / 2 .* [[0 1 1.]; [1 0 1.]; [1 1 0.]] -Si = ElementPsp(:Si, load_psp("hgh/lda/Si-q4")) -atoms = [Si, Si] -positions = [ones(3)/8, -ones(3)/8] - -## Cast to Float32, setup model and basis -model = model_DFT(lattice, atoms, positions; functionals=LDA()) +## Use AtomsBuilder to setup silicon lattice and cast model to Float32 +pseudopotentials = PseudoFamily("cp2k.nc.sr.lda.v0_1.largecore.gth") +model = model_DFT(bulk(:Si); functionals=LDA(), pseudopotentials) basis = PlaneWaveBasis(convert(Model{Float32}, model), Ecut=7, kgrid=[4, 4, 4]) ## Run the SCF diff --git a/examples/collinear_magnetism.jl b/examples/collinear_magnetism.jl index f899d2254d..0f6fb76f4f 100644 --- a/examples/collinear_magnetism.jl +++ b/examples/collinear_magnetism.jl @@ -6,25 +6,25 @@ # and compare the resulting SCF energies. In particular # the ground state can only be found if collinear spins are allowed. # -# First we setup BCC iron without spin polarization -# using a single iron atom inside the unit cell. +# The `bulk(:Fe)` function from `AtomsBuilder` returns a BCC iron setup +# with a single iron atom inside the unit cell. + +using AtomsBuilder +using PseudoPotentialData using DFTK -a = 5.42352 # Bohr -lattice = a / 2 * [[-1 1 1]; - [ 1 -1 1]; - [ 1 1 -1]] -atoms = [ElementPsp(:Fe, load_psp("hgh/lda/Fe-q8.hgh"))] -positions = [zeros(3)]; +bulk(:Fe) -# To get the ground-state energy we use an LDA model and rather moderate -# discretisation parameters. +# First we consider a setup without spin polarization. +# To get the ground-state energy of this system we use an LDA model +# and rather moderate discretisation parameters. +Ecut = 15 # kinetic energy cutoff in Hartree kgrid = [3, 3, 3] # k-point grid (Regular Monkhorst-Pack grid) -Ecut = 15 # kinetic energy cutoff in Hartree -model_nospin = model_DFT(lattice, atoms, positions; functionals=LDA(), temperature=0.01) -basis_nospin = PlaneWaveBasis(model_nospin; kgrid, Ecut) +pseudopotentials = PseudoFamily("cp2k.nc.sr.lda.v0_1.largecore.gth") +model_nospin = model_DFT(bulk(:Fe); pseudopotentials, functionals=LDA(), temperature=0.01) +basis_nospin = PlaneWaveBasis(model_nospin; kgrid, Ecut) scfres_nospin = self_consistent_field(basis_nospin; tol=1e-4, mixing=KerkerDosMixing()); #- scfres_nospin.energies @@ -56,8 +56,8 @@ magnetic_moments = [4]; # We repeat the calculation using the same model as before. DFTK now detects # the non-zero moment and switches to a collinear calculation. -model = model_DFT(lattice, atoms, positions; functionals=LDA(), - magnetic_moments, temperature=0.01) +model = model_DFT(bulk(:Fe); pseudopotentials, functionals=LDA(), + temperature=0.01, magnetic_moments) basis = PlaneWaveBasis(model; Ecut, kgrid) ρ0 = guess_density(basis, magnetic_moments) scfres = self_consistent_field(basis, tol=1e-6; ρ=ρ0, mixing=KerkerDosMixing()); diff --git a/examples/convergence_study.jl b/examples/convergence_study.jl index 62bac5519c..3efed7eb3b 100644 --- a/examples/convergence_study.jl +++ b/examples/convergence_study.jl @@ -23,9 +23,11 @@ using DFTK using LinearAlgebra using Statistics +using PseudoPotentialData function run_scf(; a=5.0, Ecut, nkpt, tol) - atoms = [ElementPsp(:Pt, load_psp("hgh/lda/Pt-q10"))] + pseudopotentials = PseudoFamily("cp2k.nc.sr.lda.v0_1.largecore.gth") + atoms = [ElementPsp(:Pt, pseudopotentials)] position = [zeros(3)] lattice = a * Matrix(I, 3, 3) diff --git a/examples/custom_solvers.jl b/examples/custom_solvers.jl index 040a22d6c5..527ea77f70 100644 --- a/examples/custom_solvers.jl +++ b/examples/custom_solvers.jl @@ -1,18 +1,14 @@ # # [Custom solvers](@id custom-solvers) # In this example, we show how to define custom solvers. Our system # will again be silicon, because we are not very imaginative -using DFTK, LinearAlgebra - -a = 10.26 -lattice = a / 2 * [[0 1 1.]; - [1 0 1.]; - [1 1 0.]] -Si = ElementPsp(:Si, load_psp("hgh/lda/Si-q4")) -atoms = [Si, Si] -positions = [ones(3)/8, -ones(3)/8] +using DFTK +using LinearAlgebra +using PseudoPotentialData +using AtomsBuilder ## We take very (very) crude parameters -model = model_DFT(lattice, atoms, positions; functionals=LDA()) +pseudopotentials = PseudoFamily("dojo.nc.sr.lda.v0_4_1.standard.upf") +model = model_DFT(bulk(:Si); functionals=LDA(), pseudopotentials) basis = PlaneWaveBasis(model; Ecut=5, kgrid=[1, 1, 1]); # We define our custom fix-point solver: simply a damped fixed-point diff --git a/examples/energy_cutoff_smearing.jl b/examples/energy_cutoff_smearing.jl index 949ac55016..0f0340d623 100644 --- a/examples/energy_cutoff_smearing.jl +++ b/examples/energy_cutoff_smearing.jl @@ -25,13 +25,14 @@ using AtomsBuilder using DFTK +using PseudoPotentialData using Statistics a0 = 10.26 # Experimental lattice constant of silicon in bohr a_list = range(a0 - 1/2, a0 + 1/2; length=20) function compute_ground_state_energy(a; Ecut, kgrid, kinetic_blowup, kwargs...) - pseudopotentials = Dict(:Si => "hgh/pbe/Si-q4") + pseudopotentials = PseudoFamily("cp2k.nc.sr.pbe.v0_1.semicore.gth") model = model_DFT(bulk(:Si); functionals=PBE(), kinetic_blowup, pseudopotentials) basis = PlaneWaveBasis(model; Ecut, kgrid) self_consistent_field(basis; callback=identity, kwargs...).energies.total diff --git a/examples/error_estimates_forces.jl b/examples/error_estimates_forces.jl index dfa28aa311..f4df526ad2 100644 --- a/examples/error_estimates_forces.jl +++ b/examples/error_estimates_forces.jl @@ -12,6 +12,7 @@ # *Practical error bounds for properties in plane-wave electronic structure calculations* # [SIAM Journal on Scientific Computing 44 (5), B1312-B1340](https://doi.org/10.1137/21M1456224) using DFTK +using PseudoPotentialData using Printf using LinearAlgebra using ForwardDiff @@ -19,8 +20,9 @@ using ForwardDiff # ## Setup # We setup manually the ``{\rm TiO}_2`` configuration from # [Materials Project](https://materialsproject.org/materials/mp-2657/). -Ti = ElementPsp(:Ti, load_psp("hgh/lda/ti-q4.hgh")) -O = ElementPsp(:O, load_psp("hgh/lda/o-q6.hgh")) +pseudopotentials = PseudoFamily("cp2k.nc.sr.lda.v0_1.largecore.gth") +Ti = ElementPsp(:Ti, pseudopotentials) +O = ElementPsp(:O, pseudopotentials) atoms = [Ti, Ti, O, O, O, O] positions = [[0.5, 0.5, 0.5], # Ti [0.0, 0.0, 0.0], # Ti diff --git a/examples/forwarddiff.jl b/examples/forwarddiff.jl index c3f76309f4..664681c2f6 100644 --- a/examples/forwarddiff.jl +++ b/examples/forwarddiff.jl @@ -8,13 +8,15 @@ using DFTK using LinearAlgebra using ForwardDiff +using PseudoPotentialData ## Construct PlaneWaveBasis given a particular electric field strength ## Again we take the example of a Helium atom. function make_basis(ε::T; a=10., Ecut=30) where {T} - lattice=T(a) * I(3) # lattice is a cube of ``a`` Bohrs + lattice = T(a) * I(3) # lattice is a cube of ``a`` Bohrs ## Helium at the center of the box - atoms = [ElementPsp(:He, load_psp("hgh/lda/He-q2"))] + pseudopotentials = PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth") + atoms = [ElementPsp(:He, pseudopotentials)] positions = [[1/2, 1/2, 1/2]] model = model_DFT(lattice, atoms, positions; diff --git a/examples/gaas_surface.jl b/examples/gaas_surface.jl index 47c8753936..019469abe2 100644 --- a/examples/gaas_surface.jl +++ b/examples/gaas_surface.jl @@ -46,9 +46,9 @@ ase.io.write("surface.png", surface * pytuple((3, 3, 1)), rotation="-90x, 30y, - # (see [AtomsBase integration](@ref) for details) to construct a DFTK model: using DFTK +using PseudoPotentialData -pseudopotentials = Dict(:Ga => "hgh/pbe/ga-q3.hgh", - :As => "hgh/pbe/as-q5.hgh") +pseudopotentials = PseudoFamily("cp2k.nc.sr.pbe.v0_1.largecore.gth") model = model_DFT(pyconvert(AbstractSystem, surface); functionals=PBE(), temperature=1e-3, diff --git a/examples/gpu.jl b/examples/gpu.jl index 2b7e918689..81b6d97b17 100644 --- a/examples/gpu.jl +++ b/examples/gpu.jl @@ -1,10 +1,11 @@ using AtomsBuilder using DFTK using CUDA +using PseudoPotentialData model = model_DFT(bulk(:Si); functionals=PBE(), - pseudopotentials=Dict(:Si => "hgh/pbe/Si-q4")) + pseudopotentials=PseudoFamily("cp2k.nc.sr.pbe.v0_1.semicore.gth")) # If available, use CUDA to store DFT quantities and perform main computations architecture = has_cuda() ? DFTK.GPU(CuArray) : DFTK.CPU() diff --git a/examples/graphene.jl b/examples/graphene.jl index 9d3ef05e8e..ed2a872eac 100644 --- a/examples/graphene.jl +++ b/examples/graphene.jl @@ -5,10 +5,11 @@ # path in reciprocal space. using DFTK -using Unitful -using UnitfulAtomic using LinearAlgebra using Plots +using PseudoPotentialData +using Unitful +using UnitfulAtomic ## Define the convergence parameters (these should be increased in production) L = 20 # height of the simulation box @@ -25,7 +26,7 @@ lattice = [a1 a2 a3] C1 = [1/3,-1/3,0.0] # in reduced coordinates C2 = -C1 positions = [C1, C2] -C = ElementPsp(:C, load_psp("hgh/pbe/c-q4")) +C = ElementPsp(:C, PseudoFamily("cp2k.nc.sr.pbe.v0_1.semicore.gth")) atoms = [C, C] ## Run SCF diff --git a/examples/metallic_systems.jl b/examples/metallic_systems.jl index b8c80e2a83..339d14ad94 100644 --- a/examples/metallic_systems.jl +++ b/examples/metallic_systems.jl @@ -9,14 +9,17 @@ using DFTK using Plots +using PseudoPotentialData using Unitful using UnitfulAtomic -a = 3.01794 # bohr -b = 5.22722 # bohr -c = 9.77362 # bohr +a = 3.01794 # Bohr +b = 5.22722 # Bohr +c = 9.77362 # Bohr lattice = [[-a -a 0]; [-b b 0]; [0 0 -c]] -Mg = ElementPsp(:Mg, load_psp("hgh/pbe/Mg-q2")) + +pseudopotentials = PseudoFamily("cp2k.nc.sr.pbe.v0_1.largecore.gth") +Mg = ElementPsp(:Mg, pseudopotentials) atoms = [Mg, Mg] positions = [[2/3, 1/3, 1/4], [1/3, 2/3, 3/4]]; diff --git a/examples/polarizability.jl b/examples/polarizability.jl index 212d029d31..7f4e3fd88d 100644 --- a/examples/polarizability.jl +++ b/examples/polarizability.jl @@ -18,11 +18,13 @@ using DFTK using LinearAlgebra +using PseudoPotentialData a = 10. lattice = a * I(3) # cube of ``a`` bohrs +pseudopotentials = PseudoFamily("cp2k.nc.sr.lda.v0_1.largecore.gth") ## Helium at the center of the box -atoms = [ElementPsp(:He, load_psp("hgh/lda/He-q2"))] +atoms = [ElementPsp(:He, pseudopotentials)] positions = [[1/2, 1/2, 1/2]] diff --git a/examples/publications/2020_silicon_scf_convergence.jl b/examples/publications/2020_silicon_scf_convergence.jl index 8b8f002c04..2a42fddf5a 100644 --- a/examples/publications/2020_silicon_scf_convergence.jl +++ b/examples/publications/2020_silicon_scf_convergence.jl @@ -5,12 +5,13 @@ using DFTK using Plots using Printf +using PseudoPotentialData using LinearAlgebra # Calculation parameters kgrid = [1, 1, 1] Ecut = 15 # 30 in the paper -Si = ElementPsp(:Si, load_psp("hgh/lda/Si-q4")) +Si = ElementPsp(:Si, PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth")) atoms = [Si, Si] positions = [ones(3)/8, -ones(3)/8] diff --git a/src/DFTK.jl b/src/DFTK.jl index 2187eb1b76..25921a9ed7 100644 --- a/src/DFTK.jl +++ b/src/DFTK.jl @@ -240,7 +240,8 @@ include("workarounds/gpu_arrays.jl") lattice = a / 2 * [[0 1 1.]; [1 0 1.]; [1 1 0.]] - Si = ElementPsp(:Si, load_psp("hgh/lda/Si-q4")) + pseudofile = joinpath(@__DIR__, "..", "test", "gth_pseudos", "Si.pbe-hgh.upf") + Si = ElementPsp(:Si, Dict(:Si => pseudofile)) atoms = [Si, Si] positions = [ones(3)/8, -ones(3)/8] magnetic_moments = [2, -2] diff --git a/src/elements.jl b/src/elements.jl index e08a7136c0..0e961d4ea3 100644 --- a/src/elements.jl +++ b/src/elements.jl @@ -113,12 +113,8 @@ or a chemical species (e.g. `ChemicalSpecies(:He3)`). - `nothing` (to return a `ElementCoulomb`) ## Examples -Construct an `ElementPsp` for silicon using a HGH pseudopotential from an identifier -```julia -ElementPsp(:Si, load_psp("psp/hgh/Si-q4")) -``` -Construct an `ElementPsp` again for silicon using the specified pseudpotential family -(from the `PseudopotentialData` package). +Construct an `ElementPsp` for silicon using a pseudodojo pseudopotential family +(provided by the `PseudopotentialData` package) ```julia using PseudoPotentialData ElementPsp(:Si, PseudoFamily("dojo.nc.sr.pbe.v0_4_1.standard.upf")) diff --git a/src/pseudo/list_psp.jl b/src/pseudo/list_psp.jl index 9c7a850e74..3f9f605197 100644 --- a/src/pseudo/list_psp.jl +++ b/src/pseudo/list_psp.jl @@ -21,6 +21,10 @@ julia> list_psp(:O, core=:semicore) will list all oxygen semicore pseudopotentials known to DFTK. """ function list_psp(element=nothing; family=nothing, functional=nothing, core=nothing) + @warn("The function list_psp and the internal pseudopotential repository of DFTK are " * + "deprecated and will be removed in a future version of DFTK. Use the " * + "PseudoPotentialData julia package instead.") + # Normalize input keys isnothing(element) || (element = Symbol(PeriodicTable.elements[element].symbol)) isnothing(functional) || (functional = lowercase(functional)) diff --git a/src/pseudo/load_psp.jl b/src/pseudo/load_psp.jl index 26527a033a..395ceb0404 100644 --- a/src/pseudo/load_psp.jl +++ b/src/pseudo/load_psp.jl @@ -2,22 +2,69 @@ datadir_psp() = normpath(joinpath(@__DIR__, "..", "..", "data", "psp")) # See also: DFTKPseudoPotentialDataExt -extra_pseudometa_kwargs(family::AbstractDict, element::Symbol) = (;) +extra_pseudometa_kwargs(::AbstractDict, ::Symbol) = NamedTuple() """ Load a pseudopotential file from a pseudopotential family. -This method should be preferred because it can automatically -use metadata from the pseudopotential family. +Uses available metadata from the pseudopotential family +(via the `pseudometa` function of `PseudoPotentialData`) +to automatically set some keyword arguments. +`pseudofamily` can be a `PseudoPotentialData.PseudoFamily` or simply +a `Dict{Symbol,String}` which returns a file path when indexed +with an element symbol. + +## Example +```julia +using PseudoPotentialData +pseudopotentials = PseudoFamily("dojo.nc.sr.lda.v0_4_1.standard.upf") +load_psp(pseudopotenitals, :Si) +``` """ function load_psp(family::AbstractDict, element::Symbol; kwargs...) load_psp(family[element]; extra_pseudometa_kwargs(family, element)..., kwargs...) end """ -Load a pseudopotential file from the library of pseudopotentials. -The file is searched in the directory `datadir_psp()` and by the `key`. -If the `key` is a path to a valid file, the extension is used to determine -the type of the pseudopotential file format and a respective class is returned. +Load all pseudopotentials from the pseudopotential family `pseudofamily` +corresponding to the atoms of a `system`. Returns the list of +the pseudopotential objects in the same order as the atoms in `system`. +Takes care that each pseudopotential object is only loaded once +(which enables later efficiency improvements in DFTK). +Applies the passed keyword arguments when loading all pseudopotentials +and additionally uses the metadata stored for each pseudopotential family +to deduce further keyword arguments (e.g. `rcut`). +`pseudofamily` can be a `PseudoPotentialData.PseudoFamily` or simply +a `Dict{Symbol,String}` which returns a file path when indexed +with an element symbol. + +## Example +```julia +using PseudoPotentialData +using AtomsBuilder +pseudopotentials = PseudoFamily("dojo.nc.sr.lda.v0_4_1.standard.upf") +load_psp(pseudopotenitals, bulk(:Si)) +``` +""" +function load_psp(pseudofamily::AbstractDict{Symbol,<:AbstractString}, + system::AbstractSystem; kwargs...) + # Cache for instantiated pseudopotentials. This is done to ensure that identical + # pseudos are indistinguishable in memory, which is used in the Model constructor + # to deduce the atom_groups. + cached_psps = Dict{String, Any}() + map(system) do atom + symbol = element_symbol(atom) + file::String = pseudofamily[symbol] + get!(cached_psps, file) do + load_psp(file; extra_pseudometa_kwargs(pseudofamily, symbol)..., kwargs...) + end + end +end + +""" +Load a pseudopotential file. The file extension is used to determine +the type of the pseudopotential file format and a respective class +(e.g. `PspHgh` or `PspUpf`) is returned. Most users will want to use +other methods of the `load_psp` function. """ function load_psp(key::AbstractString; kwargs...) if endswith(lowercase(key), ".gth") @@ -26,7 +73,7 @@ function load_psp(key::AbstractString; kwargs...) elseif endswith(lowercase(key), ".upf") pseudo_type = PspUpf extension = ".upf" - elseif startswith(key, "hgh/") || endswith(lowercase(key), ".hgh") + elseif startswith(lowercase(key), "hgh/") || endswith(lowercase(key), ".hgh") # TODO Legacy block still needed for GTH pseudos bundled with DFTK pseudo_type = PspHgh extension = ".hgh" @@ -38,10 +85,12 @@ function load_psp(key::AbstractString; kwargs...) if isfile(key) # Key is a file ... deduce identifier fullpath = key identifier = replace(key, "\\" => "/") - if startswith(identifier, datadir_psp()) - identifier = identifier[length(datadir_psp())+1:end] - end else # Not a file: treat as identifier, add extension if needed + @warn("Calling `load_psp` without specifying a full path to a pseudopotential file " * + "(i.e. identifiers such as hgh/lda/Si-q4) are deprecated as DFTK's internal " * + "pseudopotential library will be removed in the future. Please use the " * + "PseudoPotentialData package to supply pseudopotentials to DFTK. (e.g. here " * + "`load_psp(PseudoFamily(\"cp2k.nc.sr.lda.v0_1.semicore.gth\"), :Si)`)") fullpath = joinpath(datadir_psp(), lowercase(key)) isfile(fullpath) || (fullpath = fullpath * extension) identifier = replace(lowercase(key), "\\" => "/") @@ -50,35 +99,9 @@ function load_psp(key::AbstractString; kwargs...) if isfile(fullpath) return pseudo_type(fullpath; identifier, kwargs...) else - error("Could not find pseudopotential for identifier " * - "'$identifier' in directory '$(datadir_psp())'") + error("Could not find pseudopotential file '$key'") end end @deprecate(load_psp(dir::AbstractString, filename::AbstractString; kwargs...), load_psp(joinpath(dir, filename); kwargs...)) - -""" -Load all pseudopotentials from the pseudopotential family `pseudofamily` -corresponding to the atoms of a `system`. Returns the list of -the pseudopotential objects in the same order as the atoms in `system`. -Takes care that each pseudopotential object is only loaded once. -Applies the keyword arguments when loading all pseudopotentials. -`pseudofamily` can be a `PseudoPotentialData.PseudoFamily` or simply -a `Dict{Symbol,String}` which returns a file path when indexed -with an element symbol. -""" -function load_psp(pseudofamily::AbstractDict{Symbol,<:AbstractString}, - system::AbstractSystem; kwargs...) - # Cache for instantiated pseudopotentials. This is done to ensure that identical - # pseudos are indistinguishable in memory, which is used in the Model constructor - # to deduce the atom_groups. - cached_psps = Dict{String, Any}() - map(system) do atom - symbol = element_symbol(atom) - file::String = pseudofamily[symbol] - get!(cached_psps, file) do - load_psp(file; extra_pseudometa_kwargs(pseudofamily, symbol)..., kwargs...) - end - end -end diff --git a/src/scf/scfres.jl b/src/scf/scfres.jl index bbbf1429a3..92b49f3129 100644 --- a/src/scf/scfres.jl +++ b/src/scf/scfres.jl @@ -27,7 +27,7 @@ resulting `scfres` might not be fully consistent. end load_scfres(Val(ext), filename, basis; skip_hamiltonian, strict) end -function load_scfres(::Any, filename::AbstractString; kwargs...) +function load_scfres(::Val, filename::AbstractString, ::Any; kwargs...) error("The extension $(last(splitext(filename))) is currently not available. " * "A required package (e.g. JLD2 or HDF5) is not yet loaded.") end diff --git a/src/standard_models.jl b/src/standard_models.jl index ec14f8664f..18b68800ae 100644 --- a/src/standard_models.jl +++ b/src/standard_models.jl @@ -28,9 +28,9 @@ Construct an atomic system using the specified pseudo-dojo pseudopotentials for atoms of the system. ```julia-repl -julia> model_atomic(system; pseudopotentials=Dict(:Si => "hgh/lda/si-q4")) +julia> model_atomic(system; pseudopotentials=Dict(:Si => "path/to/pseudofile.upf")) ``` -same thing, but specify the pseudopotentials explicitly in a dictionary. +same thing, but specify the pseudopotential path explicitly in a dictionary. """ function model_atomic(system::AbstractSystem; pseudopotentials, kwargs...) # Note: We are enforcing to specify pseudopotentials at this interface diff --git a/src/terms/nonlocal.jl b/src/terms/nonlocal.jl index 709ea75d93..2f76b1f3ee 100644 --- a/src/terms/nonlocal.jl +++ b/src/terms/nonlocal.jl @@ -133,7 +133,7 @@ end # The ordering of the projector indices is (l,m,i), where l, m are the # AM quantum numbers and i is running over all projectors for a given l. # The matrix is block-diagonal with non-zeros only if l and m agree. -function build_projection_coefficients(T, psp::NormConservingPsp) +function build_projection_coefficients(T::Type, psp::NormConservingPsp) n_proj = count_n_proj(psp) proj_coeffs = zeros(T, n_proj, n_proj) count = 0 diff --git a/test/PspHgh.jl b/test/PspHgh.jl index 1a2687fdf8..1d02ccaeec 100644 --- a/test/PspHgh.jl +++ b/test/PspHgh.jl @@ -1,10 +1,12 @@ @testitem "Check reading 'C-lda-q4'" tags=[:psp] begin - using LinearAlgebra using DFTK: load_psp + using LinearAlgebra + using PseudoPotentialData - psp = load_psp("hgh/lda/C-q4") - - @test psp.identifier == "hgh/lda/c-q4" + filename = PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth")[:C] + psp = load_psp(filename) + @test psp isa PspHgh + @test psp.identifier == replace(filename, "\\" => "/") @test occursin("c", lowercase(psp.description)) @test occursin("pade", lowercase(psp.description)) @test psp.Zion == 4 @@ -17,12 +19,13 @@ end @testitem "Check reading 'Ni-lda-q18'" tags=[:psp] begin - using LinearAlgebra using DFTK: load_psp + using LinearAlgebra + using PseudoPotentialData - psp = load_psp("hgh/lda/Ni-q18") - - @test psp.identifier == "hgh/lda/ni-q18" + filename = PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth")[:Ni] + psp = load_psp(filename) + @test psp.identifier == replace(filename, "\\" => "/") @test occursin("ni", lowercase(psp.description)) @test occursin("pade", lowercase(psp.description)) @test psp.Zion == 18 @@ -38,8 +41,9 @@ end @testitem "Check evaluating 'Si-lda-q4'" tags=[:psp] begin using LinearAlgebra using DFTK: load_psp, eval_psp_projector_fourier, eval_psp_local_fourier + using PseudoPotentialData - psp = load_psp("hgh/lda/Si-q4") + psp = load_psp(PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth"), :Si) # Test local part evaluation @test eval_psp_local_fourier(psp, norm([0.1, 0, 0])) ≈ -400.395448865164*4π @@ -85,8 +89,9 @@ end using LinearAlgebra using DFTK: load_psp, eval_psp_projector_fourier, eval_psp_local_fourier using DFTK: pcut_psp_projector, pcut_psp_local + using PseudoPotentialData - psp = load_psp("hgh/pbe/au-q11.hgh") + psp = load_psp(PseudoFamily("cp2k.nc.sr.pbe.v0_1.semicore.gth"), :Au) ε = 1e-6 let @@ -106,9 +111,11 @@ end using LinearAlgebra using DFTK: load_psp, eval_psp_projector_fourier, eval_psp_local_fourier using DFTK: psp_local_polynomial, psp_projector_polynomial, count_n_proj_radial + using PseudoPotentialData + family = PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth") let - psp = load_psp("hgh/lda/Si-q4") + psp = load_psp(family, :Si) Qloc = psp_local_polynomial(Float64, psp) evalQloc(p) = let t = p * psp.rloc; Qloc(t) * exp(-t^2 / 2) / t^2; end for p in abs.(randn(10)) @@ -116,8 +123,8 @@ end end end - for pspfile in ["Au-q11", "Ba-q10"] - psp = load_psp("hgh/lda/" * pspfile) + for element in (:Au, :Ba) + psp = load_psp(family, element) for l = 0:psp.lmax, i = 1:count_n_proj_radial(psp, l) Qproj = psp_projector_polynomial(Float64, psp, i, l) evalQproj(p) = let t = p * psp.rp[l + 1]; Qproj(t) * exp(-t^2 / 2); end @@ -134,6 +141,7 @@ end using DFTK: count_n_proj_radial using SpecialFunctions: besselj using QuadGK + using PseudoPotentialData # The spherical bessel function of the first kind in terms of ordinary bessels: function j(n, x::T) where {T} @@ -146,8 +154,9 @@ end 4π * x^2 * eval_psp_projector_real(psp, i, l, x) * j(l, p*x) end - for pspfile in ["Au-q11", "Ba-q10"] - psp = load_psp("hgh/lda/" * pspfile) + family = PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth") + for element in (:Au, :Ba) + psp = load_psp(family, element) for l = 0:psp.lmax, i = 1:count_n_proj_radial(psp, l) for p in [0.01, 0.1, 0.2, 0.5, 1, 2, 5, 10] reference = quadgk(r -> integrand(psp, i, l, p, r), 0, Inf)[1] @@ -158,8 +167,9 @@ end end @testitem "Potentials are consistent in real and Fourier space" tags=[:psp] begin - using LinearAlgebra using DFTK: load_psp, eval_psp_local_fourier, eval_psp_local_real + using LinearAlgebra + using PseudoPotentialData using QuadGK reg_param = 1e-3 # divergent integral, needs regularization @@ -167,8 +177,9 @@ end 4π * eval_psp_local_real(psp, r) * exp(-reg_param * r) * sin(p*r) / p * r end - for pspfile in ["Au-q11", "Ba-q10"] - psp = load_psp("hgh/lda/" * pspfile) + family = PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth") + for element in (:Au, :Ba) + psp = load_psp(family, element) for p in [0.01, 0.2, 1, 1.3] reference = quadgk(r -> integrand(psp, p, r), 0, Inf)[1] @test reference ≈ eval_psp_local_fourier(psp, p) rtol=.1 atol = .1 @@ -180,6 +191,7 @@ end using LinearAlgebra using DFTK: load_psp, eval_psp_local_real, eval_psp_energy_correction using QuadGK + using PseudoPotentialData reg_param = 1e-6 # divergent integral, needs regularization p_small = 1e-6 # We are interested in p→0 term @@ -192,8 +204,9 @@ end end n_electrons = 20 - for pspfile in ["Au-q11", "Ba-q10"] - psp = load_psp("hgh/lda/" * pspfile) + family = PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth") + for element in (:Au, :Ba) + psp = load_psp(family, element) reference = quadgk(r -> integrand(psp, n_electrons, r), 0, Inf)[1] @test reference ≈ eval_psp_energy_correction(psp, n_electrons) atol=1e-2 end @@ -202,13 +215,28 @@ end @testitem "PSP energy correction is consistent with fourier-space potential" #= =# tags=[:psp] begin using LinearAlgebra + using PseudoPotentialData using DFTK: load_psp, eval_psp_local_fourier, eval_psp_energy_correction p_small = 1e-3 # We are interested in p→0 term - for pspfile in ["Au-q11", "Ba-q10"] - psp = load_psp("hgh/lda/" * pspfile) + family = PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth") + for element in (:Au, :Ba) + psp = load_psp(family, element) coulomb = -4π * psp.Zion / p_small^2 reference = eval_psp_local_fourier(psp, p_small) - coulomb @test reference ≈ eval_psp_energy_correction(psp, 1) atol=1e-3 end end + +@testitem "All pseudopotentials from common GTH families can be loaded" begin + using PseudoPotentialData + + for key in ("cp2k.nc.sr.lda.v0_1.semicore.gth", + "cp2k.nc.sr.pbe.v0_1.largecore.gth") + pseudopotentials = PseudoFamily(key) + for element in keys(pseudopotentials) + psp = load_psp(pseudopotentials, element) + @test psp isa PspHgh + end + end +end diff --git a/test/PspUpf.jl b/test/PspUpf.jl index 4662921547..9de8aeb40b 100644 --- a/test/PspUpf.jl +++ b/test/PspUpf.jl @@ -6,8 +6,8 @@ pd_pbe_family = PseudoFamily("dojo.nc.sr.pbe.v0_4_1.standard.upf") upf_pseudos = Dict( # Converted from cp2k repo (in GTH format) to UPF - :Si => load_psp(joinpath(@__DIR__, "gth_pseudos_upf", "Si.pbe-hgh.UPF")), - :Tl => load_psp(joinpath(@__DIR__, "gth_pseudos_upf", "Tl.pbe-d-hgh.UPF")), + :Si => load_psp(joinpath(@__DIR__, "gth_pseudos", "Si.pbe-hgh.upf")), + :Tl => load_psp(joinpath(@__DIR__, "gth_pseudos", "Tl.pbe-d-hgh.upf")), # No NLCC :Li => load_psp(pd_lda_family[:Li]), :Mg => load_psp(pd_lda_family[:Mg]), @@ -19,8 +19,8 @@ :Cr => load_psp(pd_pbe_family[:Cr]; rcut=12.0) ) gth_pseudos = [ - (; gth=load_psp("hgh/pbe/si-q4.hgh"), upf=upf_pseudos[:Si]), - (; gth=load_psp("hgh/pbe/tl-q13.hgh"), upf=upf_pseudos[:Tl]) + (; gth=load_psp(joinpath(@__DIR__, "gth_pseudos", "Si-q4.gth")), upf=upf_pseudos[:Si]), + (; gth=load_psp(joinpath(@__DIR__, "gth_pseudos", "Tl-q13.gth")), upf=upf_pseudos[:Tl]), ] end @@ -236,3 +236,17 @@ end end end end + +@testitem "All pseudopotentials from common UPF families can be loaded" begin + using PseudoPotentialData + + for key in ("dojo.nc.sr.lda.v0_4_1.standard.upf", + "dojo.nc.sr.pbe.v0_5.standard.upf", + "dojo.nc.sr.pbesol.v0_4_1.standard.upf") + pseudopotentials = PseudoFamily(key) + for element in keys(pseudopotentials) + psp = load_psp(pseudopotentials, element) + @test psp isa PspUpf + end + end +end diff --git a/test/aqua.jl b/test/aqua.jl index 0447f970e3..0a50fccec4 100644 --- a/test/aqua.jl +++ b/test/aqua.jl @@ -1,12 +1,19 @@ -@testitem "Aqua" tags=[:dont_test_mpi] begin +@testitem "Aqua" tags=[:dont_test_mpi, :dont_test_windows] begin # TODO For now disable type piracy check, as we use that at places to patch # up missing functionality. Should disable this on a more fine-grained scale. using DFTK using Aqua + using LinearAlgebra Aqua.test_all(DFTK; - ambiguities=false, + ambiguities=(; exclude=[ + # Type piracies we do for FFT stuff + *, \, mul!, dot, ldiv!, + # Libxc stuff + DFTK.potential_terms, DFTK.kernel_terms]), piracies=false, - deps_compat=(; check_extras=false), - stale_deps=(; ignore=[:Primes, ])) + deps_compat=(; check_extras=(; ignore=[:CUDA_Runtime_jll])), + stale_deps=(; ignore=[:Primes, ]), + persistent_tasks=(; broken=VERSION < v"1.11"), + ) end diff --git a/test/elements.jl b/test/elements.jl index d7421eaab2..f0714813a8 100644 --- a/test/elements.jl +++ b/test/elements.jl @@ -34,19 +34,21 @@ end using Unitful using UnitfulAtomic using AtomsBase + using PseudoPotentialData using DFTK: load_psp, charge_nuclear, charge_ionic, n_elec_core, n_elec_valence using DFTK: ElementPsp, local_potential_fourier, local_potential_real - el_by_symbol = ElementPsp(:W, load_psp("hgh/lda/w-q6")) + pseudopotentials = PseudoFamily("cp2k.nc.sr.lda.v0_1.largecore.gth") + el_by_symbol = ElementPsp(:W, pseudopotentials) @test charge_nuclear(el_by_symbol) == 74 @test element_symbol(el_by_symbol) == :W - el_by_number = ElementPsp(1, load_psp("hgh/pbe/H-q1")) + el_by_number = ElementPsp(1, pseudopotentials) @test el_by_number.species == ChemicalSpecies(:H) - element = ElementPsp(:C, load_psp("hgh/lda/C-q4")) + element = ElementPsp(:C, pseudopotentials) @test species(element) == ChemicalSpecies(:C) @test element.psp !== nothing - @test element.psp.identifier == "hgh/lda/c-q4" + @test element.psp.identifier == replace(pseudopotentials[:C], "\\" => "/") @test mass(element) == 12.011u"u" @test element_symbol(element) == :C diff --git a/test/energy_nuclear.jl b/test/energy_nuclear.jl index aaf3abac12..75c67de914 100644 --- a/test/energy_nuclear.jl +++ b/test/energy_nuclear.jl @@ -1,10 +1,11 @@ @testitem "energy_forces_ewald Lithium hydride" begin using DFTK + using PseudoPotentialData using LinearAlgebra: Diagonal lattice = 16 * Diagonal(ones(3)) H = ElementCoulomb(1) - Li = ElementPsp(3, load_psp("hgh/lda/Li-q1")) + Li = ElementPsp(:Li, PseudoFamily("cp2k.nc.sr.lda.v0_1.largecore.gth")) atoms = [H, Li] positions = [ [1/2, 1/2, 0.5953697526034847], @@ -18,11 +19,12 @@ end @testitem "energy_forces_ewald silicon" begin using DFTK + using PseudoPotentialData lattice = [0.0 5.131570667152971 5.131570667152971; 5.131570667152971 0.0 5.131570667152971; 5.131570667152971 5.131570667152971 0.0] - Si = ElementPsp(14, load_psp("hgh/lda/Si-q4")) + Si = ElementPsp(:Si, PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth")) atoms = [Si, Si] positions = [[1/8, 1/8, 1/8], [-1/8, -1/8, -1/8]] @@ -33,11 +35,12 @@ end @testitem "energy_psp_correction silicon" begin using DFTK + using PseudoPotentialData lattice = [0.0 5.131570667152971 5.131570667152971; 5.131570667152971 0.0 5.131570667152971; 5.131570667152971 5.131570667152971 0.0] - Si = ElementPsp(14, load_psp("hgh/lda/Si-q4")) + Si = ElementPsp(:Si, PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth")) atoms = [Si, Si] positions = [[1/8, 1/8, 1/8], [-1/8, -1/8, -1/8]] model = Model(lattice, atoms, positions; terms=[PspCorrection()]) diff --git a/test/external/atomsbase.jl b/test/external/atomsbase.jl index 530e1ba639..0932f533e8 100644 --- a/test/external/atomsbase.jl +++ b/test/external/atomsbase.jl @@ -5,9 +5,10 @@ using AtomsBase using PseudoPotentialData + family = PseudoFamily("dojo.nc.sr.pbe.v0_4_1.standard.upf") Si = ElementCoulomb(:Si) - C = ElementPsp(:C, load_psp("hgh/pbe/c-q4.hgh")) - H = ElementPsp(:H, load_psp("hgh/lda/h-q1.hgh")) + C = ElementPsp(:C, family) + H = ElementPsp(:H, family) lattice = randn(3, 3) atoms = [Si, C, H, C] @@ -21,7 +22,8 @@ @test position(system, :) == [lattice * p * u"bohr" for p in positions] @test system[:, :magnetic_moment] == magnetic_moments - let parsed = DFTK.parse_system(system, fill(nothing, length(atoms))) + @testset "Parsing system without pseudopotentials" begin + parsed = DFTK.parse_system(system, fill(nothing, length(atoms))) @test parsed.lattice ≈ lattice atol=1e-12 @test parsed.positions ≈ positions atol=1e-12 for i = 1:4 @@ -35,20 +37,21 @@ @test parsed.atoms[4] == ElementCoulomb(:C) end - pspmap = Dict(:H => "hgh/pbe/h-q1.hgh", :Si => "hgh/pbe/si-q4.hgh", - :C => "hgh/pbe/c-q4.hgh") - let parsed = DFTK.parse_system(system, pspmap) + @testset "Parsing system with dictionary of explicit paths" begin + gth = PseudoFamily("cp2k.nc.sr.lda.v0_1.largecore.gth") + pspmap = Dict(:H => family[:H], :Si => family[:Si], :C => gth[:C]) + parsed = DFTK.parse_system(system, pspmap) @test length(parsed.atoms) == 4 - @test parsed.atoms[1].psp.identifier == pspmap[:Si] - @test parsed.atoms[2].psp.identifier == pspmap[:C] - @test parsed.atoms[3].psp.identifier == pspmap[:H] - @test parsed.atoms[4].psp.identifier == pspmap[:C] - end - - family = PseudoFamily("dojo.nc.sr.pbe.v0_4_1.standard.upf") - let model = model_atomic(system; pseudopotentials=family) # Identifier is filename, but on windows we replace backslash path # delimiter by forward slash to homogenise the identifier + @test parsed.atoms[1].psp.identifier == replace(pspmap[:Si], "\\" => "/") + @test parsed.atoms[2].psp.identifier == replace(pspmap[:C], "\\" => "/") + @test parsed.atoms[3].psp.identifier == replace(pspmap[:H], "\\" => "/") + @test parsed.atoms[4].psp.identifier == replace(pspmap[:C], "\\" => "/") + end + + @testset "Constructing model with pseudo family" begin + model = model_atomic(system; pseudopotentials=family) @test length(model.atoms) == 4 @test model.atoms[1].psp.identifier == replace(family[:Si], "\\" => "/") @test model.atoms[2].psp.identifier == replace(family[:C], "\\" => "/") @@ -56,17 +59,19 @@ @test model.atoms[4].psp.identifier == replace(family[:C], "\\" => "/") end - for constructor in (Model, model_atomic) - model = constructor(system; pseudopotentials=family) - @test model.spin_polarization == :collinear - newsys = periodic_system(model, magnetic_moments) - - @test atomic_symbol(system, :) == atomic_symbol(newsys, :) - @test mass(system, :) == mass(newsys, :) - @test cell_vectors(system) == cell_vectors(newsys) - @test periodicity(system) == periodicity(newsys) - @test maximum(maximum, position(system, :) - position(newsys, :)) < 1e-12u"bohr" - @test system[:, :magnetic_moment] == newsys[:, :magnetic_moment] + @testset "system -> Model -> system" begin + for constructor in (Model, model_atomic) + model = constructor(system; pseudopotentials=family) + @test model.spin_polarization == :collinear + newsys = periodic_system(model, magnetic_moments) + + @test atomic_symbol(system, :) == atomic_symbol(newsys, :) + @test mass(system, :) == mass(newsys, :) + @test cell_vectors(system) == cell_vectors(newsys) + @test periodicity(system) == periodicity(newsys) + @test maximum(maximum, position(system, :) - position(newsys, :)) < 1e-12u"bohr" + @test system[:, :magnetic_moment] == newsys[:, :magnetic_moment] + end end end @@ -139,24 +144,26 @@ end @test model.atoms[4] == ElementCoulomb(:C) end - pbemap = Dict(:H => "hgh/pbe/h-q1.hgh", :Si => "hgh/pbe/si-q4.hgh", - :C => "hgh/pbe/c-q4.hgh") - let model = Model(system; pseudopotentials=pbemap) + pbegth = PseudoFamily("dojo.nc.sr.pbe.v0_4_1.standard.upf") + ldagth = PseudoFamily("cp2k.nc.sr.lda.v0_1.largecore.gth") + pspmap = Dict(:H => pbegth[:H], :Si => pbegth[:Si], :C => ldagth[:C]) + let model = Model(system; pseudopotentials=pspmap) @test model.lattice ≈ pos_lattice atol=1e-12 @test model.positions ≈ pos_units atol=1e-12 @test model.spin_polarization == :none @test length(model.atoms) == 4 - @test model.atoms[1].psp.identifier == "hgh/pbe/c-q4.hgh" - @test model.atoms[2].psp.identifier == "hgh/pbe/si-q4.hgh" - @test model.atoms[3].psp.identifier == "hgh/pbe/h-q1.hgh" - @test model.atoms[4].psp.identifier == "hgh/pbe/c-q4.hgh" + @test model.atoms[1].psp.identifier == replace(pspmap[:C], "\\" => "/") + @test model.atoms[2].psp.identifier == replace(pspmap[:Si], "\\" => "/") + @test model.atoms[3].psp.identifier == replace(pspmap[:H], "\\" => "/") + @test model.atoms[4].psp.identifier == replace(pspmap[:C], "\\" => "/") end let - psp_Si = load_psp("hgh/pbe/si-q4.hgh") - psp_H = load_psp("hgh/lda/h-q1.hgh") - psp_C = load_psp("hgh/pbe/c-q4.hgh") + gth = PseudoFamily("cp2k.nc.sr.lda.v0_1.largecore.gth") + psp_Si = load_psp(gth, :Si) + psp_H = load_psp(gth, :H) + psp_C = load_psp(gth, :C) model = Model(system; pseudopotentials=[nothing, psp_Si, psp_H, psp_C]) @test model.lattice ≈ pos_lattice atol=1e-12 @@ -192,16 +199,15 @@ end using Unitful using UnitfulAtomic using AtomsBase + using PseudoPotentialData lattice = [12u"bohr" * rand(3) for _ = 1:3] - # Later with AtomsBase 0.5 - # atoms = [Atom(6, randn(3)u"Å"; species=ChemicalSpecies(:C12), mass=-1u"u"), - # Atom(6, randn(3)u"Å"; species=ChemicalSpecies(:C), mass=-2u"u")] - atoms = [Atom(6, randn(3)u"Å"; atomic_symbol=:C, mass=-1u"u"), - Atom(6, randn(3)u"Å"; atomic_symbol=:C, mass=-2u"u")] + atoms = [Atom(6, randn(3)u"Å"; species=ChemicalSpecies(:C12), mass=-1u"u"), + Atom(6, randn(3)u"Å"; species=ChemicalSpecies(:C), mass=-2u"u")] system = periodic_system(atoms, lattice) - pseudopotentials = Dict(:C => "hgh/lda/c-q4.hgh") + gth = PseudoFamily("cp2k.nc.sr.lda.v0_1.largecore.gth") + pseudopotentials = Dict(:C => gth[:C]) let model = model_DFT(system; functionals=LDA(), pseudopotentials) @test model.lattice == austrip.(stack(lattice)) @test model.lattice * model.positions[1] * u"bohr" ≈ atoms[1].position @@ -212,7 +218,7 @@ end @test element_symbol(model.atoms[1]) == :C @test element_symbol(model.atoms[2]) == :C @test mass.(model.atoms) == [-1u"u", -2u"u"] - @test model.atoms[1].psp.identifier == "hgh/lda/c-q4.hgh" - @test model.atoms[2].psp.identifier == "hgh/lda/c-q4.hgh" + @test model.atoms[1].psp.identifier == replace(gth[:C], "\\" => "/") + @test model.atoms[2].psp.identifier == replace(gth[:C], "\\" => "/") end end diff --git a/test/external/spglib.jl b/test/external/spglib.jl index 3396eadfd0..2e5b1d255b 100644 --- a/test/external/spglib.jl +++ b/test/external/spglib.jl @@ -2,10 +2,11 @@ using DFTK using DFTK: spglib_dataset, spglib_standardize_cell using LinearAlgebra + using PseudoPotentialData a = 10.3 - Si = ElementPsp(:Si, load_psp("hgh/lda/Si-q4")) - Ge = ElementPsp(:Ge, load_psp("hgh/lda/Ge-q4")) + Si = ElementPsp(:Si, PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth")) + Ge = ElementPsp(:Ge, PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth")) # silicon lattice = a / 2 * [[0 1 1.]; [1 0 1.]; [1 1 0.]] diff --git a/test/forwarddiff.jl b/test/forwarddiff.jl index 0a096fdbd2..3055846e05 100644 --- a/test/forwarddiff.jl +++ b/test/forwarddiff.jl @@ -73,10 +73,11 @@ end using ForwardDiff using LinearAlgebra using ComponentArrays + using PseudoPotentialData aluminium = TestCases.aluminium function compute_band_energies(ε::T) where {T} - psp = load_psp("hgh/lda/al-q3") + psp = load_psp(PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth"), :Al) rloc = convert(T, psp.rloc) pspmod = PspHgh(psp.Zion, rloc, diff --git a/test/gth_pseudos/README.md b/test/gth_pseudos/README.md new file mode 100644 index 0000000000..aff59a0acf --- /dev/null +++ b/test/gth_pseudos/README.md @@ -0,0 +1,3 @@ +These files contain two GTH pseudopotentials from the cp2k repository +and equivalent representations as UPF files. This is for consistency +tests of PspHgh against PspUpf. diff --git a/test/gth_pseudos/Si-q4.gth b/test/gth_pseudos/Si-q4.gth new file mode 100644 index 0000000000..750172f5a8 --- /dev/null +++ b/test/gth_pseudos/Si-q4.gth @@ -0,0 +1,7 @@ +Si GTH-PBE-q4 + 2 2 + 0.44000000 1 -6.26928833 + 2 + 0.43563383 2 8.95174150 -2.70627082 + 3.49378060 + 0.49794218 1 2.43127673 diff --git a/test/gth_pseudos_upf/Si.pbe-hgh.UPF b/test/gth_pseudos/Si.pbe-hgh.upf similarity index 100% rename from test/gth_pseudos_upf/Si.pbe-hgh.UPF rename to test/gth_pseudos/Si.pbe-hgh.upf diff --git a/test/gth_pseudos/Tl-q13.gth b/test/gth_pseudos/Tl-q13.gth new file mode 100644 index 0000000000..af5d35cf95 --- /dev/null +++ b/test/gth_pseudos/Tl-q13.gth @@ -0,0 +1,10 @@ +Tl GTH-PBE-q13 + 2 1 10 + 0.55000000 1 12.29058515 + 3 + 0.51280306 2 7.19017017 -2.86301073 + 3.69613096 + 0.57711505 2 4.76094580 -3.67332496 + 4.34633671 + 0.39323001 2 -11.01268700 6.42159202 + -7.28140093 diff --git a/test/gth_pseudos_upf/Tl.pbe-d-hgh.UPF b/test/gth_pseudos/Tl.pbe-d-hgh.upf similarity index 100% rename from test/gth_pseudos_upf/Tl.pbe-d-hgh.UPF rename to test/gth_pseudos/Tl.pbe-d-hgh.upf diff --git a/test/list_psp.jl b/test/list_psp.jl index 282e24d01a..b88efbd5d3 100644 --- a/test/list_psp.jl +++ b/test/list_psp.jl @@ -1,9 +1,12 @@ @testitem "Check reading all HGH pseudos" tags=[:psp] begin using DFTK: load_psp, list_psp + using Logging - for record in list_psp() - psp = load_psp(record.identifier) - @test psp.identifier == record.identifier - @test psp.Zion == record.n_elec_valence + with_logger(NullLogger()) do + for record in list_psp() + psp = load_psp(record.identifier) + @test psp.identifier == record.identifier + @test psp.Zion == record.n_elec_valence + end end end diff --git a/test/lobpcg.jl b/test/lobpcg.jl index 56bfa50ab3..19e463a172 100644 --- a/test/lobpcg.jl +++ b/test/lobpcg.jl @@ -50,9 +50,10 @@ end @testitem "Diagonalization of kinetic + local PSP" tags=[:slow] setup=[TestCases] begin using DFTK + using PseudoPotentialData silicon = TestCases.silicon - Si = ElementPsp(silicon.atnum, load_psp("hgh/lda/si-q4")) + Si = ElementPsp(silicon.atnum, PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth")) model = Model(silicon.lattice, silicon.atoms, silicon.positions; terms=[Kinetic(),AtomicLocal()]) basis = PlaneWaveBasis(model; Ecut=25, silicon.kgrid, fft_size=[33, 33, 33]) @@ -76,9 +77,10 @@ end @testitem "Diagonalization of a core Hamiltonian" setup=[TestCases] begin using DFTK + using PseudoPotentialData silicon = TestCases.silicon - Si = ElementPsp(silicon.atnum, load_psp("hgh/lda/si-q4")) + Si = ElementPsp(silicon.atnum, PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth")) model = Model(silicon.lattice, silicon.atoms, silicon.positions; terms=[Kinetic(), AtomicLocal(), AtomicNonlocal()]) @@ -103,9 +105,10 @@ end @testitem "Full diagonalization of a LDA Hamiltonian" setup=[TestCases] begin using DFTK + using PseudoPotentialData silicon = TestCases.silicon - Si = ElementPsp(silicon.atnum, load_psp("hgh/lda/si-q4")) + Si = ElementPsp(silicon.atnum, PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth")) model = model_DFT(silicon.lattice, silicon.atoms, silicon.positions; functionals=[:lda_xc_teter93]) basis = PlaneWaveBasis(model; Ecut=2, silicon.kgrid) diff --git a/test/silicon_lda.jl b/test/silicon_lda.jl index 82fa05a31b..fdb29abbe4 100644 --- a/test/silicon_lda.jl +++ b/test/silicon_lda.jl @@ -1,5 +1,6 @@ @testmodule SiliconLDA begin using DFTK +using PseudoPotentialData using ..RunSCF: run_scf_and_compare using ..TestCases: silicon @@ -18,7 +19,7 @@ function run_silicon_lda(T; Ecut=5, grid_size=15, spin_polarization=:none, kwarg ] ref_etot = -7.911817522631488 - Si = ElementPsp(silicon.atnum, load_psp("hgh/lda/si-q4")) + Si = ElementPsp(silicon.atnum, PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth")) atoms = [Si, Si] if spin_polarization == :collinear diff --git a/test/silicon_pbe.jl b/test/silicon_pbe.jl index dc53deb10d..4cb32e7ed6 100644 --- a/test/silicon_pbe.jl +++ b/test/silicon_pbe.jl @@ -1,5 +1,6 @@ @testmodule SiliconPBE begin using DFTK +using PseudoPotentialData using ..RunSCF: run_scf_and_compare using ..TestCases: silicon @@ -22,7 +23,7 @@ function run_silicon_pbe(T; Ecut=5, grid_size=15, spin_polarization=:none, kwarg ] ref_etot = -7.854477356672080 - Si = ElementPsp(silicon.atnum, load_psp("hgh/pbe/si-q4")) + Si = ElementPsp(silicon.atnum, PseudoFamily("cp2k.nc.sr.pbe.v0_1.semicore.gth")) atoms = [Si, Si] if spin_polarization == :collinear diff --git a/test/silicon_redHF.jl b/test/silicon_redHF.jl index 337dc41004..ff8fcdeaf2 100644 --- a/test/silicon_redHF.jl +++ b/test/silicon_redHF.jl @@ -1,5 +1,6 @@ @testmodule SiliconRedHF begin using DFTK +using PseudoPotentialData using ..RunSCF: run_scf_and_compare using ..TestCases: silicon @@ -26,7 +27,7 @@ function run_silicon_redHF(T; Ecut=5, grid_size=15, spin_polarization=:none, kwa fft_size = fill(grid_size, 3) fft_size = DFTK.next_working_fft_size(T, fft_size) # ad-hoc fix for buggy generic FFTs - Si = ElementPsp(silicon.atnum, load_psp("hgh/lda/si-q4")) + Si = ElementPsp(silicon.atnum, PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth")) atoms = [Si, Si] if spin_polarization == :collinear diff --git a/test/silicon_scan.jl b/test/silicon_scan.jl index 5d54bae0c0..ef9e79d2ed 100644 --- a/test/silicon_scan.jl +++ b/test/silicon_scan.jl @@ -1,5 +1,6 @@ @testitem "Silicon SCAN (small)" tags=[:core] setup=[TestCases, RunSCF] begin using DFTK + using PseudoPotentialData run_scf_and_compare = RunSCF.run_scf_and_compare silicon = TestCases.silicon @@ -17,7 +18,7 @@ ref_etot = -7.856498623457256 T = Float64 - Si = ElementPsp(silicon.atnum, load_psp("hgh/pbe/Si-q4")) + Si = ElementPsp(silicon.atnum, PseudoFamily("cp2k.nc.sr.pbe.v0_1.semicore.gth")) model = model_DFT(silicon.lattice, [Si, Si], silicon.positions; functionals=SCAN()) basis = PlaneWaveBasis(Model{T}(model); Ecut=15, fft_size=(27, 27, 27), kgrid=(3, 3, 3)) run_scf_and_compare(T, basis, ref_scan, ref_etot; scf_ene_tol=1e-9, test_tol=5e-5, @@ -27,6 +28,7 @@ end @testitem "Silicon SCAN (large)" tags=[:slow, :core] setup=[TestCases, RunSCF] begin using DFTK + using PseudoPotentialData run_scf_and_compare = RunSCF.run_scf_and_compare silicon = TestCases.silicon @@ -44,7 +46,7 @@ end ref_etot = -7.857384389260792 T = Float64 - Si = ElementPsp(silicon.atnum, load_psp("hgh/pbe/Si-q4")) + Si = ElementPsp(silicon.atnum, PseudoFamily("cp2k.nc.sr.pbe.v0_1.semicore.gth")) model = model_DFT(silicon.lattice, [Si, Si], silicon.positions; functionals=SCAN()) basis = PlaneWaveBasis(Model{T}(model); Ecut=50, fft_size=(48, 48, 48), kgrid=(3, 3, 3)) run_scf_and_compare(T, basis, ref_scan, ref_etot; test_tol=1e-8, n_ignored=2, diff --git a/test/symmetry_issues.jl b/test/symmetry_issues.jl index 9cdca2aa27..f104fab830 100644 --- a/test/symmetry_issues.jl +++ b/test/symmetry_issues.jl @@ -26,6 +26,8 @@ end @testset "Inlining" begin + using PseudoPotentialData + # Test that the index_G_vectors function is properly inlined by comparing timing # with a locally defined function known not to be inlined. Issue initially tackled # in PR https://github.com/JuliaMolSim/DFTK.jl/pull/1025 @@ -58,7 +60,7 @@ end silicon = TestCases.silicon - Si = ElementPsp(silicon.atnum, load_psp("hgh/lda/si-q4")) + Si = ElementPsp(silicon.atnum, PseudoFamily("cp2k.nc.sr.lda.v0_1.semicore.gth")) atoms = [Si, Si] model = model_DFT(silicon.lattice, atoms, silicon.positions; functionals=[:lda_x, :lda_c_vwn])