Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
192 commits
Select commit Hold shift + click to select a range
17219e7
only create attributes if self is not an element
oscarxblanco Oct 3, 2024
84d3bf8
import numpy as np
oscarxblanco Oct 3, 2024
ce697be
isort
oscarxblanco Oct 3, 2024
7c3949d
black
oscarxblanco Oct 3, 2024
51db2ce
do flake8 easy fix; many are left
oscarxblanco Oct 3, 2024
f6dae67
fixing when saved in .mat
oscarxblanco Oct 4, 2024
6ced948
fix FamName when reading from matlab
oscarxblanco Oct 4, 2024
7a12dc4
fix read element from matlab
oscarxblanco Oct 4, 2024
05c0e82
fix max order in matlab
oscarxblanco Oct 4, 2024
aa71888
fixing flake8
oscarxblanco Oct 4, 2024
032c9da
fixing flake8
oscarxblanco Oct 4, 2024
e19c8f3
add check isempty
oscarxblanco Oct 4, 2024
ad441ba
matlab index starts in 1, obviously
oscarxblanco Oct 4, 2024
9e62915
fix help matlab
oscarxblanco Oct 4, 2024
59aeee3
fix doc string
oscarxblanco Oct 4, 2024
58d703b
fix help
oscarxblanco Oct 8, 2024
5115496
testing function derivatives
oscarxblanco Nov 18, 2024
d899d08
testing function derivatives
oscarxblanco Nov 18, 2024
93f6bb5
adding function derivatives wrt to tau
oscarxblanco Nov 19, 2024
97854d8
add Func derivatives wrt tau
oscarxblanco Nov 19, 2024
7c405e2
improving doc of SINE mode
oscarxblanco Dec 2, 2024
b531d4e
removing mode from vararging
oscarxblanco Dec 2, 2024
3ffa2f7
remove mode from varargsin
oscarxblanco Dec 2, 2024
79351f2
add docstring SINE mode
oscarxblanco Dec 2, 2024
07fc985
add docstring SINE mode
oscarxblanco Dec 2, 2024
aedf3ab
import VariableMultipole from variable_elements
oscarxblanco Dec 2, 2024
7c4361a
mode needs to be defined
oscarxblanco Dec 2, 2024
0f55260
import variable_elements; and defines pass method mappiing
oscarxblanco Dec 2, 2024
fb889ae
test
oscarxblanco Dec 3, 2024
c089301
separate amplitude and other parameters
oscarxblanco Dec 4, 2024
9d1412c
set parameters only for A or B
oscarxblanco Dec 5, 2024
aa1d905
fixing bugs
oscarxblanco Dec 12, 2024
5630fa5
add apertures and misalignments
oscarxblanco Dec 12, 2024
59adb54
add R1, R2, T1, T2, RApertures, EApertures
oscarxblanco Dec 12, 2024
6d88ad6
adds aperture, rotation and translations
oscarxblanco Dec 13, 2024
9d80e37
add mode
oscarxblanco Dec 13, 2024
67fb8dc
updating element
oscarxblanco Dec 13, 2024
c7197dd
fixing datatype
oscarxblanco Dec 13, 2024
4168268
black
oscarxblanco Dec 13, 2024
a272b79
improve docstring
oscarxblanco Dec 13, 2024
be0f0a4
Merge branch 'master' into fix_bug_pyat_variablemultipole
oscarxblanco Dec 13, 2024
a1045d7
modify comments
oscarxblanco Dec 16, 2024
a87c6c7
add mean and std on random function
oscarxblanco Dec 16, 2024
39c37d6
set mean and std on random whitenoise
oscarxblanco Dec 16, 2024
2d07122
remove MaxOrder from user input
oscarxblanco Dec 16, 2024
d11fb99
set white noise
oscarxblanco Dec 16, 2024
e0ee739
remove periodic from definition
oscarxblanco Dec 16, 2024
9227f95
testting random generator
oscarxblanco Dec 16, 2024
6a219b4
debugging mean and std
oscarxblanco Dec 16, 2024
d05627a
debugging seed of random number generator
oscarxblanco Dec 16, 2024
a4c66f1
add seed initial state
oscarxblanco Dec 17, 2024
287bb37
add seed initial state
oscarxblanco Dec 17, 2024
731b52b
add seed initial state
oscarxblanco Dec 17, 2024
74555bd
include comments
oscarxblanco Dec 17, 2024
9a804f2
set Periodic True default
oscarxblanco Dec 17, 2024
680efdb
fixing bug in conversions
oscarxblanco Dec 17, 2024
e1308ea
using Param->thread_rng
oscarxblanco Dec 18, 2024
ae9b0e1
Merge branch 'master' into fix_bug_pyat_variablemultipole
oscarxblanco Dec 18, 2024
a524815
removing seed; add comments; add Sinlimit
oscarxblanco Dec 19, 2024
f84c550
sinlimit > or =
oscarxblanco Dec 19, 2024
c0de957
remove seed; add sinlimit
oscarxblanco Dec 19, 2024
4f13031
add Sinlimit; remove seed
oscarxblanco Dec 19, 2024
1cd90d8
use pcg32_global in AT matlab
oscarxblanco Dec 19, 2024
13f1cad
black
oscarxblanco Dec 19, 2024
94d5837
get frequency
oscarxblanco Dec 19, 2024
68ff29e
fix bug in arbitrary function
oscarxblanco Dec 19, 2024
0a6e2f5
adding ACMode
oscarxblanco Dec 19, 2024
ed6be2c
import all from VariableMultipole
oscarxblanco Dec 19, 2024
8f1e7f3
improve help
oscarxblanco Dec 19, 2024
93ba719
improve DocSgtring; black
oscarxblanco Dec 19, 2024
40bf18b
fixing flake8
oscarxblanco Dec 19, 2024
aa00a4f
flake8
oscarxblanco Dec 19, 2024
5f704f7
branchless if
oscarxblanco Dec 20, 2024
cfb48be
removing mean and std value in white noise
oscarxblanco Jan 7, 2025
8da79fb
removing mean and std from white noise
oscarxblanco Jan 7, 2025
5aa0b0e
removing mean and std from white noise
oscarxblanco Jan 7, 2025
c631ae8
switch to AtWarning when amplitude is used instead of Amplitude
oscarxblanco Jan 7, 2025
7f5f574
set default mode
oscarxblanco Jan 7, 2025
3716abf
removing any; using Any
oscarxblanco Jan 7, 2025
5fecb70
setdefault Phase, SinLimit
oscarxblanco Jan 7, 2025
d0cb8f0
remove set amplitude
oscarxblanco Jan 7, 2025
acfb812
moving functions inside __init__
oscarxblanco Jan 7, 2025
1fbfcfb
black
oscarxblanco Jan 7, 2025
b47392d
isort
oscarxblanco Jan 7, 2025
956d32e
change Sinlimit to Sinabove
oscarxblanco Jan 7, 2025
8b64d11
changes Sinlimit to Sinabove
oscarxblanco Jan 7, 2025
e10b71c
changes Sinlimit to Sinabove; fixes docstring
oscarxblanco Jan 7, 2025
eabf92e
improve docstring
oscarxblanco Jan 7, 2025
19e0560
improve docstring
oscarxblanco Jan 7, 2025
2b637d3
Changes Sinabove to SinAabove and SinBabove
oscarxblanco Jan 7, 2025
8a6a266
changes Sinabove to SinAabove and SinBabove
oscarxblanco Jan 7, 2025
d4a2e66
changes Sinabove by SinAabove and SinBabove
oscarxblanco Jan 7, 2025
a1ecaa0
fix docstring
oscarxblanco Jan 7, 2025
6573a21
fixing matlab help
oscarxblanco Jan 7, 2025
7544283
Adding default pass method to docstring
oscarxblanco Jan 7, 2025
8605f7b
removing self from methods inside __init__
oscarxblanco Jan 7, 2025
cd27c42
fixing help message
oscarxblanco Jan 8, 2025
4b1812a
fixing help message
oscarxblanco Jan 8, 2025
01b2a66
Merge branch 'master' into fix_bug_pyat_variablemultipole
oscarxblanco Jan 8, 2025
02ee269
changes type hint to Sequence
oscarxblanco Jan 15, 2025
02a7bc0
fixing flake8 FNE008
oscarxblanco Jan 15, 2025
3642a67
set Periodic default False
oscarxblanco Jan 15, 2025
8c0ea73
Periodic set default false
oscarxblanco Jan 15, 2025
6de4a39
Merge branch 'master' into fix_bug_pyat_variablemultipole
oscarxblanco Jan 15, 2025
3d54be8
removing Float from type hint Sequence due to python3.7 error
oscarxblanco Jan 15, 2025
8cbcd97
change to VariableThinMultipole
oscarxblanco Jan 15, 2025
0054f6e
atvariablethinmultiple.m
oscarxblanco Jan 15, 2025
bf9b7ef
change to atvariablethinmultipole
oscarxblanco Jan 15, 2025
4084069
rename VariableMultipole to VariableThinMultipole
oscarxblanco Jan 16, 2025
02dad6f
rename VariableMultipole to VariableThinMultipole
oscarxblanco Jan 16, 2025
e25a0f1
reset PolynomB and PolynomA to zeros after tracking; set Periodic to …
oscarxblanco Jan 16, 2025
f5a341b
fix bug in help message
oscarxblanco Jan 16, 2025
df259e9
fixing help message
oscarxblanco Jan 17, 2025
f08edc0
fix help
oscarxblanco Jan 17, 2025
368ad62
fix help; work on the polynom inspection
oscarxblanco Jan 17, 2025
b97d73d
add polynom inspection
oscarxblanco Jan 23, 2025
8181d19
black
oscarxblanco Jan 23, 2025
07c1290
help docstring
oscarxblanco Jan 23, 2025
f059f00
Merge branch 'master' into fix_bug_pyat_variablemultipole
oscarxblanco Jan 28, 2025
d03522b
fix phase and Sinabove parameters
oscarxblanco Jan 28, 2025
3774656
adds atmat/atutils/atinspectvariablethinmultipole.m
oscarxblanco Jan 28, 2025
500b0a9
fixing T0
oscarxblanco Jan 28, 2025
d0fcb9b
fix custom element
oscarxblanco Jan 28, 2025
0c94dda
add default timeoffset
oscarxblanco Jan 28, 2025
01f09d9
fix help message
oscarxblanco Jan 28, 2025
9024245
add help message
oscarxblanco Jan 28, 2025
ec7da17
add to help message
oscarxblanco Jan 28, 2025
bcd928b
add T1,T2,R1,R2 comment in help message
oscarxblanco Jan 28, 2025
5c9d75e
add to help
oscarxblanco Jan 28, 2025
cddca24
add to help
oscarxblanco Jan 28, 2025
ef840e5
fixing flake8
oscarxblanco Jan 28, 2025
9b2280e
fixing flake8
oscarxblanco Jan 28, 2025
2f7549d
fixing flake8
oscarxblanco Jan 28, 2025
49e70ad
remove debug
oscarxblanco Jan 28, 2025
26bdabf
Merge branch 'master' into fix_bug_pyat_variablemultipole
oscarxblanco May 7, 2025
80d7b5d
Merge branch 'master' into fix_bug_pyat_variablemultipole
oscarxblanco May 12, 2025
f2f3087
Merge branch 'master' into fix_bug_pyat_variablemultipole
oscarxblanco Aug 14, 2025
7f8fa47
removing derivatives
oscarxblanco Aug 15, 2025
f290d2e
removing derivatives
oscarxblanco Aug 15, 2025
fba00a2
implement k-taylor orders
oscarxblanco Aug 20, 2025
7512bc0
implement k-taylor orders
oscarxblanco Aug 20, 2025
6ad9244
fix typo in comment
oscarxblanco Aug 20, 2025
8b076db
imporove commments
oscarxblanco Aug 20, 2025
89f6388
change doc
oscarxblanco Aug 20, 2025
8f2c631
change doc
oscarxblanco Aug 20, 2025
f9bab92
add Buffer for random numbers
oscarxblanco Aug 20, 2025
57abdb0
set buffer and buffersize for whitenoise
oscarxblanco Aug 20, 2025
4134f70
black
oscarxblanco Aug 20, 2025
37005ea
isort
oscarxblanco Aug 20, 2025
55b7dd5
remove print
oscarxblanco Aug 20, 2025
7a6e81a
auxiliary function
oscarxblanco Aug 20, 2025
f1b261b
black
oscarxblanco Aug 20, 2025
949ceaf
flake8
oscarxblanco Aug 20, 2025
311a363
flake8
oscarxblanco Aug 20, 2025
3755e41
flake8
oscarxblanco Aug 20, 2025
c3e7b4a
flake8
oscarxblanco Aug 20, 2025
7d402f9
flake8
oscarxblanco Aug 20, 2025
d7478c6
add buffer size check
oscarxblanco Aug 21, 2025
d2c98b9
check random values
oscarxblanco Aug 21, 2025
25f02c1
check random values
oscarxblanco Aug 21, 2025
a9961f0
check random values
oscarxblanco Aug 21, 2025
7a8dc2c
check random values
oscarxblanco Aug 21, 2025
016a7a2
improve doc
oscarxblanco Aug 21, 2025
98b2f58
improve doc
oscarxblanco Aug 21, 2025
6240ce7
set Buffer and BufferSize in WHITENOISE mode
oscarxblanco Aug 21, 2025
12691ff
add taylor parameters
oscarxblanco Aug 21, 2025
9302c09
fix bug
oscarxblanco Aug 21, 2025
17c3738
improve doc
oscarxblanco Aug 21, 2025
0f09c95
fix doc
oscarxblanco Aug 21, 2025
24959b5
update function taylor
oscarxblanco Aug 21, 2025
ed0c35a
avoid using bool to be compatible with .m files
oscarxblanco Aug 21, 2025
7c416aa
set Class VariableThinMultipole
oscarxblanco Aug 21, 2025
2f69686
variable thin multipoles
oscarxblanco Aug 21, 2025
99eede6
Merge branch 'master' into fix_bug_pyat_variablemultipole
oscarxblanco Aug 21, 2025
41f3e7e
print atvariablethinmultipole
oscarxblanco Aug 21, 2025
37238d1
remove checks
oscarxblanco Aug 21, 2025
8ecb330
switch case mod
oscarxblanco Aug 21, 2025
ec18664
Periodic bool to int
oscarxblanco Aug 21, 2025
4cbe104
remove the Polynom redefinition
oscarxblanco Aug 21, 2025
c97795f
fix bug
oscarxblanco Aug 21, 2025
5edca82
move down sin limit
oscarxblanco Aug 22, 2025
24c1772
move down sin limit
oscarxblanco Aug 22, 2025
267326c
improve doc
oscarxblanco Aug 22, 2025
b2d77ac
improve doc
oscarxblanco Aug 22, 2025
bfdf726
Merge branch 'master' into fix_bug_pyat_variablemultipole
oscarxblanco Aug 28, 2025
119eb5e
guess VariableThinMultipole
oscarxblanco Aug 29, 2025
82a122e
check non supported methods
oscarxblanco Aug 29, 2025
1d3e98b
remove warning
oscarxblanco Aug 29, 2025
0b6e3ee
Merge branch 'master' into fix_bug_pyat_variablemultipole
oscarxblanco Sep 2, 2025
534c4d1
Merge branch 'master' into fix_bug_pyat_variablemultipole
oscarxblanco Sep 22, 2025
0fd381f
Merge branch 'master' into fix_bug_pyat_variablemultipole
oscarxblanco Oct 1, 2025
0148453
Merge branch 'master' into fix_bug_pyat_variablemultipole
oscarxblanco Nov 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
350 changes: 296 additions & 54 deletions atintegrators/VariableThinMPolePass.c

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions atintegrators/interpolate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
Accelerator Toolbox
Created: 14/11/08
Z.Martí
Numerical recipies functions for 2D interpolation adapted to Matlab
* leanguagge



