openpixi/openpixi — pull request #49 by kstrel (2013-06-12 10:03:47+00:00)
Title: Particle Loader

Here I introduce an interface for ParticleLoader classes as well as a loader that produces a Maxwellian thermal distribution of the electrons.

It works in a sense that openpixi can load particles with this loader through the load() method without producing any errors. The physical implications of this (stability of the simulation) are NOT tested yet. I have the feeling that just using the random loader from the initial conditions class produces a more stable result, but this of course is also heavily dependent on the other parameters. Therefore the new loader is not used in any way yet! Hence merging this wouldnt change anything on the running program.

The math for the maxwellian was taken from Cartwright (2000, doi:10.1006/jcph.2000.6549) as well as the book by Birdsall, Chapter 16.

A good test of the interface itself would be to check if a random loader produces the same results as the one in initial conditions. But the current structure of the loader is very simple so no problems should be expected there.

I propose the following more advanced and flexible loader structure:

Loader class that contains a load method. Its arguments are a list of "Prototype Particles" and a Distribution class (like the Maxwellian implemented here).
This method then takes each prototype particle, reads its parameters and does something with it accordingly. This might be applying a velocity distribution or skipping all the steps altogether and just making lots of copies that are exactly like the prototype.

Why is this useful?
Right now I have to hard-code the particle parameters inside the distribution class. Also I have to specify how many types of particles I want etc.
With this more advanced interface I could concentrate only on the parameters that the distribution class was meant to adjust and copy the others from the prototype. This would reduce the complexity of the distribution class, s.t. one can concentrate on the math.

Applied to the maxwellian loader that would mean that the second for loop in the load method wouldnt be there as well as the code that deals with the spacial distribution.

PS: I will not work on this today because I have to take care of some bugs that I have found in the rest of the code. Properly testing this distributions requires diagnostics, but before I can implement them I need to do some changes in the classes that we already have.