Gradient and Laplacian of three functions

In summary, Smoothed Particle Hydrodynamics (SPH) is a method used for simulating fluid flow. In order to implement it, the gradient and laplacian of three functions (Wpoly6, Wspiky, and Wviscosity) are needed. These operators are covered in multi-variable or vector calculus and can be expressed as follows:Gradient: ∇W = <\frac{∂W}{∂r},\frac{∂W}{∂h}> Laplacian: ΔW = ∇ \cdot ∇W For the Wpoly6 function, the gradient and laplacian can be expressed as:∇W_{poly6}(\vec{r},
  • #1
sciwizeh
25
0
Hello, I've been reading up on Smoothed Particle Hydrodynamics. While reading some papers I found some math that I do not know how to do because I never took multi variable calculus. I need the gradient and laplacian of all three of the following functions ( h is a constant ):

Wpoly6(r,h)=[itex]\frac{315}{64\pi h^{9}}\begin{cases}
(h^{2}-|r|^{2})^{3} & 0\leq r\leq h \\
0 & \text{ otherwise }
\end{cases}[/itex]
Wspiky(r,h)=[itex]\frac{15}{\pi h^{6}}\begin{cases}
(h-|r|)^{3} & 0\leq r\leq h \\
0 & \text{ otherwise }
\end{cases}[/itex]
Wviscosity(r,h)=[itex]\frac{15}{2\pi h^{3}}\begin{cases}
-\frac{r^{3}}{2h^{3}}+\frac{r^{2}}{h^{2}}+\frac{h}{2r} & 0\leq r\leq h \\
0 & \text{ otherwise }
\end{cases}[/itex]
note: almost copied the last one wrong, the last term of the top is h over 2r and the other terms are r's over h's

If I understand correctly the magnitude operation makes this an essentially 1 dimensional problem and the gradient is the derivative and the lapracian is the second derivative. Am I right in this thought? If not what does it mean?
I am very rusty in my calculus, so even if that is true, I would prefer the answers rather than the procedure. The only thing I need in order to translate the papers to an implementation is these 6 more equations.
 
Physics news on Phys.org
  • #2
Gradient and Laplacian operators are covered in multi-variable or vector calculus.

I would start there.
 
  • #3
Yes, I know, but I am no longer in school and I never took multi-variable calculus. I also have read the wikipedia page on them and I get the principal, but I don't know how to deal with the magnitude operation, also it's been years since I've done any kind of calculus work so I don't remember much. I also just need the equations to implement in code.

OP said:
If I understand correctly the magnitude operation makes this an essentially 1 dimensional problem and the gradient is the derivative [of a function of the magnitude] and the lapracian is the second derivative. Am I right in this thought? If not what does it mean?
I am very rusty in my calculus, so even if that is true, I would prefer the answers rather than the procedure. The only thing I need in order to translate the papers to an implementation is these 6 more equations.

Because this is a homework help forum and you seem reluctant to just answer the question, I want to be clear, this is NOT homework, I'm independently trying to implement smoothed particle hydrodynamics. The papers give the functions above, but most of the formula's use the gradient of them or the laplacian without actually giving them.
 
  • #4
Since this is not for homework work, you kind of posted in the wrong forum, but I'll help you out anyway because your intention seems to be in implementing it in code.

Gradient (note that it is vector-valued; you would need to use several variables to implement this in your code; one for each component, or you could use an array/list):

[tex] ∇W = <\frac{∂W}{∂r},\frac{∂W}{∂h}> [/tex]

Laplacian (scalar valued, you only need one variable to store the Laplacian):

[tex] ΔW = ∇ \cdot ∇W [/tex]

BiP
 
  • #5
Bipolarity said:
Since this is not for homework work, you kind of posted in the wrong forum, but I'll help you out anyway because your intention seems to be in implementing it in code.

But it is:
Hurkyl said:
Please post any and all homework or other textbook-style problems in one of the Homework & Coursework Questions forums, whether the problem is part of one's assigned coursework or just independent study. And, before posting, read the section entitled "Homework Help" in the PF Global Guidelines.
Technically this would be under the heading of "just independent study." (No?)

Anyhow, h is actually a constant, the vector is r, so it would be:
[itex]∇W = <\frac{∂W}{∂r_x},\frac{∂W}{∂r_y},\frac{∂W}{∂r_z}>[/itex]
correct?

Digging through more papers I've found: (note, I've also changed r to r with arrow to better indicate vector valued)
[itex]W_{poly6}(\vec{r},h)=\frac{315}{64\pi h^{9}}\begin{cases}
(h^{2}-|r|^{2})^{3} & 0\leq |r|\leq h \\
0 & \text{ otherwise }
\end{cases}
[/itex]
[itex]
\bigtriangledown W_{poly6}(\vec{r},h)=(-6)\frac{315}{64\pi h^{9}}\begin{cases}
(h^{2}-|r|^{2})^{2} \begin{pmatrix}
r_{x}\\
r_{y}\\
r_{z}
\end{pmatrix} & 0\leq |r|\leq h \\
\mathbf{0} & \text{ otherwise }
\end{cases}[/itex]
[itex]\bigtriangledown^{2} W_{poly6}(\vec{r},h)=\frac{315}{64\pi h^{9}}\begin{cases}
-18(h^{2}-|r|^{2})^{2}+24|r|^{2}(h^2-|r|^2)
& 0\leq |r|\leq h \\
0 & \text{ otherwise }
\end{cases}
[/itex]
[itex]W_{viscosity}(\vec{r},h)=\frac{15}{2\pi h^{3}}\begin{cases}
-\frac{|r|^{3}}{2h^{3}}+\frac{|r|^{2}}{h^{2}}+\frac{h}{ 2|r|} & 0\leq |r|\leq h \\
0 & \text{ otherwise }
\end{cases}
[/itex]
[itex]\bigtriangledown W_{viscosity}(\vec{r},h)=\frac{15}{2\pi h^{3}}\begin{cases}
-\frac{3|r|}{2h^{3}}+\frac{2}{h^{2}}+\frac{h}{ 2|r|^3}
\begin{pmatrix}
r_x\\
r_y\\
r_z
\end{pmatrix}
& 0\leq |r|\leq h \\
0 & \text{ otherwise }
\end{cases}
[/itex]
[itex]\bigtriangledown^2 W_{viscosity}(\vec{r},h)=(6)\frac{15}{2\pi h^{3}}\begin{cases}
(\frac{1}{h^3})(h-|r|)
& 0\leq |r|\leq h \\
0 & \text{ otherwise }
\end{cases}
[/itex]

