@ti.kernel
def clear_particle_grad():
    for (f, i) in x:
        x.grad[(f, i)] = zero_vec()
        v.grad[(f, i)] = zero_vec()
        C.grad[(f, i)] = zero_matrix()
        F.grad[(f, i)] = zero_matrix()
@ti.kernel
def clear_particle_grad():
    for (f, i) in x:
        x.grad[(f, i)] = zero_vec()
        v.grad[(f, i)] = zero_vec()
        C.grad[(f, i)] = zero_matrix()
        F.grad[(f, i)] = zero_matrix()