diff --git a/python/tests/closed_orbit_test.py b/python/tests/closed_orbit_test.py index ca844922..4445a181 100644 --- a/python/tests/closed_orbit_test.py +++ b/python/tests/closed_orbit_test.py @@ -14,7 +14,13 @@ import gtpsa from thor_scsi.factory import accelerator_from_config from thor_scsi.utils.closed_orbit import compute_closed_orbit +from thor_scsi.utils import canonical_variables_mapping_default +from thor_scsi.utils.accelerator import ( + instrument_with_standard_observers, + extract_orbit_from_standard_observers, + extract_orbit_from_accelerator_with_standard_observers, +) path = ( Path(os.path.dirname(__file__)) @@ -28,6 +34,7 @@ def create_acc(): def test10_closed_orbit_for_zero(): + calc_config = tslib.ConfigType() acc = create_acc() @@ -56,6 +63,20 @@ def test10_closed_orbit_for_zero(): assert x0.ct == pytest.approx(ct_save, abs=1e-9) +def test20_closed_orbit_for_zero_ovservers(): + """test functions used by twin + + just that they execute without error + """ + calc_config = tslib.ConfigType() + acc = create_acc() + observers_non_perturbated = instrument_with_standard_observers( + acc, mapping=canonical_variables_mapping_default + ) + result = compute_closed_orbit(acc, calc_config, delta=0e0) + assert result.found_closed_orbit == True + extract_orbit_from_accelerator_with_standard_observers(acc) + def compensate_quadrupole_offset_with_dipole_kick(quad): dx = quad.get_dx() assert quad.get_main_multipole_number() == 2 diff --git a/python/tests/twiss_test.py b/python/tests/twiss_test.py new file mode 100644 index 00000000..21ef7092 --- /dev/null +++ b/python/tests/twiss_test.py @@ -0,0 +1,51 @@ +from thor_scsi.utils import canonical_variables_mapping_default +from thor_scsi.utils.linear_optics import compute_Twiss_along_lattice +from thor_scsi.factory import accelerator_from_config +from thor_scsi import lib as tslib +import gtpsa +import pytest +from pathlib import Path +import os.path + +desc = gtpsa.desc(6, 1) + +path = ( + Path(os.path.dirname(__file__)) + / "lattices" + / "b2_stduser_beamports_blm_tracy_corr.lat" +) + + +def create_acc(): + acc = accelerator_from_config(path) + acc.set_log_level(tslib.accelerator_log_level.warning) + return acc + + +def test_twiss_without_radiation(): + """Functions as used by digital twin""" + n_dof = 2 + calc_config = tslib.ConfigType() + calc_config.radiation = False + calc_config.Cavity_on = False + acc = create_acc() + compute_Twiss_along_lattice( + n_dof, acc, calc_config, desc=desc, mapping=canonical_variables_mapping_default + ) + + +@pytest.mark.skip +def test_twiss_with_radiation(): + """Functions as used by digital twin + + just check that it runs + """ + calc_config = tslib.ConfigType() + n_dof = 3 + calc_config.radiation = True + calc_config.Cavity_on = True + calc_config.Energy = 2.7 + acc = create_acc() + compute_Twiss_along_lattice( + n_dof, acc, calc_config, desc=desc, mapping=canonical_variables_mapping_default + )