def conf2yap(conf_fname, yap_filename): print("Yap file : ", yap_filename) positions, radii, meta = clff.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)
def conf2yap(conf_fname, yap_filename): print("Yap file : ", yap_filename) positions, radii, meta = clff.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)
def interactions_bonds_yaparray(int_snapshot, par_snapshot, icols, pcols, f_factor=None, f_chain_thresh=None, layer_contacts=1, layer_noncontacts=2, color_contacts=1, color_noncontacts=2): if f_chain_thresh is None: f_chain_thresh = 0 r1r2 = lfu.get_interaction_end_points(int_snapshot, par_snapshot, icols, pcols) f, r1r2 = filter_interactions_crossing_PBC(int_snapshot, r1r2) # display a line joining the center of interacting particles # with a thickness proportional to the normal force normal_forces = get_normal_force(f, icols) # convert the force to a thickness. case-by-case. if f_factor is None: f_factor = 0.5/np.max(np.abs(normal_forces)) normal_forces = f_factor*np.abs(normal_forces) avg_force = np.mean(np.abs(normal_forces)) large_forces = normal_forces > f_chain_thresh * avg_force contact_state = f[:, du.matching_uniq(icols, 'contact state')[1]] # contacts keep = np.logical_and(contact_state > 0, large_forces) yap_out = pyp.layer_switch(layer_contacts) yap_out = pyp.add_color_switch(yap_out, color_contacts) contact_bonds = pyp.sticks_yaparray(r1r2[keep], normal_forces[keep]) yap_out = np.row_stack((yap_out, contact_bonds)) # non contacts keep = np.logical_and(contact_state == 0, large_forces) yap_out = pyp.add_layer_switch(yap_out, layer_noncontacts) yap_out = pyp.add_color_switch(yap_out, color_noncontacts) non_contact_bonds = pyp.sticks_yaparray(r1r2[keep], normal_forces[keep]) yap_out = np.row_stack((yap_out, non_contact_bonds)) return yap_out, f_factor
def interactions_bonds_yaparray(int_snapshot, par_snapshot, icols, pcols, f_factor=None, f_chain_thresh=None, layer_contacts=1, layer_noncontacts=2, color_contacts=1, color_noncontacts=2): if f_chain_thresh is None: f_chain_thresh = 0 r1r2 = lfu.get_interaction_end_points(int_snapshot, par_snapshot, icols, pcols) f, r1r2 = filter_interactions_crossing_PBC(int_snapshot, r1r2) # display a line joining the center of interacting particles # with a thickness proportional to the normal force normal_forces = get_normal_force(f, icols) # convert the force to a thickness. case-by-case. if f_factor is None: f_factor = 0.5 / np.max(np.abs(normal_forces)) normal_forces = f_factor * np.abs(normal_forces) avg_force = np.mean(np.abs(normal_forces)) large_forces = normal_forces > f_chain_thresh * avg_force contact_state = f[:, du.matching_uniq(icols, 'contact state')[1]] # contacts keep = np.logical_and(contact_state > 0, large_forces) yap_out = pyp.layer_switch(layer_contacts) yap_out = pyp.add_color_switch(yap_out, color_contacts) contact_bonds = pyp.sticks_yaparray(r1r2[keep], normal_forces[keep]) yap_out = np.row_stack((yap_out, contact_bonds)) # non contacts keep = np.logical_and(contact_state == 0, large_forces) yap_out = pyp.add_layer_switch(yap_out, layer_noncontacts) yap_out = pyp.add_color_switch(yap_out, color_noncontacts) non_contact_bonds = pyp.sticks_yaparray(r1r2[keep], normal_forces[keep]) yap_out = np.row_stack((yap_out, non_contact_bonds)) return yap_out, f_factor