SPH - Particles (Scripted)

There are occasions where RealFlow's default particle types are not enough and you need a certain behaviour. With scripting you can manipulate the forces between the particles and control them. The standard settings are very similar to the “Liquid” type, but when you start a simulation you will see that the behaviour is completely different, because of the lacking interaction and forces between the particles.

 


Type

This submenu allows you to define the fluid’s behaviour. By default, RealFlow generates fluid particles used for all kind of liquids. Fluid particles can interact with other fluid particles and support self-collision. They are affected by any of RealFlow’s internal or imported objects, including RealWave surfaces.

Gas” is used to create substances like air. Gas particles tend to very strong expansion and high velocities. RealFlow gases are not grid-based and therefore behave completely different from other solvers.

Liquid” is RealFlow’s standard setting and provides parameters for all watery or high-viscous substances. It is surely the most often used type and is suitable for all kinds of particle-object interactions, but especially for small to mid-range simulations. For larger projects, you should consider using the new grid-based fluid solver "Hybrido".

Dumb” particles are perfectly suited for fast calculations of secondary effects, like spray or foam. Please keep in mind that these particles cannot react with each other and will not be affected by other emitters.

Elastics” establishes a so-called spring-mass system between the particles, making them behave like a soft body. This option can be used for interesting effects like jelly-like fluids or expanding and contracting substances. Please note that elastic particles are not ruled by RealFlow’s soft body solver – that is a completely different system and can only be used with objects.

Script” gives you the opportunity to write your own fluid behaviour with Python scripting or C++. Choosing this type adds an “Edit” button to the menu. Clicking on “Edit” opens a new scripting window with a predefined function that is used to enter your source code. By default, this window does not contain any executable code.

Resolution

With this setting you can increase or decrease the amount of particles, and therefore it is one of the most important parameters. “Resolution” especially depends on scene scale and emitter scale, but it also affects the fluid’s mass and therefore depends on “Density”, too. By default, resolution is 1.0. A volume of 1 x 1 x 1 units filled with 1,000 particles has a mass of exactly 1,000 kg. In other words: Each particle has a mass of exactly 1.0 kg. By raising “Resolution”, an individual particle’s mass will be lowered and vice versa. You can monitor the relationship between mass and density under

Statistics > Particle mass

Dependent on your scene, “Resolution” can dramatically increase, and values of 1,000 or even much higher are sometimes necessary. Another interesting issue – especially for scripting and plugin development – is the relation between “Resolution” and a particle’s radius, ruled by this formula:

radius = 1.0 / (1000.0 · Resolution1/3)

Density

Density” is defined as mass per volume unit and is expressed in kilograms per cubic metre [ kg/m3 ]. Water, for example, has a density of 1,000 kg/m3. “Density” is different for each substance and for some fluids, like crude oil or honey, there are only average values available, because they consist of variable amounts of ingredients.

Int Pressure

Each fluid shows a more or less strong tendency to expand. With gases this behaviour can be observed best, but even liquid substances have this tendency. “Int Pressure” simulates the forces between nearby particles, and very high values make the fluid fill a greater volume. If “Int Pressure” is set to 0.0 the particles lose their fluid behaviour.

Ext Pressure

This is “Int Pressure’s” counterpart and tries to limit a fluid’s expansion tendency. With very high values it is possible to compress the fluid. Gases, for example, should have very low “Int Pressure” and rather high “Ext Pressure” values to prevent them from flying away. Both parameters are used to fine tune a fluid’s appearance and behaviour, therefore they are fundamentally important for a realistic simulation.

Viscosity

Each fluid has a certain amount of viscosity, even water. It defines the tendency of particles to stick together. With very high values you can observe the typical strings in viscous fluids when they are torn apart. Substances with very high viscosity are honey, tar or syrup, for example. Fluids with low viscosity are alcohol, many solvents or liquid gases. Exaggerated settings can lead to misbehaving particles with high velocities.

Max Particles

The pre-adjusted default value is also the maximum value, but it can be changed any time, if you need less. Under “Statistics” you can see two entries counting particles: "Existing Particles" and "Emitted Particles". Max Particles” is connected to the latter value, and if you want to stop the emitter to create more particles you can enter a smaller value. Please note that "Max particles" is based on the total amount of emitted particles. Let's say you have entered "500,000", so even if you currently have only 1,000 particles in your scene, but have already deleted 499,000 particles, RealFlow will stop creating new particles.

Edit

A click on this button opens an extra scripting window. It contains a few comments (introduced by a “#” symbol) and an empty function for introducing forces between the particles. This part can be filled with your script and RealFlow will execute the instructions to create the desired behaviour.