Skip to main content

twiss, 2022-2024

Coupled twiss parameters (Wolski twiss matrices) computation for arbitrary even dimension.

Install & build

$ pip install git+https://github.com/i-a-morozov/twiss.git@main

or

$ pip install twiss -U

Documentation

Run In Colab

https://i-a-morozov.github.io/twiss/

Twiss

Compute tunes, normalization matrix and twiss matrices.

>>> from math import pi
>>> import torch
>>> from twiss.matrix import  rotation
>>> from twiss.wolski import twiss
>>> m = rotation(2*pi*torch.tensor(0.88, dtype=torch.float64))
>>> t, n, w = twiss(m)
>>> t
tensor([0.8800], dtype=torch.float64)
>>> n
tensor([[1.0000, 0.0000],
        [0.0000, 1.0000]], dtype=torch.float64)
>>> w
tensor([[[1.0000, 0.0000],
        [0.0000, 1.0000]]], dtype=torch.float64)

Input matrices can have arbitrary even dimension.

>>> from math import pi
>>> import torch
>>> from twiss.matrix import rotation
>>> from twiss.wolski import twiss
>>> m = rotation(*(2*pi*torch.linspace(0.1, 0.9, 9, dtype=torch.float64)))
>>> t, n, w = twiss(m)
>>> t
tensor([0.1000, 0.2000, 0.3000, 0.4000, 0.5000, 0.6000, 0.7000, 0.8000, 0.9000],
dtype=torch.float64)

Can be mapped over a batch of input matrices.

>>> from math import pi
>>> import torch
>>> from twiss.matrix import rotation
>>> from twiss.wolski import twiss
>>> m = torch.func.vmap(rotation)(2*pi*torch.linspace(0.1, 0.9, 9, dtype=torch.float64))
>>> t, n, w = torch.func.vmap(twiss)(m)
>>> t
tensor([[0.1000],
        [0.2000],
        [0.3000],
        [0.4000],
        [0.5000],
        [0.6000],
        [0.7000],
        [0.8000],
        [0.9000]], dtype=torch.float64)

Can be used to compute derivatives of observables.

    >>> from math import pi
    >>> import torch
    >>> from twiss.matrix import  rotation
    >>> from twiss.wolski import twiss
    >>> def fn(k):
    ...    m = rotation(2*pi*torch.tensor(0.88, dtype=torch.float64))
    ...    i = torch.ones_like(k)
    ...    o = torch.zeros_like(k)
    ...    m = m @ torch.stack([i, k, o, i]).reshape(m.shape)
    ...    t, *_ = twiss(m)
    ...    return t
    >>> k = torch.tensor(0.0, dtype=torch.float64)
    >>> fn(k)
    tensor([0.8800], dtype=torch.float64)
    >>> torch.func.jacfwd(fn)(k)
    tensor([0.0796], dtype=torch.float64)

Metadata

Release files for twiss 0.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for twiss 0.2.6
File Size Uploaded Provenance Actions
twiss-0.2.6.tar.gz 622.8 kB Without provenance Details for twiss-0.2.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for twiss 0.2.6
File Interpreter ABI Platform Actions
twiss-0.2.6-py3-none-any.whl Python 3 none any Details for twiss-0.2.6-py3-none-any.whl

Total release size: 636.2 kB

Release files / twiss-0.2.6.tar.gz

Download URL twiss-0.2.6.tar.gz
Size 622.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8542b8bb44fa04fc24b5f6a06fb0ec7d65d83dfc5eac5dcbe957570c2380aacd
BLAKE2b-256 checksum
How to use checksums
7feddef5c6380722460d644efe59cf7f9045d25c23706880796a0e710b16acf5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.1

Release files / twiss-0.2.6-py3-none-any.whl

Download URL twiss-0.2.6-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ccdb689b78498d09e962aea5009f0c85dd65f8f3065512dfcbb53f873588f302
BLAKE2b-256 checksum
How to use checksums
950b8753110f70ad33adbe733e22b4bc0e5390ba3b0e5c38c40a5349b6f54ae1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.1

Security for twiss 0.2.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page