Integrating Along Streamlines and Extracting Particle Statistics


Given a computed steady-state flow field, it is often desirable to compute quantities such as the residence time distribution function of the fluid within the domain, as well as other statistical data related to the distribution of times that it takes the fluid to pass through the domain. This article addresses such situations.

Modeling Notes

This example is presented in the context of a steady-state laminar flow field, representing the flow through a small device, as visualized in the image below. A fluid inlet is defined on one side of the domain, with a parabolic velocity profile, and a uniform pressure outlet defined on the other side. The Laminar Flow interface is used, and the model is solved as a stationary problem.

Simulation results showing steady-state laminar flow field through a small device, visualized in a rainbow color table with black arrows.
The computed steady-state laminar flow field through a device.

Beginning with a model that has a steady-state flow solution, add a Particle Tracing for Fluid Flow interface. Within the settings, specify to use a Massless formulation for the particles, and specify to store the particle status data. Within the Particle Properties, specify the particle velocity to be the flow field components, u,v, which is equivalent to defining a computational particle that traces streamlines.

A screenshot of the Settings window for the Particle Tracing for Fluid Flow interface, with the Particle Release and Propagation and Additional Variables sections expanded.
Settings for the Particle Tracing for Fluid Flow interface. Massless formulation is used. Particle status data is stored.

A screenshot of the settings for the Particle Properties feature, with the Particle Properties section expanded.
Particle Properties settings. The particle velocity is the fluid velocity.

An Inlet condition is defined at the same boundary as the fluid inlet, and particles are released at time zero. The distribution of particles along this boundary is set to be proportional to the fluid velocity, since there are more particles of fluid passing through the domain where the inlet velocity is higher.

A screenshot of the Settings window for the Inlet boundary condition, with the Initial Position and Initial Value of Auxiliary Dependent Variables sections expanded.
Settings for the particle Inlet condition.

As the computational particle moves along this streamline, an additional Auxiliary Dependent Variable is used to monitor the time for each particle as it moves through the domain and gets to the outlet boundary. As shown in the screenshot below, the Auxiliary Dependent Variable defines t_particle, with units of time. By integrating the source term, R = 1, with respect to time, this variable will track the time as the particle is traced through the domain. Once the particle reaches the outlet, this variable is frozen to the exit time. A Particle Counter feature is also applied at the boundary to monitor statistics of the particles as they leave the modeling domain.

A screenshot of the Settings window for the Auxiliary Dependent Variable feature, with the Auxiliary Dependent Variable and Units sections expanded.
An Auxiliary Dependent Variable is defined on each particle.

A separate study is used to compute the particle paths and uses the results from the first study. The output times specify how long to trace the particles, and how many output time steps are saved. It is not known ahead of time how long it will take for the particles to traverse the modeling domain, so the maximum time has to be studied. The intermediate output time steps, between the start and end time, only need to be saved if a visualization of the residence time is desired.

A screenshot of the Settings window for the Time Dependent study, with the Physics and Variables Selection and Values of Dependent Variables sections expanded.
Settings for the second study, which computes the particle paths.

Results Extraction

To visualize the residence time, add a Particle Trajectories plot and color it using the particle time variable. This plot will look more smooth as more output time steps are saved. If this plot is not desired, save only the start and end times as the output times.

Simulation results for the flow through a device, with the streamlines visualized in rainbow and colored by the residence time variable.
Visualization of streamlines, colored by the residence time variable.

It is also possible to plot those particles that have not yet left the modeling domain. These particles follow streamlines that pass very close to a wall, where the velocity approaches zero, leading to a trapping effect. This can be reduced with mesh refinement near the walls, although this is not always desirable due to the increased computational cost for solving the fluid flow problem. In reality, there will be some diffusion as well, but this is ignored when using the massless particle tracing formulation. One approach is to filter these remaining particles out of the results, and the Particle Counter feature creates a logical variable, defined on each particle, fpt.pcnt1.rL, which is true if the particle reaches the outlet.

A view of the laminar flow model at the end of the simulation, visualized in gray with the remaining particles shown in red. Visualization of those particles left within the computational domain at the end of the simulation time.


To plot the residence time distribution function, use the Histogram plot type, and plot either the Auxiliary Dependent Variable of the particle time or the Particle Status stop time. Use the Sum of values normalization of the output. To plot the cumulative distribution, use the same kind of Histogram plot, with Peak normalization, with the Cumulative option enabled. Plot for the last time stored. The Filter subnode is added to the Histogram plots to filter on the Particle Counter logical expression.

A screenshot of the Settings window for the Histogram plot for the residence time distribution function, with the Expression, Bins, and Output sections expanded.
Histogram plot settings for residence time distribution function.


A screenshot of the Settings window for the Histogram plot for the cumulative distribution function, with the Expression, Bins, and Output sections expanded.
Histogram plot settings for cumulative distribution function.


Side-by-side histogram plots comparing the residence time distribution and cumulative distribution for a fluid flow model.
Plots of residence time distribution (left) and cumulative distribution (right).


To compute the mean residence time, use nonlocal coupling operators via Results > Derived Values > Global Evaluation. The expression fpt.fptop1(fpt.pcnt1.rL*t_particle)/fpt.fptop1(fpt.pcnt1.rL) will average the residence time variable over all particles that have left the modeling domain. Here, fpt.fptop1 is a predefined operator to compute a sum over all particles. The same operator can be used to compute the variance, as well as construct other metrics.

The supplementary model file with this example is available below.


Submit feedback about this page or contact support here.