@@ -171,40 +171,45 @@ def test_comprehensive_lattice():
171171 wiggler = pals .Wiggler (name = "wiggler1" , length = 2.0 )
172172
173173 # Create comprehensive lattice
174- lattice = pals .BeamLine (
174+ lattice = pals .Lattice (
175175 name = "comprehensive_lattice" ,
176- line = [
177- beginning , # Start with beginning element
178- fiducial , # Global coordinate reference
179- marker , # Mark position
180- drift , # Field-free region
181- quadrupole , # Focusing element
182- sextupole , # Chromatic correction
183- octupole , # Higher order correction
184- multipole , # General multipole
185- rbend , # Rectangular bend
186- sbend , # Sector bend
187- solenoid , # Longitudinal focusing
188- rfcavity , # RF acceleration
189- crabcavity , # RF crab cavity
190- kicker , # Transverse kick
191- ackicker , # AC kicker
192- patch , # Coordinate transformation
193- floorshift , # Global coordinate shift
194- instrument , # Measurement device
195- mask , # Collimation
196- match , # Matching element
197- egun , # Electron source
198- converter , # Species conversion
199- foil , # Electron stripping
200- beambeam , # Colliding beams
201- feedback , # Feedback system
202- girder , # Support structure
203- fork , # Branch connection
204- taylor , # Taylor map
205- unionele , # Overlapping elements
206- wiggler , # Undulator
207- nullele , # Placeholder
176+ branches = [
177+ pals .BeamLine (
178+ name = "comprehensive_beamline" ,
179+ line = [
180+ beginning , # Start with beginning element
181+ fiducial , # Global coordinate reference
182+ marker , # Mark position
183+ drift , # Field-free region
184+ quadrupole , # Focusing element
185+ sextupole , # Chromatic correction
186+ octupole , # Higher order correction
187+ multipole , # General multipole
188+ rbend , # Rectangular bend
189+ sbend , # Sector bend
190+ solenoid , # Longitudinal focusing
191+ rfcavity , # RF acceleration
192+ crabcavity , # RF crab cavity
193+ kicker , # Transverse kick
194+ ackicker , # AC kicker
195+ patch , # Coordinate transformation
196+ floorshift , # Global coordinate shift
197+ instrument , # Measurement device
198+ mask , # Collimation
199+ match , # Matching element
200+ egun , # Electron source
201+ converter , # Species conversion
202+ foil , # Electron stripping
203+ beambeam , # Colliding beams
204+ feedback , # Feedback system
205+ girder , # Support structure
206+ fork , # Branch connection
207+ taylor , # Taylor map
208+ unionele , # Overlapping elements
209+ wiggler , # Undulator
210+ nullele , # Placeholder
211+ ],
212+ )
208213 ],
209214 )
210215
@@ -217,10 +222,13 @@ def test_comprehensive_lattice():
217222 print (f"\n Comprehensive lattice YAML:\n { file .read ()} " )
218223
219224 # Deserialize back to Python object using Pydantic model logic
220- loaded_lattice = pals .BeamLine .from_file (yaml_file )
225+ loaded_lattice = pals .Lattice .from_file (yaml_file )
221226
222227 # Verify the loaded lattice has the correct structure and parameter groups
223- assert len (loaded_lattice .line ) == 31 # Should have 31 elements
228+ assert len (loaded_lattice .branches ) == 1 # Should have 1 branch
229+ assert (
230+ len (loaded_lattice .branches [0 ].line ) == 31
231+ ) # Should have 31 elements in the branch
224232
225233 # Verify specific elements with parameter groups are correctly loaded
226234 sextupole_loaded = None
@@ -229,7 +237,7 @@ def test_comprehensive_lattice():
229237 rfcavity_loaded = None
230238 unionele_loaded = None
231239
232- for elem in loaded_lattice .line :
240+ for elem in loaded_lattice .branches [ 0 ]. line :
233241 if elem .name == "sextupole1" :
234242 sextupole_loaded = elem
235243 elif elem .name == "octupole1" :
@@ -272,10 +280,13 @@ def test_comprehensive_lattice():
272280 print (f"\n Comprehensive lattice JSON:\n { file .read ()} " )
273281
274282 # Deserialize back to Python object using Pydantic model logic
275- loaded_lattice_json = pals .BeamLine .from_file (json_file )
283+ loaded_lattice_json = pals .Lattice .from_file (json_file )
276284
277285 # Verify the loaded lattice has the correct structure and parameter groups
278- assert len (loaded_lattice_json .line ) == 31 # Should have 31 elements
286+ assert len (loaded_lattice_json .branches ) == 1 # Should have 1 branch
287+ assert (
288+ len (loaded_lattice_json .branches [0 ].line ) == 31
289+ ) # Should have 31 elements in the branch
279290
280291 # Verify specific elements with parameter groups are correctly loaded
281292 sextupole_loaded_json = None
@@ -284,7 +295,7 @@ def test_comprehensive_lattice():
284295 rfcavity_loaded_json = None
285296 unionele_loaded_json = None
286297
287- for elem in loaded_lattice_json .line :
298+ for elem in loaded_lattice_json .branches [ 0 ]. line :
288299 if elem .name == "sextupole1" :
289300 sextupole_loaded_json = elem
290301 elif elem .name == "octupole1" :
0 commit comments