Skip to content

Commit

Permalink
Switch position and momentum updates to make particle push symplectic
Browse files Browse the repository at this point in the history
The momentum update needs to use fields that are consistant with the
current particle locations. This requires updating the momentum first,
and then using this new momentum to push the particles.

Essentially, the update is now
p_(n - 1/2) -> p_(n + 1/2)
x_n -> x_(n + 1)

I am currently being pretty sloppy with the half timestep momentums, but
that should probably be fixed in the future.
  • Loading branch information
adamslc committed Aug 30, 2024
1 parent 1fbd1b2 commit ad644a0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/particle_updaters/electrostatic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ function step!(step::ElectrostaticParticlePush)
species = step.species

for n in eachindex(species)
# Push the particle based on its current velocity
particle_position!(
species,
n,
particle_position(species, n) .+
(step.timestep / particle_mass(species, n)) .* particle_momentum(species, n),
)

# Accelerate the particle according to E
# Find which cell the particle is in, and create a CartesianIndices
# object that extends +/- interpolation_width in all directions
Expand All @@ -68,5 +60,13 @@ function step!(step::ElectrostaticParticlePush)
step.E.values[I],
)
end

# Push the particle based on its current velocity
particle_position!(
species,
n,
particle_position(species, n) .+
(step.timestep / particle_mass(species, n)) .* particle_momentum(species, n),
)
end
end

0 comments on commit ad644a0

Please sign in to comment.