Пример #1
0
  def push_relativistic(self,dt,E,B=None):
    if B:
      blah = 0
      #t             = 0.5*dt*self.chargeOverMass*B
      #s             = 2.0*t/(1.0 + np.dot(t,t))

      #V_minus       = self.velocity + 0.5*dt*self.chargeOverMass*E
      #V_prime       = V_minus       + np.cross(V_minus,t)
      #V_plus        = V_minus       + np.cross(V_prime,s)
      #self.velocity = V_plus        + 0.5*dt*self.chargeOverMass*E
    else:
      momentum      = particleUtils.velocityToMomentum(self.mass,self.velocity)
      momentum      = momentum + dt*self.charge*E
      self.velocity = particleUtils.momentumToVelocity(self.mass,momentum)

    self.position = self.position + dt*self.velocity
Пример #2
0
    def push_relativistic(self, dt, E, B=None):
        if B:
            blah = 0
            #t             = 0.5*dt*self.chargeOverMass*B
            #s             = 2.0*t/(1.0 + np.dot(t,t))

            #V_minus       = self.velocity + 0.5*dt*self.chargeOverMass*E
            #V_prime       = V_minus       + np.cross(V_minus,t)
            #V_plus        = V_minus       + np.cross(V_prime,s)
            #self.velocity = V_plus        + 0.5*dt*self.chargeOverMass*E
        else:
            momentum = particleUtils.velocityToMomentum(
                self.mass, self.velocity)
            momentum = momentum + dt * self.charge * E
            self.velocity = particleUtils.momentumToVelocity(
                self.mass, momentum)

        self.position = self.position + dt * self.velocity
Пример #3
0
    # Compute E at particle position
    electricFieldAtPoint_NR = esSolve.electricFieldAtPoint(
        electricFieldOnGrid_NR, [DX], [X0], electron_NR.position)
    electricFieldAtPoint_R_Rpush = esSolve.electricFieldAtPoint(
        electricFieldOnGrid_R, [DX], [X0], electron_R_Rpush.position)
    electricFieldAtPoint_R_NRpush = esSolve.electricFieldAtPoint(
        electricFieldOnGrid_R, [DX], [X0], electron_R_NRpush.position)

    if step == 0:
        # Back velocity up 1/2 step
        electron_NR.velocity = electron_NR.velocity - 0.5 * DT_NR * (
            charge / mass) * electricFieldAtPoint_NR
        electron_R_NRpush.velocity = electron_R_NRpush.velocity - 0.5 * DT_R * (
            charge / mass) * electricFieldAtPoint_R_NRpush

        momentum_0 = particleUtils.velocityToMomentum(
            electron_R_Rpush.mass, electron_R_Rpush.velocity)
        momentum_minusHalf = momentum_0 - 0.5 * DT_R * electron_R_Rpush.charge * electricFieldAtPoint_R_Rpush
        electron_R_Rpush.velocity = particleUtils.momentumToVelocity(
            electron_R_Rpush.mass, momentum_minusHalf)

    elif step == steps:
        # Advance velocity by 1/2 step
        electron_NR.velocity = electron_NR.velocity + 0.5 * DT_NR * (
            charge / mass) * electricFieldAtPoint_NR
        electron_R_NRpush.velocity = electron_R_NRpush.velocity + 0.5 * DT_R * (
            charge / mass) * electricFieldAtPoint_R_NRpush

        momentum_N = particleUtils.velocityToMomentum(
            electron_R_Rpush.mass, electron_R_Rpush.velocity)
        momentum_plusHalf = momentum_N + 0.5 * DT_R * electron_R_Rpush.charge * electricFieldAtPoint_R_Rpush
        electron_R_Rpush.velocity = particleUtils.momentumToVelocity(
Пример #4
0
velocities_R_Rpush  = [electron_R_Rpush.velocity[0]]
positions_R_NRpush  = [electron_R_NRpush.position[0]]
velocities_R_NRpush = [electron_R_NRpush.velocity[0]]

for step in xrange(steps+1):
  # Compute E at particle position
  electricFieldAtPoint_NR       = esSolve.electricFieldAtPoint(electricFieldOnGrid_NR,[DX],[X0],electron_NR.position)
  electricFieldAtPoint_R_Rpush  = esSolve.electricFieldAtPoint(electricFieldOnGrid_R,[DX],[X0],electron_R_Rpush.position)
  electricFieldAtPoint_R_NRpush = esSolve.electricFieldAtPoint(electricFieldOnGrid_R,[DX],[X0],electron_R_NRpush.position)

  if step == 0:
    # Back velocity up 1/2 step
    electron_NR.velocity       = electron_NR.velocity       - 0.5*DT_NR*(charge/mass)*electricFieldAtPoint_NR
    electron_R_NRpush.velocity = electron_R_NRpush.velocity - 0.5*DT_R*(charge/mass)*electricFieldAtPoint_R_NRpush
    
    momentum_0                 = particleUtils.velocityToMomentum(electron_R_Rpush.mass,electron_R_Rpush.velocity)
    momentum_minusHalf         = momentum_0 - 0.5*DT_R*electron_R_Rpush.charge*electricFieldAtPoint_R_Rpush
    electron_R_Rpush.velocity  = particleUtils.momentumToVelocity(electron_R_Rpush.mass,momentum_minusHalf)
 
  elif step == steps:
    # Advance velocity by 1/2 step
    electron_NR.velocity       = electron_NR.velocity       + 0.5*DT_NR*(charge/mass)*electricFieldAtPoint_NR
    electron_R_NRpush.velocity = electron_R_NRpush.velocity + 0.5*DT_R*(charge/mass)*electricFieldAtPoint_R_NRpush

    momentum_N                 = particleUtils.velocityToMomentum(electron_R_Rpush.mass,electron_R_Rpush.velocity)
    momentum_plusHalf          = momentum_N + 0.5*DT_R*electron_R_Rpush.charge*electricFieldAtPoint_R_Rpush
    electron_R_Rpush.velocity  = particleUtils.momentumToVelocity(electron_R_Rpush.mass,momentum_plusHalf)

  else:
    # Push particle
    electron_NR.push(DT_NR,electricFieldAtPoint_NR)