10
$\begingroup$

I wrote a particle based fluid simulating program. It's hard to tell if I get the right result. The visualized result seems reasonable, but some part of it looks weird. I don't know wether it's a feature of fluid. Is there some accurate method to verify if my program is right?

Amending some details:

My program is a 2D particle-based simulating program. The fluid is compressible. The implementation is almost based on a classical paper:

Müller, Matthias, David Charypar, and Markus Gross. "Particle-based fluid simulation for interactive applications." Proceedings of the 2003 ACM SIGGRAPH

I solved the Navier-Stokes equation with iteration method. It only considered pressure, gravity, viscosity and surface tension.

$\endgroup$
  • $\begingroup$ Maybe you can recompute the terms of the N-S equation with numerical differentiation and check how they cancel out. $\endgroup$ – Yves Daoust Sep 23 '15 at 6:19
2
$\begingroup$

Compare it with someone else's software. Run some standardized test and find out if you get roughly the same answer as others. If you get the same answer, than the probability of having your code right is quite high.

Some tests:

  1. Flow past cylinder. In 2d take rectangular domain, cylinder in the middle, inflow on the left, outflow on the fight and calculate the force on the cylinder. Here is benchmark comparing handful of codes.

  2. Buoyancy flow. Closed box, hot plate on bottom, cold plate on top, hot fluid starts to rise due to the buoyancy force. Here is benchmark.

  3. Rising bubble, benchmark.

But unfortunately it might be quite difficult to compare your code to scientific codes in those benchmarks. I guess you implemented something as SPH or stable fluids which are not made for accuracy but for stability.

Take for example the flow past a cylinder. I would start the test with very small Reynolds number and then measure the force on cylinder as you increase accuracy of your simulation(lower time step, increase subdivision or increase number of particles). Does the force converges to some number? If no, than you have a problem, if yes, than have a look at the benchmark paper and compare your result with others.


This method is very similar technique to one I use for testing my raytracer. I just render test scene with someone else's renderer and compare it with my result. Do they converge to the same result? If yes than I have it right, if no, than I have it wrong.

$\endgroup$
  • $\begingroup$ Instead of software to test against yest against known real world measurements and fluid dynamics bechmarks. Otherwise your error is tainted. I saw the same question posted elsewhere on the stackexhange network btw $\endgroup$ – joojaa Sep 22 '15 at 13:11
  • 1
    $\begingroup$ I think that testing against real world measurement is good for testing if you have the physics right. If you only want to debug you program, than testing against others code is better idea. Plus in computer simulation you can measure anything without affecting the experiment. For example measuring fluid speed at any point is just impossible in real world experiment, but trivial in computer simulation. $\endgroup$ – tom Sep 22 '15 at 13:32
  • $\begingroup$ Yes but you also inherit problems of their solvers. I admit i did do this a few times developing a multibody simulator and checking against results form MSC Adams but in hindsight that wasn't really stellarly useful $\endgroup$ – joojaa Sep 22 '15 at 14:30
  • $\begingroup$ Checking against real world experiment was any better? I doubt it, but I might be wrong. The situation with multibody physics is quite different to fluid physics. Even something as simple as billiard has chaotic behavior. Moreover rigid body dynamics with contacts is not even well posed mathematical problem, do you know Painlevé paradox? So doing numerical simulation of multibody physics is doomed to fail in general. Some references: plus.maths.org/content/chaos-billiard-table en.wikipedia.org/wiki/Painlev%C3%A9_paradox $\endgroup$ – tom Sep 22 '15 at 15:12
  • 1
    $\begingroup$ Yes i am aware of how multi body dynamics work, i kind of teach it (and briefly researched it for a year or two). But no checking against known analytical solutions was easier. But a real fluid is similarly chaotic as a multi body dynamic. So one should be able to check against laminar flow situations etc. Friction is a bitch though. $\endgroup$ – joojaa Sep 22 '15 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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