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
Worldthat holds all objects
- you can add objects to this world such as
- time is cut up into discrete steps, and at each point in time, for each
Particlethe magnetic and electric forces that each object in the
Worldgenerates are calculated and summed up (luckily electro-magnetism is linear).
Particlemoves accordingly (using a simple estimation approach to solve the differential movement equations)
- save the
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
Quadrupoles are stored this should lead to a massive gain of performance, not having to recalculate each
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?