def main(): args = parse_cl() monomers = [] type = 0 space = model.CuboidPBC(args.box_len) # Randomly insert into box and accept if there are not overlaps for i in range(args.num_particles): overlap = True pv = random_unit_vector() ov = random_unit_vector() particle = model.OrientedPatchyParticle(i, 'A', type, patch_norm=pv, patch_orient=ov) monomer = model.SingleParticleMonomer([particle], args.diameter / 2, i) while overlap: monomer.pos = args.box_len * (np.random.rand(3) - 0.5) overlap = model.hard_sphere_overlap(monomer, monomers, args.diameter, space) monomers.append(monomer) # Write files pdb_file = model.PDBConfigOutputFile(args.output_filebase + '.pdb') pdb_file.write(monomers) json_file = model.JSONConfigOutputFile(args.output_filebase + '.json') json_file.write(monomers, args.box_len) return overlap
def main(): args = parse_cl() monomers = [] type = 0 space = model.CuboidPBC(args.box_len) # Randomly insert into box and accept if there are no overlaps radius = args.diameter / 2 acd_ntd_angle = 0.6236561373425675 blob_angle1 = -0.318827603743 blob_angle2 = -0.534300804011 s_monomers = cso.construct_monomers(radius, radius, 2, 2, args.num_monomers, acd_ntd_angle, blob_angle1, blob_angle2) monomers = [] for m in s_monomers: overlap = True while overlap: x1r = trans.axangles.axangle2aff([1, 0, 0], 2 * math.pi * random.random(), m.center) yr = trans.axangles.axangle2aff([0, 1, 0], 2 * math.pi * random.random(), m.center) x2r = trans.axangles.axangle2aff([1, 0, 0], 2 * math.pi * random.random(), m.center) m.apply_transformation(x1r) m.apply_transformation(yr) m.apply_transformation(x2r) pos = np.concatenate( [args.box_len * (np.random.rand(3) - 0.5), [0]]) ref_pos = copy.deepcopy(m.particles[0].pos) m.particles[0].pos = pos for p in m.particles[1:]: pdiff = p.pos - ref_pos p.pos = space.wrap(pos + pdiff) overlap = model.hard_sphere_overlap(m, monomers, args.diameter, space) monomers.append(m) # Write files pdb_file = model.PDBConfigOutputFile(args.output_filebase + '.pdb') pdb_file.write(monomers) json_file = model.JSONConfigOutputFile(args.output_filebase + '.json') json_file.write(monomers, args.box_len) return overlap
def main(): args = parse_cl() type = 0 space = model.CuboidPBC(args.box_len) # Randomly insert into box and accept if there are no overlaps radius = args.diameter / 2 acd_ntd_angle = 0.6236561373425675 blob_angle1 = -0.318827603743 blob_angle2 = -0.534300804011 set_monomers = [] monomers = cso.construct_monomers(radius, radius, 2, 2, 6 * args.num_hexamers, acd_ntd_angle, blob_angle1, blob_angle2) for i in range(args.num_hexamers): h_monomers = [m for m in monomers[i * 6:i * 6 + 6]] dimers = [] for j in range(0, 5, 2): monomer1 = h_monomers[j] monomer2 = h_monomers[j + 1] dimer = cso.construct_dimer(monomer1, monomer2) dimers.append(dimer) hexamer = cso.construct_hexamer(dimers[0], dimers[1], dimers[2]) overlap = [True] * 6 while np.any(overlap): #angle1 = 2*math.pi*random.random() #angle2 = 2*math.pi*random.random() #angle3 = 2*math.pi*random.random() delta_pos = args.box_len * (np.random.rand(3) - 0.5) delta_pos = np.concatenate([delta_pos, [0]]) for j, m in enumerate(h_monomers): #x1r = trans.axangles.axangle2aff([1, 0, 0], angle1, m.center) #yr = trans.axangles.axangle2aff([0, 1, 0], angle2, m.center) #x2r = trans.axangles.axangle2aff([1, 0, 0], angle3, m.center) #m.apply_transformation(x1r) #m.apply_transformation(yr) #m.apply_transformation(x2r) for p in m.particles: p.pos = space.wrap(p.pos + delta_pos) overlap[j] = model.hard_sphere_overlap(m, set_monomers, args.diameter, space) set_monomers.extend(h_monomers) # Write files json_file = model.JSONConfigOutputFile(args.output_filebase + '.json') json_file.write(set_monomers, args.box_len)