pub struct PicSimulation {
pub particles: Vec<PicParticle>,
pub grid: PicGrid,
pub dt: f32,
pub time: f32,
}Fields§
§particles: Vec<PicParticle>§grid: PicGrid§dt: f32§time: f32Implementations§
Source§impl PicSimulation
impl PicSimulation
pub fn new(nx: usize, ny: usize, dx: f32, dt: f32) -> Self
Sourcepub fn deposit_charge(&mut self)
pub fn deposit_charge(&mut self)
CIC (Cloud-In-Cell) charge deposition: distribute particle charge to grid.
Sourcepub fn solve_poisson(&mut self)
pub fn solve_poisson(&mut self)
Solve Poisson equation: ∇²φ = -ρ/ε₀ using SOR (Successive Over-Relaxation).
Sourcepub fn compute_field(&mut self)
pub fn compute_field(&mut self)
Compute electric field from potential: E = -∇φ (central differences).
Sourcepub fn push_particles(&mut self)
pub fn push_particles(&mut self)
Push particles using Boris algorithm with interpolated fields.
Sourcepub fn initialize_two_stream(&mut self, n_per_species: usize, v_beam: f32)
pub fn initialize_two_stream(&mut self, n_per_species: usize, v_beam: f32)
Initialize a two-stream instability: two counter-propagating beams.
Sourcepub fn initialize_landau_damping(&mut self, n: usize, k: f32, amplitude: f32)
pub fn initialize_landau_damping(&mut self, n: usize, k: f32, amplitude: f32)
Initialize a Landau damping test: uniform plasma with a small density perturbation.
Sourcepub fn kinetic_energy(&self) -> f32
pub fn kinetic_energy(&self) -> f32
Total kinetic energy of all particles.
Sourcepub fn field_energy(&self) -> f32
pub fn field_energy(&self) -> f32
Total field energy.
Sourcepub fn total_energy(&self) -> f32
pub fn total_energy(&self) -> f32
Total energy (kinetic + field).
Sourcepub fn total_charge(&self) -> f32
pub fn total_charge(&self) -> f32
Total charge on the grid (should be conserved).
Auto Trait Implementations§
impl Freeze for PicSimulation
impl RefUnwindSafe for PicSimulation
impl Send for PicSimulation
impl Sync for PicSimulation
impl Unpin for PicSimulation
impl UnsafeUnpin for PicSimulation
impl UnwindSafe for PicSimulation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.