taichi-dev / taichi_elements

High-performance multi-material continuum physics engine in Taichi
MIT License
483 stars 69 forks source link

Particles explode #89

Closed PavelBlend closed 2 years ago

PavelBlend commented 2 years ago

I often see unstable particles in MPM simulations. Is this a feature of the MPM method? Or is there an error somewhere? To get rid of explosions, you need to increase the number of substeps. But I do not have access to the substeps, since they are calculated automatically.

https://user-images.githubusercontent.com/7983249/148691084-8448d536-45af-4017-bb8e-96f4eb584418.mp4

Jack12xl commented 2 years ago

Hi,

I often see unstable particles in MPM simulations. Is this a feature of the MPM method? Or is there an error somewhere?

I think an unstable results could happen in any simulation if you do not take good care of the CFL conditions(or float precision etc).

But I do not have access to the substeps, since they are calculated automatically.

Wonder what MPM config(I mean the argument of the MPMSolver) are you currently using?

I think you might want to tune the self.res, or the self.default_dt in order to change the time step. Or simply turn on the self.adaptive_dt flag and the solver will automatically adjust the dt based on the CFL condition. And if that still not working, please let us know😂

BTW, pay attention to the MPM config, especially use_g2p2g and quant. These are basically for saving the GPU memory. But the cost is: you might find it hard to maintain the stability 0.0

PavelBlend commented 2 years ago

@Jack12xl hello.

I enabled use_adaptive_dt and got an error:

Traceback (most recent call last):
  File "C:\progs\blender300\3.0\python\lib\threading.py", line 973, in _bootstrap_inner
    self.run()
  File "C:\progs\blender300\3.0\python\lib\threading.py", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Pavel_Blend\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\taichi_elements\operators.py", line 405, in init_sim
    self.run_sim()
  File "C:\Users\Pavel_Blend\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\taichi_elements\operators.py", line 284, in run_sim
    self.solv.step(1 / self.fps)
  File "C:\Users\Pavel_Blend\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\taichi_elements\engine\mpm_solver.py", line 761, in step
    self.grid_v[self.input_grid])
  File "C:\progs\blender300\3.0\python\lib\site-packages\taichi\lang\util.py", line 224, in wrapped
    return func(*args, **kwargs)
  File "C:\progs\blender300\3.0\python\lib\site-packages\taichi\lang\matrix.py", line 1246, in __getitem__
    key = self.pad_key(key)
  File "C:\progs\blender300\3.0\python\lib\site-packages\taichi\lang\field.py", line 198, in pad_key
    assert len(key) == len(self.shape)
AssertionError
Jack12xl commented 2 years ago

Hi,

This is a hot fix to the problem. https://github.com/taichi-dev/taichi_elements/pull/91 .Still under review though, you might want to cherry pick that.

BTW, actually the use_adaptive_dt is designed only for g2p2g scheme. Sorry about the carelessness before😂

PavelBlend commented 2 years ago

@Jack12xl I checked and everything works:

https://user-images.githubusercontent.com/7983249/149613106-d05fba57-3ead-4d57-97e1-ed42112ff41c.mp4

Jack12xl commented 2 years ago

Thanks for the issue. Adaptive dt is merged!