Skip to content

Commit

Permalink
Merge pull request #29 from yomichi/fix_boundary_condition
Browse files Browse the repository at this point in the history
boundary condition didn't work
  • Loading branch information
yomichi authored Jun 10, 2024
2 parents 152de42 + 5a01c83 commit 6756938
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions src/lattice/generate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,26 +119,22 @@ function generatelattice_std(param)
push!(sites, s)
end
for bond in ubonds
for d in 1:D
if !(bc[d] || bond.source.offset[d] == bond.source.offset[d])
if !(0 <=
cellcoord[d] + (bond.target.offset[d] - bond.source.offset[d]) <
L[d])
continue
end
end
if any(bond.source.offset .!= 0)
error("offset in source should be zero")
end
target_coord = cellcoord .+ bond.target.offset
if all((0 .<= target_coord .< L) .| bc)
source = numsites_in_cell * coord2index(cellcoord, L) + bond.source.id
target = numsites_in_cell *
coord2index(cellcoord .+ bond.target.offset, L) + bond.target.id
dir = latvec * ((bond.target.offset .+ usites[bond.target.id].coord)
.-
(bond.source.offset .+ usites[bond.source.id].coord))
ib += 1
b = Bond(ib, ifelse(use_index_as_bondtype, ib, bond.bondtype), source,
target, dir)
push!(bonds, b)
end
source = numsites_in_cell * coord2index(cellcoord .+ bond.source.offset, L) +
bond.source.id
target = numsites_in_cell * coord2index(cellcoord .+ bond.target.offset, L) +
bond.target.id
dir = latvec * ((bond.target.offset .+ usites[bond.target.id].coord)
.-
(bond.source.offset .+ usites[bond.source.id].coord))
ib += 1
b = Bond(ib, ifelse(use_index_as_bondtype, ib, bond.bondtype), source, target,
dir)
push!(bonds, b)
end
end

Expand Down

0 comments on commit 6756938

Please sign in to comment.