Skip to content

Commit

Permalink
Adapted yaml for tests: tilt was too big (and wrong sign) to keep TCP…
Browse files Browse the repository at this point in the history
….H converging
  • Loading branch information
freddieknets committed Nov 27, 2024
1 parent 62e3ff1 commit 966218e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions tests/data/colldb_lhc_run3_ir7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ emittance:
collimators:
b1:
tcp.d6l7.b1: { <<: *TCP7, angle: 90, material: MoGR, length: 1.565 }
tcp.c6l7.b1: { <<: *TCP7, angle: 0, material: MoGR, tilt: [-250e-6, 250e-6] }
tcp.c6l7.b1: { <<: *TCP7, angle: 0, material: MoGR, tilt: [2.5e-6, -2.5e-6] }
tcp.b6l7.b1: { <<: *TCP7, angle: 127.5 }
tcsg.a6l7.b1: { <<: *TCSG7, angle: 141.1 }
tcpcv.a6l7.b1: { <<: *CRY7, angle: 90, bending_radius: 85.10, width: 5.0e-3, height: 30.0e-3 }
Expand All @@ -29,7 +29,7 @@ collimators:

b2:
tcp.d6r7.b2: { <<: *TCP7, angle: 90, material: MoGR, length: 1.565 }
tcp.c6r7.b2: { <<: *TCP7, angle: 0, material: MoGR, tilt: [-250e-6, 250e-6] }
tcp.c6r7.b2: { <<: *TCP7, angle: 0, material: MoGR, tilt: [2.5e-6, -2.5e-6] }
tcp.b6r7.b2: { <<: *TCP7, angle: 127.5 }
tcsg.a6r7.b2: { <<: *TCSG7, angle: 141.1 }
tcpcv.a6r7.b2: { <<: *CRY7, angle: 90, bending_radius: 74.88, width: 5.0e-3, height: 30.0e-3 }
Expand Down
2 changes: 1 addition & 1 deletion tests/test_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
{'field': 'record_exits', 'val': True, 'expected': {'record_impacts': True, 'record_exits': True, 'record_scatterings': True, '_record_interactions': 7}}
]
base_user_fields = {}
base_user_fields_read_only = []
base_user_fields_read_only = ['gemitt_x', 'gemitt_y']

# BaseCollimator
base_coll_fields = {**base_fields,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lossmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
[2, 'V', 500, 0.3, True],
[1, 'V', 3500, 0.1, False],
[2, 'H', 30000, 0.15, False]
], ids=["B1", "B2V", "B1V_crystals", "B2H_crystals"])
], ids=["B1H", "B2V", "B1V_crystals", "B2H_crystals"])
def test_run_lossmap(beam, plane, npart, interpolation, ignore_crystals, test_context):

line = xt.Line.from_json(path / f'sequence_lhc_run3_b{beam}.json')
Expand Down
8 changes: 4 additions & 4 deletions xcoll/beam_elements/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from ..general import _pkg_root


OPEN_JAW = 3.
OPEN_GAP = 999.
OPEN_JAW = 3
OPEN_GAP = 999


class InvalidXcoll(xt.BeamElement):
Expand Down Expand Up @@ -744,8 +744,8 @@ def divergence(self):
alfy = self.optics[self.align]['alfy'][0]
betx = self.optics[self.align]['betx'][0]
bety = self.optics[self.align]['bety'][0]
divx = -np.sqrt(self.nemitt_x/self.optics['beta_gamma_rel']/betx)*alfx
divy = -np.sqrt(self.nemitt_y/self.optics['beta_gamma_rel']/bety)*alfy
divx = -np.sqrt(self.gemitt_x/betx)*alfx
divy = -np.sqrt(self.gemitt_y/bety)*alfy
if hasattr(self, '_cos_zL'):
if self.side != 'right':
return divx if abs(self.angle_L) < 1e-6 else divy
Expand Down
3 changes: 1 addition & 2 deletions xcoll/initial_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ def generate_pencil_on_collimator(line, name, num_particles, *, side='+-', penci
# TODO: skew collimators
tilt = coll.tilt[0] if isinstance(coll.tilt, list) else coll.tilt
gemitts = {'x': coll.gemitt_x, 'y': coll.gemitt_y}
betatron_angle = -coll.gap * twiss[f'alf{plane}', name] * np.sqrt(gemitts[plane] \
/ twiss[f'bet{plane}', name])
betatron_angle = -coll.gap * coll.divergence
tolerance_tilt = 1e-12 # 0.1 urad tolerance on jaw tilt => we prioritise converging
is_converging = tilt + tolerance_tilt >= betatron_angle
print(f"Collimator {name} is {'con' if is_converging else 'di'}verging.")
Expand Down

0 comments on commit 966218e

Please sign in to comment.