Skip to content

Commit 5ec3f8b

Browse files
authored
OP knobs (#85)
1 parent 3e66fd8 commit 5ec3f8b

File tree

11 files changed

+61
-18
lines changed

11 files changed

+61
-18
lines changed

.github/workflows/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ They are organised as follows.
66
### Documentation
77

88
The `documentation` workflow triggers on any push to master, builds the documentation and pushes it to the `gh-pages` branch (if the build is successful).
9-
It runs on `ubuntu-latest` and the lowest supported Python version, `Python 3.7`.
9+
It runs on `ubuntu-latest` and `Python 3.9`.
1010

1111
### Testing Suite
1212

@@ -16,7 +16,7 @@ Tests run on a matrix of all supported operating systems for all supported Pytho
1616
### Test Coverage
1717

1818
Test coverage is calculated in the `coverage` wokflow, which triggers on pushes to `master` and any push to a `pull request`.
19-
It runs on `ubuntu-latest` & the lowest supported Python version (`Python 3.7`), and reports the coverage results of the test suite to `Codecov`.
19+
It runs on `ubuntu-latest` and `Python 3.9`, and reports the coverage results of the test suite to `Codecov`.
2020

2121

2222
### Regular Testing

.github/workflows/coverage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
matrix: # only lowest supported python on ubuntu-latest
2020
os: [ubuntu-latest]
21-
python-version: [3.7]
21+
python-version: [3.9]
2222

2323
steps:
2424
- uses: actions/checkout@v2

.github/workflows/cron.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ jobs:
1515
runs-on: ${{ matrix.os }}
1616
strategy:
1717
matrix:
18-
os: [ubuntu-16.04, ubuntu-18.04, ubuntu-20.04, macos-latest, windows-latest]
19-
python-version: [3.7, 3.8, 3.9, 3.x] # crons should always run latest python hence 3.x
18+
os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, macos-latest, windows-latest]
19+
python-version: [3.7, 3.8, 3.9, "3.10", 3.x] # crons should always run latest python hence 3.x
20+
exclude:
21+
- os: windows-latest
22+
python-version: "3.10"
23+
- os: windows-latest
24+
python-version: "3.x"
2025
fail-fast: false
2126

2227
steps:

.github/workflows/documentation.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
matrix: # only lowest supported python on ubuntu-latest
2020
os: [ubuntu-latest]
21-
python-version: [3.7]
21+
python-version: [3.9]
2222

2323
steps:
2424
- uses: actions/checkout@v2

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
matrix: # only lowest supported python on ubuntu-latest
1818
os: [ubuntu-latest]
19-
python-version: [3.7]
19+
python-version: [3.9]
2020

2121

2222
steps:

.github/workflows/tests.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ jobs:
1515
runs-on: ${{ matrix.os }}
1616
strategy:
1717
matrix:
18-
os: [ubuntu-18.04, ubuntu-20.04, macos-latest, windows-latest]
18+
os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, macos-latest, windows-latest]
1919
python-version: [3.7, 3.8, 3.9]
20+
exclude:
21+
- os: windows-latest
22+
python-version: "3.10"
2023
fail-fast: false
2124

2225
steps:

docs/release.rst

+15
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ Release Notes
33

44
The full list of releases can be found in the Github repository's `releases page <https://github.com/fsoubelet/PyhDToolkit/releases>`_.
55

6+
.. _release_0.19.1:
7+
8+
0.19.1
9+
------
10+
11+
Maintenance
12+
~~~~~~~~~~~
13+
14+
* The `~pyhdtoolkit.cpymadtools.lhc.get_lhc_tune_and_chroma_knobs` function now can has a new boolean argument, `run3`, to determine if the standard `_op` knobs should be returned.
15+
* The functions in the `~pyhdtoolkit.cpymadtools.matching` module now also have the `run3` argument, and will call the Run 3 `_op` knobs if this argument is set to `True` and the `LHC` accelerator is passed.
16+
* Fixes have been provided to the various Github Actions workflow of the repository.
17+
18+
See `v0.19.1 release notes on GitHub <https://github.com/fsoubelet/PyhDToolkit/releases/tag/0.19.1>`_ and the `full changes since v0.18.0 <https://github.com/fsoubelet/PyhDToolkit/compare/0.19.0...0.19.1>`_.
19+
20+
621
.. _release_0.19.0:
722

