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 17cc101
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 @@ -67,6 +59,14 @@ function step!(step::ElectrostaticParticlePush)
(interp_weight * step.timestep * particle_charge(species, n)) .*
step.E.values[I],
)

# 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
end

0 comments on commit 17cc101

Please sign in to comment.