Particle drag values greater than zero can cause particle velocity instability and do not behave as expected. #102093

Open
opened 2022-10-27 07:08:20 +02:00 by Paul Forgy · 8 comments

System Information
Operating system: Windows-10-10.0.19044-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3080 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 512.15

Blender Version
Broken: version: 3.3.1, branch: master, commit date: 2022-10-04 18:35, hash: b292cfe5a9
Worked: unknown

Short description of error
Setting the particle properties -> physics -> drag value to greater than zero can cause unstable and unexpected particle velocity. In the test case file, a drag value of .2 causes some particles to have extremely high velocity, while a drag value of 0 produces more consistent and stable velocities.

Exact steps for others to reproduce the error
The test file contains two particle emitters which differ only in their drag parameter settings. Scrubbing the time to frame 3, you can observe the emitter on the left produces several particles which fly outwards at very high velocities, much greater than the emitter on the right with zero drag. I would expect that higher drag values always produce slower velocities, never faster, but this appears not to be the case. This was an issue because the very distant particles produced by larger than zero drag values were causing the sun light shadows not to render, which is another bug/issue demonstrated in this file.

Particle Drag and Sun Shadow Bug.blend

More information in available in the text editor of the sample file. Thanks!

**System Information** Operating system: Windows-10-10.0.19044-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 3080 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 512.15 **Blender Version** Broken: version: 3.3.1, branch: master, commit date: 2022-10-04 18:35, hash: `b292cfe5a9` Worked: unknown **Short description of error** Setting the **particle properties -> physics -> drag** value to greater than zero can cause unstable and unexpected particle velocity. In the test case file, a drag value of .2 causes some particles to have extremely high velocity, while a drag value of 0 produces more consistent and stable velocities. **Exact steps for others to reproduce the error** The test file contains two particle emitters which differ only in their drag parameter settings. Scrubbing the time to frame 3, you can observe the emitter on the left produces several particles which fly outwards at very high velocities, much greater than the emitter on the right with zero drag. I would expect that higher drag values always produce slower velocities, never faster, but this appears not to be the case. This was an issue because the very distant particles produced by larger than zero drag values were causing the sun light shadows not to render, which is another bug/issue demonstrated in this file. [Particle Drag and Sun Shadow Bug.blend](https://archive.blender.org/developer/F13778472/Particle_Drag_and_Sun_Shadow_Bug.blend) More information in available in the text editor of the sample file. Thanks!
Author

Added subscriber: @PaulForgy

Added subscriber: @PaulForgy

Added subscriber: @edward88

Added subscriber: @edward88

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

I realized the particle instances and i can confirm that some of the positions have extremely high values, there are also some nan values among them.

I realized the particle instances and i can confirm that some of the positions have extremely high values, there are also some nan values among them.

This comment was removed by @edward88

*This comment was removed by @edward88*
Author

I see two issues with the drag force calculation.

  1. I believe the first vector should be normalized:

from: madd_v3_v3fl(force,state->vel, -part->dragfac * pa->size * pa->size * len_v3(state->vel));
to: madd_v3_v3fl(force, normalize_v3(state->vel), -part->dragfac * pa->size * pa->size * len_v3(state->vel));

This error becomes very apparent when the scale/size of the particles becomes greater than 1 and the velocities are high. May not have been readily noticed to this point because the default particle scale is 0.05. For example, a particle system with a velocity of 100, scale of 4 and drag of 0.05, the second frame of the simulation, the particle inherits a very large negative velocity due to the incorrect drag calculation. Drag force should never overcome the velocity but only retard it.

Test file attached. The particle system on the right has drag of 0.05, on the left is 0. Both particles should still have upwards velocity, though the right particle should be slightly slowed over time. Observe that at frame 2, the right side particle already has a negative velocity and is going downwards due to incorrectly high drag force being applied.
Drag force exceeds velocity.blend

  1. Drag increases exponentially with velocity, and that's not represented.
    The academic formula is: D = .5 * Cd * r * V^2 * A, where Cd = coefficient of drag, r = air density (can be ignored), V = velocity, A = area.

In this case, the formula should be something like: dragforce = 0.5 * dragfac * velocity * velocity * size * size

or: madd_v3_v3fl(force, normalize_v3(state->vel),**0.5f *** -part->dragfac * pa->size * pa->size *len_v3(state->vel) * len_v3(state->vel));

I see two issues with the drag force calculation. 1. I believe the first vector should be normalized: from: madd_v3_v3fl(force,**state->vel**, -part->dragfac * pa->size * pa->size * len_v3(state->vel)); to: madd_v3_v3fl(force, **normalize_v3(state->vel)**, -part->dragfac * pa->size * pa->size * len_v3(state->vel)); This error becomes very apparent when the scale/size of the particles becomes greater than 1 and the velocities are high. May not have been readily noticed to this point because the default particle scale is 0.05. For example, a particle system with a velocity of 100, scale of 4 and drag of 0.05, the second frame of the simulation, the particle inherits a very large negative velocity due to the incorrect drag calculation. Drag force should never overcome the velocity but only retard it. Test file attached. The particle system on the right has drag of 0.05, on the left is 0. Both particles should still have upwards velocity, though the right particle should be slightly slowed over time. Observe that at frame 2, the right side particle already has a negative velocity and is going downwards due to incorrectly high drag force being applied. [Drag force exceeds velocity.blend](https://archive.blender.org/developer/F13786476/Drag_force_exceeds_velocity.blend) 2. Drag increases exponentially with velocity, and that's not represented. The academic formula is: D = .5 * Cd * r * V^2 * A, where Cd = coefficient of drag, r = air density (can be ignored), V = velocity, A = area. In this case, the formula should be something like: dragforce = 0.5 * dragfac * velocity * velocity * size * size or: madd_v3_v3fl(force, normalize_v3(state->vel),**0.5f *** -part->dragfac * pa->size * pa->size ***len_v3(state->vel) * len_v3(state->vel)**);

Tyvm for your help!
I had a similar thought crossing my mind, unfortunally,
state->vel * len_v3(state->vel) and normalize_v3(state->vel) * len_v3(state->vel) * len_v3(state->vel) is exactly the same thing. :D
I think you are right with the missing 0.5 factor, it just does not seem to be the critical problem here.
But I don't see anything that limits this force. Maybe we should make sure that the maximum force that comes from this is a value necessary to counter out the velocity in one time step. Otherwise it may push back and go loko? Just an idea, not sure.

Tyvm for your help! I had a similar thought crossing my mind, unfortunally, `state->vel * len_v3(state->vel)` and `normalize_v3(state->vel) * len_v3(state->vel) * len_v3(state->vel)` is exactly the same thing. :D I think you are right with the missing 0.5 factor, it just does not seem to be the critical problem here. But I don't see anything that limits this force. Maybe we should make sure that the maximum force that comes from this is a value necessary to counter out the velocity in one time step. Otherwise it may push back and go loko? Just an idea, not sure.
Author

Thanks for pointing that out. I understand now that normalizing the vector makes no difference and that the formula is simplified.

I think you're correct about needing to limit the drag force. I was trying various things with the physics, and noticed that if I changed the integration type to Euler, the velocity would ping-pong on alternate frames due to the drag. On frame 2 the particle was above the XY plane, frame 3 it was below, alternating each frame and becoming farther and farther away in a runaway condition.

Thanks for pointing that out. I understand now that normalizing the vector makes no difference and that the formula is simplified. I think you're correct about needing to limit the drag force. I was trying various things with the physics, and noticed that if I changed the integration type to Euler, the velocity would ping-pong on alternate frames due to the drag. On frame 2 the particle was above the XY plane, frame 3 it was below, alternating each frame and becoming farther and farther away in a runaway condition.
Philipp Oeser added the
Module
Nodes & Physics
label 2023-02-20 09:38:38 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#102093
No description provided.