Skip to content
Projects

Scripts

Complete Python scripts are listed below. Each page shows the script and its plots.

  • Cloud-in-cell density: Deposit a Maxwellian cloud of markers on a 1D grid and compare the density with the exact profile.
  • Beam density in 2D: Deposit a sheared, tilted Gaussian beam on a 2D grid, then smooth the deposit.
  • Gather accuracy: The linear gather is second-order accurate: its error falls as the square of the node spacing.
  • Adjoint deposit and gather: Deposit and gather are transposes: the scatter of marker values and the gather of a field use the same weights, so they are adjoint.
  • Prescribed electric field: An electric field from a prescribed potential: build E=−∇ϕE = -\nabla\phi on a grid from a potential given as a function, here a three-electrode lens.
  • E x B drift: Vector fields: combine fields with arithmetic, gradient, cross, dot and magnitude: the drift velocity of a magnetized plasma.
  • Smoothing filters: The binomial, Gaussian and uniform filters of Field.smooth, as low-pass filters of a noisy deposit.
  • Periodic axis: On a periodic axis the last node neighbours the first: deposits and gathers wrap across the seam.
  • Electrodes from shapes: Mark electrodes with simgeometry shapes and relax Laplace’s equation with field arithmetic.
  • Three dimensions: Deposit a 3D cloud of markers, gather back from it, and look at it in slices and lines.
  • Test particles: Test particles in a fixed field: push charged particles through a field on a grid with a leapfrog scheme, gathering the field every step.
  • Kernel backends: The same deposit and gather through the compiled Pyccel kernels and their NumPy versions, timed.
  • Weightings and grid noise: Deposit the same markers with nearest-grid-point, linear and quadratic weights, the first one written here in NumPy.