Exemplo n.º 1
0
    tmp_vel.x = tmp_vel.y
    tmp_vel.y = -tmp

    particle.v = tmp_vel

mean_v = Vector3d()
for particle in particles:
    mean_v += particle.v
mean_v = mean_v * (1/len(particles))

for particle in particles:
    particle.v -= mean_v

for step in range(constants.steps_number):
    print('s :', step)
    io_xyz.write(particles, save_path, step)

    for particle in particles:
        particle.force = Vector3d()

    for i, p1 in enumerate(particles):
        for p2 in particles[i+1:]:
            tmp_force = forces.base_force(p1, p2)
            p1.force += tmp_force
            p2.force += -tmp_force

    for particle in particles:
        particle.v += particle.force * constants.dt
        particle.r += particle.v * constants.dt

Exemplo n.º 2
0
        if make_ax:
            plt.show()
            plt.close(fig)
            del fig


# make 100 random points
input_path = '../3d/clust2.xyz'
save_path = os.path.dirname(os.path.realpath(__file__)) + '/test'

if not os.path.exists(save_path):
    os.makedirs(save_path)

# P = np.reshape([random.random() * 100 for i in range(300)], (100, 3))
particles = io_xyz.read(input_path, format='Nick')
io_xyz.write(particles, save_path, 0)

# find the ellipsoid
ET = EllipsoidTool()
(center, radii, rotation) = ET.getMinVolEllipse(
    np.array([[particle.r.x, particle.r.y, particle.r.z]
              for particle in particles],
             dtype='float32'), .01)

num_sumples = 5000
k = 0


def criterier(*args):
    return True