Skip to content

Commit

Permalink
release 0.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fsoubelet authored Sep 22, 2021
1 parent aa5c0d4 commit 95b3a34
Show file tree
Hide file tree
Showing 19 changed files with 15,973 additions and 778 deletions.
2 changes: 1 addition & 1 deletion pyhdtoolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
__title__ = "pyhdtoolkit"
__description__ = "An all-in-one toolkit package to easy my Python work in my PhD."
__url__ = "https://github.com/fsoubelet/PyhDToolkit"
__version__ = "0.13.3"
__version__ = "0.14.0"
__author__ = "Felix Soubelet"
__author_email__ = "[email protected]"
__license__ = "MIT"
11 changes: 9 additions & 2 deletions pyhdtoolkit/cpymadtools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@

from .errors import misalign_lhc_ir_quadrupoles, misalign_lhc_triplets, switch_magnetic_errors
from .generators import LatticeGenerator
from .latwiss import plot_latwiss, plot_machine_survey
from .matching import get_closest_tune_approach, get_lhc_tune_and_chroma_knobs, match_tunes_and_chromaticities
from .orbit import correct_lhc_orbit, get_current_orbit_setup, lhc_orbit_variables, setup_lhc_orbit
from .parameters import query_beam_attributes
from .plotters import AperturePlotter, DynamicAperturePlotter, PhaseSpacePlotter, TuneDiagramPlotter
from .plotters import (
AperturePlotter,
BeamEnvelopePlotter,
CrossingSchemePlotter,
DynamicAperturePlotter,
LatticePlotter,
PhaseSpacePlotter,
TuneDiagramPlotter,
)
from .ptc import get_amplitude_detuning, get_rdts
from .special import (
apply_lhc_colinearity_knob,
Expand Down
512 changes: 0 additions & 512 deletions pyhdtoolkit/cpymadtools/latwiss.py

This file was deleted.

1,050 changes: 973 additions & 77 deletions pyhdtoolkit/cpymadtools/plotters.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyhdtoolkit/utils/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"mathtext.default": "regular", # default font for math
# ------ Text ------ #
"text.usetex": True, # Use LaTeX for text handling (Set to False if you don't have a local installation)
"text.latex.preamble": r"\usepackage{amsmath, amssymb}", # \boldmath", # Be careful with the preamble
"text.latex.preamble": r"\usepackage{amsmath, amssymb}", # Be careful with the preamble
# ------ Axes ------ #
"axes.linewidth": 2, # Linewidth of axes edges
"axes.grid": True, # Do display grid
Expand Down Expand Up @@ -90,6 +90,7 @@
# ------- Legend ------ #
"legend.loc": "best", # Default legend location
"legend.frameon": True, # Make a dedicated patch for the legend
"legend.framealpha": 0.9, # Legend patch transparency factor
"legend.fancybox": True, # Use rounded box for legend background
"legend.fontsize": 22, # Legend text font size
"legend.title_fontsize": 23, # Legend title text font size
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyhdtoolkit"
version = "0.13.3"
version = "0.14.0"
description = "An all-in-one toolkit package to easy my Python work in my PhD."
authors = ["Felix Soubelet <[email protected]>"]
license = "MIT"
Expand Down
167 changes: 107 additions & 60 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from cpymad.madx import Madx

from pyhdtoolkit.cpymadtools import special
from pyhdtoolkit.cpymadtools.generators import LatticeGenerator
from pyhdtoolkit.cpymadtools.matching import match_tunes_and_chromaticities

Expand All @@ -12,85 +13,131 @@
INPUTS_DIR = CURRENT_DIR / "inputs"
LHC_SEQUENCE = INPUTS_DIR / "lhc_as-built.seq"
LHC_OPTICS = INPUTS_DIR / "opticsfile.22"

LHC_INJ_OPTICS = INPUTS_DIR / "opticsfile.1"
LHC_B1_APERTURE = INPUTS_DIR / "aperture.b1.madx"
LHC_B1_APERTOL = INPUTS_DIR / "aper_tol.b1.madx"

# ----- Fixtures for cpymadtools tests ----- #


@pytest.fixture()
def _matched_base_lattice() -> Madx:
"""Base CAS lattice matched to default working point."""
madx = Madx(stdout=False)
madx.input(BASE_LATTICE)
match_tunes_and_chromaticities(
madx=madx,
sequence="CAS3",
q1_target=6.335,
q2_target=6.29,
dq1_target=100,
dq2_target=100,
varied_knobs=["kqf", "kqd", "ksf", "ksd"],
)
yield madx
madx.exit()
with Madx(stdout=False) as madx:
madx.input(BASE_LATTICE)
match_tunes_and_chromaticities(
madx=madx,
sequence="CAS3",
q1_target=6.335,
q2_target=6.29,
dq1_target=100,
dq2_target=100,
varied_knobs=["kqf", "kqd", "ksf", "ksd"],
)
yield madx


@pytest.fixture()
def _bare_lhc_madx() -> Madx:
"""Only loading sequence and optics."""
madx = Madx(stdout=False)
madx.call(str(LHC_SEQUENCE.absolute()))
madx.call(str(LHC_OPTICS.absolute()))
yield madx
madx.exit()
with Madx(stdout=False) as madx:
madx.call(str(LHC_SEQUENCE.absolute()))
madx.call(str(LHC_OPTICS.absolute())) # opticsfile.22
yield madx


@pytest.fixture()
def _non_matched_lhc_madx() -> Madx:
"""Important properties & beam for lhcb1 declared and in use, NO MATCHING done here."""
madx = Madx(stdout=False)
madx.call(str(LHC_SEQUENCE.absolute()))
madx.call(str(LHC_OPTICS.absolute()))

NRJ = madx.globals["NRJ"] = 6500
madx.globals["brho"] = madx.globals["NRJ"] * 1e9 / madx.globals.clight
geometric_emit = madx.globals["geometric_emit"] = 3.75e-6 / (madx.globals["NRJ"] / 0.938)
madx.command.beam(
sequence="lhcb1",
bv=1,
energy=NRJ,
particle="proton",
npart=1.0e10,
kbunch=1,
ex=geometric_emit,
ey=geometric_emit,
)
madx.use(sequence="lhcb1")
yield madx
madx.exit()
with Madx(stdout=False) as madx:
madx.call(str(LHC_SEQUENCE.absolute()))
madx.call(str(LHC_OPTICS.absolute())) # opticsfile.22

NRJ = madx.globals["NRJ"] = 6500
madx.globals["brho"] = madx.globals["NRJ"] * 1e9 / madx.globals.clight
geometric_emit = madx.globals["geometric_emit"] = 3.75e-6 / (madx.globals["NRJ"] / 0.938)
madx.command.beam(
sequence="lhcb1",
bv=1,
energy=NRJ,
particle="proton",
npart=1.0e10,
kbunch=1,
ex=geometric_emit,
ey=geometric_emit,
)
madx.use(sequence="lhcb1")
yield madx


@pytest.fixture()
def _matched_lhc_madx() -> Madx:
"""Important properties & beam for lhcb1 declared and in use, WITH matching to working point."""
madx = Madx(stdout=False)
madx.call(str(LHC_SEQUENCE.absolute()))
madx.call(str(LHC_OPTICS.absolute()))

NRJ = madx.globals["NRJ"] = 6500
madx.globals["brho"] = madx.globals["NRJ"] * 1e9 / madx.globals.clight
geometric_emit = madx.globals["geometric_emit"] = 3.75e-6 / (madx.globals["NRJ"] / 0.938)
madx.command.beam(
sequence="lhcb1",
bv=1,
energy=NRJ,
particle="proton",
npart=1.0e10,
kbunch=1,
ex=geometric_emit,
ey=geometric_emit,
)
madx.use(sequence="lhcb1")
match_tunes_and_chromaticities(madx, "lhc", "lhcb1", 62.31, 60.32, 2.0, 2.0, telescopic_squeeze=True)
yield madx
madx.exit()
with Madx(stdout=False) as madx:
madx.call(str(LHC_SEQUENCE.absolute()))
madx.call(str(LHC_OPTICS.absolute())) # opticsfile.22

NRJ = madx.globals["NRJ"] = 6500
madx.globals["brho"] = madx.globals["NRJ"] * 1e9 / madx.globals.clight
geometric_emit = madx.globals["geometric_emit"] = 3.75e-6 / (madx.globals["NRJ"] / 0.938)
madx.command.beam(
sequence="lhcb1",
bv=1,
energy=NRJ,
particle="proton",
npart=1.0e10,
kbunch=1,
ex=geometric_emit,
ey=geometric_emit,
)
madx.use(sequence="lhcb1")
match_tunes_and_chromaticities(madx, "lhc", "lhcb1", 62.31, 60.32, 2.0, 2.0, telescopic_squeeze=True)
yield madx


@pytest.fixture()
def _cycled_lhc_sequences() -> Madx:
"""Important properties & beam for lhcb1 and lhcb1 declared and in use, WITH matching to working point."""
with Madx(stdout=False) as madx:
madx.call(str(LHC_SEQUENCE.absolute()))
madx.call(str(LHC_OPTICS.absolute())) # opticsfile.22

special.re_cycle_sequence(madx, sequence="lhcb1", start="IP3")
special.re_cycle_sequence(madx, sequence="lhcb2", start="IP3")
special.make_lhc_beams(madx, energy=6500)

yield madx


@pytest.fixture()
def _injection_aperture_tolerances_lhc_madx() -> Madx:
with Madx(stdout=False) as madx:
madx.call(str(LHC_SEQUENCE.absolute()))
madx.call(str(LHC_INJ_OPTICS.absolute())) # opticsfile.1

special.make_lhc_beams(madx, energy=450) # injection
madx.use(sequence="lhcb1")

madx.call((str(LHC_B1_APERTURE.absolute())))
madx.call(str(LHC_B1_APERTOL.absolute()))

madx.command.twiss()
madx.command.aperture(cor=0.002, dp=8.6e-4, halo="{6,6,6,6}", bbeat=1.05, dparx=0.14, dpary=0.14)
yield madx


@pytest.fixture()
def _collision_aperture_tolerances_lhc_madx() -> Madx:
with Madx(stdout=False) as madx:
madx.call(str(LHC_SEQUENCE.absolute()))
madx.call(str(LHC_OPTICS.absolute())) # opticsfile.22

special.make_lhc_beams(madx, energy=6500) # collision
madx.use(sequence="lhcb1")

madx.call((str(LHC_B1_APERTURE.absolute())))
madx.call(str(LHC_B1_APERTOL.absolute()))

madx.command.twiss()
madx.command.aperture(cor=0.002, dp=8.6e-4, halo="{6,6,6,6}", bbeat=1.05, dparx=0.14, dpary=0.14)
yield madx
Loading

0 comments on commit 95b3a34

Please sign in to comment.