Closed kracon7 closed 2 years ago
If you change the 'update' with previous vel, it'll converge.
@ti.kernel
def update(self, s: ti.i32):
# update the next step velocity and position
for i in range(self.ngeom):
self.geom_vel[s+1, i] = self.geom_vel[s, i] + \
self.dt * self.geom_force[s, i] / self.geom_mass[i]
self.geom_pos[s+1, i] = self.geom_pos[s, i] + \
self.dt * self.geom_vel[s, i] # <<<< change to use previous velocity
If you change the 'update' with previous vel, it'll converge.
@ti.kernel def update(self, s: ti.i32): # update the next step velocity and position for i in range(self.ngeom): self.geom_vel[s+1, i] = self.geom_vel[s, i] + \ self.dt * self.geom_force[s, i] / self.geom_mass[i] self.geom_pos[s+1, i] = self.geom_pos[s, i] + \ self.dt * self.geom_vel[s, i] # <<<< change to use previous velocity
Thanks for helping @BisonLeo . It works. Closing this issue now.
The auto differentiation result seems incorrect.
I was trying to implement a simple differentiable particle-based 2D physics engine with spring contact. In this minimal example, I made 2 circles and the left one has an initial velocity towards the right one. A loss is defined on the final step position difference and the loss is used to regress the particle mass. However, I see that
mass_est
doesn't converge tomass_gt
. I'm a bit confused about such behavior. Thanks in advance for helping!To Reproduce
Log/Screenshots