I'm reading this paper on Position Based Fluids and I couldn't understand the meaning of $\nabla_{\mathbf{p}_k} W(\mathbf{ p_i - p_j}, h)$ in the equation 7 (see below).

…the gradient of the constraint function (1) with respect to a particle k is given by: $\;\;\;\nabla_{\mathbf{p}_k} C_i(\mathbf p_1, \mathbf p_2, \ldots, \mathbf p_n) = \frac{1}{\rho_0} \sum\limits_j \nabla_{\mathbf{p}_k} W(\mathbf p_i - \mathbf p_j, h )$

I understand the left hand side of the equation – it is $\nabla_{\mathbf{p}_k} C_i = \begin{bmatrix}\frac{\partial C_i}{\partial \mathbf{p}_{k_X}} & \frac{\partial C_i}{\partial \mathbf{p}_{k_Y}} & \frac{\partial C_i}{\partial \mathbf{p}_{k_Z}}\end{bmatrix}$. However I cannot grasp the right hand side – the function $W$ is defined (AFAIK) as $W\colon \mathbb R^{n+1} \to \mathbb R$, meaning that it takes an $n-$dimensional vector and a scalar as the inputs and produces a scalar.

I don't understand what does the notation $\nabla_{\mathbf{p}_k}W$ mean – in particular, why is there the subscript $\mathbf{p}_k$ – the function $W$ doesn't take $n$ vectors as input, like the $C_i$ function does, so it cannot be differentiated with respect to $\mathbf{p}_k$ (it can be only to its first – vector – parameter and its second – scalar – parameter).

Edit: I forgot to mention that $C_i\colon \mathbb R^{3n} \to \mathbb R$.


The point is there's several $W$'s.

$$\rho_i=\sum_j W(\mathbf{p}_i-\mathbf{p}_j,h)=W(\mathbf{p}_i-\mathbf{p}_1,h)+W(\mathbf{p}_i-\mathbf{p}_2,h)+\ldots$$ dropping the mass as they do in the paper.

The thing is they're treating the particles as indistinguishable e.g. they all have equal mass, so the form of the functions/constraints applied to them are the same. So there is so $W_j$ since as a function $W_j=W_i$ except for it's arguments. It's like $\sin(x)$ and $\sin(y)$ for example, same functional form but different argument. As an example take $W(\cdot_1,\cdot_2)=W(\cdot_1 -\cdot_2)=\|\cdot_1-\cdot_2\|$ $$C_i(\mathbf{p}_1,\mathbf{p}_2,\mathbf{p}_3)=\sum_j W(\mathbf{p}_i,\mathbf{p}_j)=\|\mathbf{p}_i-\mathbf{p}_1\|+\|\mathbf{p}_i-\mathbf{p}_2\|+\|\mathbf{p}_i-\mathbf{p}_3\|$$

They say that $$C_i=\frac{\rho_i}{\rho_0}-1=\frac{1}{\rho_0}\sum_j W(\mathbf{p}_i-\mathbf{p}_j,h) -1$$

Thus $$\nabla_{\mathbf{p}_k}C_i=\frac{1}{\rho_0}\sum_j \nabla_{\mathbf{p}_k} W(\mathbf{p}_i-\mathbf{p}_j,h)$$

The derivatives will just be zero if there's no dependence on $\mathbf{p}_k$. You see you have several $\mathbf{p}$'s and they're treated as independent parameters, like if you had particles $1$ and $2$, their co-ordinates $\mathbf{r}_1$, $\mathbf{r}_2$, and gradients w.r.t. their positions $\nabla_1$ and $\nabla_2 $.

This is emphasised when they write $$\nabla_{\mathbf{p}_k}C_i=\frac{1}{\rho_0}\begin{cases} \sum_j \nabla_{\mathbf{p}_k} W(\mathbf{p}_i-\mathbf{p}_j,h) \quad \text{ if } k=i\\ - \nabla_{\mathbf{p}_k} W(\mathbf{p}_i-\mathbf{p}_j,h) \quad \text{ if } k=j \end{cases}$$

The idea is if $k=i$ then every $W$ depends on $\mathbf{p}_i$, but if $k=j$ for specific $j$ then only that term in the sum is non-zero after differentiating. The minus sign is from the chain rule, as it's $\mathbf{p}_i-\mathbf{p}_j$.

  • $\begingroup$ Thank you @snulty ! I think I got it – but just to clarify: let's consider the case when $k=j$ for example: It is still a sum, but all the elements of the sum that do not contain $\mathbf{p}_k$ are "zeroed-out" because of the chain rule. In the end I can ignore the $\mathbf{p}_k$ subscript in $-\nabla_{\mathbf{p}_k} W(\mathbf{p}_i-\mathbf{p}_j,h)$ and compute just $-\nabla W(\mathbf{p}_i-\mathbf{p}_j,h)$. Is that right? $\endgroup$ – sarasvati Jul 18 '16 at 11:59
  • 1
    $\begingroup$ @sarasvati yes that's pretty much it. I think the notation is bad, as in choosing $k=j$ and also using $j$ for the summation. $\endgroup$ – snulty Jul 18 '16 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.