Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Computer Trajectory Tracing

  1. Mar 28, 2012 #1

    I use a numerical method to trace trajectories of particles. I want to program a sort of 'video' type graph. A graph or 3d video or perhaps just 3 graphs (xy, xz, and yz) that would show the position of the ion as the software is run.

    So my question is this...

    What software would people recommend for doing this? Can I just use C++? Should I use matlab? or is there some other software where this can be achieved quite straightforwardly without having to write tonnes of code to do the display?

    Any ideas?

  2. jcsd
  3. Mar 28, 2012 #2


    User Avatar
    Science Advisor

    Do you already know Matlab? Do you already know C++? Easier to use what you know--the equations will be the same in any case.
    Then, it depends on how efficient it needs to be. For a few particles, you might just use Matlab, because the set up is a lot easier, and you can use built in graphing functions. For 10 million particles, you might want to use c or fortran, just for speed.

    If you don't know, I recommend just using Matlab, since it's easy and won't take much code.
  4. Mar 28, 2012 #3
    Ok cool.

    Its just a case of which has the easier to user graphing functions.

    But you think C maybe faster? Whys that?
  5. Mar 28, 2012 #4


    User Avatar
    Science Advisor

    c is (much) faster than Matlab because it is a compiled language and has static typing and minimal software protections. Fortran can be faster than c sometimes, because there's even less imposed structure on function calls.

    Neither have any sort of built in graphing routines, though.
  6. Mar 28, 2012 #5
    There are special computer codes for tracing charged particles through magnetic optics, even when there are strong space-charge forces that can defocus the beam.

    This one (1998) for beams claims to include space charge effects.


    uses the long standing TRANSPORT and TURTLE codes (see references).

    This one uses Fortran 90


    I have written simple ray racing codes for charged particles in magnetic optics using TRUE BASIC. A simple plotting subroutine might be a short as 20 lines.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook