-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to apply force during for-loop in diffmpm #55
Comments
Here are some more detailed information about my question, I first tried the Nested
Then there was no output in the program Then I tried to use func.grad() instead of the AutoDiff function:
This still could not work since all the gradients were zero. |
cc @erizmr |
Hi @lynamer ,
|
Take the diffmpm_simple.py as an example, I was thinking to add an additional force during the p2g step, that is,
$\partial (total_energy) / \partial x$ $\partial (total_energy) / \partial x$ in the for-loop and $\partial (loss) / \partial init_v$ after the loop.
(at line 87)
grid_v_in[f, base + offset] += weight * (p_mass * v[f, p] - dt * x.grad[f, p] + affine @ dpos)
where x.grad is supposed to be
However, since we already use
ti.Tape(loss=loss)
to store the gradient of init_v, I am wondering how to get bothThe text was updated successfully, but these errors were encountered: