9797 'angle' ,
9898 'vkick' ,
9999 'hkick' ,
100+ 'knl' ,
101+ 'ksl' ,
100102}
101103
102104
@@ -304,6 +306,8 @@ def _split_length(self, points):
304306 accumulated_length = 0.0
305307 split_elements = []
306308 This = type (self ) # This class, we use to construct the output.
309+ if This == Element :
310+ raise TypeError ("Only a specific element can be split." )
307311 # Not length or name. We change these here. We leave
308312 # updating other parameters (based on length or otherwise) to
309313 # other methods or functions.
@@ -320,13 +324,16 @@ def _split_length(self, points):
320324
321325 def split_strength (kwo , sub_section_length ):
322326 kwargs = kwo .copy ()
327+ f = sub_section_length / total_length
323328 for k in splittable_strengths :
324329 v = other_kwargs [k ]
325330 if type (v ) == tuple :
326- nv = v [0 ] * (length / total_length )
327- kwargs [k ] = (nv , v [1 ])
331+ if k in ('knl' , 'ksl' ):
332+ kwargs [k ] = tuple (vi * f for vi in v )
333+ else :
334+ kwargs [k ] = (v [0 ] * f , v [1 ])
328335 else :
329- kwargs [k ] = v * ( length / total_length )
336+ kwargs [k ] = v * f
330337 return kwargs
331338
332339 i = 0
@@ -335,14 +342,14 @@ def split_strength(kwo, sub_section_length):
335342 length = round (point - accumulated_length , 15 )
336343 accumulated_length += length
337344 kws = split_strength (other_kwargs , length )
338- split_elements .append (This (name , category , l = length , ** kws ))
345+ split_elements .append (This (name , l = length , ** kws ))
339346 i += 1
340347
341348 # Add the final element (for n points we have n+1 elements, so
342349 # we add the last one here "by hand").
343350 left_over_length = round (total_length - accumulated_length , 15 )
344351 kws = split_strength (other_kwargs , left_over_length )
345- split_elements .append (This ("{}_split_{}" .format (self ['name' ], i + 1 ), category , l = left_over_length , ** kws ))
352+ split_elements .append (This ("{}_split_{}" .format (self ['name' ], i ) , l = left_over_length , ** kws ))
346353
347354 return split_elements
348355
@@ -584,17 +591,6 @@ class Multipole(Element):
584591 def __init__ (self , name , l , knl , ksl , ** kwargs ):
585592 Element .__init__ (self , name , 'multipole' , l = l , knl = knl , ksl = ksl , ** kwargs )
586593
587- def split (self , points ):
588- split_mps = self ._split_length (points )
589- for mp in split_mps :
590- new_knl = tuple ([integrated_strength * mp ['l' ] / self ['l' ]
591- for integrated_strength in mp ['knl' ]])
592- new_ksl = tuple ([integrated_strength * mp ['l' ] / self ['l' ]
593- for integrated_strength in mp ['ksl' ]])
594- mp ['knl' ] = new_knl
595- mp ['ksl' ] = new_ksl
596- return split_mps
597-
598594
599595class ThinMultipole (Element ):
600596 def __init__ (self , name , knl = (0 ,0 ), ksl = (0 ,0 ), ** kwargs ):
0 commit comments