jaxincell._particles¶
Functions¶
|
This function retrieves the electric or magnetic field values at particle positions |
|
This function implements the Boris algorithm to rotate the particle velocity vector |
|
This function performs one step of the Boris algorithm for particle motion. |
|
Relativistic Boris pusher for N particles. |
Module Contents¶
- jaxincell._particles.fields_to_particles_grid(x_n, field, dx, grid, grid_start, field_BC_left, field_BC_right)¶
This function retrieves the electric or magnetic field values at particle positions using a field interpolation scheme. The function first adds ghost cells to the field array to handle boundary conditions, then interpolates the field based on the particle’s position in the grid.
- Parameters:
x_n (array) – The position of particles at time step n, shape (N,).
field (array) – The field values at each grid point, shape (G,).
dx (float) – The spatial grid spacing.
grid (array) – The grid positions where the field is defined, shape (G,).
grid_start (float) – The starting position of the grid (usually the left boundary).
field_BC_left (int) – Boundary condition for the left side of the particle grid.
field_BC_right (int) – Boundary condition for the right side of the particle grid.
- Returns:
The interpolated field values at the particle positions, shape (N,).
- Return type:
array
- jaxincell._particles.rotation(dt, B, vsub, q_m)¶
This function implements the Boris algorithm to rotate the particle velocity vector in the magnetic field for one time step. This step is part of the numerical solution of the Lorentz force equation.
- Parameters:
dt (float) – Time step for the simulation.
B (array) – Magnetic field at the particle’s position, shape (3,).
vsub (array) – The particle’s velocity before the rotation, shape (3,).
q_m (array) – The charge-to-mass ratio of the particle, shape (3,).
- Returns:
The updated velocity after the rotation, shape (3,).
- Return type:
array
- jaxincell._particles.boris_step(dt, xs_nplushalf, vs_n, q_ms, E_fields_at_x, B_fields_at_x)¶
This function performs one step of the Boris algorithm for particle motion. The particle velocity is updated using the electric and magnetic fields at its position, and the particle position is updated using the new velocity.
- Parameters:
dt (float) – Time step for the simulation.
xs_nplushalf (array) – The particle positions at the half-time step n+1/2, shape (N, 3).
vs_n (array) – The particle velocities at time step n, shape (N, 3).
q_ms (array) – The charge-to-mass ratio of each particle, shape (N, 1).
E_fields_at_x (array) – The interpolated electric field values at the particle positions, shape (N, 3).
B_fields_at_x (array) – The magnetic field values at the particle positions, shape (N, 3).
- Returns:
- A tuple containing:
xs_nplus3_2 (array): The updated particle positions at time step n+3/2, shape (N, 3).
vs_nplus1 (array): The updated particle velocities at time step n+1, shape (N, 3).
- Return type:
tuple
- jaxincell._particles.boris_step_relativistic(dt, xs_nplushalf, vs_n, q_s, m_s, E_fields_at_x, B_fields_at_x)¶
Relativistic Boris pusher for N particles.
- Parameters:
dt – Time step
xs_nplushalf – Particle positions at t = n + 1/2, shape (N, 3)
vs_n – Velocities at time t = n, shape (N, 3)
q_s – Charges, shape (N,)
m_s – Masses, shape (N,)
E_fields_at_x – Electric fields at particle positions, shape (N, 3)
B_fields_at_x – Magnetic fields at particle positions, shape (N, 3)
c – Speed of light (default = 1.0 for normalized units)
- Returns:
Updated positions at t = n + 3/2, shape (N, 3) vs_nplus1: Updated velocities at t = n + 1, shape (N, 3)
- Return type:
xs_nplus3_2