Skip to content

Commit

Permalink
coupling b2 and intersect fix, coupling and rdt modules accuracy tests (
Browse files Browse the repository at this point in the history
#320)

Fixes b2 issues  for coupling, and updates the Cminus calculations (approximated and exact)
Type hinted coupling.py, added logging

Co-authored-by: awegsche <a.wegscheider7141@gmail.com>
Co-authored-by: Felix Soubelet <felix.soubelet@protonmail.com>
Co-authored-by: Felix Soubelet <19598248+fsoubelet@users.noreply.github.com>
  • Loading branch information
4 people authored Oct 4, 2021
1 parent 242dd92 commit 6763e86
Show file tree
Hide file tree
Showing 51 changed files with 66,000 additions and 231 deletions.
18 changes: 11 additions & 7 deletions omc3/definitions/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
General constants to use throughout ``omc3``, so they don't have to be redefined all the time.
Also helps with consistency.
"""
from typing import Dict, Tuple

import numpy as np

PI = np.pi
PI2 = 2 * np.pi
PI2I = 2j * np.pi
PLANES = ("X", "Y")
PLANE_TO_NUM = dict(X=1, Y=2)
PLANE_TO_HV = dict(X="H", Y="V")
PI: float = np.pi
PI2: float = 2 * np.pi
PI2I: float = 2j * np.pi
PLANES: Tuple[str] = ("X", "Y")
PLANE_TO_NUM: Dict[str, int] = dict(X=1, Y=2)
PLANE_TO_HV: Dict[str, str] = dict(X="H", Y="V")

UNIT_IN_METERS = dict(km=1e3, m=1e0, mm=1e-3, um=1e-6, nm=1e-9, pm=1e-12, fm=1e-15, am=1e-18)
UNIT_IN_METERS: Dict[str, float] = dict(
km=1e3, m=1e0, mm=1e-3, um=1e-6, nm=1e-9, pm=1e-12, fm=1e-15, am=1e-18
)
8 changes: 4 additions & 4 deletions omc3/model/accelerators/accelerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
TWISS_ELEMENTS_DAT,
)
from omc3.utils import logging_tools
from omc3.utils.iotools import PathOrStr

LOG = logging_tools.get_logger(__name__)
CURRENT_DIR = Path(__file__).parent
Expand Down Expand Up @@ -64,7 +65,7 @@ def get_parameters():
params = EntryPointParameters()
params.add_parameter(
name="model_dir",
type=Path,
type=PathOrStr,
help="Path to model directory; loads tunes and excitation from model!",
)
params.add_parameter(
Expand Down Expand Up @@ -131,7 +132,7 @@ def __init__(self, opt) -> None:
"Arguments 'nat_tunes' and 'driven_tunes' are "
"not allowed when loading from model directory."
)
self.init_from_model_dir(opt.model_dir)
self.init_from_model_dir(Path(opt.model_dir))

else:
self.init_from_options(opt)
Expand All @@ -157,8 +158,7 @@ def init_from_options(self, opt) -> None:

def init_from_model_dir(self, model_dir: Path) -> None:
LOG.debug("Creating accelerator instance from model dir")
self.model_dir = Path(model_dir)

self.model_dir = model_dir
# Elements #####################################
elements_path = model_dir / TWISS_ELEMENTS_DAT
if not elements_path.is_file():
Expand Down
82 changes: 42 additions & 40 deletions omc3/optics_measurements/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,55 @@
Specific constants to be used in optics_measurements, to help with consistency.
"""
# File Names -------------------------------------------------------------------
EXT = ".tfs"
AMP_BETA_NAME = "beta_amplitude_"
BETA_NAME = "beta_phase_"
CHROM_BETA_NAME = "chrom_beta_"
PHASE_NAME = "phase_"
SPECIAL_PHASE_NAME = "special_phase_"
TOTAL_PHASE_NAME = "total_phase_"
DISPERSION_NAME = "dispersion_"
NORM_DISP_NAME = "normalised_dispersion_"
ORBIT_NAME = "orbit_"
KICK_NAME = "kick_"
IP_NAME = "interaction_point_"
EXT: str = ".tfs"
AMP_BETA_NAME: str = "beta_amplitude_"
BETA_NAME: str = "beta_phase_"
CHROM_BETA_NAME: str = "chrom_beta_"
PHASE_NAME: str = "phase_"
SPECIAL_PHASE_NAME: str = "special_phase_"
TOTAL_PHASE_NAME: str = "total_phase_"
DISPERSION_NAME: str = "dispersion_"
NORM_DISP_NAME: str = "normalised_dispersion_"
ORBIT_NAME: str = "orbit_"
KICK_NAME: str = "kick_"
IP_NAME: str = "interaction_point_"

# Column Names -----------------------------------------------------------------
# Pre- and Suffixe
ERR = "ERR" # Error of the measurement
RMS = 'RMS' # Root-Mean-Square
RES = "RES" # Rescaled measurement
DELTA = "DELTA" # Delta between measurement and model (sometimes beating)
MDL = "MDL" # Model
ERR: str = "ERR" # Error of the measurement
RMS: str = "RMS" # Root-Mean-Square
RES: str = "RES" # Rescaled measurement
DELTA: str = "DELTA" # Delta between measurement and model (sometimes beating)
MDL: str = "MDL" # Model
REAL: str = "REAL"
IMAG: str = "IMAG"

# Names
S = 'S'
NAME = 'NAME'
NAME2 = f'{NAME}2'
TUNE = 'Q'
NAT_TUNE = 'NATQ'
PEAK2PEAK = 'PK2PK'
ALPHA = 'ALF'
BETA = 'BET'
DPP = 'DPP'
DPPAMP = 'DPPAMP'
AMPLITUDE = 'AMP'
PHASE = 'PHASE'
PHASE_ADV = 'MU'
REAL = 'REAL'
IMAG = 'IMAG'
S: str = "S"
NAME: str = "NAME"
NAME2: str = f"{NAME}2"
TUNE: str = "Q"
NAT_TUNE: str = "NATQ"
PEAK2PEAK: str = "PK2PK"
ALPHA: str = "ALF"
BETA: str = "BET"
DPP: str = "DPP"
DPPAMP: str = "DPPAMP"
AMPLITUDE: str = "AMP"
PHASE: str = "PHASE"
PHASE_ADV: str = "MU"
F1001: str = "F1001"
F1010: str = "F1010"

SECONDARY_AMPLITUDE_X = "AMP01_X" # amplitude of secondary line in horizontal spectrum
SECONDARY_AMPLITUDE_Y = "AMP10_Y" # amplitude of secondary line in vertical spectrum
SECONDARY_FREQUENCY_X = "PHASE01_X" # frequency of secondary line in horizontal spectrum
SECONDARY_FREQUENCY_Y = "PHASE10_Y" # frequency of secondary line in vertical spectrum
SECONDARY_AMPLITUDE_X: str = "AMP01_X" # amplitude of secondary line in horizontal spectrum
SECONDARY_AMPLITUDE_Y: str = "AMP10_Y" # amplitude of secondary line in vertical spectrum
SECONDARY_FREQUENCY_X: str = "PHASE01_X" # frequency of secondary line in horizontal spectrum
SECONDARY_FREQUENCY_Y: str = "PHASE10_Y" # frequency of secondary line in vertical spectrum

TIME = 'TIME'
ACTION = '2J'
SQRT_ACTION = 'sqrt2J'
TIME: str = "TIME"
ACTION: str = "2J"
SQRT_ACTION: str = "sqrt2J"


# Headers ----------------------------------------------------------------------
RESCALE_FACTOR = 'RescalingFactor'
RESCALE_FACTOR: str = "RescalingFactor"
Loading

0 comments on commit 6763e86

Please sign in to comment.