コード例 #1
0
ファイル: sim_functions.py プロジェクト: radiasoft/rsopt
def APPLE_II(_per, _nper, _gap, _gapx, _phase, _phase_type, _lx, _lz, _cx, _cz, _air, _br, _mu, _ndiv, _bs1, _s1, _bs2, _s2, _bs3, _s3, _bs2dz, _qp_ind_mag, _qp_dz, _use_sym=False):

    w = [_lx,_per/4-_air,_lz]
    px = _lx/2+_gapx/2;
    pz = _gap/2+_lz/2;

    p1 = 0; p2 = _phase; p3 = 0; p4 = _phase
    if(_phase_type < 0): p2 = -_phase

    #print('w =', w)
    g1 = MagnetArray(_per, _nper, _po=[px,p1,pz], _w=w, _si=1, _type=1, _cx=_cx, _cz=_cz, _br=_br, _mu=_mu, _ndiv=_ndiv,
                     _bs1=_bs1, _s1=_s1, _bs2=_bs2, _s2=_s2, _bs3=_bs3, _s3=_s3, _bs2dz=_bs2dz, _qp_ind_mag=_qp_ind_mag, _qp_dz=_qp_dz)

    g2 = MagnetArray(_per, _nper, _po=[-px,p2,pz], _w=w, _si=1, _type=2, _cx=_cx, _cz=_cz, _br=_br, _mu=_mu, _ndiv=_ndiv,
                     _bs1=_bs1, _s1=_s1, _bs2=_bs2, _s2=_s2, _bs3=_bs3, _s3=_s3, _bs2dz=_bs2dz, _qp_ind_mag=_qp_ind_mag, _qp_dz=_qp_dz)

    if(_use_sym):
        u = rad.ObjCnt([g1,g2])
        trf = rad.TrfCmbL(rad.TrfRot([0,0,0],[0,1,0],pi), rad.TrfInv())
        rad.TrfMlt(u, trf, 2)
        return u, g1, g2, 0, 0

    g3 = MagnetArray(_per, _nper, _po=[-px,p3,-pz], _w=w, _si=-1, _type=1, _cx=_cx, _cz=_cz, _br=-_br, _mu=_mu, _ndiv=_ndiv,
                     _bs1=_bs1, _s1=_s1, _bs2=_bs2, _s2=_s2, _bs3=_bs3, _s3=_s3, _bs2dz=_bs2dz, _qp_ind_mag=_qp_ind_mag, _qp_dz=_qp_dz)

    g4 = MagnetArray(_per, _nper, _po=[px,p4,-pz], _w=w, _si=-1, _type=2, _cx=_cx, _cz=_cz, _br=-_br, _mu=_mu, _ndiv=_ndiv,
                     _bs1=_bs1, _s1=_s1, _bs2=_bs2, _s2=_s2, _bs3=_bs3, _s3=_s3, _bs2dz=_bs2dz, _qp_ind_mag=_qp_ind_mag, _qp_dz=_qp_dz)

    u = rad.ObjCnt([g1,g2,g3,g4])
    return u, g1, g2, g3, g4
コード例 #2
0
ファイル: radia_tk.py プロジェクト: biaobin/sirepo
def _apply_clone(g_id, xform):
    # start with 'identity'
    xf = radia.TrfTrsl([0, 0, 0])
    for clone_xform in xform.transforms:
        cxf = PKDict(clone_xform)
        if cxf.model == 'translateClone':
            txf = radia.TrfTrsl(_split_comma_field(cxf.distance, 'float'))
            xf = radia.TrfCmbL(xf, txf)
        if cxf.model == 'rotateClone':
            rxf = radia.TrfRot(_split_comma_field(cxf.center, 'float'),
                               _split_comma_field(cxf.axis, 'float'),
                               numpy.pi * float(cxf.angle) / 180.)
            xf = radia.TrfCmbL(xf, rxf)
    if xform.alternateFields != '0':
        xf = radia.TrfCmbL(xf, radia.TrfInv())
    radia.TrfMlt(g_id, xf, xform.numCopies + 1)
コード例 #3
0
ファイル: radia_util.py プロジェクト: mkeilman/sirepo
def _apply_clone(g_id, xform):
    xform = PKDict(xform)
    # start with 'identity'
    xf = radia.TrfTrsl([0, 0, 0])
    for clone_xform in xform.transforms:
        cxf = PKDict(clone_xform)
        if cxf.model == 'translateClone':
            txf = radia.TrfTrsl(
                sirepo.util.split_comma_delimited_string(cxf.distance, float)
            )
            xf = radia.TrfCmbL(xf, txf)
        if cxf.model == 'rotateClone':
            rxf = radia.TrfRot(
                sirepo.util.split_comma_delimited_string(cxf.center, float),
                sirepo.util.split_comma_delimited_string(cxf.axis, float),
                numpy.pi * float(cxf.angle) / 180.
            )
            xf = radia.TrfCmbL(xf, rxf)
    if xform.alternateFields != '0':
        xf = radia.TrfCmbL(xf, radia.TrfInv())
    radia.TrfMlt(g_id, xf, xform.numCopies + 1)
