Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
* Update description.
* Update installation instructions.
* Add brief tutorial.
* Add lifecycle badge.
  • Loading branch information
Jean-Loup Tastet authored Sep 5, 2018
1 parent 40f7e88 commit 0a4eb3e
Showing 1 changed file with 50 additions and 7 deletions.
57 changes: 50 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,64 @@

[![Build Status](https://travis-ci.org/Element-126/LorentzVectors.jl.svg?branch=master)](https://travis-ci.org/Element-126/LorentzVectors.jl)
[![codecov.io](http://codecov.io/github/Element-126/LorentzVectors.jl/coverage.svg?branch=master)](http://codecov.io/github/Element-126/LorentzVectors.jl?branch=master)
[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)

This package defines the `LorentzVector{T}` and `SpatialVector{T}` types for use in computations involving Special Relativity.
It implements the usual algebraic operations as well as some relevant functions such as `boost`.
The signature of the Minkowski metric (used for the dot product) is `+,-,-,-`.
This package defines the `LorentzVector{T}` and `SpatialVector{T}` types for use in computations involving Special Relativity. These types are statically allocated and should therefore be very fast.

:floppy_disk: Installing
The usual algebraic operations are implemented, as well as some domain-specific functions (such as `boost`) and many convenience methods.

The signature of the Minkowski metric (used for the inner product) is `+,-,-,-`.

:arrow_down: Installing
---

Install it with:
From the Julia REPL:

```
(v1.0) pkg> add https://github.com/Element-126/LorentzVectors.jl.git
```

:information_source: Usage
---

```julia
Pkg.clone("https://github.com/Element-126/LorentzVectors.jl.git")
using LorentzVectors

p1 = Vec4(10, 0, 0, 10)
p2 = Vec4(7, 0, 1, 5)

m1 = (p1p1)
@assert m1 == 0 # p1 is lightlike, so its mass must be zero
m2 = (p2p2)
@assert m2 > 0

β1 = Vec3(p1/p1.t)
@assert norm(β1) 1 # Check that p1 travels at the speed of light

p2_rest = boost(p2, p2/p2.t) # Boost p2 to its rest frame
@assert p2_rest.t m2 # Check that its energy at rest is equal to its mass

@assert boost(p2, zero(Vec3)) p2 # Identity boost

p_tot = p1 + p2
β_cm = p_tot/p_tot.t # Compute the velocity of the center of mass (CM)
p1_cm = boost(p1, β_cm) # Boost p1 and p2 to the CM frame
p2_cm = boost(p2, β_cm)
@assert norm(Vec3(p1_cm + p2_cm)) < 1e-12 # Check that the spatial parts cancel in the CM

u1 = rand(Vec3{Float64}) # Generate a random 3-vector on the unit sphere
@assert norm(u1) 1
u2 = normalize(Vec3(p2)) # Extract the spatial direction of p2
@assert norm(u2) 1

@assert Vec4 === LorentzVector # Long forms
@assert Vec3 === SpatialVector

x = Vec3(1f0, 0, 0) # Float64 is used by default, but it can be overriden
@assert typeof(x) == Vec3{Float32}
```

:warning: This package is currently :construction: WIP and may change at any time without prior notice. Use at your own risk !
For more examples, have a look in the `test` directory.

:heart: Contributing
---
Expand Down

0 comments on commit 0a4eb3e

Please sign in to comment.