Gradient question for fluid simulation

Click For Summary
SUMMARY

The discussion centers on calculating the gradient vector for a kernel function used in fluid simulation, specifically for water droplets. The kernel function is defined as (10/pi*h^5)*(h-r)^3, with its gradient being (-30/pi*h^5)*(h-r)^2. The user, John, seeks clarification on how to derive a gradient vector from a scalar distance 'r' in a Cartesian coordinate system. The solution involves substituting 'r' with the Euclidean distance formula, sqrt(x^2 + y^2), to compute the gradient components in the x and y directions.

PREREQUISITES
  • Understanding of kernel functions in fluid dynamics
  • Knowledge of gradient calculations in calculus
  • Familiarity with Cartesian coordinate systems
  • Basic concepts of fluid simulation techniques
NEXT STEPS
  • Research "Gradient in Cartesian coordinates" for detailed calculations
  • Explore "Kernel functions in fluid dynamics" for practical applications
  • Study "Computational fluid dynamics (CFD) methods" for advanced simulations
  • Learn about "Spherical coordinates gradient calculations" for broader understanding
USEFUL FOR

This discussion is beneficial for fluid simulation developers, computational physicists, and anyone involved in numerical methods for simulating fluid dynamics.

johnnyk427
Messages
2
Reaction score
0
Simple gradient question.. I have a kernel function that determines the influence of each water droplet given a radius r:

(10/pi*h^5)*(h-r)^3

The gradient of that is:
(-30/pi*h^5)*(h-r)^2

But 'r' is not a vector, its a scalar, its just the distance to the point in question. So how do I get a gradient vector out of that equation? Maybe I want to replace 'r' with the x distance and use that to determine the 'x' component of the gradient, and same for 'y'? But that doesn't seem right..

(yes, i know this is a newb question, thanks for any help! It's not homework just a project I'm working on for fun.)
-John
 
Physics news on Phys.org
johnnyk427 said:
Simple gradient question.. I have a kernel function that determines the influence of each water droplet given a radius r:

(10/pi*h^5)*(h-r)^3

The gradient of that is:
(-30/pi*h^5)*(h-r)^2

But 'r' is not a vector, its a scalar, its just the distance to the point in question. So how do I get a gradient vector out of that equation? Maybe I want to replace 'r' with the x distance and use that to determine the 'x' component of the gradient, and same for 'y'? But that doesn't seem right..

(yes, i know this is a newb question, thanks for any help! It's not homework just a project I'm working on for fun.)
-John

Welcome to Physics Forums!

It depends what you mean by "r" here. What coordinate system are you using? Are you in spherical coordinates? Then you simply have to look up the gradient in spherical coordinates
[tex]\vec{\nabla} V = \frac{\partial V}{\partial r} \hat{r} + \frac{1}{r} \frac{\partial V}{\partial \theta} \hat{\theta} + \frac{1}{r sin \theta} \frac{\partial V}{\partial \phi} \hat{\phi}[/tex]
 
Welcome to Physics Forums!

Thanks :)

It depends what you mean by "r" here. What coordinate system are you using? Are you in spherical coordinates? Then you simply have to look up the gradient in spherical coordinates

It's actually in Cartesian coordinates, x and y (it's 2d, not 3d). When I calculate this function, I first compute the distance from 0,0 to x,y, and assign that to 'r'. 'h' is a constant (representing the size of the kernel I'm applying).

So maybe I want something like:

(gradient f) = { (change in x)/(change in f), (change in y)/(change in f) }

And then restructure my equation, substituting '(sqrt(x^2 + y^2))' for r... Does that sound right?
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 16 ·
Replies
16
Views
2K
Replies
7
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 51 ·
2
Replies
51
Views
9K