Skip to content

Commit

Permalink
Add split_catenation!
Browse files Browse the repository at this point in the history
  • Loading branch information
Liozou committed Oct 28, 2024
1 parent 83feae5 commit a9fe290
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/other.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,21 @@ function PeriodicGraphs.make_supercell(pge::PeriodicGraphEmbedding, t)
newpos[n*k+i] = newpos[i] .+ pos .// t
end
end
return PeriodicGraphEmbedding(g, newpos, cell)
PeriodicGraphEmbedding(g, newpos, cell)
end

function PeriodicGraphs.split_catenation(pge::PeriodicGraphEmbedding{D,T}) where {D,T}
pge.cell.hall == 1 || error("Skew a non-P1 cell is not implemented")
splits = split_catenation(pge.g)
ret = Vector{Tuple{PeriodicGraphEmbedding{D,T}, Vector{PeriodicGraphs.OffsetVertexIterator{D}}, SMatrix{D,D,Int,D*D}, Int}}(undef, length(splits))
for (i, (subgraph, vmaps, mat, dim)) in enumerate(splits)
newcell = Cell(mat * pge.cell.mat)
invmat = inv(Rational{Int}.(mat))
newpos = [invmat * pge[x] for x in first(vmaps)]
moffsets = [.-floor.(Int, pos) for pos in newpos]
subpge = PeriodicGraphEmbedding(copy(subgraph), newpos, newcell)
offset_representatives!(subpge, moffsets)
ret[i] = (subpge, vmaps, mat, dim)
end
ret
end

0 comments on commit a9fe290

Please sign in to comment.