Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add markers #59

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dea69fa
- Updated schema.json to include marker
tomerten May 26, 2020
929b570
Automated Code Formatting using Black
felix-andreas May 26, 2020
e554b78
add newline to end of file
felix-andreas May 26, 2020
7ef86a5
Merge branch 'master' into add-markers-tom
felix-andreas May 28, 2020
b0e15da
add space to end of file
felix-andreas Jul 2, 2020
c83d039
Merge branch 'add-markers-tom' of https://github.com/nobeam/latticejs…
tomerten Jul 2, 2020
4fdc191
- updated example.json in test to include monitor
tomerten Jul 2, 2020
4f06242
Delete README.txt
felix-andreas Jul 2, 2020
3799c08
- added Monitor
Jul 2, 2020
aa9d286
- added marker to tests
Jul 2, 2020
b7f1751
- updated version number in examplewq
tomerten Jul 2, 2020
6bf5031
- added Hcor and Vcor
Jul 2, 2020
03f5c82
- corrected typo in schema.json
Jul 2, 2020
327d0b1
- corrected Kick to kick in hcor and vcor
Jul 2, 2020
f1279c0
Automated Code Formatting using Black
felix-andreas Jul 3, 2020
71d7c6a
- added kicker (non linear kicker in lattice)
Jul 3, 2020
9188328
Merge branch 'add-markers-tom' of https://github.com/nobeam/latticejs…
Jul 3, 2020
739de83
- cavity removed voltage from being required both madx and elegant have
Jul 3, 2020
bcca405
Merge branch 'add-markers-tom' of https://github.com/nobeam/latticejs…
Jul 3, 2020
9eaeabe
- Working version
Jul 3, 2020
5deb2f6
- added k1 to dipoles in order to be able to convert Ji-Gwuang his
Jul 3, 2020
6b69c50
Automated Code Formatting using Black
felix-andreas Jul 3, 2020
589fba7
* updated schema to include multipole for converting maxiv lattice
Jul 3, 2020
5b9c651
- moved array to madx transformer
Jul 3, 2020
b9ac171
Merge branch 'add-markers-tom' of https://github.com/nobeam/latticejs…
Jul 3, 2020
37da071
added various attrs for dipole kicker and cavity
Jul 16, 2020
4fc9b2d
Automated Code Formatting using Black
felix-andreas Jul 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions latticejson/map.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"description": "LatticeJSON, elegant, MADX",
"map": [
["Marker", ["MARK"], ["MARKER"]],
["Drift", ["DRIF", "DRIFT"], ["DRIFT"], ["DRIFT"]],
["Dipole", ["CSBEND", "SBEND", "BEND"], ["SBEND", "RBEND"]],
["Quadrupole", ["KQUAD", "QUAD", "QUADRUPOLE"], ["QUADRUPOLE"]],
Expand Down
22 changes: 22 additions & 0 deletions latticejson/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
"patternProperties": {
"^.*$": {
"oneOf": [
{
"$ref": "#/definitions/Marker"
},
{
"$ref": "#/definitions/Drift"
},
Expand Down Expand Up @@ -119,6 +122,25 @@
}
]
},
"Marker": {
"items": [
{
"const": "Marker"
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"info": {},
"length": {},
"dx": {},
"dy": {},
"ds": {},
"tilt": {}
}
}
]
},
"Drift": {
"allOf": [
{
Expand Down
5 changes: 3 additions & 2 deletions tests/data/fodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
"info": "This is the simplest possible strong focusing lattice.",
"root": "RING",
"elements": {
"M1": ["Marker", {}],
"D1": ["Drift", {"length": 0.55}],
"Q1": ["Quadrupole", {"length": 0.2, "k1": 1.2}],
"Q2": ["Quadrupole", {"length": 0.4, "k1": -1.2}],
"B1": ["Dipole", {"length": 1.5, "angle": 0.392701, "e1": 0.1963505, "e2": 0.1963505}]
"B1": ["Dipole", {"length": 1.5, "angle": 0.39269908169872414 , "e1": 0.19634954084936207 ,"e2": 0.19634954084936207}]
},
"lattices": {
"CELL": ["Q1", "D1", "B1", "D1", "Q2", "D1", "B1", "D1", "Q1"],
"CELL": ["M1", "Q1", "D1", "B1", "D1", "Q2", "D1", "B1", "D1", "Q1"],
"RING": ["CELL", "CELL", "CELL", "CELL", "CELL", "CELL", "CELL", "CELL"]
}
}
5 changes: 3 additions & 2 deletions tests/data/fodo.lte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Q1 :KQUAD, L="2 10 /", K1=1.2
% pi 8 / sto angle
% 1 atan 4 * sto custom_pi

M1 : MARK
B1 : CSBEND, L=.15e+1, ANGLE="angle", &
E1="pi 16 /", e2="custom_pi 16 /"
FODO : LINE = (Q1, D1, B1, D1, Q2, D1, B1, D1, Q1)
RING : LINE = (2*(-2*-(2*FODO)))
CELL : LINE = (M1, Q1, D1, B1, D1, Q2, D1, B1, D1, Q1)
RING : LINE = (2*(-2*-(2*CELL)))
3 changes: 2 additions & 1 deletion tests/data/fodo.madx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ D1: DRIFT, L=0.55; !! comment with two !!
! * multiline comment
! */

M1 : MARKER;
B1 : SBEND, L=1.5, ANGLE=TWOPI/16, // MAD supports inline evaluation
E1=0.1963505 * 2 / 2, E2=PI/16;
SUB : LINE = (Q1, D1, B1, D1);
SUB : LINE = (M1, Q1, D1, B1, D1);
FODO : LINE = (SUB, Q2, -SUB);
RING : LINE = 2 * (FODO, FODO, FODO, FODO);
USE, RING;
Expand Down
18 changes: 18 additions & 0 deletions tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,31 @@


def test_to_elegant():
expected = (
"! TITLE: FODO Lattice\n"
"M1: MARK, \n"
"D1: DRIF, L=0.55\n"
"Q1: KQUAD, L=0.2, K1=1.2\n"
"Q2: KQUAD, L=0.4, K1=-1.2\n"
"B1: CSBEND, L=1.5, ANGLE=0.39269908169872414, E1=0.19634954084936207, "
"E2=0.19634954084936207\n"
"CELL: LINE=(M1, Q1, D1, B1, D1, Q2, D1, B1, D1, Q1)\n"
"RING: LINE=(CELL, CELL, CELL, CELL, CELL, CELL, CELL, CELL)\n"
"USE, RING\n"
)

felix-andreas marked this conversation as resolved.
Show resolved Hide resolved
elegant = to_elegant(fodo_json)
print(elegant)
assert expected == elegant


def test_from_elegant():
latticejson = from_elegant(fodo_lte)
latticejson.pop("title")
fodo_json.pop("info")
fodo_json.pop("title")
print(latticejson)
assert sorted(latticejson.items()) == sorted(fodo_json.items())


# Uncomment to test for elegant examples
Expand Down