@@ -1404,3 +1404,85 @@ def getUsage(self):
14041404 field will be used in calculation.
14051405 """
14061406 return self .__usage
1407+
1408+
1409+ class ContinuousFocusingTEAPOT (NodeTEAPOT ):
1410+ def __init__ (self , name = "continuous focusing no name" ):
1411+ NodeTEAPOT .__init__ (self , name )
1412+
1413+ self .addParam ("kq" , 0.0 )
1414+ self .addParam ("poles" , [])
1415+ self .addParam ("kls" , [])
1416+ self .addParam ("skews" , [])
1417+ self .setnParts (2 )
1418+ self .waveform = None
1419+
1420+ self .getNodeTiltIN ().setType ("continuous focusing tilt in" )
1421+ self .getNodeTiltOUT ().setType ("continuous focusing tilt out" )
1422+
1423+ self .setType ("continuous focusing" )
1424+
1425+ def initialize (self ):
1426+ nParts = self .getnParts ()
1427+ if nParts < 2 :
1428+ msg = "The Quad Combined Function TEAPOT class instance should have more than 2 parts!"
1429+ msg = msg + os .linesep
1430+ msg = msg + "Method initialize():"
1431+ msg = msg + os .linesep
1432+ msg = msg + "Name of element=" + self .getName ()
1433+ msg = msg + os .linesep
1434+ msg = msg + "Type of element=" + self .getType ()
1435+ msg = msg + os .linesep
1436+ msg = msg + "nParts =" + str (nParts )
1437+ orbitFinalize (msg )
1438+
1439+ lengthIN = (self .getLength () / (nParts - 1 )) / 2.0
1440+ lengthOUT = (self .getLength () / (nParts - 1 )) / 2.0
1441+ lengthStep = lengthIN + lengthOUT
1442+ self .setLength (lengthIN , 0 )
1443+ self .setLength (lengthOUT , nParts - 1 )
1444+ for i in range (nParts - 2 ):
1445+ self .setLength (lengthStep , i + 1 )
1446+
1447+ def track (self , paramsDict ):
1448+ nParts = self .getnParts ()
1449+ index = self .getActivePartIndex ()
1450+ length = self .getLength (index )
1451+
1452+ strength = 1.0
1453+ if self .waveform :
1454+ strength = self .waveform .getStrength ()
1455+
1456+ kq = strength * self .getParam ("kq" )
1457+ poleArr = self .getParam ("poles" )
1458+ klArr = self .getParam ("kls" )
1459+ skewArr = self .getParam ("skews" )
1460+
1461+ bunch = paramsDict ["bunch" ]
1462+
1463+ useCharge = 1
1464+ if "useCharge" in paramsDict :
1465+ useCharge = paramsDict ["useCharge" ]
1466+
1467+ if index == 0 :
1468+ TPB .continuousLinear (bunch , length , kq , useCharge )
1469+ return
1470+ if index > 0 and index < (nParts - 1 ):
1471+ for i in range (len (poleArr )):
1472+ pole = poleArr [i ]
1473+ kl = strength * klArr [i ] / (nParts - 1 )
1474+ skew = skewArr [i ]
1475+ TPB .multp (bunch , pole , kl , skew , useCharge )
1476+ TPB .continuousLinear (bunch , length , kq , useCharge )
1477+ return
1478+ if index == (nParts - 1 ):
1479+ for i in range (len (poleArr )):
1480+ pole = poleArr [i ]
1481+ kl = strength * klArr [i ] / (nParts - 1 )
1482+ skew = skewArr [i ]
1483+ TPB .multp (bunch , pole , kl , skew , useCharge )
1484+ TPB .continuousLinear (bunch , length , kq , useCharge )
1485+ return
1486+
1487+ def setWaveform (self , waveform ):
1488+ self .waveform = waveform
0 commit comments