Numerical recipies functions for 2D interpolation adapted to Matlab
* language

*/

#include "at.h"
Expand Down
2 changes: 1 addition & 1 deletion atmat/Contents.m
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
% atskewquad - Creates a skew quadrupole element with Class 'Multipole'
% atsolenoid - Creates a new solenoid element with Class 'Solenoid'
% atthinmultipole - Creates a thin multipole element
% atvariablemultipole - Creates a variable thin multipole element
% atvariablethinmultipole - Creates a variable thin multipole element
% atwiggler - Creates a wiggler
%
% ATMAT/LATTICE/ELEMENT_CREATION/PRIVATE
Expand Down
10 changes: 10 additions & 0 deletions atmat/atphysics/Radiation/atdiffmat.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
orbit=num2cell(linepass(ring, orb0, 1:NumElements),1)';
end

% check for non-supported pass methods
nonsupported_methods = {'VariableThinMultipole'};
for i = 1:length(nonsupported_methods)
thepassm = nonsupported_methods{i};
lidx = find(atgetcells(ring, 'Class', thepassm));
if ~isempty(lidx)
ring = atsetfieldvalues(ring, lidx, 'PassMethod', 'IdentityPass');
end
end

zr=zeros(6,6);
% Calculate cumulative Radiation-Diffusion matrix for the ring
BCUM = zeros(6,6);
Expand Down
166 changes: 166 additions & 0 deletions atmat/atutils/atinspectvariablethinmultipole.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
function [listpola,listpolb] = atinspectvariablethinmultipole(element,varargin)
% [pola_array,polb_array] = ATINSPECTVARIABLETHINMULTIPOLE(element)
%
% Get the ATVARIABLETHINMULTIPOLE polynom values per turn.
%
% Translations (T1,T2) and rotations (R1,R2) in the element are ignored.
%
% ARGUMENTS:
% element: an atvariablethinmultipole element.
% OPTIONAL ARGUMENTS:
% turns(int): Default 1. Number of turns to calculate.
% T0(float): revolution time in seconds. Only needed in SINE mode.
% tparticle(float): Default 0. Time of the particle in seconds.
%
% RETURNS
% Two cell arrays with the values of PolynomA and PolynomB per turn.
%
% See Also:
% ATVARIABLETHINMULTIPOLE
%
p = inputParser;
addOptional(p,'turns',1,@(x) isnumeric(x) && isscalar(x) && (x > 0));
if element.Mode == 0
if ~any(strcmp(varargin,'T0'))
error('T0 is required.');
end
addOptional(p,'T0',0,@(x) isnumeric(x) && (x > 0));
end
addOptional(p,'tparticle',0,@(x) isnumeric(x));
parse(p,varargin{:});
par = p.Results;

