Exemple #1
0
import taichi as ti
import numpy as np
import utils
import math
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), unbounded=True)
mpm.add_surface_collider(point=(0, 0),
                         normal=(0.3, 1),
                         surface=mpm.surface_slip)

for i in range(3):
    mpm.add_cube(lower_corner=[0.2 + i * 0.1, 0.3 + i * 0.1],
                 cube_size=[0.1, 0.1],
                 material=MPMSolver.material_elastic)

for frame in range(500):
    mpm.step(8e-3)
    if frame < 100:
        mpm.add_cube(lower_corner=[0.1, 0.4],
                     cube_size=[0.01, 0.05],
                     velocity=[1, 0],
                     material=MPMSolver.material_sand)
    if 10 < frame < 100:
        mpm.add_cube(lower_corner=[0.3, 0.7],
# Use 512 for final simulation/render
R = args.res
thickness = 2

mpm = MPMSolver(res=(R, R, R),
                size=1,
                unbounded=True,
                dt_scale=1,
                quant=True,
                use_g2p2g=False,
                support_plasticity=True,
                water_density=1.5)

mpm.add_surface_collider(point=(0, 0, 0),
                         normal=(0, 1, 0),
                         surface=mpm.surface_slip,
                         friction=0.5)

mpm.add_surface_collider(point=(0, 1.9, 0),
                         normal=(0, -1, 0),
                         surface=mpm.surface_slip,
                         friction=0.5)

bound = 1.9

for d in [0, 2]:
    point = [0, 0, 0]
    normal = [0, 0, 0]
    b = bound
    if d == 2:
        b /= 4
Exemple #3
0
    screen_x = np_x[:, 0]
    screen_y = np_x[:, 1]

    screen_pos = np.stack([screen_x, screen_y], axis=-1)

    gui.circles(screen_pos, radius=0.8, color=particles['color'])
    gui.show()


# Use 512 for final simulation/render
R = 64

mpm = MPMSolver(res=(R, R, R), size=1, unbounded=True, dt_scale=0.5, E_scale=8, max_num_particles=max_num_particles)

mpm.add_surface_collider(point=(0, 0, 0),
                         normal=(0, 1, 0),
                         surface=mpm.surface_slip,
                         friction=3.5)

mpm.set_gravity((0, -25, 0))
counter = 0

start_t = time.time()

addParticlesCount = 2000

for frame in range(15000):
    print(f'frame {frame}')
    t = time.time()

    # mpm.add_cube((0.0, 0.3, 0.0), (0.99999, 0.01, 0.8),
    #              mpm.material_water,