CeNTREX-trajectories
Code for simulating CeNTREX trajectories
Installation
Clone repo and install with pip or directly install from GitHub with:
pip install git+https://github.com/ograsdijk/CeNTREX-trajectories
Sections
The beamline is split into sections specified with Section, which can be used as follows:
sections = [
fourK = Section(
name = "4K shield",
objects = [CircularAperture(x=0, y=0, z=5e-3)],
start = 0,
stop = 10e-2,
save_collisions = False,
propagation_type=PropagationType.ballistic,
)
]
This defines a section called 4K shield, which runs from z = 0 m -> 10e-2 m. Collisions aren't
saved, the propagation_type is ballistic and it contains a single circular aperture centered around
the z axis with a radius of 5 mm.
Collision objects
Currently two type of apertures are defined for collisions:
CircularAperture(x: float,y: float,r: float)RectangularAperture(x: float,y: float,wx: float,wy: float)
Custom collision objects can be defined; apertures should inherit from Aperture, and each custom
collision object should have two functions:
check_in_bounds(start: float, stop: float)which returns a boolean specifying whether the object fully resides inside the sectionget_acceptance(coordinates: Coordinates)which returns a boolean arrays specifiying which trajectories make it through the aperture
Propagation types
There is support for ballistic and ODE solver trajectories, which is specified on a per section basis through Section.propagation_type
PropagationType.ballisticassumes a constant velocity and constant gravitational accelerationPropagationType.odeneeds a defined force function in the section and usesscipy.integrate.solve_ivpto calculate the trajectory
Working example
import numpy as np
from centrex_trajectories import (
Coordinates,
Velocities,
Force,
PropagationType,
propagate_trajectories,
PropagationOptions,
)
from centrex_trajectories.beamline_objects import CircularAperture, Section
from centrex_trajectories.particles import TlF
in_to_m = 0.0254
fourK = Section(
name="4K shield",
objects=[CircularAperture(x=0, y=0, z=1.75 * in_to_m, r=1 / 2 * in_to_m)],
start=0,
stop=2 * in_to_m,
save_collisions=False,
propagation_type=PropagationType.ballistic,
)
fourtyK = Section(
name="40K shield",
objects=[
CircularAperture(x=0, y=0, z=fourK.stop + 1.25 * in_to_m, r=1 / 2 * in_to_m)
],
start=fourK.stop,
stop=fourK.stop + 1.5 * in_to_m,
save_collisions=False,
propagation_type=PropagationType.ballistic,
)
bbexit = Section(
name="Beamsource Exit",
objects=[CircularAperture(0, 0, fourtyK.stop + 2.5 * in_to_m, 2 * in_to_m)],
start=fourtyK.stop,
stop=fourtyK.stop + 3.25 * in_to_m,
save_collisions=False,
propagation_type=PropagationType.ballistic,
)
sections = [fourK, fourtyK, bbexit]
n_trajectories = 100_000
coordinates_init = Coordinates(
x=np.random.randn(n_trajectories) * 1.5e-3,
y=np.random.randn(n_trajectories) * 1.5e-3,
z=np.zeros(n_trajectories),
)
velocities_init = Velocities(
vx=np.random.randn(n_trajectories) * 39.4,
vy=np.random.randn(n_trajectories) * 39.4,
vz=np.random.randn(n_trajectories) * 16 + 184,
)
options = PropagationOptions(n_cores=6, verbose=False)
particle = TlF()
gravity = Force(0, -9.81*particle.mass, 0)
section_data, trajectories = propagate_trajectories(
sections,
coordinates_init,
velocities_init,
particle,
force=gravity,
options=options,
)
Metadata
Release files for centrex-trajectories 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| centrex_trajectories-0.4.1.tar.gz | 100.2 kB | Without provenance | Details for centrex_trajectories-0.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| centrex_trajectories-0.4.1-py3-none-any.whl | Python 3 | none | any | Details for centrex_trajectories-0.4.1-py3-none-any.whl |
Total release size: 216.4 kB
Release files / centrex_trajectories-0.4.1.tar.gz
| Download URL | centrex_trajectories-0.4.1.tar.gz |
|---|---|
| Size | 100.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c731682f3fcc051f03719ffdc8321f31aec82b263da5d9b7ac6db5ece532a532
|
|
BLAKE2b-256 checksum How to use checksums |
10e5863755179afcc6e3f75c942466254027059d17481c4245a69951505b12f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / centrex_trajectories-0.4.1-py3-none-any.whl
| Download URL | centrex_trajectories-0.4.1-py3-none-any.whl |
|---|---|
| Size | 116.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ab0fed5e718a16b1027408a95f0c932e7bc58d6dcde569190bdcf83a8ee70739
|
|
BLAKE2b-256 checksum How to use checksums |
9d65b5f29e45e43c6c7171b7584758c8ad1a6882bc80ddabd27016afbd35ff18
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for centrex-trajectories 0.4.1
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.