Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mmikhasenko/fourvectors.jl
Basic operations with the four vectors
https://github.com/mmikhasenko/fourvectors.jl
Last synced: about 12 hours ago
JSON representation
Basic operations with the four vectors
- Host: GitHub
- URL: https://github.com/mmikhasenko/fourvectors.jl
- Owner: mmikhasenko
- License: mit
- Created: 2020-08-15T11:06:12.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-01T19:46:19.000Z (about 2 months ago)
- Last Synced: 2024-12-01T20:26:04.896Z (about 2 months ago)
- Language: Julia
- Size: 47.9 KB
- Stars: 4
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FourVectors
[![Test workflow status](https://github.com/mmikhasenko/FourVectors.jl/actions/workflows/Test.yml/badge.svg?branch=main)](https://github.com/mmikhasenko/FourVectors.jl/actions/workflows/Test.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/mmikhasenko/FourVectors.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/mmikhasenko/FourVectors.jl)The `FourVector` is Julia package for handling four-vectors based on the immutable StaticArray `FieldArray{T,4}`.
It provides a simple and efficient implementation of an immutable four-vector object, utilizing the `LorentzVectorBase.jl` interface.
Inherits from `FieldArray{T,4}` implies that the `FourVector` is a subtype of `AbstractArray`, can be indexed, and iterated.## Installation
The package is not registered yet.
Install the package using Julia's package manager:```julia
julia> ] add https://github.com/mmikhasenko/FourVectors.jl
```## Usage
First, import the package:
```julia
using FourVectors
```### Creating FourVectors
You can create a `FourVector` by specifying the spatial components and either the energy `E` or the mass `M`.
```julia
p = FourVector(1.0, 2.0, 3.0; E = 4.0)
p = FourVector(1.0, 2.0, 3.0; M = sqrt(2))
```### Properties
You can access the components directly:
```julia
px = p.px
py = p.py
pz = p.pz
E = p.E
```Or using aliases and indexing:
```julia
px = p[1]
py = p[2]
pz = p[3]
E = p[4]momentum = p[1:3] # Returns an array of [px, py, pz]
```### Kinematic Quantities
Compute various kinematic quantities using provided `LorentzVectorBase` functions and aliases:
```julia
m = mass(p) # Invariant mass
pt = pt(p) # Transverse momentum
eta = eta(p) # Pseudorapidity
phi = azimuthal_angle(p) # Azimuthal angle φ
theta = polar_angle(p) # Polar angle θ
```### Lorentz Transformations
#### Rotations and Boosts
Rotate a four-vector around the x, y, or z-axis with active rotations:
```julia
# Rotation around x-axis by angle α
p_rotated_x = Rx(p, α)# Rotation around y-axis by angle θ
p_rotated_y = Ry(p, θ)# Rotation around z-axis by angle ϕ
p_rotated_z = Rz(p, ϕ)
```Perform a boost along the z-axis with Lorentz factor γ:
```julia
p_boosted = Bz(p, γ)
```
A boost in the opposite direction can be achieved by passing a negative Lorentz factor.## Contributing
Contributions are welcome! If you find a bug or have a feature request, please open an issue on the GitHub repository.
## License
This package is released under the MIT License.