Ejemplo n.º 1
0
    def __init__(self, num_d=0, num_e=0, d=None, e=None, **kwargs):
        in_d_len = d is not None and d and len(d) or 0
        in_e_len = e is not None and e and len(e) or 0

        d_len = max(num_d, in_d_len)

        if d is None or not (d and len(d) > 0):
            d = np.zeros(d_len, dtype=np.dtype("uint8"))
        elif d and len(d) > 0:
            _d = np.zeros(d_len, dtype=np.dtype("uint8"))
            _d[:len(d)] = d
            d = _d

        if d is not None and len(d) == d_len:
            kwargs["d"] = d

        e_len = max(num_e, in_e_len)

        if e is None or not (e and len(e) > 0):
            e = np.zeros(e_len, dtype=np.dtype("float64"))
        elif e and len(e) > 0:
            _e = np.zeros(e_len, dtype=np.dtype("float64"))
            _e[:len(e)] = e
            e = _e

        if e is not None and len(e) == e_len:
            kwargs["e"] = e

        kwargs["num_d"] = d_len
        kwargs["num_e"] = e_len

        CObject.__init__(self, **kwargs)
Ejemplo n.º 2
0
 def __init__(self,
              knl=None,
              ksl=None,
              phn=None,
              phs=None,
              order=None,
              bal=None,
              **nargs):
     if order is None:
         if bal is None:
             order = max(len(knl), len(ksl)) - 1
         else:
             order = len(bal) // 4 - 1
     nbal = np.zeros(4 * order + 2, dtype=float)
     if bal is None:
         nbal[:len(knl) * 2:4] = knl
         nbal[1:len(ksl) * 2:4] = ksl
         nbal[::4] /= factorial[:order + 1]
         nbal[1::4] /= factorial[:order + 1]
         nbal[3:len(phn) * 2:4] = phn
         nbal[4:len(phs) * 2:4] = phs
     else:
         nbal[:len(bal)] = bal
     CObject.__init__(self,
                      order=order,
                      length=length,
                      hxl=hxl,
                      hyl=hyl,
                      bal=nbal,
                      **nargs)
Ejemplo n.º 3
0
    def __init__(self, **kwargs):
        slots = ('q_part', 'N_part', 'sigma_x', 'sigma_y', 'beta_s',
                 'min_sigma_diff', 'Delta_x', 'Delta_y', 'Dpx_sub', 'Dpy_sub',
                 'enabled')

        data = [kwargs[ss] for ss in slots]
        CObject.__init__(self, size=len(data), data=data, **kwargs)
Ejemplo n.º 4
0
    def __init__(self, num_d=0, num_e=0, d=None, e=None, **kwargs):
        in_d_len = d is not None and d and len(d) or 0
        in_e_len = e is not None and e and len(e) or 0

        d_len = max(num_d, in_d_len)

        if d is None or not(d and len(d) > 0):
            d = np.zeros(d_len, dtype=np.dtype('uint8'))
        elif d and len(d) > 0:
            _d = np.zeros(d_len, dtype=np.dtype('uint8'))
            _d[:len(d)] = d
            d = _d

        if d and len(d) == d_len:
            kwargs["d"] = d

        e_len = max(num_e, in_e_len)

        if e is None or not(e and len(e) > 0):
            e = np.zeros(e_len, dtype=np.dtype('float64'))
        elif e and len(e) > 0:
            _e = np.zeros(e_len, dtype=np.dtype('float64'))
            _e[:len(e)] = e
            e = _e

        if e and len(e) == e_len:
            kwargs["e"] = e

        kwargs["num_d"] = d_len
        kwargs["num_e"] = e_len

        CObject.__init__(self, **kwargs)
Ejemplo n.º 5
0
 def __init__(self, voltage=0.0, frequency=0, lag=0, **nargs):
     kfreq = 2 * np.pi * frequency / _clight
     phase = lag / 180 * np.pi
     CObject.__init__(self,
                      voltage=voltage,
                      kfreq=kfreq,
                      phase=phase,
                      **nargs)
Ejemplo n.º 6
0
 def __init__(self, data=None, **kwargs):
     if data is None:
         import pysixtrack
         data = pysixtrack.BB6Ddata.BB6D_init(
             **{kk: kwargs[kk] for kk in kwargs.keys() if kk != 'cbuffer'}).tobuffer()
         CObject.__init__(self, size=len(data), data=data, **kwargs)
     else:
         CObject.__init__(self, **kwargs)
