atcollab / at

Accelerator Toolbox
Apache License 2.0
48 stars 31 forks source link

Add get freqmap #756

Open oscarxblanco opened 5 months ago

oscarxblanco commented 5 months ago

Dear all, this is a Work-In-Progress branch open to address the limitations on the frequency map analysis found by @TeresiaOlsson and mentioned here https://github.com/atcollab/at/discussions/755.

No need to review yet.

oscarxblanco commented 5 months ago

Dear @TeresiaOlsson ,

here is a script you could use to start the test on the function get_freqmap. Please, try it with a ring you have. This function runs well on the axes ['x','y']. It also works on ['x','dp'] but I have not checked if the results make sense.

Best regards, o

''' 
This file is used to test the new function get_freqmap
oblanco 2024apr16
'''
import at
import numpy
from matplotlib import pyplot as plt

print(f'{at.__version__}=')

ring = at.load_mat('testring.mat')
# ring.disable_6d()
print(f'{ring.get_tune()=}')

fmaout = at.get_freqmap(ring,
                     ['x','y'],
                     numpy.array([200,200]),
                     numpy.array([10e-3,10e-3]),
                     bounds=[[-1,1],[0,1]],
                     verbose=True,
                     )

fmadata = fmaout[0][0]

print('Plot')
# plot diffusion map
fig = plt.figure()
sc = plt.scatter(1e3*fmadata[:,0],1e3*fmadata[:,1],c=fmadata[:,6],s=1)
plt.grid()
plt.xlabel(r'x (mm)')
plt.ylabel(r'y (mm)')
plt.xlim(-10,10)
plt.ylim(-5,5)
clb = plt.colorbar(sc)
clb.ax.set_title(r'$\log_{10} \sqrt{(\Delta\nu_x^2 + \Delta\nu_y^2)/turn}$')
plt.savefig('diffussionmap.pdf')

# plot frequency map
fig = plt.figure()
sc = plt.scatter(fmadata[:,2],fmadata[:,3],c=fmadata[:,6],s=1)
plt.grid()
plt.xlim(0,0.5)
plt.ylim(0,0.5)
plt.xlabel(r'$\nu_x$')
plt.ylabel(r'$\nu_y$')
clb = plt.colorbar(sc)
clb.ax.set_title(r'$\log_{10} \sqrt{(\Delta\nu_x^2 + \Delta\nu_y^2)/turn}$')
plt.savefig('fmap.pdf')
oscarxblanco commented 3 months ago

Dear @TeresiaOlsson , I might be back to this request on the following days. Have you tried this function ? Do you have any suggestion ?

Best regards, o

oscarxblanco commented 1 month ago

Dear @swhite2401 and @lfarv , in order to parallelize the frequency map I would need to use a large amount of memory to store the data of the turn by turn tracking. @swhite2401 proposed to track by chunks of particles (https://github.com/atcollab/at/pull/811#issuecomment-2286157696 ) At the moment I use psutils to estimate the free memory, and adjust the chunk size accordingly, but, it seems that is not yet used or installed. Could we included ? Or is there another package that could give the free memory information ? Or is there another solution to check ?