Skip to content

Commit 52c517d

Browse files
author
Lee Carver
committed
Merge branch 'master' into update_beamloading
2 parents c2be1bc + c8c5844 commit 52c517d

File tree

118 files changed

+10324
-4518
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+10324
-4518
lines changed

.github/workflows/build-python-wheels.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ jobs:
2222
# see: https://github.com/pypa/setuptools_scm/issues/480
2323
fetch-depth: 0
2424

25+
- name: Set up Python 3.12
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: 3.12
29+
2530
- name: Build wheels
26-
uses: pypa/cibuildwheel@v2.19.1
31+
uses: pypa/cibuildwheel@v2.22
2732

2833
- name: Upload wheels
2934
uses: actions/upload-artifact@v4

.github/workflows/docs.yml

-39
This file was deleted.

.github/workflows/documentation.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Deploy static content to Pages
2+
3+
on:
4+
# Runs on pushes targeting the default branch
5+
push:
6+
branches: ["master"]
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
18+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
19+
concurrency:
20+
group: "pages"
21+
cancel-in-progress: false
22+
23+
jobs:
24+
# Single deploy job since we're just deploying
25+
deploy:
26+
environment:
27+
name: github-pages
28+
url: ${{ steps.deployment.outputs.page_url }}
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
with:
34+
# Necessary to fetch tags and allow setuptools_scm
35+
# see: https://github.com/pypa/setuptools_scm/issues/480
36+
fetch-depth: 0
37+
38+
- name: Set up Python
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version: 3.12
42+
cache: pip
43+
44+
- name: Build and install at
45+
run: python -m pip install ".[plot, doc]"
46+
47+
- name: Compile documentation
48+
run: make html
49+
working-directory: docs
50+
51+
- name: Upload artifact
52+
uses: actions/upload-pages-artifact@v3
53+
with:
54+
path: 'docs/_build/html'
55+
56+
- name: Deploy to GitHub Pages
57+
id: deployment
58+
uses: actions/deploy-pages@v4

.github/workflows/matlab-tests.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ jobs:
2929
- name: Set up python
3030
uses: actions/setup-python@v5
3131
with:
32-
python-version: '3.10'
32+
python-version: '3.11'
3333
cache: pip
3434

3535
- name: Set up MATLAB
3636
uses: matlab-actions/setup-matlab@v2
3737
with:
38-
release: R2023a
38+
release: R2024a
3939

4040
- name: Atmexall
4141
uses: matlab-actions/run-command@v2
4242
with:
43-
command: run('atmat/atpath');githubsetup();
43+
command: run('atmat/atpath');githubsetup('-v');
4444

4545
- name: Build and install at
46-
run: python -m pip install .
46+
run: python -m pip install -v .
4747

4848
- name: Run tests
4949
uses: matlab-actions/run-command@v2

.github/workflows/python-tests.yml

+8-14
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ name: Build Python extension and run tests
66

77
on:
88
push:
9-
pull_request:
109

1110
jobs:
1211
build_and_run_tests:
@@ -16,24 +15,19 @@ jobs:
1615

1716
strategy:
1817
matrix:
19-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
20-
os: [macos-latest, ubuntu-latest, windows-latest]
21-
exclude:
22-
- os: windows-latest
23-
python-version: '3.7'
24-
- os: macos-latest
25-
python-version: '3.7'
26-
- os: macos-latest
27-
python-version: '3.8'
28-
- os: macos-latest
29-
python-version: '3.9'
18+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
19+
os: [macos-13, macos-latest, ubuntu-latest, windows-latest]
3020
include:
3121
- os: macos-13
3222
python-version: '3.7'
3323
- os: macos-13
3424
python-version: '3.8'
35-
- os: macos-13
36-
python-version: '3.9'
25+
- os: ubuntu-22.04
26+
python-version: '3.7'
27+
- os: ubuntu-22.04
28+
python-version: '3.8'
29+
- os: windows-latest
30+
python-version: '3.8'
3731

3832

3933
steps:

.readthedocs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ version: 2
99
build:
1010
os: ubuntu-20.04
1111
tools:
12-
python: "3.9"
12+
python: "3.10"
1313
# You can also specify other tool versions:
1414
# nodejs: "16"
1515
# rust: "1.55"

atintegrators/BndMPoleSymplectic4RadPass.c

+26-19
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#include "atconstants.h"
21
#include "atelem.c"
32
#include "atlalib.c"
4-
#include "atphyslib.c"
5-
#include "driftkickrad.c" /* bndthinkickrad.c */
3+
#include "diff_bend_fringe.c"
4+
#include "diff_bnd_kick.c"
5+
#include "diff_drift.c"
66
#include "quadfringe.c" /* QuadFringePassP, QuadFringePassN */
77

88
struct elem
@@ -47,7 +47,8 @@ void BndMPoleSymplectic4RadPass(double *r, double le, double irho, double *A, do
4747
double *T1, double *T2,
4848
double *R1, double *R2,
4949
double *RApertures, double *EApertures,
50-
double *KickAngle, double scaling, double E0, int num_particles)
50+
double *KickAngle, double scaling, double gamma, int num_particles,
51+
double *bdiff)
5152
{
5253
double SL = le/num_int_steps;
5354
double L1 = SL*DRIFT1;
@@ -58,14 +59,16 @@ void BndMPoleSymplectic4RadPass(double *r, double le, double irho, double *A, do
5859
bool useLinFrEleExit = (fringeIntM0 != NULL && fringeIntP0 != NULL && FringeQuadExit==2);
5960
double B0 = B[0];
6061
double A0 = A[0];
62+
double rad_const = RAD_CONST*pow(gamma, 3);
63+
double diff_const = DIF_CONST*pow(gamma, 5);
6164

6265
if (KickAngle) { /* Convert corrector component to polynomial coefficients */
6366
B[0] -= sin(KickAngle[0])/le;
6467
A[0] += sin(KickAngle[1])/le;
6568
}
6669
#pragma omp parallel for if (num_particles > OMP_PARTICLE_THRESHOLD) default(none) \
67-
shared(r,num_particles,R1,T1,R2,T2,RApertures,EApertures,\
68-
irho,gap,A,B,L1,L2,K1,K2,max_order,num_int_steps,E0,scaling,\
70+
shared(r,num_particles,R1,T1,R2,T2,RApertures,EApertures,bdiff,\
71+
irho,gap,A,B,L1,L2,K1,K2,max_order,num_int_steps,rad_const, diff_const,scaling,\
6972
FringeBendEntrance,entrance_angle,fint1,FringeBendExit,exit_angle,fint2,\
7073
FringeQuadEntrance,useLinFrEleEntrance,FringeQuadExit,useLinFrEleExit,fringeIntM0,fringeIntP0)
7174
for (int c = 0; c<num_particles; c++) { /* Loop over particles */
@@ -81,7 +84,7 @@ void BndMPoleSymplectic4RadPass(double *r, double le, double irho, double *A, do
8184
if (RApertures) checkiflostRectangularAp(r6,RApertures);
8285
if (EApertures) checkiflostEllipticalAp(r6,EApertures);
8386
/* edge focus */
84-
edge_fringe_entrance(r6, irho, entrance_angle, fint1, gap, FringeBendEntrance);
87+
diff_bend_fringe(r6, irho, entrance_angle, fint1, gap, FringeBendEntrance, 1.0, bdiff);
8588
/* quadrupole gradient fringe entrance*/
8689
if (FringeQuadEntrance && B[1]!=0) {
8790
if (useLinFrEleEntrance) /*Linear fringe fields from elegant*/
@@ -91,13 +94,13 @@ void BndMPoleSymplectic4RadPass(double *r, double le, double irho, double *A, do
9194
}
9295
/* integrator */
9396
for (m=0; m < num_int_steps; m++) { /* Loop over slices */
94-
ATdrift6(r6,L1);
95-
bndthinkickrad(r6, A, B, K1, irho, E0, max_order);
96-
ATdrift6(r6,L2);
97-
bndthinkickrad(r6, A, B, K2, irho, E0, max_order);
98-
ATdrift6(r6,L2);
99-
bndthinkickrad(r6, A, B, K1, irho, E0, max_order);
100-
ATdrift6(r6,L1);
97+
diff_drift(r6, L1, bdiff);
98+
diff_bnd_kick(r6, A, B, max_order, K1, irho, rad_const, diff_const, bdiff);
99+
diff_drift(r6, L2, bdiff);
100+
diff_bnd_kick(r6, A, B, max_order, K2, irho, rad_const, diff_const, bdiff);
101+
diff_drift(r6, L2, bdiff);
102+
diff_bnd_kick(r6, A, B, max_order, K1, irho, rad_const, diff_const, bdiff);
103+
diff_drift(r6, L1, bdiff);
101104
}
102105
/* quadrupole gradient fringe */
103106
if (FringeQuadExit && B[1]!=0) {
@@ -107,7 +110,7 @@ void BndMPoleSymplectic4RadPass(double *r, double le, double irho, double *A, do
107110
QuadFringePassN(r6, B[1]);
108111
}
109112
/* edge focus */
110-
edge_fringe_exit(r6, irho, exit_angle, fint2, gap, FringeBendExit);
113+
diff_bend_fringe(r6, irho, exit_angle, fint2, gap, FringeBendExit, -1.0, bdiff);
111114
/* Check physical apertures at the exit of the magnet */
112115
if (RApertures) checkiflostRectangularAp(r6,RApertures);
113116
if (EApertures) checkiflostEllipticalAp(r6,EApertures);
@@ -128,7 +131,9 @@ void BndMPoleSymplectic4RadPass(double *r, double le, double irho, double *A, do
128131
ExportMode struct elem *trackFunction(const atElem *ElemData,struct elem *Elem,
129132
double *r_in, int num_particles, struct parameters *Param)
130133
{
131-
double irho, energy;
134+
double irho, gamma;
135+
double *bdiff = Param->bdiff;
136+
132137
if (!Elem) {
133138
double Length, BendingAngle, EntranceAngle, ExitAngle, FullGap, Scaling,
134139
FringeInt1, FringeInt2, Energy;
@@ -193,7 +198,7 @@ ExportMode struct elem *trackFunction(const atElem *ElemData,struct elem *Elem,
193198
Elem->KickAngle=KickAngle;
194199
}
195200
irho = Elem->BendingAngle/Elem->Length;
196-
energy = atEnergy(Param->energy, Elem->Energy);
201+
gamma = atGamma(Param->energy, Elem->Energy, Param->rest_energy);
197202

198203
BndMPoleSymplectic4RadPass(r_in, Elem->Length, irho, Elem->PolynomA, Elem->PolynomB,
199204
Elem->MaxOrder, Elem->NumIntSteps, Elem->EntranceAngle, Elem->ExitAngle,
@@ -203,7 +208,7 @@ ExportMode struct elem *trackFunction(const atElem *ElemData,struct elem *Elem,
203208
Elem->fringeIntM0, Elem->fringeIntP0,
204209
Elem->T1, Elem->T2, Elem->R1, Elem->R2,
205210
Elem->RApertures, Elem->EApertures,
206-
Elem->KickAngle, Elem->Scaling, energy, num_particles);
211+
Elem->KickAngle, Elem->Scaling, gamma, num_particles, bdiff);
207212
return Elem;
208213
}
209214

@@ -224,6 +229,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
224229
double *PolynomA, *PolynomB, *R1, *R2, *T1, *T2, *EApertures, *RApertures, *fringeIntM0, *fringeIntP0, *KickAngle;
225230
double irho;
226231
double *r_in;
232+
double Gamma;
227233
const mxArray *ElemData = prhs[0];
228234
int num_particles = mxGetN(prhs[1]);
229235
if (mxGetM(prhs[1]) != 6) mexErrMsgTxt("Second argument must be a 6 x N matrix");
@@ -260,6 +266,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
260266

261267
/* ALLOCATE memory for the output array of the same size as the input */
262268
plhs[0] = mxDuplicateArray(prhs[1]);
269+
Gamma = atGamma(Energy, Energy, rest_energy);
263270
r_in = mxGetDoubles(plhs[0]);
264271

265272
BndMPoleSymplectic4RadPass(r_in, Length, irho, PolynomA, PolynomB,
@@ -269,7 +276,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
269276
FringeQuadEntrance, FringeQuadExit,
270277
fringeIntM0, fringeIntP0,
271278
T1, T2, R1, R2, RApertures, EApertures,
272-
KickAngle, Scaling, Energy, num_particles);
279+
KickAngle, Scaling, Gamma, num_particles, NULL);
273280
} else if (nrhs == 0) {
274281
/* list of required fields */
275282
plhs[0] = mxCreateCellMatrix(9,1);

0 commit comments

Comments
 (0)