turns = par.turns;
if element.Mode == 0
T0 = par.T0;
else
T0 = 0;
end
tparticle = par.tparticle;
mode = element.Mode;

switch mode
case 0
% revolution time
timeoffset = T0 + tparticle;
case 2
% particle time
timeoffset = tparticle;
otherwise
timeoffset = 0;
end

if isfield(element,'Ramps')
ramps = element.Ramps;
else
ramps = 0;
end

if isfield(element,'Periodic')
periodic = element.Periodic;
else
periodic = 0;
end

maxorder = element.MaxOrder;

pola = nan(1,maxorder+1);
polb = nan(1,maxorder+1);

listpola = cell(1, turns);
listpolb = cell(1, turns);

for turn = 0:turns-1
for order = 0:maxorder
if isfield(element,'AmplitudeA')
pola(order+1) = get_pol(element, 'A', ramps, mode, ...
timeoffset * turn, turn, order, periodic);
end
if isfield(element,'AmplitudeB')
pola(order+1) = get_pol(element, 'B', ramps, mode, ...
timeoffset * turn, turn, order, periodic);
end
listpola{turn+1} = pola;
listpolb{turn+1} = polb;
end
end

end

function ampt = get_amp(amp, ramps, t)
% get_amp(ele, amp, ramps, t)
%
% get_amp returns the input value `amp` when ramps is False.
% If ramps is True, it returns a value linearly interpolated
% accoding to the ramping turn.
ampt = amp;
if length(ramps) == 4
if t <= ramps(0)
ampt = 0.0;
elseif t <= ramps(1)
ampt = amp * (t - ramps(0)) / (ramps(1) - ramps(0));
elseif t <= ramps(2)
ampt = amp;
elseif t <= ramps(3)
ampt = amp - amp * (t - ramps(2))/ (ramps(3) - ramps(2));
else
ampt = 0.0;
end
end
end


