コード例 #1
0
ファイル: emPusherTest.py プロジェクト: lynch829/radtrack
        self.E = 1.e-5*np.array([2., 0., 0.])
        self.B = 1.e-5*np.array([0., 1., 0.])

    def getEField(self, x):
        return self.E

    def getBField(self, x):
        return self.B

try:

    print 'Testing Lorentz force pushers... '

    from radtrack.ptclmovers.RbBorisVay import RbBorisVay
    from PtclTests import PtclTests
    pusher = RbBorisVay(consts.e, consts.m_e, 1.e-8)
    ptclGamma = 101.  # make a particle with gamma = 101. v in y direction
    ptclu = consts.c*np.sqrt(ptclGamma**2 - 1.)
    x = [np.array([1., 0., 0.])]
    v = [np.array([0., ptclu, 0.])]
    fields = constEM()
    efield = [fields.getEField(x)]
    bfield = [fields.getBField(x)]

    expectedX = np.array([1.00000000e+00,   2.99777763e+00,   1.51624746e-16])
    expectedU = np.array([3.51764015e-02,   3.02775541e+10,   3.06281988e-06])
    tol = 1.e-8

    # Sequence tests the implementation of drift-kick-drift 2nd order
    # integrator scheme. This makes sure x and v are synchronous in time at
    # the end of the simulation
コード例 #2
0
ファイル: laserHeater03.py プロジェクト: lynch829/radtrack
    tol = 1.e-8

    # Set up the undulator
    lambda_w = 0.025 # [cm]
    B0 = 1.75 # [T]
    gap = lambda_w
    # rotate the undulator a little to get off-axis effects
    angle = 2*np.pi*0.01
    myplanarundulator = planarUndulator(B0, lambda_w, gap, angle)

    # Determine dt to resolve the undulator motion, assuming a relativistic
    # particle
    dt = 0.1*(lambda_w/consts.c)
    charge = consts.e
    mass = consts.electron_mass
    pusher = RbBorisVay(charge, mass, dt)

    # Create a relativistic particle with 1 mm-mrad "emittance" in the
    # transverse gradient direction
    gamma0 = 100.
    v0 = consts.c * (1. - 1/gamma0**2)
    pos = np.array([[0., 0.0025, 0.]])
    vel = np.array([[0., -0.0025/consts.c, gamma0*v0]])


    # Set up the length of the simulation
    undulatorPeriods = 10
    undulatorLength = undulatorPeriods*lambda_w
    nsteps = int(undulatorLength/(consts.c * dt))

    t = 0.
コード例 #3
0
ファイル: testBorisVay.py プロジェクト: lynch829/radtrack
from mpl_toolkits.mplot3d import Axes3D

mpl.rc('text', usetex=True)
from radtrack.ptclmovers.RbBorisVay import RbBorisVay
import scipy.constants as consts
import numpy as np

try:

    dt = 1.e-8
    B = [1.e-5 * np.array([1., 0.1, 0.])]
    E = [1.e-5 * np.array([0., 0., 1.])]
    charge = consts.e
    mass = consts.electron_mass

    pusher = RbBorisVay(charge, mass, dt)

    x = []
    y = []
    z = []
    gamma = 3.
    uMag = consts.c * np.sqrt(gamma**2 - 1.)
    uDir = 1.4*np.pi
    uDir2 = 0.1*np.pi
    v0 = [np.array([uMag * np.cos(uDir) * np.sin(uDir2), uMag * np.sin(uDir) *
                    np.sin(uDir2), uMag * np.cos(uDir2)])]
    x0 = [np.zeros(3)]

    x.append(x0[0][0])
    y.append(x0[0][1])
    z.append(x0[0][2])