Skill Level Intermediate
- [Instructor] Initial state is a feature of simulations in which we can set the initial conditions for a simulation based upon the current conditions, so that means you can run a simulation until you get a result that you like and then store that as the initial state or start conditions for a new simulation. This is very helpful in many situations, a classic example being this one in which I simply want this glass of water to settle down and become completely motionless before an action is performed upon it.
I have a simple animation here in which the glass gets knocked over and this purple cylinder here is going to be the emitter for a 3ds Max fluid simulation. If we rewind back to frame zero, I scale down the emitter a bit in order to make this a more dramatic example I'll make it so that the liquid sloshes around in the glass a bit so we can actually see when the initial state is being stored.
Okay so that's why I've scaled down just for clarity in the demo. But normally it would be scaled up to fit inside the boundaries of the glass. Let's open up the simulation parameters, select the icon for the 3ds Max liquid object. And go to the Modify panel, open up the simulation view. And go to the Solver Parameters tab. I've set up the master voxel size in advance to be 0.1 centimeters cubed or one cubic millimeter per voxel.
Down in the simulation parameters we need to make a few changes, we're going to increase the adaptivity for our transport steps, which increases the likelihood that more transport steps will be subdivided within the current time step. Set the adaptivity to .9. And also set the minimum number of transport steps to 100. And this will optimize the motion of particles for static colliders.
Down here in Time Steps we need to increase the number of time steps here because we're dropping this liquid into the glass and you don't want any particles to pass through the glass. Set the minimum number of time steps to two and the maximum to three, we'll leave the adaptivity at its default of 0.1 for now. And these are good settings to simply drop the water into the glass from a distance of about a centimeter. We can go up into the Simulation View Solver Management area and we have Liquid001 and inside that Solver01.
Press the play button to begin the solve. And if you wish you can go into the Options and open up the Output window as well. And that'll just tell us what frame we're on and how long each frame took to simulate. Let that run for a few frames until this liquid seems to converge right around frame eight or nine you might start to see a peak come up that'll be obvious for the demo. So I'm here on frame nine and I'll stop the simulation.
And let that finish, that last frame has to finish. And we can scrub through the timeline and find a frame that's going to be a good representative and obvious one to indicate that this will be the new initial state. I'm parked on frame nine and in the simulation view menu, go to the Solver menu and choose Set Initial State. And the screen flickers, now if we scroll back to the beginning, we're still seeing the cache that we just built, we need to clear that out as well.
Go back up into the Solver menu and choose Clear Cache Files a popup dialog comes up labeled Clear Cache, we need to enable the switch to clear the fluid cache and click OK. Now that's been erased, but the initial state is still in place. If we go back up into the Solver menu we see the clear initial state is an option that we can choose and it's not grayed out, that means we have a valid initial state storage for the currently selected solver.
Now it should go without saying that if we make any changes to parameters, we are likely to invalidate the initial state just like we would with an ordinary cache. To pick up where we left off, simply press the play button to recreate the cache on Solver01. And we see that on frame zero, the first frame of our simulation we had that peak, so we've proven our point here now the initial state is being stored. We can let that play through if we want but we'll get better results if we scale the emitter to the inside of the glass.
I'll stop the simulation, go back into the Solver menu, clear the initial state, and in the Solve Warning dialog choose Yes. Once again in the Solver menu, clear the cache files. Once again click Clear Fluid Cache and click OK. And then select the emitter, go to the Scale tool and in the transform type in just set it to a value of 100 percent, now it's scaled up properly.
I can go back to the Select Object tool and we can rerun the simulation. Once again we have simulation parameters that are optimized for static collisions and we are safe to run the simulation now and expect that it should behave pretty well. I'll move that Simulation Output window over a little bit and press play to rerun the Solver01 simulation. If your emitter is still selected you can click in the View Port to deselect it and it might be a little bit easier to see the fluid particles.
As it plays through we can see that the amount of vorticity is evening out. The color variations in the particles here are derived from the vorticity and those are constantly re-evaluated so we're always going to be seeing some amount of vorticity, it's never going to go to pure blue with no cyan color. I'll let that play through for a few frames until it seems like it's finished. Mount frame 15 I think it's safe for me to stop the solver.
And set that as the initial state, Solver, Set Initial State once again clear out the existing cache, go back into Solver Clear Cache Files. And choose Clear Fluid Cache, click OK. Now if we rerun the simulation, it will be settled down on frame zero. My animation doesn't start until later in the timeline and I can avoid a run-up to that frame by simply setting the start time of the simulation.
Back in the simulation view window in the Solver Parameters, scroll back up to the top if necessary, set the start frame to frame 60 and now we won't have the run-up from frame zero to 59, and we'll have a few frames for the liquid to settle down even further. You might see some activity on the first couple of frames just because the collider is so close to the particles. Additionally because I have that animation on the tumbler, I will need to increase the number of time steps, otherwise my particles will go through the geometry.
Back in the Time Steps, we want to increase the adaptivity to 0.9, the minimum time steps we'll leave at two, but the maximum time steps I'm going to set to a high value of 20 for a fast moving collider. Okay these are good conditions for an animation of knocking over the glass of liquid and we'll go ahead and click the Play button to create a new cache for Solver01. We can monitor that in our simulation output window and it will take longer, previously we had simulation times of five seconds, but this will go up considerably because we've increased the number of maximum time steps to a high value of 20.
By the way don't be fooled by the coloring in the view port, it looks like we have a high degree of vorticity on frame 63 here, but that is not actually accurate, once again because those colors are re-evaluated on every frame. They're just there as a guide for you to get an idea of the relative strength of that parameter. Alright so this is going to take a lot longer to calculate so we're going to pause the video and check in on this in a moment. And here is a play blast of the results in which we employed initial state in order to settle down a liquid at the beginning of an animation.