Ejemplo n.º 7
0
 def __init__(self, cbuffer=None, nparticles=0, partid=None, **nargs):
     if partid is None:
         partid = np.arange(nparticles)
     CObject.__init__(self,
                      cbuffer=cbuffer,
                      nparticles=nparticles,
                      partid=partid,
                      **nargs)
Ejemplo n.º 8
0
 def __init__(self, data=None, **kwargs):
     if data is None:
         slots = (
             'q_part',
             'N_part',
             'sigma_x',
             'sigma_y',
             'beta_s',
             'min_sigma_diff',
             'Delta_x',
             'Delta_y',
             'Dpx_sub',
             'Dpy_sub',
             'enabled')
         data = [kwargs[ss] for ss in slots]
         CObject.__init__(self, size=len(data), data=data, **kwargs)
     else:
         CObject.__init__(self, **kwargs)
Ejemplo n.º 9
0
    def __init__(self, order=None, knl=None, ksl=None, bal=None, **kwargs):
        if bal is None and \
                (knl is not None or ksl is not None or order is not None):
            if knl is None:
                knl = []
            if ksl is None:
                ksl = []
            if order is None:
                order = 0

            n = max((order + 1), max(len(knl), len(ksl)))
            assert(n > 0)

            _knl = np.array(knl)
            nknl = np.zeros(n, dtype=_knl.dtype)
            nknl[:len(knl)] = knl
            knl = nknl
            del(_knl)
            assert(len(knl) == n)

            _ksl = np.array(ksl)
            nksl = np.zeros(n, dtype=_ksl.dtype)
            nksl[:len(ksl)] = ksl
            ksl = nksl
            del(_ksl)
            assert(len(ksl) == n)

            order = n - 1
            bal = np.zeros(2 * order + 2)

            for ii in range(0, len(knl)):
                inv_factorial = 1.0 / float(Multipole._factorial(ii))
                jj = 2 * ii
                bal[jj] = knl[ii] * inv_factorial
                bal[jj + 1] = ksl[ii] * inv_factorial

            kwargs["bal"] = bal
            kwargs["order"] = order

        elif bal is not None and bal and len(bal) > 2 and ((len(bal) % 2) == 0):
            kwargs["bal"] = bal
            kwargs["order"] = (len(bal) - 2) / 2

        CObject.__init__(self, **kwargs)
Ejemplo n.º 10
0
 def __init__(self, knl=None, ksl=None, order=None, bal=None, **nargs):
     if knl is None:
         knl = []
     if ksl is None:
         ksl = []
     if order is None:
         if bal is None:
             order = max(len(knl), len(ksl) - 1)
         else:
             order = len(bal) // 2 - 1
     nbal = np.zeros(2 * order + 2, dtype=float)
     if bal is None:
         nbal[:len(knl) * 2:2] = knl
         nbal[1:len(ksl) * 2:2] = ksl
         nbal[::2] /= _factorial[:order + 1]
         nbal[1::2] /= _factorial[:order + 1]
     else:
         nbal[:len(bal)] = bal
     CObject.__init__(self, order=order, bal=nbal, **nargs)
Ejemplo n.º 11
0
 def __init__(self, cbuffer, elements=None):
     if elements is None:
         elements = np.arange(cbuffer.n_objects, dtype="int64")
     CObject.__init__(self, n_elements=len(elements), elements=elements)
Ejemplo n.º 12
0
 def __init__(self, **kwargs):
     import pysixtrack
     data = pysixtrack.BB6Ddata.BB6D_init(
         **{kk: kwargs[kk]
            for kk in kwargs.keys() if kk != 'cbuffer'}).tobuffer()
     CObject.__init__(self, size=len(data), data=data, **kwargs)
Ejemplo n.º 13
0
 def __init__(self, angle=0, **nargs):
     anglerad = angle / 180 * np.pi
     cos_z = np.cos(anglerad)
     sin_z = np.sin(anglerad)
     CObject.__init__(self, cos_z=cos_z, sin_z=sin_z, **nargs)
Ejemplo n.º 14
0
 def __init__(self, angle=0, **nargs):
     anglerad = angle / 180 * np.pi
     cos_z = np.cos(anglerad)
     sin_z = np.sin(anglerad)
     CObject.__init__(self,
                      cos_z=cos_z, sin_z=sin_z, **nargs)
Ejemplo n.º 15
0
 def __init__(self, data, **kwargs):
     CObject.__init__(self, size=len(data), data=data, **kwargs)