# Mapping SPH data on Eulerian Grid for further evolution

I'm sure this is very important for anyone working in computational astrophysics. I have a .sph file & it has 10 columns containing

x, y, z, density, temp., velx, vely, velz, smoothing length, particle mass.


Data is in some strange units but I can take care of that. But, I don't know about other details. Anyone who may have worked with SPH code probably will know how to extract physically sensible data out of it.

I'm a novice in computational astrophysics & computation as a whole but know the physical equations (MHD, Radiative transport, etc...) very well. Any help would be highly appreciated.

P.S. : Please provide some novice & some advanced references.

## 1 Answer

The data in the SPH format is perfectly "physically sensible", you just need to know how to interpret it.

In the SPH formulation, you can compute any particle quantity $A$ at any given point using

$$A(\mathbf r) = \sum_j m_j \frac{A_j}{\rho_j} W(\|\mathbf r-\mathbf r_j\|,h_j).$$

Where $\mathbf r$ is the target point, e.g. a node on your grid, and $\mathbf r_j$ is the location of the $j$th particle, and $\rho_j$, $m_j$, and $h_j$ its density, mass, and smoothing length respectively.

The function $W(r,h)$ is the kernel function which is usually zero beyond $r>2h$. This means that for any target point $\mathbf r$, you only need to inspect particles where $\|\mathbf r - \mathbf r_j\| < 2h_j$.

The target quantity $A$ can be the velocity, temperature, density, whatever is stored at the particle level.

Most of this is described in the Wikipedia article on SPH. A good source for further details is Price's excellent review of SPH available here.

Note that if you're mapping the particle data to a regular grid, it makes much more sense to loop over the particles, not the grid points, as finding the grid points within range of a particle is much easier than finding the particles within range of a grid point.

• thanks a lot for the help. Sorry about returning to this page after so long. I figured out most of the subtleties in SPH data from the Bodenheimer etal book. I would like to add one more aspect of it which I still haven't figured out completely. It's Gather vs Scatter approach to get the physical data at a point in space. Which one is better in what kind of condition etc. There is no pressing need for this but, hopefully someone can elaborate on this. – sceptic_one Feb 26 '14 at 17:42