Пример #1
0
def conf2yap(conf_fname, yap_filename):
    print("Yap file : ", yap_filename)
    positions, radii, meta = lf.read_conf_file(conf_fname)
    positions[:, 0] -= float(meta['lx'])/2
    positions[:, 1] -= float(meta['ly'])/2
    positions[:, 2] -= float(meta['lz'])/2

    if 'np_fixed' in meta:
        # for conf with fixed particles
        split_line = len(positions) - int(meta['np_fixed'])
        pos_mobile, pos_fixed = np.split(positions, [split_line])
        rad_mobile, rad_fixed = np.split(radii, [split_line])
        yap_out = pyp.layer_switch(3)
        yap_out = pyp.add_color_switch(yap_out, 3)
        yap_out = np.row_stack((yap_out,
                                particles_yaparray(pos_mobile, rad_mobile)))
        yap_out = pyp.add_layer_switch(yap_out, 4)
        yap_out = pyp.add_color_switch(yap_out, 4)
        yap_out = np.row_stack((yap_out,
                                particles_yaparray(pos_fixed, rad_fixed)))
    else:
        yap_out = pyp.layer_switch(3)
        yap_out = pyp.add_color_switch(yap_out, 3)
        yap_out = np.row_stack((yap_out,
                                particles_yaparray(positions, radii)))

    pyp.savetxt(yap_filename, yap_out)
Пример #2
0
#!/usr/bin/env python
import numpy as np
import sys
import lfdem_file as lf

if len(sys.argv) != 3:
    print(" Usage: ", sys.argv[0], " conf wall_thickness\n")
    exit(1)
fname = sys.argv[1]
wall_thickness = float(sys.argv[2])

pos, rad, meta = lf.read_conf_file(fname)
# get the top and bottom layers

ztop = pos[:, 2]+wall_thickness
top_particles = ztop > float(meta['lz'])

zbottom = pos[:, 2]-wall_thickness*rad
bottom_particles = zbottom < 0

# freeze them
fixed_part = np.logical_or(bottom_particles, top_particles)

# now trick LF_DEM PBCs along z by extending the system along z
# and putting particles in the middle of this extended box,
zextension = 4*np.amax(rad)
meta['lz'] = str(float(meta['lz']) + zextension)
pos[:, 2] += zextension/2

# separate frozen from mobile particles
fixed_rad = rad[fixed_part]