Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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 Quadrupoles 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?

share|improve this question
1  
If you can simulate the LHC why does the LHC exist? –  Pubby Mar 26 '12 at 20:41
1  
@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
1  
@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

1 Answer 1

up vote 2 down vote accepted

Check into the graphics community for particle physics simulations. There are many existing patterns (physics solvers and such for particle systems), and it is a well-understood concept for that community, and there are many implementations. You will save yourself a great deal of time.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.