From 0cf8b038dd83844a3e4d16517179bc0ec9a5357b Mon Sep 17 00:00:00 2001 From: oscarxblanco Date: Tue, 14 Jan 2025 17:40:06 +0100 Subject: [PATCH 1/3] adds dp as parameter --- pyat/at/physics/rdt.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyat/at/physics/rdt.py b/pyat/at/physics/rdt.py index 24c790c32..caba6c9ed 100644 --- a/pyat/at/physics/rdt.py +++ b/pyat/at/physics/rdt.py @@ -400,6 +400,7 @@ def get_rdts( second_order: bool = False, use_mp: bool = False, pool_size: int = None, + dp: float = 0.0, ): """ :py:func:`get_rdts` computes the ring RDTs based on the original implementation @@ -443,6 +444,7 @@ def get_rdts( Computation is significantly longer using this method use_mp: Activate parallel calculation pool_size: Number of processes used for parallelization + dp: default 0. Energy offset to calculate the optics parameters. Returns: rdts: rdt data (complex) at refpts @@ -502,7 +504,7 @@ def get_rdts( refpts = ring.uint32_refpts(refpts) idx_mag = ring.get_uint32_index(Multipole) - lo, avebeta, avemu, avedisp, *_ = ring.avlinopt(refpts=All) + lo, avebeta, avemu, avedisp, *_ = ring.avlinopt(refpts=All,dp=dp) sall = ring.get_s_pos(All) smag = sall[idx_mag] From 75fcd4fe2c64d9ff8504774d66546fcac17dbee5 Mon Sep 17 00:00:00 2001 From: oscarxblanco Date: Tue, 14 Jan 2025 18:08:51 +0100 Subject: [PATCH 2/3] computes the rdts with energy offset dp --- atmat/atphysics/NonLinearDynamics/computeRDT.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/atmat/atphysics/NonLinearDynamics/computeRDT.m b/atmat/atphysics/NonLinearDynamics/computeRDT.m index c16c24dfd..b049928f9 100644 --- a/atmat/atphysics/NonLinearDynamics/computeRDT.m +++ b/atmat/atphysics/NonLinearDynamics/computeRDT.m @@ -6,27 +6,35 @@ % % RDT=computeRDT(ring, index, varargin) % +% INPUTS % ring is the AT lattice % index is the vector of indexes where one wants to compute RDTs % The additional arguments can be up to five strings: % chromatic, coupling, geometric1, geometric2 and tuneshifts +% +% OPTIONS (order does not matter) +% dp: Default 0. Energy offset to calculate the optics parameters. % -% example: +% EXAMPLES % RDT=computeRDT(ring, indexBPM, 'geometric1', 'tuneshifts'); % creates an array of structs (the length of the array is the number of % indexes where you want to compute driving terms) with first order % geometric driving terms and tune shifts with amplitude. % The driving terms are complex numbers, the tune shifts are real. % +% RDT=computeRDT(ring, indexBPM, 'geometric1', 'dp',0.01); +% Calculate the first order geometric RDTs using the optics with +% 0.01 energy offset. naddvar=length(varargin); +[dp,args] = getoption(varargin,'dp',0); chromatic=0; coupling=0; geometric1=0; geometric2=0; tuneshifts=0; for ii=1:naddvar - switch varargin{ii} + switch args{ii} case 'chromatic' chromatic=1; case 'coupling' @@ -55,7 +63,7 @@ indDQSO=findcells(ring,'Class','Bend','Quadrupole','Sextupole','Octupole','Multipole'); -[~,AVEBETA,AVEMU,AVEDISP,~,~]=atavedata(ring,0,1:length(ring)); +[~,AVEBETA,AVEMU,AVEDISP,~,~]=atavedata(ring,dp,1:length(ring)); Lin=atlinopt(ring,0,1:(length(ring)+1)); From 150cd6e0f401c6d2d755e88e6389982303e5e160 Mon Sep 17 00:00:00 2001 From: oscarxblanco Date: Tue, 14 Jan 2025 18:11:48 +0100 Subject: [PATCH 3/3] black --- pyat/at/physics/rdt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyat/at/physics/rdt.py b/pyat/at/physics/rdt.py index caba6c9ed..2429f08c3 100644 --- a/pyat/at/physics/rdt.py +++ b/pyat/at/physics/rdt.py @@ -504,7 +504,7 @@ def get_rdts( refpts = ring.uint32_refpts(refpts) idx_mag = ring.get_uint32_index(Multipole) - lo, avebeta, avemu, avedisp, *_ = ring.avlinopt(refpts=All,dp=dp) + lo, avebeta, avemu, avedisp, *_ = ring.avlinopt(refpts=All, dp=dp) sall = ring.get_s_pos(All) smag = sall[idx_mag]