Square Lattice Symmetric Clusters
This example generates square-lattice clusters up to order 4 and compares translation, point-group symmetry, and graph-isomorphism reductions.
Setup
Define the square unit cell and bonds:
using Lincege
basis = [[0.0, 0.0]]
primitive_vectors = [[1.0, 0.0], [0.0, 1.0]]
bonds = [Bond(1, 1, [1, 0], 1), Bond(1, 1, [0, 1], 1)]
unit_cell = UnitCell(basis, primitive_vectors, bonds, [1])
max_order = 4
lattice = SiteExpansionLattice(max_order, unit_cell)SiteExpansionLattice(0x04, UnitCell([0.0; 0.0;;], [1.0 0.0; 0.0 1.0], [1], Bond[Bond(1, 1, [1, 0], 1), Bond(1, 1, [0, 1], 1)]), [-4 -3 … 3 4; -4 -4 … 4 4; 1 1 … 1 1], [0 1 … 0 0; 1 0 … 0 0; … ; 0 0 … 0 1; 0 0 … 1 0], LatticeVertices{Int64}[Vertices: [2, 10], Vertices: [1, 3, 11], Vertices: [2, 4, 12], Vertices: [3, 5, 13], Vertices: [4, 6, 14], Vertices: [5, 7, 15], Vertices: [6, 8, 16], Vertices: [7, 9, 17], Vertices: [8, 18], Vertices: [1, 11, 19] … Vertices: [63, 71, 81], Vertices: [64, 74], Vertices: [65, 73, 75], Vertices: [66, 74, 76], Vertices: [67, 75, 77], Vertices: [68, 76, 78], Vertices: [69, 77, 79], Vertices: [70, 78, 80], Vertices: [71, 79, 81], Vertices: [72, 80]])Explicit symmetry matrices
These are the eight square lattice matrices which act on Cartesian position vectors and form the square's point group.
Available geometry presets are :Square, :Shastry_Sutherland, :Pyrochlore, :Triangular, and :Kagome; use SymmetricClusterSet(lattice, :Square) to select a preset instead of supplying the matrices explicitly.
symmetries = Vector{Matrix{Float64}}([
[1 0; 0 1],
[0 1; -1 0],
[-1 0; 0 -1],
[0 -1; 1 0],
[0 1; 1 0],
[0 -1; -1 0],
[1 0; 0 -1],
[-1 0; 0 1],
])8-element Vector{Matrix{Float64}}:
[1.0 0.0; 0.0 1.0]
[0.0 1.0; -1.0 0.0]
[-1.0 0.0; 0.0 -1.0]
[0.0 -1.0; 1.0 0.0]
[0.0 1.0; 1.0 0.0]
[0.0 -1.0; -1.0 0.0]
[1.0 0.0; 0.0 -1.0]
[-1.0 0.0; 0.0 1.0]Generating and reducing clusters
First generate the translational clusters then reduce them into the symmetric clusters and finally isomorphic clusters.
translation_clusters = TranslationClusterSet(lattice)
clusters_from_lattice!(translation_clusters, lattice)
symmetric_clusters = SymmetricClusterSet(lattice, symmetries)
reduce_clusters!(symmetric_clusters, translation_clusters)
isomorphic_clusters = IsomorphicClusterSet(lattice)
reduce_clusters!(isomorphic_clusters, symmetric_clusters)ClusterSet{IsomorphicHasher} with 6 clustersComputing the expansions
Build an Expansion for each reduction and compute its weights:
symmetric_expansion = Expansion(symmetric_clusters, lattice)
summation!(symmetric_expansion, max_order)
isomorphic_expansion = Expansion(isomorphic_clusters, lattice)
summation!(isomorphic_expansion, max_order)Expansion(Dict{UInt64, Lincege.ExpansionCluster}(0xa4edc62b2b97e8ba => Lincege.ExpansionCluster(Vertices: [14, 23, 32, 41], 14.0, UInt64[0x14acd1057b698a40, 0x14acd1057b698a40, 0x6a7f9b876202d912, 0x14acd1057b698a40, 0x757e0ac51ad2d852, 0x757e0ac51ad2d852, 0x14acd1057b698a40, 0x6a7f9b876202d912, 0x6a7f9b876202d912], Dict{UInt64, Float64}(0xa4edc62b2b97e8ba => 1.0, 0x757e0ac51ad2d852 => -2.0, 0x14acd1057b698a40 => 0.0, 0x6a7f9b876202d912 => 1.0)), 0x757e0ac51ad2d852 => Lincege.ExpansionCluster(Vertices: [31, 32, 41], 6.0, UInt64[0x14acd1057b698a40, 0x14acd1057b698a40, 0x6a7f9b876202d912, 0x14acd1057b698a40, 0x6a7f9b876202d912], Dict{UInt64, Float64}(0x757e0ac51ad2d852 => 1.0, 0x14acd1057b698a40 => 1.0, 0x6a7f9b876202d912 => -2.0)), 0x6320d7945cb53665 => Lincege.ExpansionCluster(Vertices: [32, 40, 41, 42], 4.0, UInt64[0x14acd1057b698a40, 0x6a7f9b876202d912, 0x6a7f9b876202d912, 0x757e0ac51ad2d852, 0x14acd1057b698a40, 0x14acd1057b698a40, 0x6a7f9b876202d912, 0x14acd1057b698a40, 0x757e0ac51ad2d852, 0x757e0ac51ad2d852], Dict{UInt64, Float64}(0x757e0ac51ad2d852 => -3.0, 0x6320d7945cb53665 => 1.0, 0x14acd1057b698a40 => -1.0, 0x6a7f9b876202d912 => 3.0)), 0x295bed9436114cdf => Lincege.ExpansionCluster(Vertices: [31, 32, 40, 41], 1.0, UInt64[0x14acd1057b698a40, 0x757e0ac51ad2d852, 0x6a7f9b876202d912, 0x757e0ac51ad2d852, 0x14acd1057b698a40, 0x6a7f9b876202d912, 0x14acd1057b698a40, 0x14acd1057b698a40, 0x6a7f9b876202d912, 0x6a7f9b876202d912, 0x757e0ac51ad2d852, 0x757e0ac51ad2d852], Dict{UInt64, Float64}(0x295bed9436114cdf => 1.0, 0x757e0ac51ad2d852 => -4.0, 0x14acd1057b698a40 => 0.0, 0x6a7f9b876202d912 => 4.0)), 0x14acd1057b698a40 => Lincege.ExpansionCluster(Vertices: [41], 1.0, UInt64[], Dict{UInt64, Float64}(0x14acd1057b698a40 => 1.0)), 0x6a7f9b876202d912 => Lincege.ExpansionCluster(Vertices: [32, 41], 2.0, UInt64[0x14acd1057b698a40, 0x14acd1057b698a40], Dict{UInt64, Float64}(0x6a7f9b876202d912 => 1.0, 0x14acd1057b698a40 => -2.0))), Vector{UInt64}[[0x14acd1057b698a40], [0x6a7f9b876202d912], [0x757e0ac51ad2d852], [0xa4edc62b2b97e8ba, 0x6320d7945cb53665, 0x295bed9436114cdf]], 0)Relating symmetric and isomorphic clusters
Each isomorphic entry includes its weights and a related_symmetric list containing the symmetric cluster's weights and coordinates reordered to match the canonical graph.
json_path = joinpath(output_dir, "square_lattice_site_expansion_isomorphic_symmetric.json")
write_to_json(
isomorphic_expansion, isomorphic_clusters,
symmetric_expansion, symmetric_clusters,
lattice, json_path,
)The text export preserves every field of the joint JSON export:
txt_path = joinpath(output_dir, "square_lattice_site_expansion_isomorphic_symmetric.txt")
write_to_txt_file(
isomorphic_expansion, isomorphic_clusters,
symmetric_expansion, symmetric_clusters,
lattice, txt_path,
)The colon-separated records have two layouts:
isomorphic : n_sites : cluster_hash : canonical_bonds : canonical_site_colors : weights : order
symmetric : isomorphic_hash : cluster_hash : permuted_coordinates : weightsEach isomorphic record is followed by its related symmetric records. The parent hash links the two reductions; both retain their own hashes and weights. Bonds are space-separated triples, coordinates use (x,y) tuples, and empty fields represent empty vectors. Header lines beginning with # name the fields.