コード例 #4
0
ファイル: radia_util.py プロジェクト: mkeilman/sirepo
def _clone_with_translation(g_id, num_copies, distance, alternate_fields):
    xf = radia.TrfTrsl(distance)
    if alternate_fields:
        xf = radia.TrfCmbL(xf, radia.TrfInv())
    radia.TrfMlt(g_id, xf, num_copies + 1)
コード例 #5
0
def Geom():

    #Pole faces
    rap = 0.5
    ct = [0, 0, 0]
    z0 = gap / 2
    y0 = width / 2
    amax = hyp * asinh(y0 / z0)
    dz = z0 * (cosh(amax) - 1)
    aStep = amax / np
    na = int(amax * (1 + 2 / np) / aStep) + 1
    qq = [[(z0 * sinh(ia * aStep / hyp)), (z0 * cosh(ia * aStep))]
          for ia in range(na)]
    hh = qq[np][1] + height * rap - dz
    qq[np + 1] = [qq[np][0], hh]
    qq[np + 2] = [0, hh]
    g1 = rad.ObjThckPgn(thick / 4, thick / 2, qq)
    rad.ObjDivMag(g1, n1)

    #Vertical segment on top of pole faces
    g2 = rad.ObjRecMag(
        [thick / 4, width / 4, gap / 2 + height * (1 / 2 + rap / 2)],
        [thick / 2, width / 2, height * (1 - rap)])
    rad.ObjDivMag(g2, n2)

    #Corner
    gg = rad.ObjCnt([g1, g2])
    gp = rad.ObjCutMag(gg, [thick / 2 - chamfer - gap / 2, 0, 0],
                       [1, 0, -1])[0]
    g3 = rad.ObjRecMag([thick / 4, width / 4, gap / 2 + height + depth / 2],
                       [thick / 2, width / 2, depth])
    cy = [[[0, width / 2, gap / 2 + height], [1, 0, 0]],
          [0, 0, gap / 2 + height], 2 * depth / width]
    rad.ObjDivMag(g3, [nr3, np3, nx], 'cyl', cy)

    #Horizontal segment between the corners
    tan_n = tan(2 * pi / 2 / Nn)
    length = tan_n * (height + gap / 2) - width / 2
    g4 = rad.ObjRecMag(
        [thick / 4, width / 2 + length / 2, gap / 2 + height + depth / 2],
        [thick / 2, length, depth])
    rad.ObjDivMag(g4, n4)

    #The other corner
    posy = width / 2 + length
    posz = posy / tan_n
    g5 = rad.ObjThckPgn(thick / 4, thick / 2,
                        [[posy, posz], [posy, posz + depth],
                         [posy + depth * tan_n, posz + depth]])
    cy = [[[0, posy, posz], [1, 0, 0]], [0, posy, posz + depth], 1]
    rad.ObjDivMag(g5, [nr5, np5, nx], 'cyl', cy)

    #Generation of the coil
    Rmax = Rmin - width / 2 + gap / 2 + offset - 2
    coil1 = rad.ObjRaceTrk([0, 0, gap / 2 + height / 2 + offset / 2],
                           [Rmin, Rmax], [thick, width - 2 * Rmin],
                           height - offset, 3, CurDens)
    rad.ObjDrwAtr(coil1, coilcolor)
    hh = (height - offset) / 2
    coil2 = rad.ObjRaceTrk([0, 0, gap / 2 + height - hh / 2],
                           [Rmax, Rmax + hh * 0.8], [thick, width - 2 * Rmin],
                           hh, 3, CurDens)
    rad.ObjDrwAtr(coil2, coilcolor)

    #Make container, set the colors and define symmetries
    g = rad.ObjCnt([gp, g3, g4, g5])
    rad.ObjDrwAtr(g, ironcolor)
    gd = rad.ObjCnt([g])

    rad.TrfZerPerp(gd, ct, [1, 0, 0])
    rad.TrfZerPerp(gd, ct, [0, 1, 0])

    t = rad.ObjCnt([gd, coil1, coil2])
    rad.TrfZerPara(t, ct, [0, cos(pi / Nn), sin(pi / Nn)])

    rad.TrfMlt(t, rad.TrfRot(ct, [1, 0, 0], 4 * pi / Nn), int(round(Nn / 2)))
    rad.MatApl(g, ironmat)
    rad.TrfOrnt(t, rad.TrfRot([0, 0, 0], [1, 0, 0], pi / Nn))

    return t