# Are there design patterns or generalised approaches for particle simulations?

I'm working on a project (for college) in C++. The goal is to write a program that can more or less simulate a beam of particles flying trough the LHC synchrotron.

Not wanting to rush into things, me and my team are thinking about how to implement this and I was wondering if there are general design patterns that are used to solve this kind of problem.

The general approach we came up with so far is the following:

• there is a `World` that holds all objects
• you can add objects to this world such as `Particle`, `Dipole` and `Quadrupole`
• time is cut up into discrete steps, and at each point in time, for each `Particle` the magnetic and electric forces that each object in the `World` generates are calculated and summed up (luckily electro-magnetism is linear).
• each `Particle` moves accordingly (using a simple estimation approach to solve the differential movement equations)
• save the `Particle` positions
• repeat

This seems a good approach but, for instance, it is hard to take into account symmetries that might be present (such as the magnetic field of each `Quadrupole`) and is this thus suboptimal.

To take into account such symmetries as that of the `Quadrupole` field, it would be much easier to (also) make space discrete and somehow store form of the `Quadrupole` field somewhere. (Since 2532 or so `Quadrupole`s are stored this should lead to a massive gain of performance, not having to recalculate each `Quadrupole` field)

So, are there any design patterns? Is the `World`-approach feasible or is it old-fashioned, bad programming? What about symmetry, how is that generally taken into acount?

-
If you can simulate the LHC why does the LHC exist? – Pubby Mar 26 '12 at 20:41
@Pubby: Because it is a long-standing belief that experiments are a necessary part of the scientific method. Many great thinkers have shown this, including Aristotle, Francis Bacon and Descartes. (BAM, went right into the troll-trap there) – romeovs Mar 27 '12 at 6:21
@Pubby: Because you can only simulate what's already understood? You cannot build a model of something you haven't even seen yet. – sbi Mar 27 '12 at 7:01
@sbi: indeed, modelling/simulating is a good test for any scientific theory. – romeovs Mar 27 '12 at 8:24