Skip to main content

No project description provided

Project description

Python versions on PyPI CeNTREX-TlF version on PyPI Code style: black

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 section
  • get_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.ballistic assumes a constant velocity and constant gravitational acceleration
  • PropagationType.ode needs a defined force function in the section and uses scipy.integrate.solve_ivp to 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,
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

centrex_trajectories-0.4.tar.gz (52.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

centrex_trajectories-0.4-py3-none-any.whl (59.3 kB view details)

Uploaded Python 3

File details

Details for the file centrex_trajectories-0.4.tar.gz.

File metadata

  • Download URL: centrex_trajectories-0.4.tar.gz
  • Upload date:
  • Size: 52.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.14 {"installer":{"name":"uv","version":"0.9.14","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}

File hashes

Hashes for centrex_trajectories-0.4.tar.gz
Algorithm Hash digest
SHA256 74a39952661b6f6d1870c2ca0ef085c668d3a3c662990475e302d58f6a7d0a99
MD5 bdeb34d9a94cde640d54969487f338fc
BLAKE2b-256 3946fe5533f74babbb7a6bab0b55ca221421782efc17e234b5bf479765ba39bc

See more details on using hashes here.

File details

Details for the file centrex_trajectories-0.4-py3-none-any.whl.

File metadata

  • Download URL: centrex_trajectories-0.4-py3-none-any.whl
  • Upload date:
  • Size: 59.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.14 {"installer":{"name":"uv","version":"0.9.14","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}

File hashes

Hashes for centrex_trajectories-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3f1572f3db3d4086bc9a110dbb3168a2d1de6eed06044f01bfd2771aa2934c8a
MD5 775c9a42e9edfdcb8470d8b84897ffad
BLAKE2b-256 c17c1d8534a73151019081abf051fa1067aa0cc0769d13778c538e6783f15755

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page