Ejemplo n.º 1
0
def test_compress():
    top = Topology.open(cwd + '/files/10-H2O-5-C3H6.lmp', improper_center=3)
    molecules = top.molecules
    for mol in molecules[4:]:
        for atom in mol.atoms:
            atom.charge *= 2

    top = Topology.open(cwd + '/files/Im11.zmat')
    molecules += top.molecules

    top = Topology.open(cwd + '/files/10-H2O-5-C3H6.lmp', improper_center=3)
    molecules += top.molecules

    top = Topology.open(cwd + '/files/Im11.zmat')
    molecules += top.molecules

    top = Topology()
    top.update_molecules(molecules)
    mols_unique = top.get_unique_molecules()
    for mol, count in mols_unique.items():
        print(str(mol), count)

    assert list(mols_unique.values()) == [4, 6, 5, 1, 10, 5, 1]
Ejemplo n.º 2
0
if args.ljscale is not None:
    scaler = PaduaLJScaler(args.ljscale)
    scaler.scale(ff)

if args.scaleeps != 1.0 or args.scalesig != 1.0:
    for vdw in list(ff.vdw_terms.values()) + list(ff.pairwise_vdw_terms.values()):
        if vdw.type1 in args.scaleignoreatom or vdw.type2 in args.scaleignoreatom:
            continue
        if args.scaleeps != 1.0:
            vdw.epsilon *= args.scaleeps
            vdw.comments.append('eps*%.3f' % args.scaleeps)
        if args.scalesig != 1.0:
            vdw.sigma *= args.scalesig
            vdw.comments.append('sig*%.3f' % args.scalesig)

mol_count = top.get_unique_molecules(deepcopy=False)
for mol in mol_count.keys():
    mol: Molecule
    logger.info('Processing %s ...' % str(mol))
    if typer is not None:
        try:
            typer.type_molecule(mol)
        except TypingNotSupportedError as e:
            pass
        except TypingUndefinedError as e:
            xyz = '_typing_' + mol.name + '.xyz'
            Topology([mol]).write(xyz)
            logger.error('Failed typing %s: %s. Check %s' % (mol, str(e), xyz))
            sys.exit(1)

    if mol.n_atom > 1 and mol.n_bond == 0: