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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/docs/build/

.DS_Store
.vscode/
32 changes: 6 additions & 26 deletions src/struct.jl
Original file line number Diff line number Diff line change
@@ -1,33 +1,13 @@
struct Lattice{T}
vectors::AbstractMatrix{T}
pbc::AbstractVector{Bool}
vectors::Matrix{T}
pbc::Vector{Bool}
end

struct Ion{T}
species::String
species::Symbol
charge::Int
frac_pos::AbstractVector{T}
frac_pos::Vector{T}
end

function periodic_vectors(lattice::Lattice{T}) where T
periodic_vectors = Matrix{T}(undef, size(lattice.vectors)[1], sum(lattice.pbc))
for column in range(1, size(lattice.vectors)[2])
if lattice.pbc[column]
periodic_vectors[:, column] = lattice.vectors[:, column]
end
end
return periodic_vectors
end

function build_grid(nsize::AbstractVector{Int})
function decompose(n::Int)
remain = n
result = Vector{Int}(undef, length(nsize))
for i in range(1, length(nsize))
result[i] = remain ÷ prod(nsize[i+1:end])
remain = remain % prod(nsize[i+1:end])
end
return result
end
return [decompose(n) for n in range(0, prod(nsize) - 1)]
end
periodic_vectors(lattice::Lattice) = lattice.vectors[:, lattice.pbc]
build_grid(nsize::AbstractVector{Int}) = map(x->collect(x.I[end:-1:1] .- 1), vec(CartesianIndices(Tuple(nsize[end:-1:1]))))
12 changes: 6 additions & 6 deletions test/interaction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ using CrystalStructurePrediction
end

@testset "real_space_sum" begin
ion_a = Ion("", rand(3), 1)
ion_b = Ion("", rand(3), 2)
ion_a = Ion(:none, 1, rand(3))
ion_b = Ion(:none, 2, rand(3))
lattice = Lattice(rand(3,3), [true, true, true])
alpha = 2.0
for depth in range(0,4)
Expand All @@ -18,8 +18,8 @@ end
end

@testset "reciprocal_space_sum" begin
ion_a = Ion("", rand(3), 1)
ion_b = Ion("", rand(3), 2)
ion_a = Ion(:none, 1, rand(3))
ion_b = Ion(:none, 2, rand(3))
lattice = Lattice(rand(3,3), [true, true, true])
alpha = 2.0
for depth in range(0,4)
Expand All @@ -29,8 +29,8 @@ end
end

@testset "buckingham_sum" begin
ion_a = Ion("Sr", rand(3), 1)
ion_b = Ion("O", rand(3), 2)
ion_a = Ion(:Sr, 1, rand(3))
ion_b = Ion(:O, 2, rand(3))
lattice = Lattice(rand(3,3), [true, true, true])
for depth in range(0,4)
depth_list = [depth for _ in range(1,3)]
Expand Down
Loading