Skip to content

Commit

Permalink
(fixed) boundary condition didn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
yomichi committed Jun 10, 2024
1 parent 77ac4fa commit edd3bc5
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions src/lattice/generate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,31 +114,24 @@ function generatelattice_std(param)
for site in usites
id = numsites_in_cell * icell + site.id
coord = latvec * (cellcoord .+ site.coord)
s = Site(id, ifelse(use_index_as_sitetype, id, site.sitetype), Int[], Int[],
coord, site.id, cellcoord)
s = Site(id, ifelse(use_index_as_sitetype, id, site.sitetype), Int[], Int[], coord, site.id, cellcoord)
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 * cellcoord + 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 edd3bc5

Please sign in to comment.