823
0.19.0

pyhdtoolkit/cpymadtools/lhc.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ def get_lhc_bpms_list(madx: Madx) -> List[str]:
669669

670670

671671
def get_lhc_tune_and_chroma_knobs(
672-
accelerator: str, beam: int = 1, telescopic_squeeze: bool = True
672+
accelerator: str, beam: int = 1, telescopic_squeeze: bool = True, run3: bool = False
673673
) -> Tuple[str, str, str, str]:
674674
"""
675675
Gets names of knobs needed to match tunes and chromaticities as a tuple of strings,
@@ -682,6 +682,7 @@ def get_lhc_tune_and_chroma_knobs(
682682
beam (int): Beam to use, for the knob names. Defaults to 1.
683683
telescopic_squeeze (bool): if set to `True`, returns the knobs for Telescopic
684684
Squeeze configuration. Defaults to `True` to reflect run III scenarios.
685+
run3 (bool): if set to `True`, returns the Run 3 `*_op` knobs.
685686
686687
Returns:
687688
A `tuple` of strings with knobs for ``(qx, qy, dqx, dqy)``.
@@ -698,7 +699,12 @@ def get_lhc_tune_and_chroma_knobs(
698699
('kqtf.b2_sq', 'kqtd.b2_sq', 'ksf.b2_sq', 'ksd.b2_sq')
699700
"""
700701
beam = 2 if beam == 4 else beam
701-
suffix = "_sq" if telescopic_squeeze else ""
702+
if run3:
703+
suffix = "_op"
704+
elif telescopic_squeeze:
705+
suffix = "_sq"
706+
else:
707+
suffix = ""
702708

703709
if accelerator.upper() not in ("LHC", "HLLHC"):
704710
logger.error("Invalid accelerator name, only 'LHC' and 'HLLHC' implemented")

