Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Math behind density and pressure calculations #16

Open
M-J-Laurent opened this issue Jan 23, 2025 · 0 comments
Open

Math behind density and pressure calculations #16

M-J-Laurent opened this issue Jan 23, 2025 · 0 comments

Comments

@M-J-Laurent
Copy link

M-J-Laurent commented Jan 23, 2025

If anyone can help me with understanding two things from the video I will be eternally grateful. These are kind of math things and a lack of understanding in how they are avoided in the code shown in the video. I specify the video because I am not very familiar with reading and understanding hlsl and c# even though I have tried; in this scenario I have not found what I am looking for.

  1. When we calculate the pressure we are basically doing a calculation of the value of the slope(derivative) of the smoothing kernel divided by the density(basically original kernel function). You can mark these two functions down as basically some scalar multiplied by the difference between the radius and the distance between the particles to the power of some integer which for math reasons we can just ignore the scalar for simplicity when talking about how functions act as they approach certain points. This gives us a smoothing kernel where we have this distance to some power and its derivative where we have this distance to the power of 1 less than the original smoothing function. So we now have (d^(n-1))/(d^n) where d is distance, however, I see a problem where when the distance between your current particle you are trying to find the total pressure for and the particle you are trying to find the current pressure for approaches the edge of the smoothing radius we get an increasingly small number for distance d. This creates a situation where when you do smoothingfunctionsderivative/smoothingfunction we have (small number)/((small number)^2) (for arguments sake I am using 2 as our power) which gives us (small number)/(extremely small number) because of how raising small numbers to the power of integers larger than 1 works. This gives us an insane pressure force because even if the difference is just something like 0.01 we end up getting 0.01/0.001=100, 100 is quite large and this gets even bigger quadratically. We can even simplify this down to the fact that x/x^2=1/x or (x^(n-1))/(x^n)=1/x and lim as x->0^+ of 1/x=infinity making a situation where the simulation should quickly go completely out of control with an insane acceleration being added once this happens. So the main question is why does Sebastian's simulations not show this problem and how is he avoiding it specifically in code?
  2. This is a much more simple question; why at 7:08 in the video does he multiply his smoothing kernel by x in the integrand to find the volume of the smoothing function. It has been a while since I have done this type of math and just do not understand where the x came from. So can anyone tell me why it was included?

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant