• Insights

Published on April 8, 2021 by Jenny Maat

Understanding the results of your simulation is key to progress in your research. As a scientist, you want to not only know how your experiment is behaving, but also why it is behaving in a certain way. Data visualization is one of the most important tools we have to achieve this, and gives us direct insight into our simulations.

Visualizing RheoCube data

In RheoCube, we simulate fluids and particles using continuous smoothed particle hydrodynamics (CSPH). The simulation is broken up into small ‘blobs’ that can contain multiple components and are free to move around. Components can also flow between blobs, changing their compositions. The most straightforward way to visualize the blob data is to render a sphere for every blob. The spheres are then colored according to the concentrations of the components, or any other physical quantity.


This representation, however, can be especially confusing to RheoCube users without simulation experience. A common misconception is that the spheres behave like billiard balls, bouncing off each other, or that the spheres represent atoms or molecules. It can be helpful to think of every blob as a source of colored light moving through the simulation box. You can then simply measure the intensity and the color of the light at a particular spot to measure a concentration or physical quantity. Heat maps like the ones shown below provide a nice, intuitive alternative (although they may take longer to generate).


The physical quantities in the simulation box are measured on a regular grid by interpolating the values at the blob positions, and each grid point is then displayed as a colored pixel. Unfortunately, the interface of the droplet still looks fuzzy, with pixels around the interface being a mix of the two colors. When we study an emulsion of droplets under the microscope, we see a smooth round surface. To visualize and study surface shapes or contact angles in RheoCube, we need a visualization that produces similar well-defined interfaces.

Using isosurfaces to neaten up

An isosurface connects points in 3D space having equal value of a quantity. It is an extension of isolines in 2D, like isobars on weather maps connecting points of equal pressure or contour lines on a topographic map connecting points of equal height. If we render an isosurface at 50% concentration of the droplet component, we get a close approximation of a sphere representing the droplet surface. Hence, this approach gives us the well-defined interfaces we could not produce with the previous visualization methods.


If we are able to interpolate the CSPH data on a regular grid, we can calculate the shape of the isosurface with the ‘marching cubes’ algorithm. Grid data can be divided into cubic cells, with the values at the 8 vertices known. Within each of these cells, the shape of the isosurface can be determined by interpolating the values at the vertices. Because the interpolation in each cell is independent, it can easily be parallelized and is much faster than calculating isosurfaces from irregular data.

Getting a regular grid with interpolation

The main challenge with integrating isosurfaces into our visualization tools is the interpolation of the irregular CSPH data to a regular grid. The CSPH algorithm developed by our modelers is highly customized, preventing us from using the more common interpolation algorithms (such as trilinear interpolation). Additionally, another complication in our simulations is the use of periodic boundary conditions to avoid modeling edge effects and to simulate shear. Blobs moving through a simulation box boundary appear on the opposite side. To simulate shear, blobs moving through the z-boundaries get shifted in their x position and velocity.


If we want to interpolate the value of a quantity in the top right corner of the original simulation box, we not only have to take into account the value of blob 2, but also the value of blob 4, since the boundary means blob 4 is actually close to blob 2. To avoid complicated boundary checks during interpolation, we add a cubic shell of copied blobs during the calculation, for a slice through a simulation box, with the original blobs colored in orange. By copying blobs across the boundaries, we make sure that the blobs near a boundary influence the value on the grid points close to the opposing boundary.

Generating the isosurface

With the periodic boundaries taken care of, the only thing left is to apply the marching cubes algorithm to generate some isosurfaces. For example, we can render the droplet from the first image.


Not only do isosurfaces look better, but they also have the potential to improve the contact angle analysis. To illustrate this, we took a simulation of a droplet of decane adhering to a particle and rendered both the particle and the droplet as an isosurface and added a the solvent as a volume render.

Bringing better surfaces to RheoCube

The improved rendering of surfaces in RheoCube brings a simple and intuitive visualization to aid our customers with their interpretation of their data. As this exciting new feature appears in the upcoming release, we hope to deliver another helpful tool that gives our users better understanding of their data.