1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Gradient and Laplacian of three functions

  1. Jan 10, 2013 #1
    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.
     
  2. jcsd
  3. Jan 11, 2013 #2

    SteamKing

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    Gradient and Laplacian operators are covered in multi-variable or vector calculus.

    I would start there.
     
  4. Jan 11, 2013 #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.

    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.
     
  5. Jan 11, 2013 #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
     
  6. Jan 11, 2013 #5
    But it is:
    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: Jan 11, 2013
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Gradient and Laplacian of three functions
Loading...