5 ms·
I can't help but notice there is a magical "Theta" parameter, with the description "Higher = faster, less accurate". I think here it's a threshold for ignoring
by conistonwater 12y ago
I can't help but notice there is a magical "Theta" parameter, with the description "Higher = faster, less accurate". I think here it's a threshold for ignoring children nodes' internal structure in an octree.
As a matter of good software engineering (and numerical analysis, and mathematics, too), your software shouldn't have magical parameters with mysterious consequences for the correctness of your software. (I know correctness is maybe not the point here, but still...) Also, note that there is no way for a user to check how accurate the simulation is for a given "Theta" parameter. The name is completely non-descriptive as well.
There are mathematically sound ways to determine the accuracy of the simulation. If they are expensive, tell that to the user explicitly, but default to the correct implementation, not the fast one.
Note that while the user has no clue what "Theta" is, the user might instead be able intuitively specify that they want the simulation to be accurate "to X digits for the first Y seconds of the simulation". I think that would be a better software design. As it is, "Theta" is an exposed quirk of the implementation.
- mcdevhammer 12y agoIt was really meant just as a toy and not a scientifically rigorous simulation. Any value of theta is going to make not 100% accurate (not to mention the simulation speed which also affects accuracy).
- conistonwater 12y agoMy criticism is aimed not at you personally, but at the general pattern in (what I consider to be) poorly designed numerical software.
- lutusp 12y ago> As a matter of good software engineering (and numerical analysis, and mathematics, too), your software shouldn't have magical parameters with mysterious consequences for the correctness of your software. To some extent, yes, but consider that we're speaking of a numerical differential equation solver. If we make the time steps too large, the program runs fast but the simulation is less realistic. If we go too far and make the time steps very small, we'll start seeing rounding errors in the floating-point processing. The reason this class of simulation is numeric is because all but the the most trivial orbital simulations must be performed numerically. The reason for that, in turn, is because of the Three-Body Problem: http://en.wikipedia.org/wiki/Three-body_problem http://en.wikipedia.org/wiki/Three-body_problem By the way, while we're on the topic, here's my HTML5/JavaScript orbital simulator plus math tutorial: http://arachnoid.com/orbital_dynamics http://arachnoid.com/orbital_dynamics
- conistonwater 12y ago> To some extent, yes, but consider that we're speaking of a numerical differential equation solver. If we make the time steps too large, the program runs fast but the simulation is less realistic. If we go too far and make the time steps very small, we'll start seeing rounding errors in the floating-point processing. But this just means that the problem needs to be solved carefully; what you've done is state the problem. Look at any textbook on numerical analysis, such as Numerical Recipes, or even something more basic. It will explain how to implement adaptive time-stepping for numerical solution of ODEs. Here the parameter is not for time-stepping, it's for ignoring nodes in an octree, but you can still mathematically pick a parameter that generates something like a desired level of accuracy, instead of having to specify the parameter itself. > The reason this class of simulation is numeric is because all but the the most trivial orbital simulations must be performed numerically. The reason for that, in turn, is because of the Three-Body Problem: You make all of this sound like it's a difficult problem. For a basic ODE solver, adaptive time-stepping is one of the most standard techniques. Most introductory numerical analysis courses in universities cover this, so usually the reason people implement it this way is that they simply haven't heard about it, and don't know that they can look it up in a textbook.
- lutusp 12y ago> You make all of this sound like it's a difficult problem. It is a difficult problem. Consider all the elements of a solution on which space missions depend. All of them must be generated using numerical modeling methods, and for a solar system simulation in which most or all the candidate bodies are modeled, the computation load is quite high. > but you can still mathematically pick a parameter that generates something like a desired level of accuracy, instead of having to specify the parameter itself. This isn't true, or it's not assured to be true. The reason is that orbital systems with > 2 bodies meet the definition of a chaotic system, a system acutely sensitive to initial conditions. Everyone who works in this field understands that there's a time horizon past which we really cannot say what the solar system's configuration will be.
- conistonwater 12y ago
- gamegoblin 12y agoTheta is a well-known parameter in the Barnes-Hut algorithm which this simulation uses. It isn't a magic constant and is well-defined. Read: http://en.wikipedia.org/wiki/Barnes–Hut_simulation http://en.wikipedia.org/wiki/Barnes–Hut_simulation , look for the theta symbol. The only thing you can really knock this implementation is not explaining the definition of theta, but you can't much do that without a writeup of how the Barnes-Hut simulation works. I think "higher = faster, less accurate" is just fine for a demo's purpose.