Are these correct? I sort of get how to get the gradient, but I don't understand the Lapracian at all.
With these equations I could implement what I need to, however one paper mentions a stability issue if the third W function is not used. So for completeness I need the gradient and lapracian of:

[itex]
W_{spiky}(\vec{r},h)=\frac{15}{\pi h^{6}}\begin{cases}
(h-|r|)^{3} & 0\leq r\leq h \\
0 & \text{ otherwise }
\end{cases}
[/itex]
 
Last edited:

FAQ: Gradient and Laplacian of three functions

1. What is a gradient?

A gradient is a vector operation that calculates the rate of change of a scalar field in a specific direction. It is represented by the symbol ∇ and is commonly used in physics, engineering, and mathematics.

2. How is the gradient of a function calculated?

The gradient of a function is calculated by taking the partial derivatives of the function with respect to each independent variable and arranging them into a vector. This vector represents the direction and magnitude of the steepest ascent of the function at a given point.

3. What is the significance of the gradient in real-world applications?

The gradient is used to determine the direction and magnitude of change in a physical quantity, such as temperature, pressure, or concentration, which is important in fields such as fluid mechanics, heat transfer, and chemical engineering.

4. What is a Laplacian?

A Laplacian is a scalar operation that measures the rate of change of the gradient of a scalar field. It is represented by the symbol ∇² and is commonly used in fields such as electromagnetism, fluid dynamics, and image processing.

5. How is the Laplacian of a function calculated?

The Laplacian of a function is calculated by taking the second partial derivatives of the function with respect to each independent variable and then summing them together. It can also be expressed as the divergence of the gradient of the function.

Similar threads

Replies
9
Views
667
Replies
1
Views
1K
Replies
8
Views
1K
Replies
1
Views
954
Replies
5
Views
756
Back
Top