# Understanding Substeps in RealFlow

##### ‌‌
There's a lot of parameters in RealFlow that are vital to making your simulations a success, but perhaps none are more important than having a thorough understanding of substeps. If they're set too low, they'll likely ruin your simulation and if they're set too high, they'll likely crash your system. Substeps can be a very abstract term, but in this article you'll get to know more about substeps in RealFlow so you can use them in your own simulations that much more effectively.

### Simulation Basics

To understand substeps, it's important to first understand the basics of dynamic simulations. A simulation is a form of animation that's used to speed up the animation process for things that would be extremely difficult, if not impossible, to animate by hand. For example, instead of manually animating millions of polygons to create a realistic-looking ocean, it's a lot easier to set parameters like the size of the ocean, the minimum and maximum size of the waves and the amount of wind and then let the computer calculate all of the actual movement. Like any other animation, a huge part of a dynamic simulation is the duration of the animation. Using the example above, how long is this ocean going to be animated for? Is it going to be animated for five seconds or 30 seconds? This is, of course, determined by the framerate. So if 24 frames equal a second in your animation, then a 30 second dynamic simulation is going to be 1,440 frames.

### Frames and Steps

Similar to the way the concept of frames relates to seconds for an animation, the concept of steps relates to frames for a dynamic simulation in RealFlow. Inside each frame, is a number of steps that make up that frame. So, in essence, RealFlow isn't really calculating each frame. Instead it's calculating each step and then once a certain number of steps are calculated, the frame is complete. You can think of this a lot like the way that you accomplish any project of your own. You don't do a project. You do a series of tasks that, in the end, complete the project. For example, let's say you want to make yourself a nice meal. Some of the actions that might go into making yourself a meal could be finding a recipe to learn what ingredients you need for the meal, buying the ingredients at the store and cooking the meal. Then you get to enjoy a delicious, home-cooked meal. Enjoying the meal is similar to the frame being simulated, it's the best part. Whereas the steps that you took to create the meal is similar to the substeps RealFlow takes to create a frame. The same sort of concept is how RealFlow handles it's calculations for each frame in your simulation. Once the series of steps inside of each frame are calculated, that means the frame is complete and it's onto the next one. For this reason sometimes the steps in RealFlow are referred to as time steps and, accumulatively, all of those steps on each frame are referred to as just the substeps.

### Accuracy vs. Speed

As you might imagine, the more substeps you have the more time it'll take for your simulation to calculate. On the other hand, you'll find that RealFlow's calculations of your simulation might start to give you some rather unexpected results when you have fewer substeps. Most commonly, the symptom of this is seen when you have particles popping out of place or not colliding with objects as you might expect. For example, in the video above notice how there are particles that are falling completely through the plane as if it wasn't even there. There's also some random particles that pop out of place, these issues are directly effected by the substeps that you chose. What's interesting about the video above is that not all of the particles are going completely through the plane. Likewise, not all of the particles are popping around randomly. The reason for this unexpected behavior has to do with the number of steps that RealFlow is calculating. For a particle going through the plane, the interaction that should've occurred is something that is between the two steps that RealFlow has calculated. As a result, the particle keeps on moving as if there was nothing there because, as far as it's concerned, there isn't anything there. With thousands or millions of particles in any given simulation, the end result of this can quickly become pure chaos. To fix issues like this, you'll need to increase your substeps. That'll increase the number of calculations per frame that RealFlow is solving for and, by extension, mitigate the chance of a particle going through something that it should've collided with. Just keep in mind that the higher you set your substeps, the more calculation time it'll take. In the example video above, the substeps were set to a minimum of 1 and a maximum of 3 instead of RealFlow's default of 1 and 300.

### Controlling Substeps

The number of substeps that occur on any given frame is generally going to be determined automatically by RealFlow. You can, however, give it a minimum and maximum range for it to work within. Of course, if you really need to set a specific number of substeps then you can just set the minimum and maximum to the same number but for most simulations it's best to work within a pretty wide range. Depending on what your simulation entails, RealFlow gives you a number of ways that you can control the number of substeps used. Primarily, these options are found in the three different tabs either in the Preferences window (to set it globally) or in the Simulation Options window (to set it in the scene). For fluid simulations with either particles or Hybrido you'll find the MIN substeps and MAX substeps parameter in the General and Hybrido tabs. If you're working with a soft or rigid body simulation using Caronte, you'll find the substep controls in the Caronte tab. However, you'll notice that they aren't the same MIN substeps and MAX substeps as it is with fluids. Instead, controlling substeps for with the Caronte solver is done with the Quality slider and the actual number of substeps are then calculated by RealFlow behind the scenes.

### Conclusion

Unfortunately there's no magic number of substeps that will be perfect for every simulation. You'll probably find that the default settings work great when you're getting started, but as your RealFlow projects get more and more complex then you'll run into situations where you'll need to make adjustments. Much like someone rendering in a 3D program will often need to perform a lot of test renders, working with substeps will require a bit of trial and error to find the right balance of speed and accuracy for your simulations. Now that you've got a better understanding of how substeps play a vital role in the quality of your RealFlow simulations, don't be afraid to start pushing the envelope on your own simulations. If you've found success working with substeps, let us know in the comments below!