Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
11 views3 pages

PIC Algorithm He

The document outlines a generic 2D electrostatic/electromagnetic Particle-In-Cell (PIC) algorithm, detailing initialization, main time-step loop, and post-processing steps. Key components include particle injection, charge/current deposition, field solving, particle pushing, and diagnostics. It emphasizes the importance of self-consistent fields, resolution conditions, and energy conservation in the simulation process.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

PIC Algorithm He

The document outlines a generic 2D electrostatic/electromagnetic Particle-In-Cell (PIC) algorithm, detailing initialization, main time-step loop, and post-processing steps. Key components include particle injection, charge/current deposition, field solving, particle pushing, and diagnostics. It emphasizes the importance of self-consistent fields, resolution conditions, and energy conservation in the simulation process.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

PIC Algorithm

Here’s a generic 2D electrostatic / electromagnetic PIC algorithm, laid out in logical steps and
pseudocode. You can adapt it to your FDTD–PIC coupling for Smith–Purcell:

1. Initialization
1. Define physical constants
1
ε 0 , μ0 , c= , me , q e , …
√ ε0 μ 0
2. Set up spatial grid

o $N_{x},\text{\:\,}N_{y}$ cells, spacing $\Delta x,\text{\:\,}\Delta y$


o Field arrays: E ( i , j ), B (i , j ) (staggered Yee grid)
o Charge density array ρ ( i , j ), current density J ( i, j )
3. Load or define conductor/geometry masks (e.g. grating)

4. Initialize particles

o Positions ( x p , y p ), velocities ( v x , p , v y, p , v z , p )
o Flags “active/inactive”
5. Precompute any static fields (e.g. Bx ) and PML damping profiles

2. Main time-step loop (for n=1 … N s t e p s)

2.1 Particle injection (if continuous beam)


for each injection slot:
find inactive particle p
x_p ← injection plane + small offset
y_p ← beam center + random spread
v_{x,p} ← beam speed, v_{y,p}=0, v_{z,p}=0
mark p active
end

2.2 Charge/current deposition (“scatter”)


1. Zero ρ ( i , j ), J ( i, j )

2. For each active particle p:

o Locate cell indices ( i , j ) ≃ $\left\lfloor (x_{p} - x_{\min})/\Delta x \


right\rfloor,\text{\:\,}\lfloor(y_{p} - y_{\min})/\Delta y\rfloor$
o Compute weights W i ± 1, j ± 1 (e.g. linear or quadratic)

o Accumulate

$$\rho(i,j)\text{\:\,} + \text{ ⁣} = \text{\:\,}q_{e}\, W_{i,j},\quad J_{x}(i,j)\text{\:\,} + \text{ ⁣} = \


text{\:\,}q_{e}\, v_{x,p}\, W_{i,j},\text{\:\,}\ldots$$

2.3 Field solve (FDTD or Poisson)


 Electromagnetic (Yee FDTD):
B^{n+½} ← B^{n−½} − Δt ∇×E^n
E^{n+1} ← E^n + Δt ( c² ∇×B^{n+½} − J/ε₀ )

 Electrostatic (if applicable): solve ∇²φ=−ρ/ε₀ then E=−∇φ

 Apply PML or boundary conditions

2.4 Field gather to particles (“interpolate”)


For each active p:
1. Locate surrounding grid nodes ( i , j )
2. Interpolate E p =∑ E ( i, j ) W i , j, B p=∑ B ( i, j ) W i , j

2.5 Particle push (Boris scheme)


v⁻ = v^n + (q/m) E_p (Δt/2)
t = (q/m) B_p (Δt/2)
s = 2 t / (1+|t|²)
v′ = v⁻ + v⁻×t
v⁺ = v⁻ + v′×s
v^{n+1} = v⁺ + (q/m) E_p (Δt/2)
x^{n+1}_p = x^n_p + v^{n+1} Δt

 Handle domain exits → deactivate


2.6 Diagnostics & visualization
 Track energy conservation, particle counts
 Plot fields/particles every few steps

3. End of loop / post-processing


 Compute spectra of fields (e.g., via FFT)
 Extract radiation intensity vs. angle or frequency

Key points
 Charge → field coupling via deposition and interpolation ensures self-consistent fields.
 Lambda_D (Debye length) and c/ωₚ must be resolved by Δ x , Δ t .
 Courant condition: Δ t <1/ ( c √ 1/ Δ x 2+ 1/ Δ y 2 ).
 Boris push is symplectic and preserves energy very well.
 PML absorbs outgoing waves to avoid reflections.
Feel free to adapt each step to your vectorized MATLAB implementation and to your metallic‐
grating boundary treatment.

You might also like