Skip to content
Snippets Groups Projects
Commit c9c211d5 authored by Alexis GAMELIN's avatar Alexis GAMELIN
Browse files

Merge branch 'fix-transverse_map_sector_generator' into 'develop'

Fix transverse map sector generator

See merge request !38
parents 2ccb20ce a7120386
No related branches found
No related tags found
2 merge requests!480.9.0,!38Fix transverse map sector generator
...@@ -415,7 +415,7 @@ class TransverseMap(TransverseMapSector): ...@@ -415,7 +415,7 @@ class TransverseMap(TransverseMapSector):
2 * np.pi * ring.tune, ring.chro, ring.adts) 2 * np.pi * ring.tune, ring.chro, ring.adts)
def transverse_map_sector_generator(ring, positions): def transverse_map_sector_generator(ring, positions, **kwargs):
""" """
Convenience function which generate a list of TransverseMapSector elements Convenience function which generate a list of TransverseMapSector elements
from a ring: from a ring:
...@@ -436,6 +436,8 @@ def transverse_map_sector_generator(ring, positions): ...@@ -436,6 +436,8 @@ def transverse_map_sector_generator(ring, positions):
The array should contain the initial position (s=0) but not the end The array should contain the initial position (s=0) but not the end
position (s=ring.L), so like position = np.array([0, pos1, pos2, ...]). position (s=ring.L), so like position = np.array([0, pos1, pos2, ...]).
See at.physics.nonlinear.chromaticity for **kwargs
Returns Returns
------- -------
sectors : list sectors : list
...@@ -463,8 +465,10 @@ def transverse_map_sector_generator(ring, positions): ...@@ -463,8 +465,10 @@ def transverse_map_sector_generator(ring, positions):
adts=adts)) adts=adts))
else: else:
import at import at
dp = kwargs.get('dp', 1e-2)
order = kwargs.get('order', 1)
def _compute_chro(ring, N_sec, dp=1e-2, order=4): def _compute_chro(ring, N_sec, dp, order):
lat = deepcopy(ring.optics.lattice) lat = deepcopy(ring.optics.lattice)
lat.append(at.Marker("END")) lat.append(at.Marker("END"))
fit, _, _ = at.physics.nonlinear.chromaticity(lat, fit, _, _ = at.physics.nonlinear.chromaticity(lat,
...@@ -472,12 +476,18 @@ def transverse_map_sector_generator(ring, positions): ...@@ -472,12 +476,18 @@ def transverse_map_sector_generator(ring, positions):
dpm=dp, dpm=dp,
n_points=100, n_points=100,
order=order) order=order)
Chrox, Chroy = fit[0, 1:], fit[1, 1:] chro_xy = [
chrox = np.array([np.linspace(0, val, N_sec) for val in Chrox]) elem for pair in zip(fit[0, 1:], fit[1, 1:]) for elem in pair
chroy = np.array([np.linspace(0, val, N_sec) for val in Chroy]) ]
return np.array([chrox, chroy]) len_chro = int(order * 2)
_chro = np.zeros((len_chro, N_sec))
for i in range(len_chro):
chro_order_splited = np.linspace(0, chro_xy[i], N_sec)
_chro[i, :] = chro_order_splited
return _chro
_chro = _compute_chro(ring, N_sec) _chro = _compute_chro(ring, N_sec, dp, order)
for i in range(N_sec): for i in range(N_sec):
alpha0 = ring.optics.alpha(positions[i]) alpha0 = ring.optics.alpha(positions[i])
beta0 = ring.optics.beta(positions[i]) beta0 = ring.optics.beta(positions[i])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment