{"id":21402911,"url":"https://github.com/gregstrq/lightlattices.jl","last_synced_at":"2025-09-12T11:49:25.238Z","repository":{"id":61798631,"uuid":"327754397","full_name":"Gregstrq/LightLattices.jl","owner":"Gregstrq","description":"Lazy interface to lattices with arbitrary unit cells.","archived":false,"fork":false,"pushed_at":"2022-01-18T15:40:09.000Z","size":242,"stargazers_count":4,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-09-09T16:35:03.821Z","etag":null,"topics":["julia"],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Gregstrq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-08T00:09:08.000Z","updated_at":"2024-09-06T15:42:02.000Z","dependencies_parsed_at":"2022-10-21T11:15:28.706Z","dependency_job_id":null,"html_url":"https://github.com/Gregstrq/LightLattices.jl","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gregstrq%2FLightLattices.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gregstrq%2FLightLattices.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gregstrq%2FLightLattices.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gregstrq%2FLightLattices.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gregstrq","download_url":"https://codeload.github.com/Gregstrq/LightLattices.jl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225924439,"owners_count":17546263,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["julia"],"created_at":"2024-11-22T15:41:54.622Z","updated_at":"2024-11-22T15:41:55.427Z","avatar_url":"https://github.com/Gregstrq.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LightLattices.jl\n\nThe package provides a convenient interface to work with Lattices with arbitrary reapeated basis cells.\n\n\n For the exported types of basis cells and lattices, it defines the array interface which allows to access the coordinate of specific node by its index. In addition to that, it provides a function `relative_coordinate` which allows to calculate the shortest vector connecting the two nodes.\n\n[![Build status (Github Actions)](https://github.com/Gregstrq/LightLattices.jl/workflows/CI/badge.svg)](https://github.com/Gregstrq/LightLattices.jl/actions)\n[![codecov.io](http://codecov.io/github/Gregstrq/LightLattices.jl/coverage.svg?branch=main)](http://codecov.io/github/Gregstrq/LightLattices.jl?branch=main)\n[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://Gregstrq.github.io/LightLattices.jl/stable)\n[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://Gregstrq.github.io/LightLattices.jl/dev)\n\n## Overview\n\nThe package exports the type `RegularLattice{D,T}` and several types used to describe the basis cell of the lattice. All the exported types are subtypes of the abstract type `AbstractNodeCollection{D,T}`. Here, `D` refers to the dimensionality of space (number of coordinates), `T` refers to the type used to store the coordinates. For all the exported subtypes, the package defines the array interface\n```julia\nnode_collection[I]\n```\nwhich allows to access the coordinate of the `I`-th node of the collection.\nIn addition to that, the package provides the function `relative_coordinate`:\n```julia\nrelative_coordinate(node_collection::AbstractNodeCollection, I1, I2)\n```\nwhich returns the vector connecting the `I2`-th node with the `I1`-th node.\nIn the case of `RegularLattice`-s with periodic boundary conditions, `relative_coordinate` returns the shortest connecting vector.\n(Actually, in the case of complex basis cell, there can be several \"shortest\" vectors. The problem is resolved by a simple heuristic, described in the [docs](https://gregstrq.github.io/LightLattices.jl/dev/manual/#Lattices-with-periodic-boundaries)).\n\nThere are three available types to describe the basis cell: `HomogeneousCell`, `TrivialCell` and `InhomogeneousCell`.\n`HomogeneousCell` refers to a homogeneous collection of nodes. `TrivialCell` behaves like `HomogeneousCell` with single node at the origin (zero coordinates). Finally, `InhomogeneousCell` is useful in the situation where one need to distinguish between several groups of nodes in the basis cell. For example, we can have several groupes of nodes corresponding to the different types of nuclei which occupy these nodes.\n\nFor the detailed account of exported types and the interface, please look at the [manual section of the docs](https://gregstrq.github.io/LightLattices.jl/dev/manual/).\n\n## Examples\n\n### Chain\nHere we construct a periodic chain with ``11`` nodes. The separation between nodes is ``1`` by default.\n```julia\nusing LightLattices\n\nchain = RegularLattice((11,); label=:chain)\n```\n\n### Square Lattice\nNow, let us construct a square ``11x11`` lattice with the size of the square equal to ``2``.\n```julia\nusing LightLattices\n\nsquare_lattice = RegularLattice((11,11), 2; label = :square)\n```\n\n### Cubic Lattice\nFor the cubic lattice example, let us draw inspiration from the real world.\nThe Fluorine nuclei in ``CaF2`` consitute a cubic lattice with lattice parameter ``a=2.725 Å``.\nLet us construct fluorine sublattice of size ``11x11x11`` with free boundary conditions:\n```julia\nusing LightLattices, Unitful\n\nfluorine_sublattice = RegularLattice((11,11,11), 2.725u\"Å\"; label=:cubic, periodic=false)\n```\n\n### Diamond lattice with homogeneous basis cell.\nThe lattice of diamond is face-centered cubic with a basis cell consisting of two nodes.\nLet us take the size of cube equal to `1`. The following creates diamond lattice with ``11x11x11`` basis cells with periodic boundary conditions:\n```julia\nusing LightLattices\n\nfcc_pvecs = 0.5*hcat([0,1,1],[1,1,0],[1,0,1]) |\u003e SMatrix{3,3}\n\ndiamond_cell = HomogeneousCell([[0.0,0.0,0.0], [0.25,0.25,0.25]]; label = :diamond)\ndimond_lattice = RegularLattice((11,11,11), fcc_pvecs, diamond_cell; label=:fcc)\n```\nHere, `HomogeneousCell` constructor takes the vector of coordinates of the nodes.\nCoordinates can be expressed as `Vector`-s, `SVector`-s or `NTuple`-s. Under the hood, all coordinates are converted to `SVector`-s.\n\n### Magnetic sublattice of fluorapatite with inhomogeneous basis cell.\nThis example is going to be quite elaborated, but it illustrates the application of additional type of basis cell: `InhomogeneousCell`.\nFluorapatite has the hexagonal structure with the space group ``P6_3/m``. The three lattice parameters are ``a=b=9.462 Å`` and ``c=6.849 Å``.\nThe **c**-axis is orthogonal to (**a**, **b**) plane and the angle between **a** and **b** is ``120°``.\nThus, we can construct the matrix of primitive vectors as\n```julia\nusing Unitful\n\nconst a = 9.462u\"Å\"\nconst c = 6.849u\"Å\"\n\nfpvecs = hcat(a*[0.5, 0.5*sqrt(3), 0.0],\n              a*[0.5, -0.5*sqrt(3), 0.0],\n              c*[0.0, 0.0, 1.0]\n             ) |\u003e SMatrix{3,3}\n```\nThe basis cell for magnetically active sublattice of fluorapatite contains two F nuceli at positions\n```math\n[0.0,0.0,0.25],    [0.0,0.0,0.75]\n```\nand six P nuclei at positions\n```math\n[x,y,0.25],        [1-y,x-y,0.25],    [y-x,1-x,0.25],\n[1-x,1-y,0.75],    [y, y-x,0.75],     [x-y, x, 0.75],\n```\nwhere ``x=0.369`` and ``y=0.3985``. All the coordinates here are relative to the set of  primitive vectors `fpvecs`.\n\nSince we have two different types of nuclei, it is a good idea somehow to separate two groups of nuclei in the basis cell. In this case, one should use `InhomogeneousCell`.\n```julia\nconst x = 0.369\nconst y = 0.3985\n\ncell_vectors_raw1 = [[0.0, 0.0, 0.25], [0.0, 0.0, 0.75]]\ncell_vectors_raw2 = [[x, y, 0.25], [-y, x-y, 0.25], [y-x, -x, 0.25],\n                  [-x, -y, 0.75], [y, y-x, 0.75], [x-y, x, 0.75]]\n\nfcell = InhomogeneousCell([fpvecs*vec for vec in cell_vectors_raw1], [fpvecs*vec for vec in cell_vectors_raw2]; label = :fluorapatite_magnetic)\n```\nFinally, we can construct the lattice. Let us choose the size of ``11x11x11`` basis cells and periodic boundary conditions.\n```julia\nfluorapatite_magnetic_sublattice = RegularLattice((11,11,11), fpvecs, fcell; label = :hexagonal)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregstrq%2Flightlattices.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregstrq%2Flightlattices.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregstrq%2Flightlattices.jl/lists"}