laura-accelerator 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Testing/.gitignore +21 -0
- Testing/FEBE_2_Bunches.def +42 -0
- Testing/GUI/__main__.py +85 -0
- Testing/Settings/250pC/1/FEBE_transverse_best_changes.yaml +34 -0
- Testing/Settings/250pC/1/S07_transverse_best_changes_Simple.yaml +20 -0
- Testing/Settings/250pC/1/nelder_mead_best_changes_Simple.yaml +25 -0
- Testing/Settings/250pC/1/transverse_best_changes_upto_S07_Simple.yaml +36 -0
- Testing/__init__.py +0 -0
- Testing/cameras.py +13 -0
- Testing/convert_SimFrame.py +62 -0
- Testing/convert_yaml.py +47 -0
- Testing/make_model_from_scratch.py +85 -0
- Testing/padantic.py +35 -0
- Testing/save_machine.py +57 -0
- Testing/test.yaml +67 -0
- Testing/test_currents.yaml +28 -0
- Testing/unit_tests/PAdantic/__init__.py +0 -0
- Testing/unit_tests/PAdantic/models/__init__.py +0 -0
- Testing/unit_tests/PAdantic/models/test_element.py +123 -0
- Testing/unit_tests/PAdantic/test_padantic.py +131 -0
- Testing/unit_tests/__init__.py +0 -0
- laura/Exporters/CATAP.py +44 -0
- laura/Exporters/Export_CATAP_YAML.py +11 -0
- laura/Exporters/YAML.py +61 -0
- laura/Exporters/__init__.py +0 -0
- laura/Importers/CATAP_Loader.py +155 -0
- laura/Importers/CLARA Magnet Table v6.xlsx +0 -0
- laura/Importers/Magnet_Table.py +61 -0
- laura/Importers/MySafeConstructor.py +13 -0
- laura/Importers/MySafeLoader.py +17 -0
- laura/Importers/SimFrame_Loader.py +261 -0
- laura/Importers/YAML_Loader.py +88 -0
- laura/Importers/__init__.py +0 -0
- laura/Importers/camera_assignments.yaml +37 -0
- laura/PV_Values.yaml +331 -0
- laura/__init__.py +6 -0
- laura/debug_wrapper.py +22 -0
- laura/laura.py +900 -0
- laura/models/RF.py +317 -0
- laura/models/__init__.py +0 -0
- laura/models/_functions.py +48 -0
- laura/models/baseModels.py +187 -0
- laura/models/control.py +269 -0
- laura/models/degauss.py +29 -0
- laura/models/diagnostic.py +360 -0
- laura/models/electrical.py +18 -0
- laura/models/element.py +1467 -0
- laura/models/elementList.py +913 -0
- laura/models/exceptions.py +2 -0
- laura/models/laser.py +153 -0
- laura/models/lighting.py +5 -0
- laura/models/magnetic.py +805 -0
- laura/models/manufacturer.py +26 -0
- laura/models/physical.py +409 -0
- laura/models/plasma.py +44 -0
- laura/models/reference.py +18 -0
- laura/models/shutter.py +25 -0
- laura/models/simulation.py +397 -0
- laura/translator/__init__.py +0 -0
- laura/translator/conversion_rules/codes/__init__.py +0 -0
- laura/translator/conversion_rules/codes/cheetah_conversion.py +54 -0
- laura/translator/conversion_rules/codes/ocelot_conversion.py +59 -0
- laura/translator/conversion_rules/codes/wake_t_conversion.py +17 -0
- laura/translator/conversion_rules/codes/xsuite_conversion.py +82 -0
- laura/translator/conversion_rules/elements/element_keywords.yaml +546 -0
- laura/translator/conversion_rules/elements/elements_cheetah.yaml +88 -0
- laura/translator/conversion_rules/elements/elements_elegant.yaml +2392 -0
- laura/translator/conversion_rules/elements/elements_genesis.yaml +38 -0
- laura/translator/conversion_rules/elements/elements_ocelot.yaml +255 -0
- laura/translator/conversion_rules/elements/elements_opal.yaml +575 -0
- laura/translator/conversion_rules/keywords/keyword_conversion_rules_Xsuite.yaml +16 -0
- laura/translator/conversion_rules/keywords/keyword_conversion_rules_cheetah.yaml +96 -0
- laura/translator/conversion_rules/keywords/keyword_conversion_rules_elegant.yaml +125 -0
- laura/translator/conversion_rules/keywords/keyword_conversion_rules_genesis.yaml +25 -0
- laura/translator/conversion_rules/keywords/keyword_conversion_rules_ocelot.yaml +105 -0
- laura/translator/conversion_rules/keywords/keyword_conversion_rules_opal.yaml +29 -0
- laura/translator/conversion_rules/keywords/keyword_conversion_rules_wake_t.yaml +22 -0
- laura/translator/conversion_rules/types/type_conversion_rules.yaml +128 -0
- laura/translator/converters/__init__.py +105 -0
- laura/translator/converters/aperture.py +180 -0
- laura/translator/converters/base.py +1033 -0
- laura/translator/converters/cavity.py +604 -0
- laura/translator/converters/codes/__init__.py +8 -0
- laura/translator/converters/codes/astra.py +434 -0
- laura/translator/converters/codes/bmad.py +369 -0
- laura/translator/converters/codes/csrtrack.py +213 -0
- laura/translator/converters/codes/elegant.py +192 -0
- laura/translator/converters/codes/gpt.py +548 -0
- laura/translator/converters/codes/ocelot.py +311 -0
- laura/translator/converters/codes/opal.py +586 -0
- laura/translator/converters/codes/xsuite.py +316 -0
- laura/translator/converters/converter.py +100 -0
- laura/translator/converters/diagnostic.py +57 -0
- laura/translator/converters/drift.py +35 -0
- laura/translator/converters/laser.py +88 -0
- laura/translator/converters/layout.py +113 -0
- laura/translator/converters/magnet.py +1253 -0
- laura/translator/converters/model.py +114 -0
- laura/translator/converters/plasma.py +163 -0
- laura/translator/converters/section.py +601 -0
- laura/translator/converters/twiss.py +12 -0
- laura/translator/converters/wake.py +213 -0
- laura/translator/utils/SDDSFile.py +499 -0
- laura/translator/utils/__init__.py +0 -0
- laura/translator/utils/classes.py +49 -0
- laura/translator/utils/elegant/SDDSFile.py +499 -0
- laura/translator/utils/elegant/sdds_classes_APS.py +264 -0
- laura/translator/utils/fields/FieldParameter.py +21 -0
- laura/translator/utils/fields/__init__.py +486 -0
- laura/translator/utils/fields/astra.py +368 -0
- laura/translator/utils/fields/gdf.py +297 -0
- laura/translator/utils/fields/hdf5.py +171 -0
- laura/translator/utils/fields/opal.py +269 -0
- laura/translator/utils/fields/sdds.py +160 -0
- laura/translator/utils/functions.py +334 -0
- laura/translator/utils/pmd_units.py +522 -0
- laura/translator/utils/units.py +553 -0
- laura/unit_tests/__init__.py +0 -0
- laura/unit_tests/models/__init__.py +0 -0
- laura/unit_tests/models/test_controls.py +153 -0
- laura/unit_tests/models/test_element.py +59 -0
- laura/unit_tests/models/test_elementList.py +98 -0
- laura/unit_tests/models/test_machine_model.py +326 -0
- laura/unit_tests/models/test_magnetic.py +94 -0
- laura/unit_tests/models/test_physical.py +55 -0
- laura_accelerator-0.2.0.dist-info/METADATA +199 -0
- laura_accelerator-0.2.0.dist-info/RECORD +129 -0
- laura_accelerator-0.2.0.dist-info/WHEEL +5 -0
- laura_accelerator-0.2.0.dist-info/top_level.txt +2 -0
Testing/.gitignore
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
build/
|
|
2
|
+
dist/
|
|
3
|
+
*.egg*/
|
|
4
|
+
magnet-table/magnet-table.ini
|
|
5
|
+
*.pyc
|
|
6
|
+
*.pyc
|
|
7
|
+
MagnetApp/GUI_FileLoad.pyc
|
|
8
|
+
magnet-table/.idea/*.*
|
|
9
|
+
magnet-table/tmp/*.*
|
|
10
|
+
magnet-table/rf_sol_gui.py
|
|
11
|
+
magnet-table/src/pip-delete-this-directory.txt
|
|
12
|
+
.idea
|
|
13
|
+
SimulationFramework/Examples/S2EBunchPrePostCombined_v3.sdds
|
|
14
|
+
SimulationFramework/Examples/S2EBunchPrePostCombined_v2.sdds
|
|
15
|
+
SimulationFramework/Examples/S2EBunchPrePostCombined.astra
|
|
16
|
+
SAMM3.0/Examples
|
|
17
|
+
*checkpoint.ipynb
|
|
18
|
+
*.pyc*
|
|
19
|
+
*Untitled*
|
|
20
|
+
|
|
21
|
+
to_CATAP/
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
generator:
|
|
2
|
+
default: clara_400_3ps
|
|
3
|
+
files:
|
|
4
|
+
injector400:
|
|
5
|
+
code: ASTRA
|
|
6
|
+
charge:
|
|
7
|
+
cathode: True
|
|
8
|
+
space_charge_mode: 2D
|
|
9
|
+
mirror_charge: True
|
|
10
|
+
input:
|
|
11
|
+
particle_definition: 'initial_distribution'
|
|
12
|
+
output:
|
|
13
|
+
zstart: 0
|
|
14
|
+
end_element: CLA-S02-SIM-APER-01
|
|
15
|
+
FEBE:
|
|
16
|
+
code: elegant
|
|
17
|
+
charge:
|
|
18
|
+
cathode: False
|
|
19
|
+
space_charge_mode: 3D
|
|
20
|
+
output:
|
|
21
|
+
start_element: CLA-S02-SIM-APER-01
|
|
22
|
+
end_element: CLA-FED-SIM-DUMP-01-START
|
|
23
|
+
groups:
|
|
24
|
+
bunch_compressor:
|
|
25
|
+
type: chicane
|
|
26
|
+
elements: [CLA-VBC-MAG-DIP-01, CLA-VBC-MAG-DIP-02, CLA-VBC-MAG-DIP-03, CLA-VBC-MAG-DIP-04]
|
|
27
|
+
FODO_F:
|
|
28
|
+
type: element_group
|
|
29
|
+
elements: [CLA-FEA-MAG-QUAD-01, CLA-FEA-MAG-QUAD-03, CLA-FEA-MAG-QUAD-05, CLA-FEA-MAG-QUAD-07, CLA-FEA-MAG-QUAD-09, CLA-FEA-MAG-QUAD-11]
|
|
30
|
+
FODO_D:
|
|
31
|
+
type: element_group
|
|
32
|
+
elements: [CLA-FEA-MAG-QUAD-02, CLA-FEA-MAG-QUAD-04, CLA-FEA-MAG-QUAD-06, CLA-FEA-MAG-QUAD-08, CLA-FEA-MAG-QUAD-10, CLA-FEA-MAG-QUAD-12]
|
|
33
|
+
ARC_R56:
|
|
34
|
+
type: r56_group
|
|
35
|
+
elements: [FODO_F, FODO_D]
|
|
36
|
+
ratios: [1.5924900169720815 - 2.38 * (r56 - 0.007714832782173741), -1.1063900117914343 - 2.2 * (r56 - 0.007714832782173741)]
|
|
37
|
+
keys: [k1l, k1l]
|
|
38
|
+
elements:
|
|
39
|
+
layout_file: Machines/CLARA/layouts.yaml
|
|
40
|
+
section_file: Machines/CLARA/sections.yaml
|
|
41
|
+
yaml_dir: Machines/CLARA/YAML
|
|
42
|
+
lattice: CLARA
|
Testing/GUI/__main__.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from PyQt5.QtWidgets import (
|
|
3
|
+
QApplication,
|
|
4
|
+
QWidget,
|
|
5
|
+
QVBoxLayout,
|
|
6
|
+
QHBoxLayout,
|
|
7
|
+
QLabel,
|
|
8
|
+
QTextEdit,
|
|
9
|
+
QComboBox,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
sys.path.append("..")
|
|
13
|
+
from PAdantic.PAdantic import PAdantic # noqa E402
|
|
14
|
+
|
|
15
|
+
machine = PAdantic(
|
|
16
|
+
layout_file="../../../padantic-clara/CLARA/layouts.yaml",
|
|
17
|
+
section_file="../../../padantic-clara/CLARA/sections.yaml",
|
|
18
|
+
yaml_dir="../../../padantic-clara/CLARA/YAML/",
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ElementWidget(QWidget):
|
|
23
|
+
def __init__(self, element):
|
|
24
|
+
super().__init__()
|
|
25
|
+
|
|
26
|
+
self.element = element
|
|
27
|
+
|
|
28
|
+
self.layout = QVBoxLayout()
|
|
29
|
+
|
|
30
|
+
self.name_label = QLabel(f"Name: {self.element.name}")
|
|
31
|
+
self.type_label = QLabel(f"Type: {self.element.type}")
|
|
32
|
+
self.position_label = QLabel(f"Position: {self.physical.position}")
|
|
33
|
+
|
|
34
|
+
self.layout.addWidget(self.name_label)
|
|
35
|
+
self.layout.addWidget(self.type_label)
|
|
36
|
+
self.layout.addWidget(self.position_label)
|
|
37
|
+
|
|
38
|
+
self.setLayout(self.layout)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class MainWindow(QWidget):
|
|
42
|
+
def __init__(self):
|
|
43
|
+
super().__init__()
|
|
44
|
+
|
|
45
|
+
self.setWindowTitle("Pydantic Model Comparator")
|
|
46
|
+
|
|
47
|
+
self.layout = QVBoxLayout()
|
|
48
|
+
|
|
49
|
+
self.model_a_layout = QVBoxLayout()
|
|
50
|
+
self.model_b_layout = QVBoxLayout()
|
|
51
|
+
|
|
52
|
+
self.element_a_dropdown = QComboBox()
|
|
53
|
+
self.element_a_dropdown.addItems(
|
|
54
|
+
[element for element in machine.get_all_elements()]
|
|
55
|
+
)
|
|
56
|
+
self.model_a_layout.addWidget(self.element_a_dropdown)
|
|
57
|
+
|
|
58
|
+
self.element_b_dropdown = QComboBox()
|
|
59
|
+
self.element_b_dropdown.addItems(
|
|
60
|
+
[element for element in machine.get_all_elements()]
|
|
61
|
+
)
|
|
62
|
+
self.model_b_layout.addWidget(self.element_b_dropdown)
|
|
63
|
+
|
|
64
|
+
# self.compare_button = QPushButton("Compare Models")
|
|
65
|
+
# self.compare_button.clicked.connect(self.compare_models)
|
|
66
|
+
|
|
67
|
+
self.result_text = QTextEdit()
|
|
68
|
+
self.result_text.setReadOnly(True)
|
|
69
|
+
|
|
70
|
+
self.models_layout = QHBoxLayout()
|
|
71
|
+
self.models_layout.addLayout(self.model_a_layout)
|
|
72
|
+
self.models_layout.addLayout(self.model_b_layout)
|
|
73
|
+
|
|
74
|
+
self.layout.addLayout(self.models_layout)
|
|
75
|
+
# self.layout.addWidget(self.compare_button)
|
|
76
|
+
self.layout.addWidget(self.result_text)
|
|
77
|
+
|
|
78
|
+
self.setLayout(self.layout)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
if __name__ == "__main__":
|
|
82
|
+
app = QApplication(sys.argv)
|
|
83
|
+
window = MainWindow()
|
|
84
|
+
window.show()
|
|
85
|
+
sys.exit(app.exec_())
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
CLA-FEA-MAG-QUAD-13:
|
|
2
|
+
k1l: 2.76203
|
|
3
|
+
CLA-FEA-MAG-QUAD-14:
|
|
4
|
+
k1l: -1.26341
|
|
5
|
+
CLA-FEA-MAG-QUAD-15:
|
|
6
|
+
k1l: 1.54787
|
|
7
|
+
CLA-FEA-MAG-QUAD-16:
|
|
8
|
+
k1l: -0.853439
|
|
9
|
+
CLA-FEH-MAG-QUAD-01:
|
|
10
|
+
k1l: -1.73654
|
|
11
|
+
CLA-FEH-MAG-QUAD-02:
|
|
12
|
+
k1l: 2.16079
|
|
13
|
+
CLA-FEH-MAG-QUAD-03:
|
|
14
|
+
k1l: 2.16079
|
|
15
|
+
CLA-FEH-MAG-QUAD-04:
|
|
16
|
+
k1l: -1.73654
|
|
17
|
+
CLA-FEH-MAG-QUAD-05:
|
|
18
|
+
k1l: -1.73654
|
|
19
|
+
CLA-FEH-MAG-QUAD-06:
|
|
20
|
+
k1l: 2.16079
|
|
21
|
+
CLA-FEH-MAG-QUAD-07:
|
|
22
|
+
k1l: 2.23248
|
|
23
|
+
CLA-FEH-MAG-QUAD-08:
|
|
24
|
+
k1l: -1.77706
|
|
25
|
+
CLA-FED-MAG-QUAD-01:
|
|
26
|
+
k1l: -0.430639
|
|
27
|
+
CLA-FED-MAG-QUAD-02:
|
|
28
|
+
k1l: 0.515619
|
|
29
|
+
CLA-FED-MAG-QUAD-03:
|
|
30
|
+
k1l: 0.354496
|
|
31
|
+
CLA-FEA-MAG-SEXT-01:
|
|
32
|
+
k2l: -23.75
|
|
33
|
+
CLA-FEA-MAG-SEXT-02:
|
|
34
|
+
k2l: 23.5
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
CLA-S07-MAG-QUAD-01:
|
|
2
|
+
k1l: -0.05340743848414945
|
|
3
|
+
CLA-S07-MAG-QUAD-02:
|
|
4
|
+
k1l: -0.20163027374524783
|
|
5
|
+
CLA-S07-MAG-QUAD-03:
|
|
6
|
+
k1l: 0.1984398551681979
|
|
7
|
+
CLA-S07-MAG-QUAD-04:
|
|
8
|
+
k1l: -0.010262003991475024
|
|
9
|
+
CLA-S07-MAG-QUAD-05:
|
|
10
|
+
k1l: 0.3302727022111446
|
|
11
|
+
CLA-S07-MAG-QUAD-06:
|
|
12
|
+
k1l: -0.050009122630117725
|
|
13
|
+
CLA-S07-MAG-QUAD-07:
|
|
14
|
+
k1l: -0.554622781097504
|
|
15
|
+
CLA-S07-MAG-QUAD-08:
|
|
16
|
+
k1l: 0.6082534034240715
|
|
17
|
+
CLA-S07-MAG-QUAD-09:
|
|
18
|
+
k1l: 0.44124225191239036
|
|
19
|
+
CLA-S07-MAG-QUAD-10:
|
|
20
|
+
k1l: -0.8355499117001817
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
CLA-FEA-MAG-SEXT-01:
|
|
2
|
+
k2l: -23.884692610046763
|
|
3
|
+
CLA-FEA-MAG-SEXT-02:
|
|
4
|
+
k2l: 23.876025233154596
|
|
5
|
+
CLA-FEH-MAG-QUAD-01:
|
|
6
|
+
k1l: -1.7523204570742734
|
|
7
|
+
CLA-FEH-MAG-QUAD-02:
|
|
8
|
+
k1l: 2.229620341388219
|
|
9
|
+
CLA-L02-CAV:
|
|
10
|
+
field_amplitude: 30400165.856168382
|
|
11
|
+
phase: 13.145199683004805
|
|
12
|
+
CLA-L03-CAV:
|
|
13
|
+
field_amplitude: 28767479.697271083
|
|
14
|
+
phase: 13.92473569310755
|
|
15
|
+
CLA-L04-CAV:
|
|
16
|
+
field_amplitude: 28750423.661143437
|
|
17
|
+
phase: -40.22324842524038
|
|
18
|
+
CLA-L4H-CAV:
|
|
19
|
+
field_amplitude: 39184230.18182634
|
|
20
|
+
phase: -209.44382920460058
|
|
21
|
+
bunch_compressor:
|
|
22
|
+
angle: 0.11400168563746166
|
|
23
|
+
CLA-S07-DCP-01:
|
|
24
|
+
factor: 0.0
|
|
25
|
+
current_bins: 0
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
CLA-S02-MAG-QUAD-01:
|
|
2
|
+
k1l: 0.1788784186044036
|
|
3
|
+
CLA-S02-MAG-QUAD-02:
|
|
4
|
+
k1l: -0.2703041532771389
|
|
5
|
+
CLA-S02-MAG-QUAD-03:
|
|
6
|
+
k1l: 0.17305939436836157
|
|
7
|
+
CLA-S02-MAG-QUAD-04:
|
|
8
|
+
k1l: -0.3341192210430433
|
|
9
|
+
CLA-S02-MAG-QUAD-05:
|
|
10
|
+
k1l: 0.20172329817100404
|
|
11
|
+
CLA-S03-MAG-QUAD-01:
|
|
12
|
+
k1l: -0.033393164326790147
|
|
13
|
+
CLA-S04-MAG-QUAD-01:
|
|
14
|
+
k1l: 0.21100025830025484
|
|
15
|
+
CLA-S04-MAG-QUAD-02:
|
|
16
|
+
k1l: -0.525327429452284
|
|
17
|
+
CLA-S04-MAG-QUAD-03:
|
|
18
|
+
k1l: 0.15292725565481927
|
|
19
|
+
CLA-S04-MAG-QUAD-04:
|
|
20
|
+
k1l: -0.2080256467782457
|
|
21
|
+
CLA-S04-MAG-QUAD-05:
|
|
22
|
+
k1l: -0.04642895665984697
|
|
23
|
+
CLA-S04-MAG-QUAD-06:
|
|
24
|
+
k1l: 0.031480831603194676
|
|
25
|
+
CLA-S04-MAG-QUAD-07:
|
|
26
|
+
k1l: 0.4162095016567937
|
|
27
|
+
CLA-S04-MAG-QUAD-08:
|
|
28
|
+
k1l: -0.31000356498492626
|
|
29
|
+
CLA-S05-MAG-QUAD-01:
|
|
30
|
+
k1l: 0.08711426820204221
|
|
31
|
+
CLA-S05-MAG-QUAD-02:
|
|
32
|
+
k1l: 0.010569473641598992
|
|
33
|
+
CLA-S06-MAG-QUAD-01:
|
|
34
|
+
k1l: 0.013200502339147014
|
|
35
|
+
CLA-S06-MAG-QUAD-02:
|
|
36
|
+
k1l: 0.06640824605249836
|
Testing/__init__.py
ADDED
|
File without changes
|
Testing/cameras.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from pprint import pprint
|
|
3
|
+
|
|
4
|
+
sys.path.append("../")
|
|
5
|
+
from PAdantic.PAdantic import PAdantic # noqa E402
|
|
6
|
+
|
|
7
|
+
machine = PAdantic(
|
|
8
|
+
layout_file="../../padantic-clara/CLARA/layouts.yaml",
|
|
9
|
+
section_file="../../padantic-clara/CLARA/sections.yaml",
|
|
10
|
+
yaml_dir="../../padantic-clara/CLARA/YAML/",
|
|
11
|
+
)
|
|
12
|
+
machine.default_layout = "CLARA"
|
|
13
|
+
pprint(machine.get_screens_and_cameras(end="CLA-S05-MAG-QUAD-01"))
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
|
|
3
|
+
sys.path.append("..")
|
|
4
|
+
from PAdantic.Importers.SimFrame_Loader import read_SimFrame_YAML # noqa E402
|
|
5
|
+
from PAdantic.models.elementList import MachineModel # noqa E402
|
|
6
|
+
from PAdantic.models.element import Element # noqa E402
|
|
7
|
+
from PAdantic.Exporters.YAML import export_machine # noqa E402
|
|
8
|
+
from PAdantic.models.control import ControlsInformation, ControlVariable # noqa E402
|
|
9
|
+
|
|
10
|
+
master_lattice_location = "../../masterlattice/MasterLattice/YAML"
|
|
11
|
+
|
|
12
|
+
SF_files = [
|
|
13
|
+
f"{master_lattice_location}/CLA_Gun400.yaml",
|
|
14
|
+
f"{master_lattice_location}/CLA_SP2.yaml",
|
|
15
|
+
f"{master_lattice_location}/CLA_SP3.yaml",
|
|
16
|
+
f"{master_lattice_location}/CLA_FEBE.yaml",
|
|
17
|
+
f"{master_lattice_location}/CLA_SP1.yaml",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
machine = MachineModel(
|
|
22
|
+
layout="../../padantic-lattices/CLARA/layouts.yaml",
|
|
23
|
+
section="../../padantic-lattices/CLARA/sections.yaml",
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
for f in SF_files:
|
|
27
|
+
elem = read_SimFrame_YAML(f)
|
|
28
|
+
for name, element in elem.items():
|
|
29
|
+
example_controls = {
|
|
30
|
+
"variables": {
|
|
31
|
+
"state": {
|
|
32
|
+
"identifier": f"{element.name}:STATE",
|
|
33
|
+
"dtype": "int",
|
|
34
|
+
"protocol": "CA",
|
|
35
|
+
"units": "N/A",
|
|
36
|
+
"description": f"State of {element.name}",
|
|
37
|
+
"read_only": False,
|
|
38
|
+
},
|
|
39
|
+
"setpoint": {
|
|
40
|
+
"identifier": f"{element.name}:SP",
|
|
41
|
+
"dtype": "float",
|
|
42
|
+
"protocol": "CA",
|
|
43
|
+
"units": "N/A",
|
|
44
|
+
"description": f"Setpoint of {element.name}",
|
|
45
|
+
},
|
|
46
|
+
"readback": {
|
|
47
|
+
"identifier": f"{element.name}:RBV",
|
|
48
|
+
"dtype": "float",
|
|
49
|
+
"protocol": "CA",
|
|
50
|
+
"units": "N/A",
|
|
51
|
+
"description": f"Readback of {element.name}",
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
controls = ControlsInformation(**example_controls)
|
|
56
|
+
if isinstance(element, Element):
|
|
57
|
+
element.controls = controls
|
|
58
|
+
machine.update({n: e for n, e in elem.items()})
|
|
59
|
+
|
|
60
|
+
export_machine("../../padantic-lattices/NEW/CLARA/YAML", machine, overwrite=True)
|
|
61
|
+
|
|
62
|
+
exit()
|
Testing/convert_yaml.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import yaml
|
|
3
|
+
from pysdds import read as sddsread
|
|
4
|
+
|
|
5
|
+
sys.path.append("..")
|
|
6
|
+
from PAdantic.PAdantic import PAdantic # noqa E402
|
|
7
|
+
|
|
8
|
+
machine = PAdantic(
|
|
9
|
+
layout_file="Machines/CLARA/layouts.yaml",
|
|
10
|
+
section_file="Machines/CLARA/sections.yaml",
|
|
11
|
+
yaml_dir="Machines/CLARA/YAML/",
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
machine.default_layout = "CLARA"
|
|
15
|
+
|
|
16
|
+
simframe_examples = "../../SimFrame_Examples/FEBE/StandardSetups/Setups/Setup_1_250pC"
|
|
17
|
+
|
|
18
|
+
with open(
|
|
19
|
+
f"{simframe_examples}/lattice.yaml",
|
|
20
|
+
"r",
|
|
21
|
+
) as stream:
|
|
22
|
+
try:
|
|
23
|
+
lattice = yaml.safe_load(stream)
|
|
24
|
+
except yaml.YAMLError as exc:
|
|
25
|
+
print(exc)
|
|
26
|
+
|
|
27
|
+
sdds_twiss = {}
|
|
28
|
+
sdds_twiss_file = sddsread(f"{simframe_examples}/FEBE.twi")
|
|
29
|
+
for idx, name in enumerate(sdds_twiss_file.col("ElementName").data[0]):
|
|
30
|
+
sdds_twiss[name] = 0.511 * sdds_twiss_file.col("pCentral0").data[0][idx]
|
|
31
|
+
|
|
32
|
+
current_dictionary = {}
|
|
33
|
+
for name, elem in lattice["elements"].items():
|
|
34
|
+
if (
|
|
35
|
+
elem["type"] == "quadrupole"
|
|
36
|
+
and "-FEA-" not in name
|
|
37
|
+
and "-FEH-" not in name
|
|
38
|
+
and "-FED-" not in name
|
|
39
|
+
):
|
|
40
|
+
linsat = machine.get_element(name).magnetic.linear_saturation_coefficients
|
|
41
|
+
momentum = sdds_twiss[name]
|
|
42
|
+
k1 = elem["k1l"] / elem["length"]
|
|
43
|
+
print(name, k1, momentum, linsat.KToCurrent(k1, momentum))
|
|
44
|
+
current_dictionary[name] = float(linsat.KToCurrent(k1, momentum))
|
|
45
|
+
|
|
46
|
+
with open("test_currents.yaml", "w") as file:
|
|
47
|
+
yaml.dump(current_dictionary, file)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
|
|
3
|
+
sys.path.append("..")
|
|
4
|
+
|
|
5
|
+
from pprint import pprint # noqa E402
|
|
6
|
+
from PAdantic.models.magnetic import Quadrupole_Magnet # noqa E402
|
|
7
|
+
from PAdantic.models.physical import PhysicalElement, Position # noqa E402
|
|
8
|
+
from PAdantic.models.element import Quadrupole # noqa E402
|
|
9
|
+
from PAdantic.models.elementList import MachineModel # noqa E402
|
|
10
|
+
from PAdantic.PAdantic import PAdantic # noqa E402
|
|
11
|
+
|
|
12
|
+
# We are able to specify layouts even without section definitions
|
|
13
|
+
machine = MachineModel(
|
|
14
|
+
layout={
|
|
15
|
+
"layouts": {
|
|
16
|
+
"line1": {
|
|
17
|
+
"FODO": ["QUAD1"],
|
|
18
|
+
"NODO": ["QUAD2"],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
# Make an element from scratch and add it to the machine
|
|
25
|
+
q1 = Quadrupole(
|
|
26
|
+
name="QUAD1",
|
|
27
|
+
machine_area="FODO",
|
|
28
|
+
magnetic=Quadrupole_Magnet(
|
|
29
|
+
length=0.1,
|
|
30
|
+
k1l=1.0,
|
|
31
|
+
),
|
|
32
|
+
physical=PhysicalElement(
|
|
33
|
+
middle=Position(
|
|
34
|
+
x=0,
|
|
35
|
+
y=0,
|
|
36
|
+
z=0.1,
|
|
37
|
+
),
|
|
38
|
+
length=0.1,
|
|
39
|
+
),
|
|
40
|
+
)
|
|
41
|
+
machine.append({q1.name: q1})
|
|
42
|
+
print(f"Machine sections after QUAD-01 addition: {machine.sections}")
|
|
43
|
+
|
|
44
|
+
# Make another element from scratch and add it to the machine
|
|
45
|
+
q2 = Quadrupole(
|
|
46
|
+
name="QUAD2",
|
|
47
|
+
machine_area="NODO",
|
|
48
|
+
magnetic=Quadrupole_Magnet(
|
|
49
|
+
length=0.1,
|
|
50
|
+
k1l=1.0,
|
|
51
|
+
),
|
|
52
|
+
physical=PhysicalElement(
|
|
53
|
+
middle=Position(
|
|
54
|
+
x=0,
|
|
55
|
+
y=0,
|
|
56
|
+
z=0.5,
|
|
57
|
+
),
|
|
58
|
+
length=0.1,
|
|
59
|
+
),
|
|
60
|
+
)
|
|
61
|
+
machine.append({q2.name: q2})
|
|
62
|
+
|
|
63
|
+
print("============= Machine Model Creation =============")
|
|
64
|
+
# Check the sections and layouts have been built correctly
|
|
65
|
+
print(f"Machine sections after QUAD-02 addition: {machine.sections}")
|
|
66
|
+
print(f"Machine lattices after QUAD-02 addition: {machine.lattices}")
|
|
67
|
+
|
|
68
|
+
sections = {
|
|
69
|
+
"sections": {
|
|
70
|
+
"FODO": ["QUAD1"],
|
|
71
|
+
"NODO": ["QUAD2"],
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
layouts = {
|
|
75
|
+
"layouts": {
|
|
76
|
+
"line1": ["FODO", "NODO"],
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
print("============= PADantic Creation =============")
|
|
81
|
+
pa_machine = PAdantic(element_list=[q1, q2], layout=layouts, section=sections)
|
|
82
|
+
pprint(f"PADantic creation result [elements]: {pa_machine.elements}")
|
|
83
|
+
print(f"PADantic creation result [sections]: {pa_machine.sections}")
|
|
84
|
+
print(f"PADantic creation result [lattices]: {pa_machine.lattices}")
|
|
85
|
+
pa_machine.get_magnets()
|
Testing/padantic.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from pprint import pprint
|
|
3
|
+
|
|
4
|
+
sys.path.append("..")
|
|
5
|
+
from PAdantic.PAdantic import PAdantic # noqa E402
|
|
6
|
+
|
|
7
|
+
machine = PAdantic(
|
|
8
|
+
layout="../../padantic-lattices/CLARA/layouts.yaml",
|
|
9
|
+
section="../../padantic-lattices/CLARA/sections.yaml",
|
|
10
|
+
element_list="../../padantic-lattices/NEW/CLARA/YAML/",
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def flatten(xss):
|
|
15
|
+
return [x for xs in xss for x in xs]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def unique_list(a_list):
|
|
19
|
+
seen = list()
|
|
20
|
+
for x in flatten(a_list):
|
|
21
|
+
if x not in seen:
|
|
22
|
+
seen.append(x)
|
|
23
|
+
return seen
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
machine.default_path = "SP3"
|
|
27
|
+
print(machine.get_elements_s_pos())
|
|
28
|
+
pprint({d: machine.get_element(d).base_model_dump() for d in machine.get_dipoles()})
|
|
29
|
+
# exit()
|
|
30
|
+
for magnet_name in machine.get_quadrupoles():
|
|
31
|
+
linsat = machine.get_element(magnet_name).magnetic.linear_saturation_coefficients
|
|
32
|
+
kvals = magnet_name, linsat.currentToK(48, 30)
|
|
33
|
+
print(magnet_name, kvals[1]["K"], linsat.KToCurrent(kvals[1], 30))
|
|
34
|
+
print(magnet_name, kvals[1]["KL"], linsat.KLToCurrent(kvals[1], 30))
|
|
35
|
+
exit()
|
Testing/save_machine.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
|
|
3
|
+
sys.path.append("..")
|
|
4
|
+
from PAdantic.Importers.SimFrame_Loader import ( # noqa E402
|
|
5
|
+
SF_files,
|
|
6
|
+
read_SimFrame_YAML,
|
|
7
|
+
)
|
|
8
|
+
from PAdantic.Exporters.YAML import ( # noqa E402
|
|
9
|
+
export_machine,
|
|
10
|
+
export_machine_combined_file,
|
|
11
|
+
)
|
|
12
|
+
from PAdantic.models.elementList import MachineModel # noqa E402
|
|
13
|
+
from PAdantic.models.control import ControlsInformation # noqa E402
|
|
14
|
+
from PAdantic.models.element import Element # noqa E402
|
|
15
|
+
|
|
16
|
+
machine = MachineModel(
|
|
17
|
+
layout_file="../../padantic-lattices/CLARA/layouts.yaml",
|
|
18
|
+
section_file="../../padantic-lattices/CLARA/sections.yaml",
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
for f in SF_files:
|
|
22
|
+
elem = read_SimFrame_YAML(f)
|
|
23
|
+
for name, element in elem.items():
|
|
24
|
+
example_controls = {
|
|
25
|
+
"variables": {
|
|
26
|
+
"state": {
|
|
27
|
+
"identifier": f"{element.name}:STATE",
|
|
28
|
+
"dtype": "int",
|
|
29
|
+
"protocol": "CA",
|
|
30
|
+
"units": "N/A",
|
|
31
|
+
"description": f"State of {element.name}",
|
|
32
|
+
"read_only": False,
|
|
33
|
+
},
|
|
34
|
+
"setpoint": {
|
|
35
|
+
"identifier": f"{element.name}:SP",
|
|
36
|
+
"dtype": "float",
|
|
37
|
+
"protocol": "CA",
|
|
38
|
+
"units": "N/A",
|
|
39
|
+
"description": f"Setpoint of {element.name}",
|
|
40
|
+
},
|
|
41
|
+
"readback": {
|
|
42
|
+
"identifier": f"{element.name}:RBV",
|
|
43
|
+
"dtype": "float",
|
|
44
|
+
"protocol": "CA",
|
|
45
|
+
"units": "N/A",
|
|
46
|
+
"description": f"Readback of {element.name}",
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
controls = ControlsInformation(**example_controls)
|
|
51
|
+
if isinstance(element, Element):
|
|
52
|
+
element.controls = controls
|
|
53
|
+
machine.update({n: e for n, e in elem.items()})
|
|
54
|
+
machine.update({n: e for n, e in elem.items()})
|
|
55
|
+
|
|
56
|
+
export_machine("../../padantic-lattices/CLARA_export/YAML", machine)
|
|
57
|
+
export_machine_combined_file("../../padantic-lattices/CLARA_export/", machine)
|
Testing/test.yaml
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
alias: null
|
|
2
|
+
controls:
|
|
3
|
+
GETSETI: CLA-S07-MAG-QUAD-01:GETSETI
|
|
4
|
+
ILK_RESET: CLA-S07-MAG-QUAD-01:Rst
|
|
5
|
+
INT_STR: CLA-S07-MAG-QUAD-01:INT_STR
|
|
6
|
+
INT_STR_MM: CLA-S07-MAG-QUAD-01:INT_STR_MM
|
|
7
|
+
K_ANG: CLA-S07-MAG-QUAD-01:K_ANG
|
|
8
|
+
K_DIP_P: CLA-S07-MAG-QUAD-01:K_DIP_P
|
|
9
|
+
K_MRAD: CLA-S07-MAG-QUAD-01:K_MRAD
|
|
10
|
+
K_SET_P: CLA-S07-MAG-QUAD-01:K_SET_P
|
|
11
|
+
K_VAL: CLA-S07-MAG-QUAD-01:K_VAL
|
|
12
|
+
READI: CLA-S07-MAG-QUAD-01:READI
|
|
13
|
+
RILK: CLA-S07-MAG-QUAD-01:RILK
|
|
14
|
+
RPOWER: CLA-S07-MAG-QUAD-01:RPOWER
|
|
15
|
+
SETI: CLA-S07-MAG-QUAD-01:SETI
|
|
16
|
+
SPOWER: CLA-S07-MAG-QUAD-01:SPOWER
|
|
17
|
+
degauss:
|
|
18
|
+
steps: 11
|
|
19
|
+
tolerance: 0.5
|
|
20
|
+
values: [94.81, -94.81, 57.0, -57.0, 38.0, -38.0, 19.0, -19.0, 9.5, -9.5, 0.0]
|
|
21
|
+
electrical:
|
|
22
|
+
maxI: 95
|
|
23
|
+
minI: -95.0
|
|
24
|
+
read_tolerance: 0.1
|
|
25
|
+
hardware_class: Magnet
|
|
26
|
+
hardware_type: Quadrupole
|
|
27
|
+
machine_area: S07
|
|
28
|
+
magnetic:
|
|
29
|
+
field_integral_coefficients:
|
|
30
|
+
coefficients: [0]
|
|
31
|
+
length: 0.15
|
|
32
|
+
linear_saturation_coefficients:
|
|
33
|
+
I0: 276.83934324438246
|
|
34
|
+
I_max: 86.68317235082367
|
|
35
|
+
L: 173.0
|
|
36
|
+
a: -0.000105175752221088
|
|
37
|
+
d: 7.1045011906834175
|
|
38
|
+
f: 0.0
|
|
39
|
+
m: 0.03817924790625646
|
|
40
|
+
multipoles:
|
|
41
|
+
K1L:
|
|
42
|
+
normal: 0.362686
|
|
43
|
+
order: 1
|
|
44
|
+
radius: 0.0
|
|
45
|
+
skew: 0.0
|
|
46
|
+
order: 1
|
|
47
|
+
random_multipoles: {}
|
|
48
|
+
settle_time: 45.0
|
|
49
|
+
skew: false
|
|
50
|
+
systematic_multipoles: {}
|
|
51
|
+
manufacturer:
|
|
52
|
+
hardware_class: Magnet
|
|
53
|
+
manufacturer: Quadrupole Type QFA
|
|
54
|
+
serial_number: '8'
|
|
55
|
+
name: CLA-S07-MAG-QUAD-01
|
|
56
|
+
physical:
|
|
57
|
+
error:
|
|
58
|
+
position: [0.0, 0.0, 0.0]
|
|
59
|
+
rotation: [0.0, 0.0, 0.0]
|
|
60
|
+
global_rotation: [0.0, 0.0, 0.0]
|
|
61
|
+
length: 0.15
|
|
62
|
+
middle: [0.0, 0.0, 38.852988]
|
|
63
|
+
rotation: [0.0, 0.0, 0.0]
|
|
64
|
+
survey:
|
|
65
|
+
position: [0.0, 0.0, 0.0]
|
|
66
|
+
rotation: [0.0, 0.0, 0.0]
|
|
67
|
+
virtual_name: ''
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
CLA-S02-MAG-QUAD-01: 1.0532151200009552
|
|
2
|
+
CLA-S02-MAG-QUAD-02: -1.5909563056582057
|
|
3
|
+
CLA-S02-MAG-QUAD-03: 1.0185930603938722
|
|
4
|
+
CLA-S02-MAG-QUAD-04: -1.9753602758089224
|
|
5
|
+
CLA-S02-MAG-QUAD-05: 1.1926167811244415
|
|
6
|
+
CLA-S03-MAG-QUAD-01: -0.4552738142243507
|
|
7
|
+
CLA-S04-MAG-QUAD-01: 4.849564495274338
|
|
8
|
+
CLA-S04-MAG-QUAD-02: -12.124072708241822
|
|
9
|
+
CLA-S04-MAG-QUAD-03: 3.5294610975780896
|
|
10
|
+
CLA-S04-MAG-QUAD-04: -4.788950208967723
|
|
11
|
+
CLA-S04-MAG-QUAD-05: -1.0727687889709547
|
|
12
|
+
CLA-S04-MAG-QUAD-06: 0.7236545487016648
|
|
13
|
+
CLA-S04-MAG-QUAD-07: 9.577817893305385
|
|
14
|
+
CLA-S04-MAG-QUAD-08: -7.153628482248903
|
|
15
|
+
CLA-S05-MAG-QUAD-01: 1.8276107524696898
|
|
16
|
+
CLA-S05-MAG-QUAD-02: 0.2514816578462343
|
|
17
|
+
CLA-S06-MAG-QUAD-01: 0.24423999972649715
|
|
18
|
+
CLA-S06-MAG-QUAD-02: 1.2582419093928305
|
|
19
|
+
CLA-S07-MAG-QUAD-01: 0.2993561438953997
|
|
20
|
+
CLA-S07-MAG-QUAD-02: -0.5690391264413037
|
|
21
|
+
CLA-S07-MAG-QUAD-03: -4.8547816279929
|
|
22
|
+
CLA-S07-MAG-QUAD-04: -3.101560770459436
|
|
23
|
+
CLA-S07-MAG-QUAD-05: 1.753458774648059
|
|
24
|
+
CLA-S07-MAG-QUAD-06: 2.3592674705859427
|
|
25
|
+
CLA-S07-MAG-QUAD-07: 10.533759040554989
|
|
26
|
+
CLA-S07-MAG-QUAD-08: 3.5467264403708865
|
|
27
|
+
CLA-S07-MAG-QUAD-09: -13.917088256125794
|
|
28
|
+
CLA-S07-MAG-QUAD-10: -0.07799373552930876
|
|
File without changes
|
|
File without changes
|