Esempio n. 1
0
def Materials():
    #Defines magnetic materials for the Undulators Poles and Magnets
    #Pole (~iron type Va Permendur) material data
    H = [
        0.8, 1.5, 2.2, 3.6, 5, 6.8, 9.8, 18, 28, 37.5, 42, 55, 71.5, 80, 85,
        88, 92, 100, 120, 150, 200, 300, 400, 600, 800, 1000, 2000, 4000, 6000,
        10000, 25000, 40000
    ]
    M = [
        0.000998995, 0.00199812, 0.00299724, 0.00499548, 0.00699372,
        0.00999145, 0.0149877, 0.0299774, 0.0499648, 0.0799529, 0.0999472,
        0.199931, 0.49991, 0.799899, 0.999893, 1.09989, 1.19988, 1.29987,
        1.41985, 1.49981, 1.59975, 1.72962, 1.7995, 1.89925, 1.96899, 1.99874,
        2.09749, 2.19497, 2.24246, 2.27743, 2.28958, 2.28973
    ]
    convH = 4. * 3.141592653589793e-07
    #ma = []
    #for i in range(len(H)): ma.append([H[i]*convH, M[i]])
    #mp = rad.MatSatIsoTab(ma)
    #A more compact way:
    mp = rad.MatSatIsoTab([[H[i] * convH, M[i]] for i in range(len(H))])

    #(Permanent) Magnet material: NdFeB with 1.2 Tesla Remanent Magnetization
    mm = rad.MatStd('NdFeB', 1.2)

    return mp, mm
Esempio n. 2
0
def build_box(center, size, material, magnetization, div, h_m_curve=None):
    n_mag = numpy.linalg.norm(magnetization)
    g_id = radia.ObjRecMag(center, size, magnetization)
    if div:
        radia.ObjDivMag(g_id, div)
    # do not apply a material unless a magentization of some magnitude has been set
    if n_mag > 0:
        if material == 'custom':
            mat = radia.MatSatIsoTab(
                [[_MU_0 * h_m_curve[i][0], h_m_curve[i][1]]
                 for i in range(len(h_m_curve))])
        else:
            mat = radia.MatStd(material, n_mag)
        radia.MatApl(g_id, mat)
    return g_id
Esempio n. 3
0
def eval_hybrid_und(_gap, _gap_ofst, _nper, _air, _pole_width, _lp, _ch_p, _np, _np_tip, _mp, _cp, _lm, _ch_m_xz,
                    _ch_m_yz, _ch_m_yz_r, _nm, _mm, _cm, _use_ex_sym=False):
    from mpi4py import MPI
    comMPI = MPI.COMM_WORLD
    size = comMPI.Get_size()
    rank = comMPI.Get_rank()
    rad.UtiMPI('in')
    
    _lp = [_pole_width, *_lp]
    
    # Set up material properties if they weren't created by a pre-process function
    if not _mp or not _mm:
        # Pole Material 
        # B [G] vs H [G] data from NEOMAX
        BvsH_G = [[0., 0], [0.5, 5000], [1, 10000], [1.5, 13000], [2, 15000], [3, 16500], [4, 17400], [6, 18500],
                  [8, 19250], [10, 19800],
                  [12, 20250], [14, 20600], [16, 20900], [18, 21120], [20, 21250], [25, 21450], [30, 21590],
                  [40, 21850], [50, 22000],
                  [70, 22170], [100, 22300], [200, 22500], [300, 22650], [500, 23000], [1000, 23900], [2000, 24900]]
        
        MvsH_T = [[BvsH_G[i][0]*1.e-4, (BvsH_G[i][1]-BvsH_G[i][0])*1.e-4] for i in range(len(BvsH_G))]
        _mp = rad.MatSatIsoTab(MvsH_T)
        
        # Magnet Material
        magBr = 1.67  # Remanent Magnetization
        _mm = rad.MatLin({0.05, 0.15}, magBr)
    
    grp = HybridUndCenPart(_gap, _gap_ofst, _nper, _air, _lp, _ch_p, _np, _np_tip, _mp, _cp, _lm, _ch_m_xz, _ch_m_yz,
                           _ch_m_yz_r, _nm, _mm, _cm, _use_ex_sym)
    
    # Construct Interaction Matrix
    t0 = time.time()
    IM = rad.RlxPre(grp)
    # Perform the Relaxation
    t0 = time.time()
    res = rad.RlxAuto(IM, 0.001, 5000)
    # Synchronizing all processes
    rad.UtiMPI('barrier')
    
    Bz0 = rad.Fld(grp, 'bz', [0,0,0])
    if rank <= 0:
        print("Bz0:", Bz0)
    if size > 1:
        if rank == 0:
            np.save(NP_FILENAME, Bz0)
    rad.UtiMPI('off')
    
    return Bz0
