Beispiel #1
0
def _find_tips(run, ind):
    orb = run.orbit.read()
    if 'vr' in orb:
        pitch = eval_mrkr.eval_particle('pitch',
                                        mass=None,
                                        charge=None,
                                        R=None,
                                        phi=None,
                                        z=None,
                                        vR=orb['vr'][ind],
                                        vphi=orb['vphi'][ind],
                                        vz=orb['vz'][ind],
                                        BR=orb['br'][ind],
                                        Bphi=orb['bphi'][ind],
                                        Bz=orb['bz'][ind],
                                        psi=None)
    else:
        pitch = eval_mrkr.eval_guidingcenter('pitch',
                                             mass=2. * 1.60e-27,
                                             charge=None,
                                             R=None,
                                             phi=None,
                                             z=None,
                                             vpar=orb['vpar'][ind],
                                             mu=orb['mu'][ind],
                                             theta=None,
                                             BR=orb['br'][ind],
                                             Bphi=orb['bphi'][ind],
                                             Bz=orb['bz'][ind],
                                             psi=None)
    ind_tips = np.where(
        np.logical_and(pitch[:-1] * pitch[1:] < 0,
                       np.abs(pitch[1:]) < 0.005))[0] + 1
    return pitch, ind_tips
Beispiel #2
0
def evaluate_initial_quant(inistate, id_part):
    print()
    print('particle:', id_part)
    ind = np.where(inistate['id'] == id_part)[0]
    pitch = eval_mrkr.eval_particle('pitchprt',
                                    mass=None,
                                    charge=None,
                                    R=None,
                                    phi=None,
                                    z=None,
                                    vR=inistate['vr'][ind],
                                    vphi=inistate['vphi'][ind],
                                    vz=inistate['vz'][ind],
                                    BR=inistate['br'][ind],
                                    Bphi=inistate['bphi'][ind],
                                    Bz=inistate['bz'][ind],
                                    psi=None)
    print('initial pitch', pitch)
    energy = eval_mrkr.eval_particle('energy',
                                     mass=2. * 1.66e-27,
                                     charge=None,
                                     R=None,
                                     phi=None,
                                     z=None,
                                     vR=inistate['vr'][ind],
                                     vphi=inistate['vphi'][ind],
                                     vz=inistate['vz'][ind],
                                     BR=None,
                                     Bphi=None,
                                     Bz=None,
                                     psi=None)
    print('initial E', energy)
    mu = eval_mrkr.eval_particle('mu',
                                 mass=2. * 1.66e-27,
                                 charge=None,
                                 R=None,
                                 phi=None,
                                 z=None,
                                 vR=inistate['vr'][ind],
                                 vphi=inistate['vphi'][ind],
                                 vz=inistate['vz'][ind],
                                 BR=inistate['br'][ind],
                                 Bphi=inistate['bphi'][ind],
                                 Bz=inistate['bz'][ind],
                                 psi=None)
    print('initial mu', mu)
    return ind, mu
Beispiel #3
0
def evaluate_derived_quant(orb, id_part):
    # evaluate derived quantities
    ind = np.where(orb['id'] == id_part)[0]
    pitch = eval_mrkr.eval_particle('pitch',
                                    mass=2. * 1.60e-27,
                                    charge=None,
                                    R=None,
                                    phi=None,
                                    z=None,
                                    vpar=orb['vpar'][ind],
                                    mu=orb['mu'][ind],
                                    theta=None,
                                    BR=orb['br'][ind],
                                    Bphi=orb['bphi'][ind],
                                    Bz=orb['bz'][ind],
                                    psi=None)
    energy = eval_mrkr.eval_particle('energy',
                                     mass=2. * 1.60e-27,
                                     charge=None,
                                     R=None,
                                     phi=None,
                                     z=None,
                                     vpar=orb['vpar'][ind],
                                     mu=orb['mu'][ind],
                                     theta=None,
                                     BR=orb['br'][ind],
                                     Bphi=orb['bphi'][ind],
                                     Bz=orb['bz'][ind],
                                     psi=None)
    energy = energy / 1.602e-19
    dE = np.diff(energy, prepend=energy[0])
    mu = eval_mrkr.eval_particle('mu',
                                 mass=2. * 1.60e-27,
                                 charge=None,
                                 R=None,
                                 phi=None,
                                 z=None,
                                 vR=orb['vr'][ind],
                                 vphi=orb['vphi'][ind],
                                 vz=orb['vz'][ind],
                                 BR=orb['br'][ind],
                                 Bphi=orb['bphi'][ind],
                                 Bz=orb['bz'][ind],
                                 psi=None)
    mu = mu * 1e14
    return ind, pitch, energy, mu, dE
_zmin = np.squeeze(bb['b_zmin'])
_zmax = np.squeeze(bb['b_zmax'])
_nz = np.squeeze(bb['b_nz'])
z = np.linspace(_zmin, _zmax, _nz)
nphi = np.squeeze(bb['b_nphi'])
Rgrid, zgrid, tg = np.meshgrid(R, z, 0, indexing="ij")

#particles
inistate = run.inistate.read()
pitch = evaluate.eval_particle('pitch',
                               mass=inistate['mass'],
                               charge=None,
                               R=None,
                               phi=None,
                               z=None,
                               vR=inistate['vr'],
                               vphi=inistate['vphi'],
                               vz=inistate['vz'],
                               BR=inistate['br'],
                               Bphi=inistate['bphi'],
                               Bz=inistate['bz'],
                               psi=None)
