Weekly Development Notes #54 – New APIC Solver in FLIP Fluids 1.0.9b

Covering the week of April 5th – 9th, 2021.

Thanks for checking out our our 54th development update for the FLIP Fluids liquid simulation addon for Blender! It was quite a busy last week with the release of FLIP Fluids 1.0.9b and the Blender Market Spring Sale, but now we’re back to a regular development schedule. In this post I’ll detail the new APIC solver that we added in the latest versions.

New APIC Solver

Since the release of Blender 2.92, Blender’s built-in Mantaflow simulator added an APIC solver, and we heard from so many of you that you’d love to see this in our FLIP Fluids addon, so we had to add an APIC solver as well! Let’s try to explain some of the differences between the PIC, FLIP, and APIC method. The following sections can also be found in our new FLIP vs APIC documentation section.

PIC vs FLIP vs APIC

  • PIC (Particle-In-Cell) – The PIC simulation method is stable, but not very accurate. Energy in PIC simulations quickly dissipate over time and can end up looking viscous. In this section, when we refer to PIC, this will mean that the simulation method is set to FLIP and the PIC/FLIP Ratio is set to 1.0.
  • FLIP (FLuid Implicit Particle) – The FLIP simulation method is unstable, but has an improved accuracy compared to PIC. FLIP simulations are energetic and do not quickly dissipate, unlike PIC. FLIP simulations are good for high energy, noisy, and chaotic simulations. Generally better for large scale simulations where noisy splashes are desirable. Due to being unstable, we mix in a small amount of PIC simulation to tame the chaos. In this section, when we refer to FLIP, this will mean that the Simulation Method is set to FLIP and the PIC/FLIP Ratio is set to 0.05.
  • APIC (Affine Particle-In-Cell) – The APIC simulation method is both stable and has an improved accuracy compared to PIC. APIC simulations are energetic, do not dissipate energy as much as PIC, and are also able to better preserve vorticity (rotational energy) compared to FLIP. APIC simulations are good for high vorticity, swirly, and stable simulations. Generally better for small scale simulations where reduced surface noise is desirable or for viscous simulations. In this section, when we refer to APIC, this will mean that the Simulation Method is set to APIC.

For a more technical overview of PIC vs FLIP vs APIC simulation, see this video created by the researchers of the APIC method: The Affine Particle-In-Cell Method.

Comparisons

Lets take a look at some comparisons!

Fountain Comparison

This comparison shows how APIC can generate smoother sheets of fluid compared to FLIP.

  • FLIP (left): FLIP is naturally chaotic and part of this causes fluid motion to ripple back and forth, resulting in dimples on the surface. This is what is preventing the smooth curved flow compared to APIC. These noisy sheets can make FLIP a good choice for large scale fountains where noisy behavior is more expected.
  • APIC (right): APIC improves on motion stability, leading to smoother thin sheets, even at low resolutions (res = 150). These smooth sheets make APIC a good choice for a small scale fountain.

Vortex Ring Comparison

This comparison is a cross section visualization the underwater movement of a vortex ring.

  • FLIP (top): Due to the noise of FLIP and the dissipation of PIC that is mixed in, the vortex ring become disorganized in its rolling motion and rotational energy dissipates over time.
  • APIC (right): APIC is better at conserving the rotation in both direction and energy. Is able to maintain rolling vortex ring within the fluid for a longer amount of time compared to FLIP.

Stream Comparison

This comparison shows how the underwater motion of PIC, FLIP, and APIC affects motion of whitewater bubbles.

  • PIC (Left): Rotational energy dissipates quite quickly, leading to low amounts of swirling motion. Dissipation results in the fluid looking a bit viscous.
  • FLIP (middle): FLIP is more energetic and able to capture more rotational detail compared to PIC. But due to FLIP being mixed with PIC, some energy ends up dissipating over time.
  • APIC (right): Very good at preserving rotational energy compared to PIC and FLIP. Able to capture smaller motion details and complex motion that expand into a larger area of the fluid. Due to the increased turbulence, this results in whitewater particles being generating in more areas of the fluid.

