Skip to content

Commit

Permalink
Test reformatting and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mfherbst committed Feb 4, 2020
1 parent 0de1c2f commit a691bbb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Memoization = "6fafb56a-5788-4b4e-91ca-c0cea6611c73"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
NLSolversBase = "d41bc354-129a-5804-8e4c-c37616107c6c"
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
Primes = "27ebfcd6-29c5-5fa9-bf4b-fb8fc14df3ae"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Expand All @@ -36,7 +35,8 @@ julia = "1.2"
[extras]
DoubleFloats = "497a8b3b-efae-58df-a0af-a86822472b78"
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "DoubleFloats", "IntervalArithmetic"]
test = ["Test", "DoubleFloats", "IntervalArithmetic", "Random"]
21 changes: 3 additions & 18 deletions test/forces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,18 @@ using Test
lattice = silicon.lattice
Si = Element(silicon.atnum, psp=load_psp(silicon.psp))
atoms = [Si => pos]

model = Model(lattice;
atoms=atoms,
external=term_external(atoms),
nonlocal=term_nonlocal(atoms),
hartree=term_hartree(),
xc=term_xc(:lda_xc_teter93))

model = model_dft(silicon.lattice, :lda_xc_teter93, atoms)
kcoords, ksymops = bzmesh_ir_wedge(kgrid, lattice, atoms)
basis = PlaneWaveBasis(model, Ecut, kcoords, ksymops)

# Run SCF. Note Silicon is a semiconductor, so we use an insulator
# occupation scheme. This will cause warnings in some models, because
# e.g. in the :reduced_hf model silicon is a metal
n_bands_scf = Int(model.n_electrons / 2)
ham = Hamiltonian(basis, guess_density(basis))
scfres = self_consistent_field(ham, n_bands_scf, tol=1e-12)
ham = scfres.ham

energies = scfres.energies
sum(values(energies)), forces(scfres)
sum(values(scfres.energies)), forces(scfres)
end

using Random
Random.seed!(0)

pos1 = [(ones(3)+.1*randn(3))/8, -ones(3)/8]
pos1 = [(ones(3)+0.1*randn(3))/8, -ones(3)/8]
disp = randn(3)
ε = 1e-7
pos2 = [pos1[1]+ε*disp, pos1[2]]
Expand Down
6 changes: 5 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Test
using DFTK
using Random

#
# This test suite test arguments. For example:
Expand All @@ -26,6 +27,8 @@ else
println(" Running tests (TAGS = $(join(TAGS, ", "))).")
end

# Initialise seed
Random.seed!(0)

# Wrap in an outer testset to get a full report if one test fails
@testset "DFTK.jl" begin
Expand Down Expand Up @@ -65,11 +68,12 @@ end
end

if "all" in TAGS
include("energy_ewald.jl")
include("ewald.jl")
include("energy_nuclear.jl")
include("occupation.jl")
include("energies_guess_density.jl")
include("compute_density.jl")
include("forces.jl")
end

if "all" in TAGS
Expand Down

0 comments on commit a691bbb

Please sign in to comment.