import numpy as np
import utils
from engine.mpm_solver import MPMSolver

write_to_disk = False

ti.init(arch=ti.cuda)  # Try to run on GPU

gui = ti.GUI("Taichi MLS-MPM-99", res=512, background_color=0x112F41)

mpm = MPMSolver(res=(256, 256))
mpm.set_gravity([0, 0])

mpm.add_ellipsoid(center=[0.25, 0.45],
                  radius=0.07,
                  velocity=[1, 0],
                  color=0xAAAAFF,
                  material=MPMSolver.material_snow)

mpm.add_ellipsoid(center=[0.75, 0.52],
                  radius=0.07,
                  velocity=[-1, 0],
                  color=0xFFAAAA,
                  material=MPMSolver.material_snow)

for frame in range(500):
    mpm.step(8e-3)
    particles = mpm.particle_info()
    gui.circles(particles['position'], radius=1.5, color=particles['color'])
    gui.show(f'{frame:06d}.png' if write_to_disk else None)
Ejemplo n.º 2
0
import taichi as ti
import numpy as np
import utils
from engine.mpm_solver import MPMSolver

write_to_disk = False

# Try to run on GPU
ti.init(arch=ti.cuda, device_memory_GB=2.0, use_unified_memory=False)

gui = ti.GUI("Taichi Elements", res=512, background_color=0x112F41)

mpm = MPMSolver(res=(64, 64, 64), size=10)

mpm.add_ellipsoid(center=[2, 4, 3],
                  radius=1,
                  material=MPMSolver.material_snow,
                  velocity=[0, -10, 0])
mpm.add_cube(lower_corner=[2, 6, 3],
             cube_size=[1, 1, 3],
             material=MPMSolver.material_elastic)
mpm.add_cube(lower_corner=[2, 8, 3],
             cube_size=[1, 1, 3],
             material=MPMSolver.material_sand)

mpm.set_gravity((0, -50, 0))

for frame in range(1500):
    mpm.step(4e-3)
    colors = np.array([0x068587, 0xED553B, 0xEEEEF0, 0xFFFF00],
                      dtype=np.uint32)
    particles = mpm.particle_info()
import taichi as ti
import numpy as np
import utils
from engine.mpm_solver import MPMSolver

write_to_disk = False

ti.init(arch=ti.cuda)  # Try to run on GPU

gui = ti.GUI("Taichi MLS-MPM-99", res=512, background_color=0x112F41)

mpm = MPMSolver(res=(128, 128))

mpm.add_ellipsoid(center=[0.4, 0.4],
                  radius=[0.2, 0.2],
                  material=MPMSolver.material_snow)

for frame in range(500):
    mpm.step(8e-3)
    colors = np.array([0x068587, 0xED553B, 0xEEEEF0, 0xFFFF00],
                      dtype=np.uint32)
    particles = mpm.particle_info()
    gui.circles(particles['position'],
                radius=1.5,
                color=colors[particles['material']])
    gui.show(f'{frame:06d}.png' if write_to_disk else None)