Skip to content

Commit

Permalink
maddening; let's sleep on it
Browse files Browse the repository at this point in the history
  • Loading branch information
epolack committed Feb 16, 2024
1 parent 5d23a38 commit e50f306
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 31 deletions.
9 changes: 7 additions & 2 deletions src/abinit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function AbinitState(params::AbinitParameters; extra_parameters...)
ase_atoms.calc = pyimport("ase.calculators.abinit").Abinit(;
label="abinit",
params.ecut,
params.kpts,
#params.kpts,
params.tolwfr,
params.xc,
#ixc = "-001012", # explicit [:lda_x, :lda_c_pw]
Expand All @@ -47,6 +47,11 @@ function AbinitState(params::AbinitParameters; extra_parameters...)
# pseudos="tt",
params.pps,
nsym=1,
# Otherwise, cannot have non-symmetric kgrid because of ASE that uses kptopt=1…
kptopt=1,
nshiftk=1,
ngkpt="1 2 1",
shiftk="0.0 0.0 0.0",
v8_legacy_format=false,
extra_parameters...,
)
Expand Down Expand Up @@ -101,7 +106,7 @@ function energy(state::AbinitState)
finally
@debug open("$tmpdir/abinit.in") do f
while !eof(f)
@debug readline(f)
@info readline(f)
end
end
cd(cdir)
Expand Down
59 changes: 30 additions & 29 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,36 @@ ENV["HDF5_DISABLE_VERSION_CHECK"] = "2"
end
end

@testset "Abinit" begin
using ASEconvert
using DFTK
using LinearAlgebra
using LazyArtifacts

system = pyconvert(AbstractSystem, ase.build.bulk("Si"))
# Yep, LDA for PBE computations…
system = attach_psp(system; Si="hgh/lda/si-q4")
#= Systematic error…
pd_pbe_family = artifact"pd_nc_sr_pbe_standard_0.4.1_upf"
system = attach_psp(system; Si=joinpath(pd_pbe_family, "Si.upf"))
=#

energy_abinit = let
state_abinit = AbinitState(AbinitParameters(; system))
energy(state_abinit)
end
energy_dftk = let
state_dftk = DftkState(DftkParameters(; system,
# functionals=[:lda_x, :lda_c_pw],
basis_kwargs = (; Ecut=10, kgrid=[1, 2, 1]),
scf_kwargs = (; tol=1e-6),
))
state_dftk = calculate(DftkCalculator(), state_dftk)
energy(state_dftk)
end
@test norm(energy_dftk - energy_abinit) < 1e-6
end

@testset "Abinit: Phonon" begin
using ASEconvert
using DFTK
Expand Down Expand Up @@ -49,32 +79,3 @@ end
#end
# Not equivalent for the moment.
end

@testset "Abinit" begin
using ASEconvert
using DFTK
using LinearAlgebra
using LazyArtifacts

system = pyconvert(AbstractSystem, ase.build.bulk("Si"))
system = attach_psp(system; Si="hgh/lda/si-q4")
#= Systematic error…
pd_pbe_family = artifact"pd_nc_sr_pbe_standard_0.4.1_upf"
system = attach_psp(system; Si=joinpath(pd_pbe_family, "Si.upf"))
=#

energy_abinit = let
state_abinit = AbinitState(AbinitParameters(; system))
energy(state_abinit)
end
energy_dftk = let
state_dftk = DftkState(DftkParameters(; system,
# functionals=[:lda_x, :lda_c_pw],
basis_kwargs = (; Ecut=10, kgrid=[1, 1, 1]),
scf_kwargs = (; tol=1e-6),
))
state_dftk = calculate(DftkCalculator(), state_dftk)
energy(state_dftk)
end
@test norm(energy_dftk - energy_abinit) < 1e-6
end

0 comments on commit e50f306

Please sign in to comment.