ewaagaard / fma_ions

Frequency Map Analysis (FMA) for ions in the CERN accelerator complex.
Apache License 2.0
0 stars 1 forks source link

Install space charge on beta-beat gives unstable Twiss #2

Closed ewaagaard closed 10 months ago

ewaagaard commented 11 months ago

Trying to run tests/sps/test_sps_fma_default_with_beta_beat.py gives the error

line = self.install_SC_and_get_line(line0, beamParams)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/elwaagaa/cernbox/PhD/Projects/fma_ions/fma_ions/fma_ions.py", line 110, in install_SC_and_get_line
    twiss_xtrack_with_sc = line.twiss()
                           ^^^^^^^^^^^^
  File "/home/elwaagaa/anaconda3/envs/fma_xsuite_env/lib/python3.11/site-packages/xtrack/line.py", line 1017, in twiss
    return twiss_line(self, **tw_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/elwaagaa/anaconda3/envs/fma_xsuite_env/lib/python3.11/site-packages/xtrack/twiss.py", line 549, in twiss_line
    twiss_init, R_matrix, steps_r_matrix, eigenvalues, Rot, RR_ebe = _find_periodic_solution(
                                                                     ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/elwaagaa/anaconda3/envs/fma_xsuite_env/lib/python3.11/site-packages/xtrack/twiss.py", line 1716, in _find_periodic_solution
    lnf._assert_matrix_stability(eigenvals, matrix_stability_tol)
  File "/home/elwaagaa/anaconda3/envs/fma_xsuite_env/lib/python3.11/site-packages/xtrack/linear_normal_form.py", line 240, in _assert_matrix_stability
    raise ValueError('One-turn matrix is unstable. '
ValueError: One-turn matrix is unstable. Magnitudes of eigenvalues are:
array([1.00000104, 1.00000104, 1.00000005, 1.00000005, 1.06467384,
       0.93925463])

Should one add the beta-beat after space charge has been installed, or are they even compatible overall?

ewaagaard commented 10 months ago

Actually not correct in this case to perform Twiss with space charge, this twiss unstable as it overlaps with resonances and excited the Qy = 0.5.