I am currently learning the Smoothed Particle Hydrodynamics method that I need to use later in my thesis. I have studied the mathematics behind the method and I want to code a simple example to show how the classical SPH does not reproduce a constant field exactly. So, if we consider for example

$$f(x,y)=\frac{1}{2}\left(\frac{\partial x}{\partial x}+\frac{\partial y}{\partial y}\right)=1$$

I would like to know how to get the following approximation of $f$

enter image description here

I am familiar with Fortran, so I would prefer to use it for this example.

Any help with this would be appreciated and thank you in advance.

  • $\begingroup$ I think that your question is not clear enough. Are you asking how to modify the classical SPH to obtain a constant field? $\endgroup$ – nicoguaro Feb 1 '18 at 21:18
  • $\begingroup$ No, i am just asking how to create a code that produce the linked image (to show that sph does not reproduce constant field exactly) i don't know how to do it $\endgroup$ – hamza boulahia Feb 1 '18 at 21:20
  • 1
    $\begingroup$ So, you are asking how to program the method? $\endgroup$ – nicoguaro Feb 1 '18 at 21:21
  • $\begingroup$ Yes if you want, but even some instruction to start wloud be very helpfull $\endgroup$ – hamza boulahia Feb 1 '18 at 21:23
  • 1
    $\begingroup$ Have you read an introductory text on the topic? $\endgroup$ – nicoguaro Feb 1 '18 at 21:31

The SPH implementation of the function in your question reads as:

$f(x,y)=\frac{1}{2}\big(\frac{\partial x}{\partial x}+\frac{\partial y}{\partial y}\big)=\frac{1}{2}\nabla\cdot\textbf{r}\approx\frac{1}{2}\sum_j^n(r_j-r_i)\frac{m_j}{\rho_j}\nabla W_{ij}=\langle f_i\rangle.\qquad(*)$

A very useful simulation tool could be the open-source Aboria, constructed to facilitate the application of particle methods like SPH. Although it requires C++ programming skills, this is a good choice for your problem. You can find Aboria on GitHub here and a related SPH example here.

As long as programming is not a requirement, probably the easiest way to investigate this and other properties of SPH is using Nauticle, which is also an open-source tool with objectives similar to that of Aboria. The Nauticle code is available here with examples and user-guide. However, this tool is not an option if you prefer programming SPH manually.

Running Nauticle with the following simple configuration file

        - L: 1
        - rho0: 1000
        - csize: L/2
        - dx: csize/2.5
        - mass: dx^2*rho0
        - dt: 1
          cell_size: csize|csize
          minimum: 0|0
          maximum: L/csize|L/csize
          boundary: 2|2
          gpos: 0|0
          gsize: L|L
          goffset: 0|0
          gip_dist: dx|dx
        - f: 0
      - eq: f=sph_D00(r,mass,rho0,Wp52220,csize)/2
    simulated_time: dt
    print_interval: dt

gives the result you requested. The equation in the fourth line from below implements the SPH differential operator $(*)$

Visualisation of the result in Paraview:

enter image description here

| cite | improve this answer | |
  • $\begingroup$ Any suggested documentations on how to visualize SPH results on Paraview ? $\endgroup$ – hamza boulahia Mar 2 '18 at 16:48
  • $\begingroup$ Most of the SPH simulation tools generate .vtk result files, which can be simply read in Paraview. You can read about the usage through the link below. This material is not related to particle data but the procedure is similar. cac.cornell.edu/education/Training/data10/… $\endgroup$ – BalazsToth Mar 2 '18 at 21:21

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.