Esempio n. 4
0
def Material():
    #Define steel MH curve
    H = [
        0, 159.2, 318.3, 477.5, 636.6, 795.8, 1591.5, 3183.1, 4774.6, 6366.2,
        7957.7, 15915.5, 31831, 47746.5, 63662, 79577.5, 159155, 318310, 397887
    ]
    M = [
        0, 0.24, 0.865, 1.11, 1.245, 1.33, 1.498, 1.596, 1.677, 1.733, 1.77,
        1.885, 1.985, 2.025, 2.05, 2.065, 2.08, 2.085, 2.0851
    ]
    convH = 4. * 3.141592653589793e-07
    ma = []
    for i in range(len(H)):
        ma.append([H[i] * convH, M[i]])
    mp = rad.MatSatIsoTab(ma)

    return mp
Esempio n. 5
0
def materials(H, M, material_type_string, magnet_remanence):
    """
    define magnetic materials for the undulator poles and magnets
    arguments:
      H    = list of magnetic field values / (Amp/m)
      M    = corresponding magnetization values / T
      material_type_string = material type string
      magnet_remanence   = remanent magnetization / T
    return: Radia representations of ...
      pole-tip material, magnet material
    """
    # -- magnetic property of poles
    ma = [[sc.mu_0 * H[i], M[i]] for i in range(len(H))]
    mp = rad.MatSatIsoTab(ma)
    # -- permanent magnet material
    mm = rad.MatStd(material_type_string, magnet_remanence)
    return mp, mm
Esempio n. 6
0
    def materials(h, m, smat, rm):
        """
        define magnetic materials for the undulator poles and magnets
        arguments:
          H    = list of magnetic field values / (Amp/m)
          M    = corresponding magnetization values / T
          smat = material type string
          rm   = remanent magnetization / T
        return: Radia representations of ...
          pole-tip material, magnet material
        """
        # -- magnetic property of poles
        ma = [[mu0 * h[i], m[i]] for i in range(len(h))]
        mp = radia.MatSatIsoTab(ma)
        # -- permanent magnet material
        mm = radia.MatStd(smat, rm)

        return mp, mm
Esempio n. 7
0
def set_mag_properties(J):
    # Preprocessing function to setup objects that must be passed to `_mp` and `_mm`
    # Can be used with serial evaluation - otherwise eval_hybrid_und will perform this calculation
    
    # Pole Material 
    # B [G] vs H [G] data from NEOMAX
    BvsH_G = [[0., 0], [0.5, 5000], [1, 10000], [1.5, 13000], [2, 15000], [3, 16500], [4, 17400], [6, 18500],
              [8, 19250], [10, 19800],
              [12, 20250], [14, 20600], [16, 20900], [18, 21120], [20, 21250], [25, 21450], [30, 21590], [40, 21850],
              [50, 22000],
              [70, 22170], [100, 22300], [200, 22500], [300, 22650], [500, 23000], [1000, 23900], [2000, 24900]]
    MvsH_T = [[BvsH_G[i][0] * 1.e-4, (BvsH_G[i][1] - BvsH_G[i][0]) * 1.e-4] for i in range(len(BvsH_G))]
    mp = rad.MatSatIsoTab(MvsH_T)

    # Magnet Material
    magBr = 1.67  # Remanent Magnetization
    mm = rad.MatLin({0.05, 0.15}, magBr)
    print("J starts as:", J)
    J['inputs']['_mm'] = mm 
    J['inputs']['_mp'] = mp
    print("J ends as:", J)
Esempio n. 8
0
def _radia_material(material_type, magnetization_magnitude, h_m_curve):
    if material_type == 'custom':
        return radia.MatSatIsoTab(
            [[_MU_0 * h_m_curve[i][0], h_m_curve[i][1]] for i in range(len(h_m_curve))]
        )
    return radia.MatStd(material_type, magnetization_magnitude)
    chMagXZ = 3.  #Magnet Chamfer in the XZ plane
    chMagYZ = 0.05  #Magnet Chamfer in the YZ plane
    chMagYZrat = sqrt(3.)  #Magnet Chamfer Ratio: Longitudinal/Vertical

    #Pole Material
    #B [G] vs H [G] data from NEOMAX
    BvsH_G = [[0., 0], [0.5, 5000], [1, 10000], [1.5, 13000], [2, 15000],
              [3, 16500], [4, 17400], [6, 18500], [8, 19250], [10, 19800],
              [12, 20250], [14, 20600], [16, 20900], [18, 21120], [20, 21250],
              [25, 21450], [30, 21590], [40, 21850], [50, 22000], [70, 22170],
              [100, 22300], [200, 22500], [300, 22650], [500, 23000],
              [1000, 23900], [2000, 24900]]
    MvsH_T = [[BvsH_G[i][0] * 1.e-04, (BvsH_G[i][1] - BvsH_G[i][0]) * 1.e-04]
              for i in range(len(BvsH_G))]
    mp = rad.MatSatIsoTab(MvsH_T)

    #Magnet Material
    magBr = 1.67  #Remanent Magnetization
    mm = rad.MatLin({0.05, 0.15}, magBr)

    grp = HybridUndCenPart(_gap=gap,
                           _gap_ofst=gapOffset,
                           _nper=nPer,
                           _air=air,
                           _lp=lp,
                           _ch_p=chPole,
                           _np=np,
                           _np_tip=npTip,
                           _mp=mp,
                           _cp=cp,