2424 [2 , 'V' , 500 , 0.3 , True ],
2525 [1 , 'V' , 3500 , 0.1 , False ],
2626 [2 , 'H' , 30000 , 0.15 , False ]
27- ], ids = ["B1 " , "B2V" , "B1V_crystals" , "B2H_crystals" ])
27+ ], ids = ["B1H " , "B2V" , "B1V_crystals" , "B2H_crystals" ])
2828def test_run_lossmap (beam , plane , npart , interpolation , ignore_crystals , test_context ):
2929
3030 line = xt .Line .from_json (path / f'sequence_lhc_run3_b{ beam } .json' )
@@ -45,12 +45,15 @@ def test_run_lossmap(beam, plane, npart, interpolation, ignore_crystals, test_co
4545 line .scattering .enable ()
4646 line .track (part , num_turns = 2 )
4747 line .scattering .disable ()
48+ assert_lossmap (beam , npart , line , part , tcp , interpolation , ignore_crystals , 'EverestCollimator' , 'EverestCrystal' )
4849
49- line_is_reversed = True if beam == 2 else False
50- with flaky_assertions ():
5150
51+ def assert_lossmap (beam , npart , line , part , tcp , interpolation , ignore_crystals , coll_cls , cry_cls ):
52+ with flaky_assertions ():
53+ line_is_reversed = True if beam == 2 else False
5254 ThisLM = xc .LossMap (line , line_is_reversed = line_is_reversed , part = part ,
5355 interpolation = interpolation )
56+ print (ThisLM .summary )
5457
5558 ThisLM .to_json ("lossmap.json" )
5659 assert Path ("lossmap.json" ).exists ()
@@ -65,9 +68,10 @@ def test_run_lossmap(beam, plane, npart, interpolation, ignore_crystals, test_co
6568 # TODO: check the lossmap quantitaively: rough amount of losses at given positions
6669 summ = ThisLM .summary
6770 assert list (summ .columns ) == ['collname' , 'nabs' , 'length' , 's' , 'type' ]
68- assert len (summ [summ .type == 'EverestCollimator' ]) == 10
71+ assert len (summ [summ .type == coll_cls ]) == 10
6972 if not ignore_crystals :
70- assert len (summ [summ .type == 'EverestCrystal' ]) == 2
73+ assert len (summ [summ .type == cry_cls ]) == 2
74+
7175 # We want at least 5% absorption on the primary
7276 assert summ .loc [summ .collname == tcp ,'nabs' ].values [0 ] > 0.05 * npart
7377
@@ -94,5 +98,3 @@ def test_run_lossmap(beam, plane, npart, interpolation, ignore_crystals, test_co
9498 assert np .all ([s < lm ['machine_length' ] for s in lm ['aperture' ]['s' ]])
9599 assert lm ['interpolation' ] == interpolation
96100 assert lm ['reversed' ] == line_is_reversed
97-
98-
0 commit comments