Note: APIC can be good for effects where underwater bubbles are the focus, but in our tests, we found that APIC is not as good as FLIP for generating foam particles on the fluid surface. The high amount of rotation of APIC tends to concentrate foam into thinner lines on the fluid surface. The more chaotic motion of FLIP seems to be better for breaking up foam.

Dam Break Comparison

This comparison displays the differences between PIC, FLIP, and APIC for a classic Dam Break setup (A block of fluid dropping on one side of the domain). This shows how APIC can be energetic like FLIP, while also taking less time to compute. FLIP and APIC require very similar amounts of computation, but due to the increased stability and reduced noise in the velocities of APIC, this can result in quicker baking times due to requiring fewer substeps.

  • PIC (Left):
    • Energy of PIC dissipates quickly and doesn’t result in large splashes like FLIP and APIC.
    • Due to the dampened motion, whitewater particles are more clumped together and do not get spread out through the fluid as much as the others.
    • Due to the generally slower and stable velocities of PIC, this is the quickest to compute and required 1118 total timesteps to compute.
  • FLIP (middle):
    • FLIP is very energetic and creates large splashes. The slow motion section shows how FLIP creates more chaotic and noisy splashes compared to APIC.
    • Due to FLIP being naturally chaotic and less stable than PIC, this results in larger velocities and was the slowest to compute. Required 1427 total timesteps to compute.
  • APIC (right):
    • APIC preserves a similar energy as FLIP and also creates large splashes. The slow motion section shows how APIC creates more stable, but still energetic splashes compared to FLIP.
    • More turbulent detail of APIC results in more whitewater particles.
    • APIC motion creates more stable velocities and results in a quicker baking time. Required 1221 total timesteps to compute.

High Impact Comparison

This comparison shows how a high impact splash can differ between FLIP and APIC.

  • FLIP (left): The chaotic and noisy nature of FLIP causes impacted fluid to spread out into a large number of droplets in a large area.
  • APIC (right): The more stable nature of APIC causes impacted fluid to spread out into more uniform and cohesive splashes compared to FLIP.

FLIP Fluids 1.0.9b

Our latest stable version, FLIP Fluids 1.0.9b, released last week! This new version can be found in your Blender Market account downloads.

