-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathflush_cubes.py
More file actions
112 lines (101 loc) · 3.04 KB
/
Copy pathflush_cubes.py
File metadata and controls
112 lines (101 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import os
import argparse
import numpy as np
import genesis as gs
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--vis", action="store_true", default=False)
args = parser.parse_args()
########################## init ##########################
gs.init(precision="32", logging_level="info")
########################## create a scene ##########################
scene = gs.Scene(
sim_options=gs.options.SimOptions(
dt=4e-3,
substeps=20,
),
mpm_options=gs.options.MPMOptions(
lower_bound=(-0.45, -0.65, -0.01),
upper_bound=(0.45, 0.65, 1.0),
grid_density=64,
),
viewer_options=gs.options.ViewerOptions(
camera_pos=(4.5, 1.0, 1.42),
camera_lookat=(0.0, 0.0, 0.3),
camera_fov=22,
),
show_viewer=args.vis,
vis_options=gs.options.VisOptions(
visualize_mpm_boundary=True,
rendered_envs_idx=[0],
),
)
plane = scene.add_entity(morph=gs.morphs.Plane())
cube0 = scene.add_entity(
material=gs.materials.MPM.Elastic(rho=400),
morph=gs.morphs.Box(
pos=(0.0, 0.25, 0.4),
size=(0.12, 0.12, 0.12),
),
surface=gs.surfaces.Rough(
color=(1.0, 0.5, 0.5, 1.0),
vis_mode="particle",
),
)
cube0 = scene.add_entity(
material=gs.materials.MPM.Elastic(rho=400),
morph=gs.morphs.Sphere(
pos=(0.15, 0.45, 0.5),
radius=0.06,
),
surface=gs.surfaces.Rough(
color=(1.0, 1.0, 0.5, 1.0),
vis_mode="particle",
),
)
cube0 = scene.add_entity(
material=gs.materials.MPM.Elastic(rho=400),
morph=gs.morphs.Cylinder(
pos=(-0.15, 0.45, 0.6),
radius=0.05,
height=0.14,
),
surface=gs.surfaces.Rough(
color=(0.5, 1.0, 1.0, 1.0),
vis_mode="particle",
),
)
emitter1 = scene.add_emitter(
material=gs.materials.MPM.Liquid(sampler="random"),
max_particles=800000,
surface=gs.surfaces.Rough(
color=(0.0, 0.9, 0.4, 1.0),
),
)
emitter2 = scene.add_emitter(
material=gs.materials.MPM.Liquid(sampler="random"),
max_particles=800000,
surface=gs.surfaces.Rough(
color=(0.0, 0.4, 0.9, 1.0),
),
)
scene.build(n_envs=0)
horizon = 100 if "PYTEST_VERSION" not in os.environ else 5
for i in range(horizon):
emitter1.emit(
pos=np.array([0.16, -0.4, 0.5]),
direction=np.array([0.0, 0.0, -1.0]),
speed=1.5,
droplet_shape="circle",
droplet_size=0.16,
)
emitter2.emit(
pos=np.array([-0.16, -0.4, 0.5]),
direction=np.array([0.0, 0.0, -1.0]),
speed=1.5,
droplet_shape="circle",
droplet_size=0.16,
)
scene.step()
if __name__ == "__main__":
main()