From 51f9eb23aae882c9ffbf11c8036cf027e908055c Mon Sep 17 00:00:00 2001 From: giadarol Date: Wed, 22 Mar 2023 15:31:45 +0100 Subject: [PATCH 1/7] This kills the other peak but makes the footrint dirty --- examples/hllhc15_collision/004_footprint.py | 38 +++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 examples/hllhc15_collision/004_footprint.py diff --git a/examples/hllhc15_collision/004_footprint.py b/examples/hllhc15_collision/004_footprint.py new file mode 100644 index 0000000..7d8097b --- /dev/null +++ b/examples/hllhc15_collision/004_footprint.py @@ -0,0 +1,38 @@ +import numpy as np + +import xtrack as xt + + +collider = xt.Multiline.from_json('./collider_03_tuned_bb_on.json') +collider.build_trackers() + +collider.vars['beambeam_scale'] = 1 + +fp = collider['lhcb1'].get_footprint(nemitt_x=1e-6, nemitt_y=1e-6, + theta_range=(0.05, np.pi/2-0.05), + n_fft=2**18, keep_fft=True) +# Find problematic points + +i_problems = np.where(np.abs(fp.qx.flatten() - fp.qy.flatten()) < 1e-4) + +fftp_x = np.squeeze(fp.fft_x[98, :]) +fftp_y = np.squeeze(fp.fft_y[98, :]) + + +fftp_y_scaled = np.abs(fftp_y) / np.max(np.abs(fftp_y)) * np.max(np.abs(fftp_x)) + +import matplotlib.pyplot as plt +plt.close('all') +plt.figure(1) +freq = np.fft.rfftfreq(len(fftp_x)*2 - 1) +plt.plot(freq, np.abs(fftp_x)) +plt.plot(freq, fftp_y_scaled) +plt.plot(freq, np.abs(fftp_x) - np.abs(fftp_y_scaled)) + +plt.show() + + +# fpj = collider['lhcb1'].get_footprint(nemitt_x=1e-6, nemitt_y=1e-6, +# mode='uniform_action_grid', +# x_norm_range=(0.1, 6), +# y_norm_range=(0.1, 6)) From d256440c70eb10bed950dc83fac856a9dc2ea557 Mon Sep 17 00:00:00 2001 From: giadarol Date: Wed, 22 Mar 2023 16:06:36 +0100 Subject: [PATCH 2/7] With weaker beambeam it works --- examples/hllhc15_collision/004_footprint.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/hllhc15_collision/004_footprint.py b/examples/hllhc15_collision/004_footprint.py index 7d8097b..5541ac0 100644 --- a/examples/hllhc15_collision/004_footprint.py +++ b/examples/hllhc15_collision/004_footprint.py @@ -6,11 +6,11 @@ collider = xt.Multiline.from_json('./collider_03_tuned_bb_on.json') collider.build_trackers() -collider.vars['beambeam_scale'] = 1 +collider.vars['beambeam_scale'] = 0.3 -fp = collider['lhcb1'].get_footprint(nemitt_x=1e-6, nemitt_y=1e-6, +fp = collider['lhcb1'].get_footprint(nemitt_x=2.5e-6, nemitt_y=2.5e-6, theta_range=(0.05, np.pi/2-0.05), - n_fft=2**18, keep_fft=True) + n_fft=2**18) # Find problematic points i_problems = np.where(np.abs(fp.qx.flatten() - fp.qy.flatten()) < 1e-4) From 674035ff978e730983f7387591c7825bd766a0b9 Mon Sep 17 00:00:00 2001 From: giadarol Date: Wed, 22 Mar 2023 17:15:54 +0100 Subject: [PATCH 3/7] Linear rescale works --- examples/hllhc15_collision/004_footprint.py | 39 ++++++++++----------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/examples/hllhc15_collision/004_footprint.py b/examples/hllhc15_collision/004_footprint.py index 5541ac0..a557646 100644 --- a/examples/hllhc15_collision/004_footprint.py +++ b/examples/hllhc15_collision/004_footprint.py @@ -6,33 +6,30 @@ collider = xt.Multiline.from_json('./collider_03_tuned_bb_on.json') collider.build_trackers() -collider.vars['beambeam_scale'] = 0.3 +# collider.vars['beambeam_scale'] = 0.0 -fp = collider['lhcb1'].get_footprint(nemitt_x=2.5e-6, nemitt_y=2.5e-6, - theta_range=(0.05, np.pi/2-0.05), - n_fft=2**18) -# Find problematic points +# fp0 = collider['lhcb1'].get_footprint(nemitt_x=2.5e-6, nemitt_y=2.5e-6, +# theta_range=(0.05, np.pi/2-0.05), +# n_fft=2**18) -i_problems = np.where(np.abs(fp.qx.flatten() - fp.qy.flatten()) < 1e-4) -fftp_x = np.squeeze(fp.fft_x[98, :]) -fftp_y = np.squeeze(fp.fft_y[98, :]) +# collider.vars['beambeam_scale'] = 0.1 +# fp1 = collider['lhcb1'].get_footprint(nemitt_x=2.5e-6, nemitt_y=2.5e-6, +# theta_range=(0.05, np.pi/2-0.05), +# n_fft=2**18) -fftp_y_scaled = np.abs(fftp_y) / np.max(np.abs(fftp_y)) * np.max(np.abs(fftp_x)) +# qx = fp0.qx + (fp1.qx - fp0.qx)/0.1*1. +# qy = fp0.qy + (fp1.qy - fp0.qy)/0.1*1. -import matplotlib.pyplot as plt -plt.close('all') -plt.figure(1) -freq = np.fft.rfftfreq(len(fftp_x)*2 - 1) -plt.plot(freq, np.abs(fftp_x)) -plt.plot(freq, fftp_y_scaled) -plt.plot(freq, np.abs(fftp_x) - np.abs(fftp_y_scaled)) +from xtrack.footprint import _footprint_with_linear_rescale, LinearRescale -plt.show() +collider.vars['beambeam_scale'] = 1 +fp_lr = _footprint_with_linear_rescale(line= collider['lhcb1'], + kwargs={'nemitt_x': 2.5e-6, 'nemitt_y': 2.5e-6, + 'theta_range': (0.05, np.pi/2-0.05), + 'n_fft': 2**18}, + linear_rescale_on_knobs=[ + LinearRescale(knob_name='beambeam_scale', v0=0.0, dv=0.1)]) -# fpj = collider['lhcb1'].get_footprint(nemitt_x=1e-6, nemitt_y=1e-6, -# mode='uniform_action_grid', -# x_norm_range=(0.1, 6), -# y_norm_range=(0.1, 6)) From 0fa9c3e091b98b8774006dc336fe9561ad093d24 Mon Sep 17 00:00:00 2001 From: giadarol Date: Wed, 22 Mar 2023 17:30:18 +0100 Subject: [PATCH 4/7] A clean footprint --- examples/hllhc15_collision/004_footprint.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/hllhc15_collision/004_footprint.py b/examples/hllhc15_collision/004_footprint.py index a557646..4dfd276 100644 --- a/examples/hllhc15_collision/004_footprint.py +++ b/examples/hllhc15_collision/004_footprint.py @@ -25,11 +25,10 @@ from xtrack.footprint import _footprint_with_linear_rescale, LinearRescale collider.vars['beambeam_scale'] = 1 -fp_lr = _footprint_with_linear_rescale(line= collider['lhcb1'], - kwargs={'nemitt_x': 2.5e-6, 'nemitt_y': 2.5e-6, - 'theta_range': (0.05, np.pi/2-0.05), - 'n_fft': 2**18}, - linear_rescale_on_knobs=[ - LinearRescale(knob_name='beambeam_scale', v0=0.0, dv=0.1)]) +fp = collider['lhcb1'].get_footprint( + nemitt_x=2.5e-6, nemitt_y=2.5e-6, + linear_rescale_on_knobs=[ + LinearRescale(knob_name='beambeam_scale', v0=0.0, dv=0.1)] + ) From 002fb3734b3394af3e7da59b18cc8101b86fdd35 Mon Sep 17 00:00:00 2001 From: giadarol Date: Wed, 22 Mar 2023 17:39:02 +0100 Subject: [PATCH 5/7] Working on example --- examples/hllhc15_collision/004_footprint.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/hllhc15_collision/004_footprint.py b/examples/hllhc15_collision/004_footprint.py index 4dfd276..2a322b6 100644 --- a/examples/hllhc15_collision/004_footprint.py +++ b/examples/hllhc15_collision/004_footprint.py @@ -13,20 +13,20 @@ # n_fft=2**18) -# collider.vars['beambeam_scale'] = 0.1 - -# fp1 = collider['lhcb1'].get_footprint(nemitt_x=2.5e-6, nemitt_y=2.5e-6, -# theta_range=(0.05, np.pi/2-0.05), -# n_fft=2**18) - -# qx = fp0.qx + (fp1.qx - fp0.qx)/0.1*1. -# qy = fp0.qy + (fp1.qy - fp0.qy)/0.1*1. from xtrack.footprint import _footprint_with_linear_rescale, LinearRescale collider.vars['beambeam_scale'] = 1 -fp = collider['lhcb1'].get_footprint( +fp_ua = collider['lhcb1'].get_footprint( + nemitt_x=2.5e-6, nemitt_y=2.5e-6, + mode='uniform_action_grid', + linear_rescale_on_knobs=[ + LinearRescale(knob_name='beambeam_scale', v0=0.0, dv=0.1)] + ) + +fp_polar = collider['lhcb1'].get_footprint( nemitt_x=2.5e-6, nemitt_y=2.5e-6, + mode='uniform_action_grid', linear_rescale_on_knobs=[ LinearRescale(knob_name='beambeam_scale', v0=0.0, dv=0.1)] ) From 8de8c0bc7357cc1aa1474beaecd826c9b5b8f1bf Mon Sep 17 00:00:00 2001 From: giadarol Date: Wed, 22 Mar 2023 17:44:05 +0100 Subject: [PATCH 6/7] Plots in example --- examples/hllhc15_collision/004_footprint.py | 25 +++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/examples/hllhc15_collision/004_footprint.py b/examples/hllhc15_collision/004_footprint.py index 2a322b6..28ad5ee 100644 --- a/examples/hllhc15_collision/004_footprint.py +++ b/examples/hllhc15_collision/004_footprint.py @@ -1,4 +1,5 @@ import numpy as np +import matplotlib.pyplot as plt import xtrack as xt @@ -6,29 +7,29 @@ collider = xt.Multiline.from_json('./collider_03_tuned_bb_on.json') collider.build_trackers() -# collider.vars['beambeam_scale'] = 0.0 - -# fp0 = collider['lhcb1'].get_footprint(nemitt_x=2.5e-6, nemitt_y=2.5e-6, -# theta_range=(0.05, np.pi/2-0.05), -# n_fft=2**18) - - - -from xtrack.footprint import _footprint_with_linear_rescale, LinearRescale collider.vars['beambeam_scale'] = 1 fp_ua = collider['lhcb1'].get_footprint( nemitt_x=2.5e-6, nemitt_y=2.5e-6, mode='uniform_action_grid', linear_rescale_on_knobs=[ - LinearRescale(knob_name='beambeam_scale', v0=0.0, dv=0.1)] + xt.LinearRescale(knob_name='beambeam_scale', v0=0.0, dv=0.1)] ) fp_polar = collider['lhcb1'].get_footprint( nemitt_x=2.5e-6, nemitt_y=2.5e-6, - mode='uniform_action_grid', linear_rescale_on_knobs=[ - LinearRescale(knob_name='beambeam_scale', v0=0.0, dv=0.1)] + xt.LinearRescale(knob_name='beambeam_scale', v0=0.0, dv=0.1)] ) +plt.close('all') + +plt.figure(1) +fp_polar.plot() +plt.suptitle('Polar mode (default) - linear rescale on beambeam_scale') + +plt.figure(2) +fp_ua.plot() +plt.suptitle('Uniform action grid mode - linear rescale on beambeam_scale') +plt.show() From c8549841d44c799eb8bcec90a7643cb6e963bb87 Mon Sep 17 00:00:00 2001 From: giadarol Date: Wed, 22 Mar 2023 17:53:46 +0100 Subject: [PATCH 7/7] Cleaned up plots --- examples/hllhc15_collision/004_footprint.py | 27 ++++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/examples/hllhc15_collision/004_footprint.py b/examples/hllhc15_collision/004_footprint.py index 28ad5ee..f4d5820 100644 --- a/examples/hllhc15_collision/004_footprint.py +++ b/examples/hllhc15_collision/004_footprint.py @@ -7,29 +7,38 @@ collider = xt.Multiline.from_json('./collider_03_tuned_bb_on.json') collider.build_trackers() +fp0 = collider['lhcb1'].get_footprint(nemitt_x=2.5e-6, nemitt_y=2.5e-6) -collider.vars['beambeam_scale'] = 1 -fp_ua = collider['lhcb1'].get_footprint( +fp_polar = collider['lhcb1'].get_footprint( nemitt_x=2.5e-6, nemitt_y=2.5e-6, - mode='uniform_action_grid', linear_rescale_on_knobs=[ xt.LinearRescale(knob_name='beambeam_scale', v0=0.0, dv=0.1)] ) -fp_polar = collider['lhcb1'].get_footprint( + +fp_ua = collider['lhcb1'].get_footprint( nemitt_x=2.5e-6, nemitt_y=2.5e-6, + mode='uniform_action_grid', linear_rescale_on_knobs=[ xt.LinearRescale(knob_name='beambeam_scale', v0=0.0, dv=0.1)] ) + plt.close('all') -plt.figure(1) -fp_polar.plot() -plt.suptitle('Polar mode (default) - linear rescale on beambeam_scale') +fig1 = plt.figure(1) +ax1 = fig1.add_subplot(111) +fp0.plot(ax=ax1, label='no rescale bb') +plt.suptitle('Polar mode (default) - no rescale on beambeam') + +fig2 = plt.figure(2) +ax2 = fig2.add_subplot(111, sharex=ax1, sharey=ax1) +fp_polar.plot(ax=ax2, label='rescale bb') +plt.suptitle('Polar mode (default) - linear rescale on beambeam') -plt.figure(2) +fig3 = plt.figure(3) +ax3 = fig3.add_subplot(111, sharex=ax1, sharey=ax1) fp_ua.plot() -plt.suptitle('Uniform action grid mode - linear rescale on beambeam_scale') +plt.suptitle('Uniform action grid mode - linear rescale on beambeam') plt.show()