From edd3bc5ebf0bfb49962c2d50f54a8667a6111249 Mon Sep 17 00:00:00 2001 From: Yuichi Motoyama Date: Mon, 10 Jun 2024 12:56:18 +0900 Subject: [PATCH 1/4] (fixed) boundary condition didn't work --- src/lattice/generate.jl | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/src/lattice/generate.jl b/src/lattice/generate.jl index 6c6051c..473882e 100644 --- a/src/lattice/generate.jl +++ b/src/lattice/generate.jl @@ -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 From 26c0184222d04854b792adf545e5e9455e80875c Mon Sep 17 00:00:00 2001 From: Yuichi Motoyama Date: Mon, 10 Jun 2024 12:57:41 +0900 Subject: [PATCH 2/4] format --- src/lattice/generate.jl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lattice/generate.jl b/src/lattice/generate.jl index 473882e..beb9381 100644 --- a/src/lattice/generate.jl +++ b/src/lattice/generate.jl @@ -114,7 +114,8 @@ 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 @@ -124,12 +125,14 @@ function generatelattice_std(param) 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 + 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) + b = Bond(ib, ifelse(use_index_as_bondtype, ib, bond.bondtype), source, + target, dir) push!(bonds, b) end end From 35607d1cf9e5a5b91534159eee881422dac90080 Mon Sep 17 00:00:00 2001 From: Yuichi Motoyama Date: Mon, 10 Jun 2024 13:08:04 +0900 Subject: [PATCH 3/4] use .| instead of .|| --- src/lattice/generate.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lattice/generate.jl b/src/lattice/generate.jl index beb9381..1a1386e 100644 --- a/src/lattice/generate.jl +++ b/src/lattice/generate.jl @@ -123,7 +123,7 @@ function generatelattice_std(param) error("offset in source should be zero") end target_coord = cellcoord .+ bond.target.offset - if all((0 .<= target_coord .< L) .|| bc) + 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 From 5a01c83bcd97551b869dd8c4c6479946f396120a Mon Sep 17 00:00:00 2001 From: Yuichi Motoyama Date: Mon, 10 Jun 2024 13:30:23 +0900 Subject: [PATCH 4/4] fix --- src/lattice/generate.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lattice/generate.jl b/src/lattice/generate.jl index 1a1386e..a5ff1ef 100644 --- a/src/lattice/generate.jl +++ b/src/lattice/generate.jl @@ -124,7 +124,7 @@ function generatelattice_std(param) end target_coord = cellcoord .+ bond.target.offset if all((0 .<= target_coord .< L) .| bc) - source = numsites_in_cell * cellcoord + bond.source.id + 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)