Skip to content

Commit

Permalink
Merge branch 'master' into fix_bug_pyat_variablemultipole
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarxblanco authored Dec 18, 2024
2 parents e1308ea + 8620504 commit ae9b0e1
Show file tree
Hide file tree
Showing 13 changed files with 299 additions and 593 deletions.
21 changes: 8 additions & 13 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,19 @@ jobs:

strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
os: [macos-latest, ubuntu-latest, windows-latest]
exclude:
- os: windows-latest
python-version: '3.7'
- os: macos-latest
python-version: '3.7'
- os: macos-latest
python-version: '3.8'
- os: macos-latest
python-version: '3.9'
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
os: [macos-13, macos-latest, ubuntu-latest, windows-latest]
include:
- os: macos-13
python-version: '3.7'
- os: macos-13
python-version: '3.8'
- os: macos-13
python-version: '3.9'
- os: ubuntu-22.04
python-version: '3.7'
- os: ubuntu-22.04
python-version: '3.8'
- os: windows-latest
python-version: '3.8'


steps:
Expand Down
14 changes: 8 additions & 6 deletions atmat/atphysics/Radiation/atgetU0.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@
function U0=tracking(ring)
% Ensure 6d is enabled
check_6d(ring,true);
% Turn cavities off
ringtmp=atdisable_6d(ring,'allpass','','cavipass','auto',...
'quantdiffpass','auto','simplequantdiffpass','auto');
o0=zeros(6,1);
o6=ringpass(ringtmp,o0);
U0=-o6(5)*energy;
radiating=atgetcells(ring,'PassMethod','*RadPass');
sumd=sum(cellfun(@comp, ring(radiating)));
U0=-sumd*energy;

function delta = comp(elem)
rout=elempass(elem,zeros(6,1),'Energy',energy);
delta=rout(5);
end
end

end
3 changes: 2 additions & 1 deletion atmat/atplot/xplot.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@

function newelems=splitelem(elem)
if isfield(elem,'Length') && elem.Length > 0 ...
&& ~strcmp(elem.PassMethod, 'IdTablePass')
&& ~any(strcmp(elem.PassMethod,...
{'IdTablePass', 'GWigSymplecticPass', 'GWigSymplecticRadPass'}))
nslices=ceil(elem.Length/elmlength);
if ~KeepAxis
newelems=atdivelem(elem,ones(1,nslices)./nslices);
Expand Down
4 changes: 2 additions & 2 deletions atmat/attests/pytests.m
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ function tunechrom6(testCase,lat2,dp)
[mtune,mchrom]=tunechrom(mlat,'get_chrom');
ptune=double(plat.get_tune());
pchrom=double(plat.get_chrom());
testCase.verifyEqual(mod(mtune*periodicity,1),ptune,AbsTol=1.e-9);
testCase.verifyEqual(mchrom*periodicity,pchrom,RelTol=1.e-4,AbsTol=3.e-4);
testCase.verifyEqual(mod(mtune*periodicity,1),ptune,AbsTol=2.5e-9);
testCase.verifyEqual(mchrom*periodicity,pchrom,RelTol=3.e-4,AbsTol=2.e-4);
end

function linopt1(testCase,dp)
Expand Down
23 changes: 17 additions & 6 deletions docs/common/indx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,36 @@ The Accelerator Toolbox is based on a fast and modular tracking engine.

Coordinate system
-----------------
AT runs in 6 dimensions using the following coordinate system:
The AT coordinate system is based on a design trajectory along which the magnetic
elements are aligned, and a reference particle:

.. image:: /images/coord_system.*
:alt: coordinate system
:align: center

By convention, the reference particle travels along the design trajectory at constant
nominal energy and defines the phase origin of the RF voltage.

The 6-d coordinate vector :math:`\vec Z` is:

.. math::
\vec Z =
\begin{pmatrix}
x \\ p_x \\
y \\ p_y \\
x \\ p_x/p_0 \\
y \\ p_y/p_0 \\
\delta \\ \beta c\tau
\end{pmatrix}
:math:`p_0` is the nominal momentum,

