Beispiel #1
0
scene_params = np.array([x, y, z, dim_x, dim_y, dim_z, box_dis_x, box_dis_z])
print("scene_params", scene_params)
pyflex.set_scene(6, scene_params, 0)

boxes = calc_box_init(box_dis_x, box_dis_z)

for i in range(len(boxes)):
    halfEdge = boxes[i][0]
    center = boxes[i][1]
    quat = boxes[i][2]
    pyflex.add_box(halfEdge, center, quat)

### read scene info
print("Scene Upper:", pyflex.get_scene_upper())
print("Scene Lower:", pyflex.get_scene_lower())
print("Num particles:", pyflex.get_phases().reshape(-1, 1).shape[0])
print("Phases:", np.unique(pyflex.get_phases()))

n_particles = pyflex.get_n_particles()
n_shapes = pyflex.get_n_shapes()
n_rigids = pyflex.get_n_rigids()
n_rigidPositions = pyflex.get_n_rigidPositions()

print("n_particles", n_particles)
print("n_shapes", n_shapes)
print("n_rigids", n_rigids)
print("n_rigidPositions", n_rigidPositions)

positions = np.zeros((time_step, n_particles, dim_position))
velocities = np.zeros((time_step, n_particles, dim_velocity))
Beispiel #2
0
#Written by Henry M. Clever. November 15, 2018.

import pyflex
from time import time
from random import random
import numpy as np

main_loop_quit = False
time_step = 100
dim_position = 4
dim_velocity = 3

pyflex.initialize()

bbox = [pyflex.get_scene_lower(), pyflex.get_scene_upper()]
d_size = pyflex.get_scene_upper() - pyflex.get_scene_lower()
n_particles = pyflex.get_n_particles()

print("Scene Lower:", bbox[0])
print("Scene Upper:", bbox[1])
print('domain size', d_size)
print("Num particles:", n_particles)

r = 0.05
rest_dist = r * 0.65
dt = 1 / 60

positions = np.zeros((time_step, n_particles, dim_position))
velocities = np.zeros((time_step, n_particles, dim_velocity))

t = 0