nobeam / latticejson

A JSON based lattice file format
https://nobeam.github.io/latticejson
GNU General Public License v3.0
12 stars 2 forks source link

Move root lattice definition to `lattices` dict #51

Closed felix-andreas closed 4 years ago

felix-andreas commented 4 years ago

Fixes: #19

New Structure:

{
  "version": "2.0",
  "title": "FODO Lattice",
  "info": "This is the simplest possible strong focusing lattice.",
  "root": "RING",
  "elements": {
    "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}]
  },
  "lattices": {
    "CELL": ["Q1", "D1", "B1", "D1", "Q2", "D1", "B1", "D1", "Q1"],
    "RING": ["CELL", "CELL", "CELL", "CELL", "CELL", "CELL", "CELL", "CELL"]
  }
}

Motivation: Sometimes it is necessary to have a dict of ALL lattices. Currently one has to write

all_lattices = {**sub_lattices, lattice}

to achieve this. I cannot come up with a case where it would be beneficial to have a dict ONLY containing sub-lattices.

This makes it also easier to generate a sub_lattice file: Just replace the "root" attribute.

Naming: Other options for the name of the root attribute would be main, base, use (like MADX) or main_lattice.

@tomerten @PaulGoslawski Any comments?

PaulGoslawski commented 4 years ago

I would prefer to use main_lattice instead of all other proposals! All other proposals are used in other contexts. main_lattice is clearly defined.