# What scale problem can be simulated on an PC using Smooth Particle Hydrodynamics?

I want to simulate tidal features in a large body of water using was smooth particle hydrodynamics. For a system composed of an incompressible fluid, what general scale of problem can be tackled with an home computer? That is, how large of a body of water can I accurately represent using Smooth Particle Hydrodynamics?

• Based on the comments below, the term 'scale' does not directly translate to a quantifiable computational load. Without providing a specific problem and accuracy constraints, it is impossible to answer this question in any meaningful way. – Paul May 29 '14 at 3:56
• I think this is a perfectly fine question. It's not specific, and I'm interested in hearing anecdotes. For example, I can say in electromagnetics, you can simulate a 2D domain that's maybe a dozen wavelengths on a side for hundreds of optical cycles in a reasonable amount of time. I think this kind of answer is both useful and interesting. – Victor Liu May 29 '14 at 6:57
• You can simulate the ocean with 10 grid points on a home computer, but that simulation isn't going to be very good. – James May 29 '14 at 13:47
• What is the characteristic length between individual particles in a "Smooth Particle Hydrodynamics" model? Also, how many spatial dimensions are you simulating on? Hypothetically, any computer will only be able to work efficiently with some maximum number of $N$ degrees of freedom in its memory. If you're simulating in $d$ dimensions and the characteristic length is $L$, you can only simulate a problem of scale $L\cdot\sqrt[d]{N}$. – Paul May 29 '14 at 13:47
• If I understand your comment, the characteristic length is L should be quite large for a tidal type phenomenon? – user1750289 May 29 '14 at 16:00

All models are wrong, but some models are useful - George E. P. Box

Let's establish one important fact: Simulation Models are not exact replicas of reality. We use models to understand only a small piece of the real physics that is actually happening. No model, no matter how good the equations are or how powerful the computer is, can exactly mimic reality.

Models can be useful to understand certain physics, whether at the atomic scale (ab-initio models), mesoscopic scale (molecular dynamics or lattice boltzmann models), or macroscopic scale (navier stokes equations). Depending on which scale you choose (among other factors), you can make certain assumptions to model a glass of water or a lake (or even an ocean).

The word 'scale' (as the OP is using it) does not translate directly into a computational load directly. As others have already pointed out, the computational load depends on the total number of the resulting degrees of freedom after discretization. Any 'scale' can be simulated on a desktop computer provided that the total number of resulting "degrees of freedom" is small enough to fit in the computer's memory. Scale is independent of degrees of freedom. Accuracy, on the other hand, is highly dependent on the number of degrees of freedom, the type of problem, and the solver being used.

The key questions to ask are:

1. Which 'physics' are most important for this particular problem?
2. How much accuracy is needed?

Neither of these two questions is easy to generalize for any problem, no matter what the scale is. Therefore, it's really not possible to answer your question in any kind of general sense. It really depends on the kind of problem you want to model and how much accuracy you really need.

This depends a great deal on the type of CFD problem and the methods being used. But as a rough start using a lightweight geometric multigrid for the pressure solve and explicit time stepping for velocity, suppose you have 100 bytes per cell. If you have 8 GB of memory, you could solve a problem with about 80 million cells. This will likely be slower than you want because explicit CFD typically needs many time steps, in which case you should move to a smaller problem size. More storage will be needed if you use assembled matrices or Krylov methods (which may or may not make the code run faster).

• How would that corispond to a "real" system? Is is a glass of water or a large lake? – user1750289 May 28 '14 at 15:26
• The 80 M figure roughly corresponds to the number of degrees of freedom. The question of estimating the number of degrees of freedom in a "real" system is 1) hard and 2) not general. Could you make your question more specific? – Max Hutchinson May 28 '14 at 15:41

Wow what an open question to ask!

As already mentioned the answer depends on so many factors. Here are just a few: Type of method (i.e. finite difference, spectral, finite volume, finite element etc), the power of your home computer, your skill as a programmer, the language you use, the algorithms you use for solving linear systems, explicit verses implicit time stepping, any parallelization you are able to exploit, the time you are willing to wait, how many time steps you need....

I assume by "general scale" you are talking about what grid sizes can be solved on a home PC. For 2D problems as a rough estimate I would say O(1024^2) is definitely do-able for many problems with maybe around 100000 time steps.

In addition to the other answers, let me just note this as a comparison: if you do not smoothed particle hydrodynamics but just a traditional Q2xQ1 (Taylor-Hood) finite element discretization of the Stokes equations in 3d, then you end up with ~400 nonzero entries per row of the matrix. That means ~5000 bytes per degree of freedom in the matrix alone, plus maybe that much again if you want a good preconditioner. So 10kB per degree of freedom. (I know @Jed Brown is going to say that one could get away with less, or do use matrix free methods, and that is all true, but for the sake of argument let us consider a "traditional" approach.)

Then, if you have say 16GB of memory, you can do ~1.6M unknowns in total. Given that every cell in a uniform mesh has 25 unique degrees of freedom, this equates to 64,000 cells -- i.e., for example a 64x32x32 mesh. Whether that's appropriate for your problem is a question that depends on what you want to do.

How long will it take to solve such a problem? A rule of thumb is that solving 100,000 unknowns on a single core in a parallel context will take 1 minute. So if your computer has 8 cores, then that's 200k unknowns per core and it would take 2 minutes to solve a Stokes system of the size outlined above.