diff --git a/src/lattice/generate.jl b/src/lattice/generate.jl index 6c6051c..a5ff1ef 100644 --- a/src/lattice/generate.jl +++ b/src/lattice/generate.jl @@ -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