Skip to content

Commit

Permalink
Merge pull request #79 from ULB-Metronu/issue-77
Browse files Browse the repository at this point in the history
Improve apertures definition
  • Loading branch information
Robin Tesse committed Dec 29, 2023
2 parents a0648c1 + d349e24 commit 785bb2a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![ci](https://github.com/ULB-Metronu/georges/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/ULB-Metronu/georges/actions/workflows/master.yml)
[![documentation](https://github.com/ULB-Metronu/georges/actions/workflows/documentation.yml/badge.svg?branch=master)](https://github.com/ULB-Metronu/georges/actions/workflows/documentation.yml)
![Python](docs/_static/python_versions.svg)
![version](https://img.shields.io/badge/version-2023.1-blue)
![version](https://img.shields.io/badge/version-2023.2-blue)

[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=ULB-Metronu_georges&metric=bugs)](https://sonarcloud.io/summary/overall?id=ULB-Metronu_georges)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ULB-Metronu_georges&metric=coverage)](https://sonarcloud.io/summary/overall?id=ULB-Metronu_georges)
Expand Down
4 changes: 3 additions & 1 deletion georges/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
__version__ = "2023.1"
from importlib.metadata import version

__version__ = version("georges")

from georges_core import Q_, Kinematics, particles, ureg
from georges_core.distribution import *
Expand Down
26 changes: 17 additions & 9 deletions georges/manzoni/apertures.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
The file `apertures.py` is for the `collimator` elements and contains the implementation of the
selection of the particle according to the type of collimator (rectangular, circular, elliptical).
selection of the particle according to the type of collimator (circular, elliptical, rectangular or phase-space).
"""
import numpy as _np
from numba import njit
Expand All @@ -9,12 +9,14 @@
@njit
def circular_aperture_check(b1, kargs: _np.ndarray):
"""
The aperture is circular and defined by its radius.
Args:
b1:
kargs:
b1: The beam before the collimator
kargs: Radius of the aperture.
Returns:
The collimated beam
"""
return (b1[:, 0] ** 2 + b1[:, 2] ** 2) < kargs[0] ** 2
Expand All @@ -23,12 +25,14 @@ def circular_aperture_check(b1, kargs: _np.ndarray):
@njit
def elliptical_aperture_check(b1, kargs: _np.ndarray):
"""
The aperture is elliptical and defined by the semi-axes of the elliptical aperture.
Args:
b1:
kargs:
b1: The beam before the collimator
kargs: Semi-axes of the aperture.
Returns:
The collimated beam
"""
return (b1[:, 0] / kargs[0]) ** 2 + (b1[:, 2] / kargs[1] ** 2) < 1
Expand All @@ -37,12 +41,14 @@ def elliptical_aperture_check(b1, kargs: _np.ndarray):
@njit
def rectangular_aperture_check(b1, kargs: _np.ndarray):
"""
The aperture is rectangular and defined by its horizontal and vertical half apertures.
Args:
b1:
kargs:
b1: The beam before the collimator
kargs: horizontal and vertical half apertures
Returns:
The collimated beam
"""
return _np.multiply(_np.abs(b1[:, 0]) < kargs[0], _np.abs(b1[:, 2]) < kargs[1])
Expand All @@ -51,12 +57,14 @@ def rectangular_aperture_check(b1, kargs: _np.ndarray):
@njit
def phase_space_aperture_check(b1, kargs: _np.ndarray):
"""
The phase space aperture allows the user to cut either the position or the momentum of the beam.
Args:
b1:
kargs:
b1: The beam before the collimator
kargs: Radius of the aperture in each coordinates system (position and momentum).
Returns:
The collimated beam
"""
return ((b1[:, 0] / kargs[0]) ** 2 + (b1[:, 1] / kargs[1]) ** 2) < 1 and (
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ exclude = ['docs/**', '.venv/**']

[tool.poetry]
name = "georges"
version = "2023.1"
version = "2023.2"
description = "Georges' accelerator physics library - Core"
authors = ["Cédric Hernalsteens <[email protected]>",
"Robin Tesse <[email protected]>",
Expand Down

0 comments on commit 785bb2a

Please sign in to comment.