Skip to content

Commit c76cf6d

Browse files
authored
Use the correct knobs for Run3 (#366)
* This updates so we can use the correct knobs in Run3. * Only if 2022 is activated and added the macros. * Renamed and added a comment to clarify the macros. * Removed paranthesis.
1 parent a8cb731 commit c76cf6d

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

omc3/model/accelerators/lhc.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
B2_SETTINGS_MADX,
9797
GENERAL_MACROS,
9898
LHC_MACROS,
99+
LHC_MACROS_RUN3,
99100
MACROS_DIR,
100101
MODIFIER_TAG,
101102
)
@@ -322,6 +323,13 @@ def get_base_madx_script(self, best_knowledge: bool = False) -> str:
322323
# f"option, -echo;\n"
323324
f"call, file = '{self.model_dir / MACROS_DIR / GENERAL_MACROS}';\n"
324325
f"call, file = '{self.model_dir / MACROS_DIR / LHC_MACROS}';\n"
326+
)
327+
if self.year == "2022":
328+
madx_script += (
329+
f"call, file = '{self.model_dir / MACROS_DIR / LHC_MACROS_RUN3}';\n"
330+
)
331+
332+
madx_script += (
325333
f'title, "LHC Model created by OMC3";\n'
326334
f"{self.load_main_seq_madx()}\n"
327335
f"exec, define_nominal_beams();\n"

omc3/model/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
GENERAL_MACROS = "general.macros.madx"
2525
LHC_MACROS = "lhc.macros.madx"
26+
LHC_MACROS_RUN3 = "lhc.macros.run3.madx"
2627

2728
B2_SETTINGS_MADX = "b2_settings.madx"
2829
B2_ERRORS_TFS = "b2_errors.tfs"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Macros for runIII of the LHC using the new standard of the _op for the knobs used in operation.
3+
*/
4+
5+
!requires general.macros.madx
6+
7+
8+
/*
9+
* Performs the matching of the LHC tunes, adapted to ATS optics.
10+
* @param qx: The horizontal tune to match to.
11+
* @param qy: The vertical tune to match to.
12+
* @param beam_number: The beam to use either 1 or 2.
13+
*/
14+
match_tunes_ats(nqx, nqy, beam_number): macro = {
15+
exec, find_complete_tunes(nqx, nqy, beam_number);
16+
match;
17+
vary, name=dQx_op.bbeam_number_sq;
18+
vary, name=dQy_op.bbeam_number_sq;
19+
constraint, range=#E, mux=total_qx, muy=total_qy;
20+
lmdif;
21+
endmatch;
22+
};
23+
24+
/*
25+
* Coupling knobs convention for Run3
26+
*/
27+
coupling_knob_ats(beam_number): macro = {
28+
Cmrs.b1_op := b1_re_ip7_knob;
29+
Cmrs.b2_op := b2_re_ip7_knob;
30+
Cmis.b1_op := b1_im_ip7_knob;
31+
Cmis.b2_op := b2_im_ip7_knob;
32+
};
33+

omc3/model/model_creators/lhc_model_creator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
ERROR_DEFFS_TXT,
2121
GENERAL_MACROS,
2222
LHC_MACROS,
23+
LHC_MACROS_RUN3,
2324
MACROS_DIR,
2425
TWISS_AC_DAT,
2526
TWISS_ADT_DAT,
@@ -100,6 +101,7 @@ def prepare_run(cls, accel: Lhc) -> None:
100101
lib_path = Path(__file__).parent.parent / "madx_macros"
101102
shutil.copy(lib_path / GENERAL_MACROS, macros_path / GENERAL_MACROS)
102103
shutil.copy(lib_path / LHC_MACROS, macros_path / LHC_MACROS)
104+
shutil.copy(lib_path / LHC_MACROS_RUN3, macros_path / LHC_MACROS_RUN3)
103105

104106
if accel.energy is not None:
105107
LOGGER.debug("Copying B2 error files for given energy in model directory")

0 commit comments

Comments
 (0)