@@ -678,13 +678,14 @@ def test_stress_co_correction_and_lumi_leveling():
678678 }
679679
680680 # Lumi leveling assuming ideal behavior of the knobs
681+ tw0 = collider .twiss (lines = ['lhcb1' , 'lhcb2' ])
681682 collider .match (
682683 solver_options = { # Standard jacobian settings not sufficient
683684 #(fsolve makes it in less iterations)
684685 'n_bisections' : 3 , 'min_step' : 0 , 'n_steps_max' : 200 },
685686 ele_start = ['e.ds.l8.b1' , 's.ds.r8.b2' ],
686687 ele_stop = ['s.ds.r8.b1' , 'e.ds.l8.b2' ],
687- twiss_init = 'preserve' ,
688+ twiss_init = tw0 , ele_init = xt . START ,
688689 lines = ['lhcb1' , 'lhcb2' ],
689690 vary = [
690691 # Knobs to control the separation
@@ -711,14 +712,15 @@ def test_stress_co_correction_and_lumi_leveling():
711712 collider .vars ['on_sep8v' ] = knob_values_before_ideal_matching ['on_sep8v' ]
712713
713714 # Lumi leveling with orbit correction
715+ tw0 = collider .twiss (lines = ['lhcb1' , 'lhcb2' ])
714716 collider .match (
715717 solver_options = { # Standard jacobian settings not sufficient
716718 #(fsolve makes it in less iterations)
717719 'n_bisections' : 3 , 'min_step' : 0 , 'n_steps_max' : 200 },
718720 lines = ['lhcb1' , 'lhcb2' ],
719721 ele_start = ['e.ds.l8.b1' , 's.ds.r8.b2' ],
720722 ele_stop = ['s.ds.r8.b1' , 'e.ds.l8.b2' ],
721- twiss_init = 'preserve' ,
723+ twiss_init = tw0 , ele_init = xt . START ,
722724 targets = [
723725 xt .TargetLuminosity (
724726 ip_name = 'ip8' , luminosity = 2e14 , tol = 1e12 , f_rev = f_rev ,
@@ -727,13 +729,13 @@ def test_stress_co_correction_and_lumi_leveling():
727729 nemitt_x = nemitt_x , nemitt_y = nemitt_y , sigma_z = sigma_z , crab = False ),
728730 xt .TargetSeparationOrthogonalToCrossing (ip_name = 'ip8' ),
729731 # Preserve crossing angle
730- xt .TargetList (['px' , 'py' ], at = 'ip8' , line = 'lhcb1' , value = 'preserve' , tol = 1e-7 , scale = 1e3 ),
731- xt .TargetList (['px' , 'py' ], at = 'ip8' , line = 'lhcb2' , value = 'preserve' , tol = 1e-7 , scale = 1e3 ),
732+ xt .TargetList (['px' , 'py' ], at = 'ip8' , line = 'lhcb1' , value = tw0 , tol = 1e-7 , scale = 1e3 ),
733+ xt .TargetList (['px' , 'py' ], at = 'ip8' , line = 'lhcb2' , value = tw0 , tol = 1e-7 , scale = 1e3 ),
732734 # Close the bumps
733- xt .TargetList (['x' , 'y' ], at = 's.ds.r8.b1' , line = 'lhcb1' , value = 'preserve' , tol = 1e-5 , scale = 1 ),
734- xt .TargetList (['px' , 'py' ], at = 's.ds.r8.b1' , line = 'lhcb1' , value = 'preserve' , tol = 1e-5 , scale = 1e3 ),
735- xt .TargetList (['x' , 'y' ], at = 'e.ds.l8.b2' , line = 'lhcb2' , value = 'preserve' , tol = 1e-5 , scale = 1 ),
736- xt .TargetList (['px' , 'py' ], at = 'e.ds.l8.b2' , line = 'lhcb2' , value = 'preserve' , tol = 1e-5 , scale = 1e3 ),
735+ xt .TargetList (['x' , 'y' ], at = 's.ds.r8.b1' , line = 'lhcb1' , value = tw0 , tol = 1e-5 , scale = 1 ),
736+ xt .TargetList (['px' , 'py' ], at = 's.ds.r8.b1' , line = 'lhcb1' , value = tw0 , tol = 1e-5 , scale = 1e3 ),
737+ xt .TargetList (['x' , 'y' ], at = 'e.ds.l8.b2' , line = 'lhcb2' , value = tw0 , tol = 1e-5 , scale = 1 ),
738+ xt .TargetList (['px' , 'py' ], at = 'e.ds.l8.b2' , line = 'lhcb2' , value = tw0 , tol = 1e-5 , scale = 1e3 ),
737739 ],
738740 vary = [
739741 xt .VaryList (['on_sep8h' , 'on_sep8v' ], step = 1e-4 ), # to control separation
@@ -828,22 +830,23 @@ def test_stress_co_correction_and_lumi_leveling():
828830
829831 # Match separation to 2 sigmas in IP2
830832 print (f'Knobs before matching: on_sep2 = { collider .vars ["on_sep2" ]._value } ' )
833+ tw0 = collider .twiss (lines = ['lhcb1' , 'lhcb2' ])
831834 collider .match (
832835 lines = ['lhcb1' , 'lhcb2' ],
833836 ele_start = ['e.ds.l2.b1' , 's.ds.r2.b2' ],
834837 ele_stop = ['s.ds.r2.b1' , 'e.ds.l2.b2' ],
835- twiss_init = 'preserve' ,
838+ twiss_init = tw0 , ele_init = xt . START ,
836839 targets = [
837840 xt .TargetSeparation (ip_name = 'ip2' , separation_norm = 3 , plane = 'x' , tol = 1e-4 ,
838841 nemitt_x = nemitt_x , nemitt_y = nemitt_y ),
839842 # Preserve crossing angle
840- xt .TargetList (['px' , 'py' ], at = 'ip2' , line = 'lhcb1' , value = 'preserve' , tol = 1e-7 , scale = 1e3 ),
841- xt .TargetList (['px' , 'py' ], at = 'ip2' , line = 'lhcb2' , value = 'preserve' , tol = 1e-7 , scale = 1e3 ),
843+ xt .TargetList (['px' , 'py' ], at = 'ip2' , line = 'lhcb1' , value = tw0 , tol = 1e-7 , scale = 1e3 ),
844+ xt .TargetList (['px' , 'py' ], at = 'ip2' , line = 'lhcb2' , value = tw0 , tol = 1e-7 , scale = 1e3 ),
842845 # Close the bumps
843- xt .TargetList (['x' , 'y' ], at = 's.ds.r2.b1' , line = 'lhcb1' , value = 'preserve' , tol = 1e-5 , scale = 1 ),
844- xt .TargetList (['px' , 'py' ], at = 's.ds.r2.b1' , line = 'lhcb1' , value = 'preserve' , tol = 1e-5 , scale = 1e3 ),
845- xt .TargetList (['x' , 'y' ], at = 'e.ds.l2.b2' , line = 'lhcb2' , value = 'preserve' , tol = 1e-5 , scale = 1 ),
846- xt .TargetList (['px' , 'py' ], at = 'e.ds.l2.b2' , line = 'lhcb2' , value = 'preserve' , tol = 1e-5 , scale = 1e3 ),
846+ xt .TargetList (['x' , 'y' ], at = 's.ds.r2.b1' , line = 'lhcb1' , value = tw0 , tol = 1e-5 , scale = 1 ),
847+ xt .TargetList (['px' , 'py' ], at = 's.ds.r2.b1' , line = 'lhcb1' , value = tw0 , tol = 1e-5 , scale = 1e3 ),
848+ xt .TargetList (['x' , 'y' ], at = 'e.ds.l2.b2' , line = 'lhcb2' , value = tw0 , tol = 1e-5 , scale = 1 ),
849+ xt .TargetList (['px' , 'py' ], at = 'e.ds.l2.b2' , line = 'lhcb2' , value = tw0 , tol = 1e-5 , scale = 1e3 ),
847850 ],
848851 vary =
849852 [xt .Vary ('on_sep2' , step = 1e-4 ),
@@ -1578,11 +1581,12 @@ def test_multiline_match():
15781581 assert np .isclose (tw1 .lhcb2 .qy , 60.323 , atol = 1e-4 , rtol = 0 )
15791582
15801583 # Match bumps in the two likes
1584+ tw0 = collider .twiss (lines = ['lhcb1' , 'lhcb2' ])
15811585 collider .match (
15821586 lines = ['lhcb1' , 'lhcb2' ],
15831587 ele_start = ['mq.33l8.b1' , 'mq.22l8.b2' ],
15841588 ele_stop = ['mq.23l8.b1' , 'mq.32l8.b2' ],
1585- twiss_init = 'preserve' ,
1589+ twiss_init = tw0 , ele_init = xt . START ,
15861590 vary = [
15871591 xt .VaryList ([
15881592 'acbv30.l8b1' , 'acbv28.l8b1' , 'acbv26.l8b1' , 'acbv24.l8b1' ],
@@ -1597,10 +1601,10 @@ def test_multiline_match():
15971601 xt .Target ('y' , at = 'mb.b27l8.b2' , line = 'lhcb2' , value = 2e-3 , tol = 1e-4 , scale = 1 ),
15981602 xt .Target ('py' , at = 'mb.b27l8.b2' , line = 'lhcb2' , value = 0 , tol = 1e-6 , scale = 1000 ),
15991603 # I want the bump to be closed
1600- xt .TargetList (['y' ], at = 'mq.23l8.b1' , line = 'lhcb1' , value = 'preserve' , tol = 1e-6 , scale = 1 ),
1601- xt .TargetList (['py' ], at = 'mq.23l8.b1' , line = 'lhcb1' , value = 'preserve' , tol = 1e-7 , scale = 1000 ),
1602- xt .TargetList (['y' ], at = 'mq.32l8.b2' , line = 'lhcb2' , value = 'preserve' , tol = 1e-6 , scale = 1 ),
1603- xt .Target ('py' , at = 'mq.32l8.b2' , line = 'lhcb2' , value = 'preserve' , tol = 1e-10 , scale = 1000 ),
1604+ xt .TargetList (['y' ], at = 'mq.23l8.b1' , line = 'lhcb1' , value = tw0 , tol = 1e-6 , scale = 1 ),
1605+ xt .TargetList (['py' ], at = 'mq.23l8.b1' , line = 'lhcb1' , value = tw0 , tol = 1e-7 , scale = 1000 ),
1606+ xt .TargetList (['y' ], at = 'mq.32l8.b2' , line = 'lhcb2' , value = tw0 , tol = 1e-6 , scale = 1 ),
1607+ xt .Target ('py' , at = 'mq.32l8.b2' , line = 'lhcb2' , value = tw0 , tol = 1e-10 , scale = 1000 ),
16041608 ]
16051609 )
16061610 tw_bump = collider .twiss (lines = ['lhcb1' , 'lhcb2' ])
0 commit comments