Release Notes

  • FLIP Fluids version 1.0.9b adds many bug fixes, stability improvements, and by popular demand, a new solver feature using the APIC simulation method!
  • Added an APIC solver using the Affine Particle-In-Cell method.
    • The simulation method, FLIP or APIC, can be set in the FLIP Fluid Simulation panel or FLIP Fluid Advanced panel.
    • Choose FLIP for high energy, noisy, and chaotic simulations. Generally better for large scale simulations where noisy splashes are desirable.
    • Choose APIC for high vorticity, swirly, and stable simulations. Generally better for small scale simulations where reduced surface noise is desirable or for viscous simulations.
    • FLIP vs APIC documentation and comparisons
  • Added an Accuracy option to the viscosity solver to control the solver error tolerance.
    • Decrease to speed up baking at the cost of accuracy. Increase to improve accuracy at the cost of baking speed. High viscosity thick or stiff fluids benefit the most from increasing accuracy. Low viscosity thin fluids often work well at a lower accuracy. Setting above a value of 4 may have greatly diminishing returns on improvement.
    • The default value of 4 is the same amount of error tolerance used internally in previous versions.
  • Added an operator to the FLIP Fluid Helper sidebar menu to generate a Windows batch file (.bat) to command line render each frame of an animation one by one.
    • Operator will detect already rendered frames in the output directory and disregard these from the batch file.
    • Upon a render crash, the batch file will start up Blender again and begin rendering the next frame. In this way, you can minimize unrendered frames if your system is prone to render crashes.
    • Can be used outside of the FLIP Fluids addon to render a sequence of frames individually. There are some bugs in Blender which can cause an animation to be rendered incorrectly and a workaround to these issues is to render each frame one by one.
  • Added viewport visibility toggles to the fluid particle, force field, and obstacle debug tools.
  • Added a UI warning and tooltip if the Estimated Surface Tension Substeps info value exceeds the allowed Max Frame Substeps Value (Documentation).
  • Bug Fix: Fixed issue in Blender 2.91+ where rendering fluid meshes with motion blur enabled could result in longer Cycles render times.
    • Note: Motion Blur Rendering of fluid surfaces or whitewater particles is not currently supported (See: Motion Blur Support).
    • This fix will only apply to newly created scenes. To workaround this issue in an existing scene, select a fluid/whitewater object and disable the Object Properties > Motion Blur option (only applies if Cycles is the selected renderer).
  • Bug Fix: Fixed issue where low viscosity streams would have a velocity bias in the positive X/Y/Z direction (issue #455).
  • Bug Fix: Fixed an issue where many particles could become stuck to sharp obstacle edges which could lead to an unstable simulation (issue #508).
  • Bug Fix: Bug where using the inflow Constrain Inflow Velocity option could cause a bulge to form in the lower x/y/z corner of the domain.
  • Bug Fix: Fixed issue where disabling the whitewater feature and resuming a simulation would result in invalid whitewater cache files being generated in the cache directory.
  • Bug Fix: Issue where keyframing a min/max property could overwrite other min/max properties (issue #516).
  • Bug Fix: Issue where the bake operator status could hang on Calculating time remaining….
  • Bug Fix: UI issue where the Resume From Frame X label could be displayed in red text instead of the default white.
  • Bug Fix: UI issue where domain FLIP operator displayed the hide/show viewport/render icons in reverse order compared to regular Blender convention.
  • Bug Fix: UI issue where bake information would not be updated when using the Reset operator if the current cache directory did not exist.
  • Bug Fix: An error that would prevent a helpful error message from being displayed when loading the fluid engine library (Pull Request Here).
  • Bug Fix: Potential fix for render crashes when the Fluid Particle Debugging or Force Field Debugging tools are enabled (issue #521).
  • Bug Fix: Bug where using the FLIP Fluids Helper > Solid/Wireframe operator would deselect Fluid/Inflow/Outflow objects after execution.
  • Bug Fix: Removed deprecated cache operators (Copy/Move/Rename) from being searchable and executable in the F3 operator search menu.
  • Bug Fix: ValueError that could be triggered upon creating a domain if the .blend file was located on a different drive than the Blender installation.
  • Bug Fix: ‘TypeError’ that could be triggered in Blender 2.93 by pressing the F3 operator search key.
  • Bug Fix: Removed extraneous debugging code that would cause (harmless) error messages in Blender 2.79.
  • Bug Fix: Fixed error messages in Blender 2.79 due to difference in icon names in Blender 2.8+.
  • Example Scene Fix: Fixed volume_force_animated_character.blend example scene issue where the fluid objects would be emitted in the wrong direction. Corrected in the example scenes file as of March 25, 2021.
  • Changed: The FLIP Fluids Helper > Solid/Wireframe operators no longer change the render visibility of the objects. This functionality has been split into a separate row of Show/Hide Render operators that sets the render visibility of all selected objects.
  • Changed: Safety Factor (CFL Number) setting in the FLIP Fluid Advanced panel has moved from the Simulation Stability section to the Frame Substeps section. The Safety Factor option is more closely related to how the simulator calculates adaptive substeps.
  • Blender Support: Updated addon code to be compatible with Python 3.9 for future versions of Blender.
  • Blender Support: At the moment, there are no known compatibility issues between FLIP Fluids and Blender 2.93 Alpha. This may change as development of 2.93 progresses and bugs can be tracked in (issue #519).
  • Improved accuracy of viscosity solver setup.
  • Improved memory handling and storage of fluid particles and attributes.
  • Improved stability and performance.

What’s Coming Up Next?

We’ll be staring up our experimental builds again next week! Some exciting features related to Blender 2.93’s new geometry attributes are in the works and almost ready, but we’ll save that for another post.