commit fb760bb48b99bf135ee7a55171fd1d5bbcfdd990 Author: Valentin Boettcher Date: Fri Mar 10 13:59:25 2023 -0500 Squashed 'src/Looping/' content from commit 3aa4825 git-subtree-dir: src/Looping git-subtree-split: 3aa4825440f582609f7c3f4faface46a25f60193 diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..a6599c7 --- /dev/null +++ b/.envrc @@ -0,0 +1,12 @@ +watch_file flake.nix flake.lock + +{ + # create gc root dir -> .direnv + mkdir -p "$(direnv_layout_dir)" + eval "$( + nix print-dev-env \ + --no-update-lock-file \ + --no-write-lock-file \ + --profile $(direnv_layout_dir)/flake-profile + )" +} || use nix diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..68c126b --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,36 @@ +name: CI +on: + push: + branches: + - main + tags: ['*'] + pull_request: +concurrency: + # Skip intermediate builds: always. + # Cancel intermediate builds: only if it is a pull request build. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + version: + - '1.0' + - '1.8' + - 'nightly' + os: + - ubuntu-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - uses: julia-actions/cache@v1 + - uses: julia-actions/julia-buildpkg@v1 + - uses: julia-actions/julia-runtest@v1 diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml new file mode 100644 index 0000000..cba9134 --- /dev/null +++ b/.github/workflows/CompatHelper.yml @@ -0,0 +1,16 @@ +name: CompatHelper +on: + schedule: + - cron: 0 0 * * * + workflow_dispatch: +jobs: + CompatHelper: + runs-on: ubuntu-latest + steps: + - name: Pkg.add("CompatHelper") + run: julia -e 'using Pkg; Pkg.add("CompatHelper")' + - name: CompatHelper.main() + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} + run: julia -e 'using CompatHelper; CompatHelper.main()' diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml new file mode 100644 index 0000000..f49313b --- /dev/null +++ b/.github/workflows/TagBot.yml @@ -0,0 +1,15 @@ +name: TagBot +on: + issue_comment: + types: + - created + workflow_dispatch: +jobs: + TagBot: + if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' + runs-on: ubuntu-latest + steps: + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + ssh: ${{ secrets.DOCUMENTER_KEY }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b1410dd --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/Manifest.toml +/.direnv/ +docs/build diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bfb8c43 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Valentin Boettcher + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Project.toml b/Project.toml new file mode 100644 index 0000000..01617d7 --- /dev/null +++ b/Project.toml @@ -0,0 +1,20 @@ +name = "Looping" +uuid = "5edfbbf5-67b9-46d9-8ca5-929143abcc11" +authors = ["Valentin Boettcher"] +version = "0.1.0" + +[deps] +DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa" +Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +LanguageServer = "2b0e0bc5-e4fd-59b4-8912-456d1b03d8d7" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" + +[compat] +julia = "1" + +[extras] +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[targets] +test = ["Test"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..24e9834 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Looping + +[![Build Status](https://github.com/vale981/Looping.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/vale981/Looping.jl/actions/workflows/CI.yml?query=branch%3Amain) diff --git a/docs/make.jl b/docs/make.jl new file mode 100644 index 0000000..3cca0f6 --- /dev/null +++ b/docs/make.jl @@ -0,0 +1,7 @@ +push!(LOAD_PATH, "../src/") +using Documenter, Looping + +DocMeta.setdocmeta!(Looping.Utilities, :DocTestSetup, :(using Looping.Utilities); recursive=true) +DocMeta.setdocmeta!(Looping.FloquetUtils, :DocTestSetup, :(using Looping.FloquetUtils); recursive=true) + +makedocs(sitename="Looping Documentation", modules=[Looping.Utilities, Looping.FloquetUtils], draft=false, strict=:doctest) diff --git a/docs/src/index.md b/docs/src/index.md new file mode 100644 index 0000000..210ded9 --- /dev/null +++ b/docs/src/index.md @@ -0,0 +1,4 @@ +# Looping.jl Documentation + +Some numerical tools and experiments for the fiber loop reservoir +engineering project. diff --git a/docs/src/modules/FloquetUtils.md b/docs/src/modules/FloquetUtils.md new file mode 100644 index 0000000..3207b79 --- /dev/null +++ b/docs/src/modules/FloquetUtils.md @@ -0,0 +1,5 @@ +# Floquet Utilities + +```@autodocs +Modules = [Looping.FloquetUtils] +``` diff --git a/docs/src/modules/Utilities.md b/docs/src/modules/Utilities.md new file mode 100644 index 0000000..282f507 --- /dev/null +++ b/docs/src/modules/Utilities.md @@ -0,0 +1,5 @@ +# Utilities + +```@autodocs +Modules = [Looping.Utilities] +``` diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..786b378 --- /dev/null +++ b/flake.lock @@ -0,0 +1,726 @@ +{ + "nodes": { + "blank": { + "locked": { + "lastModified": 1625557891, + "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=", + "owner": "divnix", + "repo": "blank", + "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "blank", + "type": "github" + } + }, + "cells-lab": { + "inputs": { + "nixos": "nixos", + "nixpkgs": "nixpkgs", + "org-roam-book-template": "org-roam-book-template", + "std": "std", + "std-data-collection": "std-data-collection", + "xnlib": "xnlib" + }, + "locked": { + "lastModified": 1676268445, + "narHash": "sha256-FjVVzu9pGQmpuyZwJlPgEGLePfDL94gR+M1PNM1gNKM=", + "owner": "gtrunsec", + "repo": "cells-lab", + "rev": "ab176d3030d2d742d48b9045f07564f5aeda936f", + "type": "github" + }, + "original": { + "owner": "gtrunsec", + "repo": "cells-lab", + "type": "github" + } + }, + "cortex": { + "flake": false, + "locked": { + "lastModified": 1643528409, + "narHash": "sha256-ldmenmCzCEuuBlMtaQYe79vYbcTORgkCXgYgGkOzkL8=", + "owner": "gtrunsec", + "repo": "cortex", + "rev": "ad9a963534e5be323a33eaf0f9aa3e914cca8093", + "type": "github" + }, + "original": { + "owner": "gtrunsec", + "repo": "cortex", + "type": "github" + } + }, + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1677793770, + "narHash": "sha256-sPBZTh6MNV0R5cMe6It+3BP75PhfP4nXP0M9nRtUHVU=", + "owner": "numtide", + "repo": "devshell", + "rev": "a027fa50746d95abf0ea35847bed0e0bc2d7a9da", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "devshell_2": { + "inputs": { + "flake-utils": [ + "julia2nix", + "cells-lab", + "std", + "flake-utils" + ], + "nixpkgs": [ + "julia2nix", + "cells-lab", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1663445644, + "narHash": "sha256-+xVlcK60x7VY1vRJbNUEAHi17ZuoQxAIH4S4iUFUGBA=", + "owner": "numtide", + "repo": "devshell", + "rev": "e3dc3e21594fe07bdb24bdf1c8657acaa4cb8f66", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "dmerge": { + "inputs": { + "nixlib": [ + "julia2nix", + "cells-lab", + "std", + "nixpkgs" + ], + "yants": [ + "julia2nix", + "cells-lab", + "std", + "yants" + ] + }, + "locked": { + "lastModified": 1659548052, + "narHash": "sha256-fzI2gp1skGA8mQo/FBFrUAtY0GQkAIAaV/V127TJPyY=", + "owner": "divnix", + "repo": "data-merge", + "rev": "d160d18ce7b1a45b88344aa3f13ed1163954b497", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "data-merge", + "type": "github" + } + }, + "emacs-overlay": { + "inputs": { + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1676258056, + "narHash": "sha256-LhXVnPc+IPHupy7QexUrzYuloSGXvXEgvIkAlhFs+yY=", + "owner": "nix-community", + "repo": "emacs-overlay", + "rev": "09ebba158540ba3171b5f319b71427b51db8794b", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "emacs-overlay", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1642700792, + "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_4": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_5": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "incl": { + "inputs": { + "nixlib": [ + "julia2nix", + "cells-lab", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1669263024, + "narHash": "sha256-E/+23NKtxAqYG/0ydYgxlgarKnxmDbg6rCMWnOBqn9Q=", + "owner": "divnix", + "repo": "incl", + "rev": "ce7bebaee048e4cd7ebdb4cee7885e00c4e2abca", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "incl", + "type": "github" + } + }, + "julia2nix": { + "inputs": { + "cells-lab": "cells-lab", + "nix-filter": "nix-filter_2", + "nixpkgs": "nixpkgs_3", + "std": [ + "julia2nix", + "cells-lab", + "std" + ], + "std-data-collection": [ + "julia2nix", + "cells-lab", + "std-data-collection" + ] + }, + "locked": { + "lastModified": 1677373375, + "narHash": "sha256-94y8UyaoSlQjsrSIsHdMrzOT7RBaGQFV2dlFqlK6x8g=", + "owner": "JuliaCN", + "repo": "Julia2Nix.jl", + "rev": "4dd90bedf3a3fbc36273670b3fbcfd1b63484142", + "type": "github" + }, + "original": { + "owner": "JuliaCN", + "repo": "Julia2Nix.jl", + "type": "github" + } + }, + "n2c": { + "inputs": { + "flake-utils": [ + "julia2nix", + "cells-lab", + "std", + "flake-utils" + ], + "nixpkgs": [ + "julia2nix", + "cells-lab", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1665039323, + "narHash": "sha256-SAh3ZjFGsaCI8FRzXQyp56qcGdAqgKEfJWPCQ0Sr7tQ=", + "owner": "nlewo", + "repo": "nix2container", + "rev": "b008fe329ffb59b67bf9e7b08ede6ee792f2741a", + "type": "github" + }, + "original": { + "owner": "nlewo", + "repo": "nix2container", + "type": "github" + } + }, + "nix-filter": { + "locked": { + "lastModified": 1666547822, + "narHash": "sha256-razwnAybPHyoAyhkKCwXdxihIqJi1G6e1XP4FQOJTEs=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "1a3b735e13e90a8d2fd5629f2f8363bd7ffbbec7", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, + "nix-filter_2": { + "locked": { + "lastModified": 1666547822, + "narHash": "sha256-razwnAybPHyoAyhkKCwXdxihIqJi1G6e1XP4FQOJTEs=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "1a3b735e13e90a8d2fd5629f2f8363bd7ffbbec7", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, + "nix-std": { + "locked": { + "lastModified": 1671250799, + "narHash": "sha256-uPIakP98gOf6504NtrAb2/0O0BgRRXNShM0PTV8z+T0=", + "owner": "chessai", + "repo": "nix-std", + "rev": "b300fd6dfeae8cc331c7d8cde0e81b404d50d40c", + "type": "github" + }, + "original": { + "owner": "chessai", + "repo": "nix-std", + "type": "github" + } + }, + "nixago": { + "inputs": { + "flake-utils": [ + "julia2nix", + "cells-lab", + "std", + "flake-utils" + ], + "nixago-exts": [ + "julia2nix", + "cells-lab", + "std", + "blank" + ], + "nixpkgs": [ + "julia2nix", + "cells-lab", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1676075813, + "narHash": "sha256-X/aIT8Qc8UCqnxJvaZykx3CJ0ZnDFvO+dqp/7fglZWo=", + "owner": "nix-community", + "repo": "nixago", + "rev": "9cab4dde31ec2f2c05d702ea8648ce580664e906", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixago", + "type": "github" + } + }, + "nixlib": { + "locked": { + "lastModified": 1673743903, + "narHash": "sha256-sloY6KYyVOozJ1CkbgJPpZ99TKIjIvM+04V48C04sMQ=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "7555e2dfcbac1533f047021f1744ac8871150f9f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixos": { + "locked": { + "lastModified": 1676177817, + "narHash": "sha256-OQnBnuKkpwkfNY31xQyfU5hNpLs1ilWt+hVY6ztEEOM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1b82144edfcd0c86486d2e07c7298f85510e7fb8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1675940568, + "narHash": "sha256-epG6pOT9V0kS+FUqd7R6/CWkgnZx2DMT5Veqo+y6G3c=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6ccc4a59c3f1b56d039d93da52696633e641bc71", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1673540789, + "narHash": "sha256-xqnxBOK3qctIeUVxecydrEDbEXjsvHCPGPbvsl63M/U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0f213d0fee84280d8c3a97f7469b988d6fe5fcdf", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1672428209, + "narHash": "sha256-eejhqkDz2cb2vc5VeaWphJz8UXNuoNoM8/Op8eWv2tQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "293a28df6d7ff3dec1e61e37cc4ee6e6c0fb0847", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1677655566, + "narHash": "sha256-I8G8Lmpp3YduYl4+pkiIJFGT1WKw+8ZMH2QwANkTu2U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ae8bdd2de4c23b239b5a771501641d2ef5e027d0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nosys": { + "locked": { + "lastModified": 1668010795, + "narHash": "sha256-JBDVBnos8g0toU7EhIIqQ1If5m/nyBqtHhL3sicdPwI=", + "owner": "divnix", + "repo": "nosys", + "rev": "feade0141487801c71ff55623b421ed535dbdefa", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "nosys", + "type": "github" + } + }, + "org-roam-book-template": { + "inputs": { + "cortex": "cortex", + "emacs-overlay": "emacs-overlay", + "flake-compat": "flake-compat", + "flake-utils": "flake-utils_4", + "nix-filter": "nix-filter", + "nixpkgs": [ + "julia2nix", + "cells-lab", + "nixpkgs" + ], + "ox-hugo": "ox-hugo" + }, + "locked": { + "lastModified": 1676267610, + "narHash": "sha256-rweyZN0cRYY9Uoeo/94Sa1DHgBI2NRXC+/iNdqypptc=", + "owner": "gtrunsec", + "repo": "org-roam-book-template", + "rev": "fd76272fb78c5fae39e7bd8e8c8165ca85fa2d1a", + "type": "github" + }, + "original": { + "owner": "gtrunsec", + "repo": "org-roam-book-template", + "type": "github" + } + }, + "ox-hugo": { + "flake": false, + "locked": { + "lastModified": 1669851508, + "narHash": "sha256-7m9B647uOBnSWYsxIfavlTCsT8loDm33v/epqYSUhLw=", + "owner": "kaushalmodi", + "repo": "ox-hugo", + "rev": "706b5f622d168bb8e0cf503e0525d2db9177c83e", + "type": "github" + }, + "original": { + "owner": "kaushalmodi", + "repo": "ox-hugo", + "type": "github" + } + }, + "paisano": { + "inputs": { + "nixpkgs": [ + "julia2nix", + "cells-lab", + "std", + "nixpkgs" + ], + "nosys": "nosys", + "yants": [ + "julia2nix", + "cells-lab", + "std", + "yants" + ] + }, + "locked": { + "lastModified": 1676226775, + "narHash": "sha256-MiY0Y9JOo71wu0K9cSxW+N4gOCuS7taI3bSUMFGtbPI=", + "owner": "divnix", + "repo": "paisano", + "rev": "143afa3083274af3be808687ab23fddbbc9d22ed", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "paisano", + "type": "github" + } + }, + "root": { + "inputs": { + "devshell": "devshell", + "flake-utils": "flake-utils_2", + "julia2nix": "julia2nix", + "nixpkgs": "nixpkgs_4" + } + }, + "std": { + "inputs": { + "arion": [ + "julia2nix", + "cells-lab", + "std", + "blank" + ], + "blank": "blank", + "devshell": "devshell_2", + "dmerge": "dmerge", + "flake-utils": "flake-utils_5", + "incl": "incl", + "makes": [ + "julia2nix", + "cells-lab", + "std", + "blank" + ], + "microvm": [ + "julia2nix", + "cells-lab", + "std", + "blank" + ], + "n2c": "n2c", + "nixago": "nixago", + "nixpkgs": [ + "julia2nix", + "cells-lab", + "nixpkgs" + ], + "paisano": "paisano", + "yants": "yants" + }, + "locked": { + "lastModified": 1676232625, + "narHash": "sha256-M9xLaFVhD58UwGKoodAzeZD1iBdrCTtAsqKwWX5mUXA=", + "owner": "divnix", + "repo": "std", + "rev": "b462198baa6b3a3c6f3f46662500f683e105a2fa", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "std", + "type": "github" + } + }, + "std-data-collection": { + "inputs": { + "nixpkgs": [ + "julia2nix", + "cells-lab", + "nixpkgs" + ], + "std": [ + "julia2nix", + "cells-lab", + "std" + ] + }, + "locked": { + "lastModified": 1676163535, + "narHash": "sha256-xofkWLBqU4zj5vzJhWor2Z9CyPGKt7UGkTchsCT48Po=", + "owner": "divnix", + "repo": "std-data-collection", + "rev": "f713d81a6197e1b0854fb201cc7acde5ef9e93d4", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "std-data-collection", + "type": "github" + } + }, + "xnlib": { + "inputs": { + "nix-std": "nix-std", + "nixlib": "nixlib", + "std": [ + "julia2nix", + "cells-lab", + "std" + ] + }, + "locked": { + "lastModified": 1674228201, + "narHash": "sha256-2ONv2b8TTkCAyOSO9LMp3wTzOS9BW6riEBxq5xwsvvc=", + "owner": "gtrunsec", + "repo": "xnlib", + "rev": "b9625c523d34617dc5aab311abb59590406fa8be", + "type": "github" + }, + "original": { + "owner": "gtrunsec", + "repo": "xnlib", + "type": "github" + } + }, + "yants": { + "inputs": { + "nixpkgs": [ + "julia2nix", + "cells-lab", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1667096281, + "narHash": "sha256-wRRec6ze0gJHmGn6m57/zhz/Kdvp9HS4Nl5fkQ+uIuA=", + "owner": "divnix", + "repo": "yants", + "rev": "d18f356ec25cb94dc9c275870c3a7927a10f8c3c", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "yants", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..bd2630a --- /dev/null +++ b/flake.nix @@ -0,0 +1,76 @@ +{ + description = "Julia2Nix development environment"; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + devshell.url = "github:numtide/devshell"; + devshell.inputs.nixpkgs.follows = "nixpkgs"; + + julia2nix.url = "github:JuliaCN/Julia2Nix.jl"; + }; + + outputs = inputs @ { + self, + julia2nix, + ... + }: + ( + inputs.flake-utils.lib.eachDefaultSystem + (system: let + pkgs = inputs.nixpkgs.legacyPackages.${system}.appendOverlays ([ + self.overlays.default + inputs.devshell.overlays.default + ]); + julia-wrapped = inputs.julia2nix.lib.${system}.julia-wrapped { + # package = pkgs.julia_17-bin; + package = julia2nix.packages.${system}.julia_18-bin; + enable = { + # only x86_64-linux is supported + GR = true; + python = + pkgs.python3.buildEnv.override + { + extraLibs = with pkgs.python3Packages; [xlrd matplotlib pyqt5]; + # ignoreCollisions = true; + }; + }; + }; + + # run this command in your project: nix run github:JuliaCN/Julia2Nix.jl#packages.x86_64-linux.julia2nix + # we need to generate the julia2nix.toml first + project = inputs.julia2nix.lib.${system}.buildProject { + src = ./.; + name = "Looping"; + package = julia-wrapped; + }; + in { + packages = { + # make sure you have generated the julia2nix.toml + default = project; + }; + devShells.default = pkgs.devshell.mkShell { + imports = [ + # you can keep either one of them devshellProfiles.packages or julia-wrapped + # inputs.julia2nix.${pkgs.system}.julia2nix.devshellProfiles.packages + + # add dev-tools in your devshell + inputs.julia2nix.${pkgs.system}.julia2nix.devshellProfiles.dev + + # add nightly julia + # inputs.julia2nix.${pkgs.system}.julia2nix.devshellProfiles.nightly + ]; + commands = [ + { + package = julia-wrapped; + help = julia2nix.packages.${pkgs.system}.julia_18-bin.meta.description; + } + ]; + }; + }) + ) + // { + overlays.default = final: prev: {}; + }; +} diff --git a/julia2nix.toml b/julia2nix.toml new file mode 100644 index 0000000..e75458d --- /dev/null +++ b/julia2nix.toml @@ -0,0 +1,6 @@ + +[depot.x86_64-linux.fetchzip.registry-General] +name = "registries/General" +sha256 = "sha256-WfmgU1GuxVGn9yl/EQ7doYdnDUSMDi7SqCyEy8YamXY=" +stripRoot = false +url = "https://pkg.julialang.org/registry/23338594-aafe-5451-b93e-139f81909106/93737299af624d55235fd13616742788b10c0ed3#registry.tar.gz" diff --git a/src/FloquetUtils.jl b/src/FloquetUtils.jl new file mode 100644 index 0000000..dc8aad9 --- /dev/null +++ b/src/FloquetUtils.jl @@ -0,0 +1,132 @@ +""" +This is a loose collection to naively calculate the time evolution +operator and Floquet Hamiltonian for a given time dependent +Hamiltonian `H(t)`. +""" +module FloquetUtils + +import LinearAlgebra: I, eigvecs, eigen, Diagonal +import DifferentialEquations as de + +export time_evolution_op +export floquet_hamiltonian +export KickOperator + +using ..Utilities + +""" + time_evolution_op(H, T, args...; kwargs...) + +Calculate the time evolution operator for a Hamiltonian `H` up to a +total time `T`. The rest arguments are passed on to +[`de.solve`](@ref). +""" +function time_evolution_op(H::Function, T::Real, args...; kwargs...) + function u_step!(dU, U, _, t) + dU .= -1im * H(t) * U + end + + N = size(H(0), 1) + u0 = Matrix{ComplexF64}(I, N, N) + + tspan = (0.0, T) + prob = de.ODEProblem(u_step!, u0, tspan) + de.solve(prob, args...; kwargs...) +end + + +""" + floquet_hamiltonian(U::Matrix, T) + +Returns the Floquet Hamiltonian given a unitary matrix `U` and a time +`T`. +""" +function floquet_hamiltonian(U::Matrix, T::Real) + 1im / T * log(U) +end + + + +""" + floquet_hamiltonian(H::Function, T) + +Returns the Floquet Hamiltonian given a Hamiltionian `H` and a time +`T`. The rest arguments are passed on to +[`de.solve`](@ref). +""" +function floquet_hamiltonian(H::Function, T::Real, args...; kwargs...) + U = time_evolution_op(H, T, args...; kwargs...) + floquet_hamiltonian(U(T), T) +end + +""" + trivial_floquet_hamiltonian(H, T, restrict_energies=false) + +Returns the Floquet Hamiltonian for a Hamiltonain `H` that commutes +with itself at different times. +""" +function trivial_floquet_hamiltonian(H::Function, T::Real, restrict_energies::Bool=false) + function h_step!(dU, _, _, t) + dU .= H(t) + end + + dimension = size(H(0), 1) + u0 = zeros(ComplexF64, dimension, dimension) + prob = de.ODEProblem(h_step!, u0, (0.0, T)) + + integrated_hamiltonian = de.solve(prob) + + H_F = integrated_hamiltonian(T) / T + + if restrict_energies + energies, vecs = eigen(H_F) + energies .= restrict_to_range.(energies, π / T) + H_F .= vecs * Diagonal(energies) * vecs' + end + + H_F +end + + +struct KickOperator + U + H_F::Matrix + + + @doc """ + KickOperator(U(t), H_F::Matrix) + + Return the Kick operator Given the time evolution operator `U(t)` and the Floquet Hamiltonian + `H_F`. + """ + function KickOperator(U, H_F::Matrix) + if size(U(0)) != size(H_F) + throw(DimensionMismatch("`U` and `H_F` should have the same dimension.")) + end + new(U, H_F) + end +end + +""" + KickOperator(H(t), T) + +Return the Kick operator Given the Hamiltonian `H(t)` and the total time ``T``. +""" +function KickOperator(H::Function, T::Real) + U = time_evolution_op(H, T) + H_F = floquet_hamiltonian(U(T), T) + KickOperator(U, H_F) +end + +""" + K(t) + +Return the Kick operator at time t. +""" +function (K::KickOperator)(t::Real) + K.U(t) * exp(1im * K.H_F * t) +end + + + +end diff --git a/src/Looping.jl b/src/Looping.jl new file mode 100644 index 0000000..2a57df1 --- /dev/null +++ b/src/Looping.jl @@ -0,0 +1,4 @@ +module Looping +include("Utilities.jl") +include("FloquetUtils.jl") +end diff --git a/src/Utilities.jl b/src/Utilities.jl new file mode 100644 index 0000000..ec42714 --- /dev/null +++ b/src/Utilities.jl @@ -0,0 +1,61 @@ +""" +Some common utilities that haven't yet made it into their own packagage. +""" +module Utilities + +export periodic_distance +export restrict_to_range + +""" + periodic_distance(m, n, N) + +Calculate the distance `(m-n)`, but assuming periodic boundary +conditions for a chain of length `N`. + +# Examples +```jldoctest +julia> periodic_distance(1, 4, 5) +2 + +julia> periodic_distance(1, 3, 5) +-2 +``` +""" +function periodic_distance(m::Integer, n::Integer, N::Integer) + diff = m - n + adiff = abs(diff) + if abs(diff + N) < adiff + diff + N + elseif abs(diff - N) < adiff + diff - N + else + diff + end +end + +""" + restrict_to_range(x, border) + +Returns the value `x` restricted to the range `[-border, border]` by +lettting it roll over to `+-border`. + +# Examples +```jldoctest +julia> restrict_to_range(6, 5) +-4 + +julia> restrict_to_range(5, 5) +5 +``` +""" +function restrict_to_range(x::Real, border::Real) + sign = x ≥ border ? -1 : 1 + + while abs(x) > border + x += sign * border * 2 + end + + x +end + +end diff --git a/test/runtests.jl b/test/runtests.jl new file mode 100644 index 0000000..7cb7e89 --- /dev/null +++ b/test/runtests.jl @@ -0,0 +1,6 @@ +using Looping +using Test + +@testset "Looping.jl" begin + # Write your tests here. +end