#Trapping condition
d = np.sqrt((b2d['axisr'] - inistate['r'])**2 +
            (b2d['axisz'] - inistate['z'])**2)
lhs = pitch / np.sqrt(1 - pitch**2)
rhs = np.sqrt(d * 2. / abs(b2d['axisr'] - d))
ind_trapp = np.where(lhs < rhs)

#rz
f = plt.figure(figsize=(6, 10))
Beispiel #5
0
# check matching initial condition
for i in range(2):
    # find indexes of interest
    id_part = fcoll.inistate['id'][ind_nocoll[i]]
    #ind = np.where(fnocoll.inistate['id']==id_part)[0]
    ind = np.where(orb_coll['id'] == id_part)[0]

    #only initial points
    ind_i_coll = np.where(fcoll.inistate['id'] == id_part)[0]
    pitch = eval_mrkr.eval_particle('pitchprt',
                                    mass=None,
                                    charge=None,
                                    R=None,
                                    phi=None,
                                    z=None,
                                    vR=fcoll.inistate['vr'][ind_i_coll],
                                    vphi=fcoll.inistate['vphi'][ind_i_coll],
                                    vz=fcoll.inistate['vz'][ind_i_coll],
                                    BR=fcoll.inistate['br'][ind_i_coll],
                                    Bphi=fcoll.inistate['bphi'][ind_i_coll],
                                    Bz=fcoll.inistate['bz'][ind_i_coll],
                                    psi=None)
    print('pitch coll', pitch)
    energy = eval_mrkr.eval_particle('energy',
                                     mass=2. * 1.60e-27,
                                     charge=None,
                                     R=None,
                                     phi=None,
                                     z=None,
                                     vR=fcoll.inistate['vr'][ind_i_coll],
                                     vphi=fcoll.inistate['vphi'][ind_i_coll],
Beispiel #6
0
def evaluate_derived_quant_go(a5, orb, id_part):
    print('GO')
    # evaluate derived quantities
    ind = np.where(orb['id'] == id_part)[0]
    pitch = eval_mrkr.eval_particle('pitch',
                                    mass=2. * 1.66e-27,
                                    charge=None,
                                    R=None,
                                    phi=None,
                                    z=None,
                                    vR=orb['vr'][ind],
                                    vphi=orb['vphi'][ind],
                                    vz=orb['vz'][ind],
                                    BR=orb['br'][ind],
                                    Bphi=orb['bphi'][ind],
                                    Bz=orb['bz'][ind],
                                    psi=None)
    energy = eval_mrkr.eval_particle('energy',
                                     mass=2. * 1.66e-27,
                                     charge=None,
                                     R=None,
                                     phi=None,
                                     z=None,
                                     vR=orb['vr'][ind],
                                     vphi=orb['vphi'][ind],
                                     vz=orb['vz'][ind],
                                     BR=orb['br'][ind],
                                     Bphi=orb['bphi'][ind],
                                     Bz=orb['bz'][ind],
                                     psi=None)
    dE = np.diff(energy - energy[0], prepend=energy[0])
    mu = eval_mrkr.eval_particle('mu',
                                 mass=2. * 1.66e-27,
                                 charge=None,
                                 R=None,
                                 phi=None,
                                 z=None,
                                 vR=orb['vr'][ind],
                                 vphi=orb['vphi'][ind],
                                 vz=orb['vz'][ind],
                                 BR=orb['br'][ind],
                                 Bphi=orb['bphi'][ind],
                                 Bz=orb['bz'][ind],
                                 psi=None)
    #mu=mu*1.602e-19;
    Bn = eval_mrkr.eval_particle('bnorm',
                                 mass=2. * 1.66e-27,
                                 charge=None,
                                 R=None,
                                 phi=None,
                                 z=None,
                                 BR=orb['br'][ind],
                                 Bphi=orb['bphi'][ind],
                                 Bz=orb['bz'][ind],
                                 psi=None)
    div = a5.evaluate(orb['r'][ind], orb['phi'][ind], orb['z'][ind], 0,
                      "divergence")
    plt.figure()
    plt.plot(div, 'r')
    plt.suptitle('GO div {:d}'.format(id_part))

    #    plt.figure(); plt.plot((energy-energy[0])/energy[0]*100., 'r'); plt.suptitle('GO E {:d}'.format(id_part))
    #    plt.figure(); plt.plot((mu-mu[0])/mu[0]*100., 'r'); plt.suptitle('GO mu {:d}'.format(id_part))
    plt.figure()
    plt.plot(np.sqrt(Bn**2 - orb['bphi'][ind]**2), 'r')
    plt.suptitle('GO bnorm {:d}'.format(id_part))

    psi = a5.evaluate(orb['r'][ind], orb['phi'][ind], orb['z'][ind], 0, "psi")
    pphi = eval_mrkr.eval_particle('ptor',
                                   mass=2. * 1.66e-27,
                                   charge=orb['charge'][ind] * 1.602e-19,
                                   R=orb['r'][ind],
                                   phi=None,
                                   z=None,
                                   vR=orb['vr'][ind],
                                   vphi=orb['vphi'][ind],
                                   vz=orb['vz'][ind],
                                   BR=None,
                                   Bphi=None,
                                   Bz=None,
                                   psi=psi)
    return ind, pitch, energy, mu, dE, pphi, psi