def generate_raspa_mol(ciffile, chargefile, outputfile): atoms = Atoms.from_cif(ciffile) # update charges charges = np.array( [float(line.strip()) for line in chargefile if line.strip() != '']) assert len(charges) == len(atoms.positions) atoms.charges = charges atoms.to_mol(outputfile)
def cif2lmpdat(ciffile, outputfile, chargefile=None, mic=None): atoms = Atoms.from_cif(ciffile) # update charges if chargefile is not None: charges = np.array( [float(line.strip()) for line in chargefile if line.strip() != '']) assert len(charges) == len(atoms.positions) atoms.charges = charges # replicate to meet minimum image convention, if necessary if mic is not None: repls = np.array(np.ceil(2 * mic / np.diag(atoms.cell)), dtype=int) atoms = atoms.replicate(repls) assign_pair_params_to_structure(atoms) atoms.to_lammps_data(outputfile)
def functionalize_structure_with_linkers(structure_path, linker_path, fnlinkers, output_dir=Path()): linker = Atoms.from_cml(Path(linker_path)) structure = Atoms.from_cif(structure_path) output_dir = Path(output_dir) assign_pair_params_to_structure(structure) for fnlinker_path in fnlinkers: print("reading %s" % fnlinker_path) fnlinker = Atoms.from_lammps_data(open(fnlinker_path, "r"), use_comment_for_type_labels=True) try: new_structure = replace_pattern_in_structure( structure, linker, fnlinker) with open( output_dir.joinpath(Path(fnlinker_path).stem + ".lmpdat"), "w") as fd: new_structure.to_lammps_data(fd) except Exception as e: print("ERROR! ", e.args)