function ampout = get_pol(element , ab, ramps, mode, t, turn, order, periodic)
% get_pol(element , ab, ramps, mode, t, turn, order, periodic)
%
% get_pol returns the polynom a or b for a given mode, turn, order,
% time and periodicity.
allamp = element.(strcat("Amplitude",ab) );
amp = allamp(order+1);
ampout = 0;

if amp == 0
return
end

% get the ramp value
ampoutaux = get_amp(amp, ramps, turn);

switch mode
case 0
% sin mode parameters
whole_sin_above = element.(strcat("Sin",ab,"above"));
freq = element.(strcat("Frequency",ab));
ph = element.(strcat("Phase",ab));
sinval = sin(2 * pi * freq * t + ph);
if sinval >= whole_sin_above
ampout = ampoutaux * sinval;
else
ampout = 0;
end
case 1
ampout = nan;
case 2
nsamples = element.(strcat("NSamples",ab));
if periodic || turn < nsamples
func = element.(strcat("Func",ab));
funcdelay = element.(strcat("Func",ab,"TimeDelay"));
[ktaylor, nsamples] = size(func);
turnidx = mod(turn, nsamples)+1;
t = t - funcdelay;
functot = func(1,turnidx);
thefactorial = 1;
tpow = 1;
for i = 1:(ktaylor-1)
tpow = t *tpow;
thefactorial = thefactorial *i;
functot = functot + tpow/thefactorial * func(i+1,turnidx);
end
ampout = ampoutaux * functot;
else
ampout = 0.0;
end
otherwise
ampout = 0.0;
end
end
6 changes: 6 additions & 0 deletions atmat/lattice/at2str.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@
'xtable', ...
'ytable' ...
});
case 'VariableThinMultipole'
create=@atvariablethinmultipole;
[options,args]=doptions(elem,create,{'Mode'});
if isfield(options,'Energy')
options=rmfield(options,'Energy');
end
otherwise %'Marker'
create=@atmarker;
[options,args]=doptions(elem,create);
Expand Down
4 changes: 3 additions & 1 deletion atmat/lattice/atguessclass.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
%
% NOTES
% 1. atclass=atguessclass(atelem,'useclass')
% By default, ATGUESSCLASS will default "useless" elements (PolynopmB==0)
% By default, ATGUESSCLASS will default "useless" elements (PolynomB==0)
% to 'Drift' or 'Marker', depending on 'Length'. When specifying
% 'UseClass', it it will preserve the 'Class' field for those elements.
%
Expand All @@ -30,6 +30,8 @@
atclass='RingParam';
elseif isfield(elem,'Limits')
atclass='Aperture';
elseif isfield(elem,'Mode')
atclass='VariableThinMultipole';
elseif isfield(elem,'PolynomB')
if useclass && isfield(elem,'Class')
atclass=elem.Class;
Expand Down
129 changes: 0 additions & 129 deletions atmat/lattice/element_creation/atvariablemultipole.m

This file was deleted.

Loading