pyhdtoolkit/cpymadtools/matching.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def match_tunes_and_chromaticities(
2929
dq2_target: float = None,
3030
varied_knobs: Sequence[str] = None,
3131
telescopic_squeeze: bool = True,
32+
run3: bool = False,
3233
step: float = 1e-7,
3334
calls: int = 100,
3435
tolerance: float = 1e-21,
@@ -81,7 +82,8 @@ def match_tunes_and_chromaticities(
8182
could be ``["kqf", "ksd", "kqf", "kqd"]`` as they are common names used for quadrupole and sextupole
8283
strengths (focusing / defocusing) in most examples.
8384
telescopic_squeeze (bool): ``LHC`` specific. If set to `True`, uses the ``(HL)LHC`` knobs for Telescopic
84-
Squeeze configuration. Defaults to `True` as of run III.
85+
Squeeze configuration. Defaults to `True` since `v0.9.0`.
86+
run3 (bool): if set to `True`, uses the `LHC` Run 3 `*_op` knobs. Defaults to `False`.
8587
step (float): step size to use when varying knobs.
8688
calls (int): max number of varying calls to perform.
8789
tolerance (float): tolerance for successfull matching.
@@ -120,7 +122,7 @@ def match_tunes_and_chromaticities(
120122
if accelerator and not varied_knobs:
121123
logger.trace(f"Getting knobs from default {accelerator.upper()} values")
122124
lhc_knobs = get_lhc_tune_and_chroma_knobs(
123-
accelerator=accelerator, beam=int(sequence[-1]), telescopic_squeeze=telescopic_squeeze
125+
accelerator=accelerator, beam=int(sequence[-1]), telescopic_squeeze=telescopic_squeeze, run3=run3
124126
)
125127
tune_knobs, chroma_knobs = lhc_knobs[:2], lhc_knobs[2:] # first two, last two
126128

@@ -171,6 +173,7 @@ def match_tunes(
171173
q2_target: float = None,
172174
varied_knobs: Sequence[str] = None,
173175
telescopic_squeeze: bool = True,
176+
run3: bool = False,
174177
step: float = 1e-7,
175178
calls: int = 100,
176179
tolerance: float = 1e-21,
@@ -195,7 +198,8 @@ def match_tunes(
195198
q2_target (float): vertical tune to match to.
196199
varied_knobs (Sequence[str]): the variables names to ``VARY`` in the ``MAD-X`` ``MATCH`` routine.
197200
telescopic_squeeze (bool): ``LHC`` specific. If set to `True`, uses the ``(HL)LHC`` knobs for Telescopic
198-
Squeeze configuration. Defaults to `True` as of run III.
201+
Squeeze configuration. Defaults to `True` since `v0.9.0`.
202+
run3 (bool): if set to `True`, uses the `LHC` Run 3 `*_op` knobs. Defaults to `False`.
199203
step (float): step size to use when varying knobs. Defaults to `1E-7`.
200204
calls (int): max number of varying calls to perform. Defaults to `100`.
201205
tolerance (float): tolerance for successfull matching. Defaults to `1E-21`.
@@ -236,6 +240,7 @@ def match_tunes(
236240
dq2_target=None,
237241
varied_knobs=varied_knobs,
238242
telescopic_squeeze=telescopic_squeeze,
243+
run3=run3,
239244
step=step,
240245
calls=calls,
241246
tolerance=tolerance,
@@ -250,6 +255,7 @@ def match_chromaticities(
250255
dq2_target: float = None,
251256
varied_knobs: Sequence[str] = None,
252257
telescopic_squeeze: bool = True,
258+
run3: bool = False,
253259
step: float = 1e-7,
254260
calls: int = 100,
255261
tolerance: float = 1e-21,
@@ -274,7 +280,8 @@ def match_chromaticities(
274280
q2_target (float): vertical tune to match to.
275281
varied_knobs (Sequence[str]): the variables names to ``VARY`` in the ``MAD-X`` ``MATCH`` routine.
276282
telescopic_squeeze (bool): ``LHC`` specific. If set to `True`, uses the ``(HL)LHC`` knobs for Telescopic
277-
Squeeze configuration. Defaults to `True` as of run III.
283+
Squeeze configuration. Defaults to `True` since `v0.9.0`.
284+
run3 (bool): if set to `True`, uses the `LHC` Run 3 `*_op` knobs. Defaults to `False`.
278285
step (float): step size to use when varying knobs. Defaults to `1E-7`.
279286
calls (int): max number of varying calls to perform. Defaults to `100`.
280287
tolerance (float): tolerance for successfull matching. Defaults to `1E-21`.
@@ -315,6 +322,7 @@ def match_chromaticities(
315322
dq2_target=dq2_target,
316323
varied_knobs=varied_knobs,
317324
telescopic_squeeze=telescopic_squeeze,
325+
run3=run3,
318326
step=step,
319327
calls=calls,
320328
tolerance=tolerance,

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pyhdtoolkit"
3-
version = "0.19.0"
3+
version = "0.19.1"
44
description = "An all-in-one toolkit package to ease my Python work in my PhD."
55
authors = ["Felix Soubelet <[email protected]>"]
66
license = "MIT"

tests/test_cpymadtools/test_lhc.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,16 @@ def test_vary_independent_ir_quads_raises_on_wrong_quads(self, _non_matched_lhc_
281281

282282
@pytest.mark.parametrize("beam", [1, 2, 3, 4])
283283
@pytest.mark.parametrize("telescopic_squeeze", [False, True])
284-
def test_lhc_tune_and_chroma_knobs(self, beam, telescopic_squeeze):
284+
@pytest.mark.parametrize("run3", [False, True])
285+
def test_lhc_tune_and_chroma_knobs(self, beam, telescopic_squeeze, run3):
285286
expected_beam = 2 if beam == 4 else beam
286-
expected_suffix = "_sq" if telescopic_squeeze else ""
287-
assert get_lhc_tune_and_chroma_knobs("LHC", beam, telescopic_squeeze) == (
287+
if run3:
288+
expected_suffix = "_op"
289+
elif telescopic_squeeze:
290+
expected_suffix = "_sq"
291+
else:
292+
expected_suffix = ""
293+
assert get_lhc_tune_and_chroma_knobs("LHC", beam, telescopic_squeeze, run3) == (
288294
f"dQx.b{expected_beam}{expected_suffix}",
289295
f"dQy.b{expected_beam}{expected_suffix}",
290296
f"dQpx.b{expected_beam}{expected_suffix}",

0 commit comments

Comments
 (0)