Gradient and Laplacian of three functions

sciwizeh
Messages
25
Reaction score
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)=\frac{315}{64\pi h^{9}}\begin{cases}<br /> (h^{2}-|r|^{2})^{3} &amp; 0\leq r\leq h \\ <br /> 0 &amp; \text{ otherwise } <br /> \end{cases}
Wspiky(r,h)=\frac{15}{\pi h^{6}}\begin{cases}<br /> (h-|r|)^{3} &amp; 0\leq r\leq h \\ <br /> 0 &amp; \text{ otherwise } <br /> \end{cases}
Wviscosity(r,h)=\frac{15}{2\pi h^{3}}\begin{cases}<br /> -\frac{r^{3}}{2h^{3}}+\frac{r^{2}}{h^{2}}+\frac{h}{2r} &amp; 0\leq r\leq h \\ <br /> 0 &amp; \text{ otherwise } <br /> \end{cases}
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
Gradient and Laplacian operators are covered in multi-variable or vector calculus.

I would start there.
 
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.
 
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):

∇W = &lt;\frac{∂W}{∂r},\frac{∂W}{∂h}&gt;

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

ΔW = ∇ \cdot ∇W

BiP
 
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:
∇W = &lt;\frac{∂W}{∂r_x},\frac{∂W}{∂r_y},\frac{∂W}{∂r_z}&gt;
correct?

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

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:

<br /> W_{spiky}(\vec{r},h)=\frac{15}{\pi h^{6}}\begin{cases} <br /> (h-|r|)^{3} &amp; 0\leq r\leq h \\ <br /> 0 &amp; \text{ otherwise } <br /> \end{cases}<br />
 
Last edited:
There are two things I don't understand about this problem. First, when finding the nth root of a number, there should in theory be n solutions. However, the formula produces n+1 roots. Here is how. The first root is simply ##\left(r\right)^{\left(\frac{1}{n}\right)}##. Then you multiply this first root by n additional expressions given by the formula, as you go through k=0,1,...n-1. So you end up with n+1 roots, which cannot be correct. Let me illustrate what I mean. For this...

Similar threads

Back
Top