:math:`\delta=\dfrac{p-p_0}{p_0}` is the relative momentum deviation.

AT works with relative path lengths: the 6\ :sup:`th` coordinate :math:`\beta c\tau`
represents the path lengthening with respect to the reference particle. :math:`\tau`
is the delay with respect to the reference particle: the particle is late for
:math:`\tau > 0`.

The reference particle is conventionally a particle travelling on the reference orbit
at constant nominal energy and crossing the RF cavities at their 0 voltage.

Tracking
--------
All the AT processing is based on tracking. For instance, linear optics properties
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
# -- Options for the myst markdown parser ------------------------------------

myst_enable_extensions = [
"attrs_inline",
"colon_fence",
"dollarmath",
"replacements",
Expand Down
Binary file added docs/images/coord_system.pdf
Binary file not shown.
Binary file added docs/images/coord_system.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 19 additions & 6 deletions docs/p/notebooks/ATPrimer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,29 @@
"charged particle beam simulation. It was created by Andrei Terebilo in\n",
"the late 1990’s. The original papers[^at1][^at2] still serve as a good introduction to AT. The AT described in those papers is AT1.3, the latest version produced by Terebilo. The next version of AT is considered AT2.0[^nash]. Here we provide examples showing some of the changes from AT1.3, but also serving as an introduction for someone just starting AT.\n",
"\n",
"### Coordinates\n",
"### AT Coordinate system\n",
"\n",
"The 6-d phase space coordinates used in AT are as follows:\n",
"The AT coordinate system is based on a design trajectory along which the magnetic elements are aligned,\n",
"and a reference particle:\n",
"\n",
"```{image} /images/coord_system.*\n",
":alt: coordinate system\n",
":align: center\n",
"```\n",
"\n",
"By convention, the reference particle travels along the design trajectory at constant nominal energy and defines the phase origin of the RF voltage.\n",
"\n",
"The 6-d coordinate vector $\\vec Z$ is:\n",
"\n",
"$$\n",
"\\vec Z = \\begin{pmatrix} x \\\\ \\frac{p_x}{p_0} \\simeq x'(1+\\delta) \\\\ y \\\\ \\frac{p_y}{p_0} \\simeq y'(1+\\delta) \\\\ \\delta=\\frac{\\left(p-p_0\\right)}{p_0} \\\\ \\beta c \\tau\\end{pmatrix}\n",
"\\vec Z = \\begin{pmatrix} x \\\\ \\dfrac{p_x}{p_0} \\approx x'(1+\\delta) \\\\ y \\\\ \\dfrac{p_y}{p_0} \\approx y'(1+\\delta) \\\\ \\delta=\\dfrac{p-p_0}{p_0} \\\\ \\beta c \\tau\\end{pmatrix}\n",
"$$\n",
"\n",
"$p_0$ is the reference momentum. $\\tau$ is the\n",
"time lag relative to the ideal particle."
"$p_0$ is the reference momentum.\n",
"\n",
"AT works with relative path lengths: the 6{sup}`th` coordinate $\\beta c\\tau$ represents\n",
"the path lengthening with respect to the reference particle. $\\tau$ is the delay with\n",
"respect to the reference particle: the particle is late for $\\tau > 0$.\n"
]
},
{
Expand Down Expand Up @@ -1760,7 +1773,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.10"
"version": "3.9.21"
},
"toc-autonumbering": false,
"toc-showcode": false,
Expand Down
4 changes: 4 additions & 0 deletions pyat/at/lattice/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,10 @@ def __init__(
self.NHharm = self.By.shape[1]
self.NVharm = self.Bx.shape[1]

def divide(self, frac) -> list[Element]:
# A wiggler is indivisible
return [self]


class QuantumDiffusion(_DictLongtMotion, Element):
_BUILD_ATTRIBUTES = Element._BUILD_ATTRIBUTES + ["Lmatp"]
Expand Down
Loading

0 comments on commit ae9b0e1

Please sign in to comment.