Simulation Flow (SF)

The “Simulation Flow” window is located under RealFlow's “Layout” menu. With simulation- or event-based scripts and graphs it is possible to influence a running simulation. You can, for example

  • manipulate emitters, particles and objects
  • record changes in position or rotation
  • activate and deactivate nodes on demand
  • emit particles from surfaces
  • shift particles between emitters
  • do everything to customize a simulation.

 

 

Simulation Flow” scripts and graphs are saved together with the scene. We recommend storing your simulation programs in a save place anyway.

Quick Start

In this short example, particles which collide with a vase object are shifted to a second emitter, e.g. for the separation of water and foam. The scene consists of a “Circle” and a “Container” emitter, a “Gravity” daemon, and a vase object:

  • Reposition the “Circle” emitter with the W key to make its particles collide with the inside of the vase.
  • Resize the vase with R.
  • If you change the “Circle” emitter's → “Resolution” please use exactly the same value for the “Container” node to avoid instabilities.


Proceed as follows (see image above for the result):

  • Right-click on “FramesPre” and choose “Add Script”.
  • A new script appears, named “Script_embedded_” followed by a number.
  • In the right area of the panel you will also see a new tab with exactly the same name. Click on this tab to open the script editor.

 

Copy/paste the script below to the empty editor, or transcribe it. But, no matter what you do, please always mind the leading tabs – they are essential! When you simulate you will see that the colliding particles are shifted to the “Container” node.

 

# Get the emitters
emitterA = scene.get_PB_Emitter("Circle01")
emitterB = scene.get_PB_Emitter("Container01")
 
# Get emitterA's particles and loop through every single particle
particlesA = emitterA.getParticles()
for singleParticle in particlesA:
 
# If the particle is colliding...
if (singleParticle.isColliding() == True):
 
	# ... get some basic properties
	particleAPos = singleParticle.getPosition()
	particleAVel = singleParticle.getVelocity()
	particleAId = singleParticle.getId()
 
	# Add a new particle to emitterB with the properties of particleA
	emitterB.addParticle(particleAPos, particleAVel)
 
	# Remove the particle from emitterA
	emitterA.removeParticle(particleAId)

 

Now, drag the script from the events tree's “FramesPre” to “StepsPre” and simulate again. The simulation performs much slower, but the result is more accurate. The reason is that the script is not executed once when a new frame starts, but each time a new substep begins. The actual number of executions depends on your “MIN substeps” and “MAX substeps” settings in the → “Simulation Options”.