cmelab / flowerMD

Flexible Library of Organic Workflows and Extensible Recipes for Molecular Dynamics.
https://flowermd.readthedocs.io/en/latest/
GNU General Public License v3.0
12 stars 8 forks source link

Can't type p3ht #153

Open StephMcCallum opened 1 month ago

StephMcCallum commented 1 month ago
from flowermd.base import Molecule
from flowermd.base import Pack
from flowermd.library.forcefields import FF_from_file
import unyt

p3ht = Molecule(num_mols=20, smiles="CCCCCCc1ccsc1")
system = Pack(molecules=p3ht, density=0.5 * unyt.g/unyt.cm**3)
p3ht_ff = FF_from_file(forcefield_files="/home/smccallum/flowerMD/P3HT.xml")
system.apply_forcefield(r_cut=2.5, force_field=p3ht_ff, auto_scale=True)

For the minimal working example above, Foyer isn't getting the expected atom types.

File ~/miniforge3/envs/flowermd/lib/python3.11/site-packages/foyer/atomtyper.py:228, in _resolve_atomtypes(topology_graph, typemap) 222 raise FoyerError( 223 "Found multiple types for atom {} ({}): {}.".format( 224 atom_id, atoms[atom_id].atomic_number, atomtype 225 ) 226 ) 227 else: --> 228 raise FoyerError( 229 "Found no types for atom {} ({}).".format( 230 atom_id, atoms[atom_id].atomic_number 231 ) 232 )

FoyerError: Found no types for atom 0 (6).

chrisjonesBSU commented 1 month ago

Can you upload, or post a code snippet of the contents of the xml file you're using?

marjanalbooyeh commented 1 month ago

If this is a missing parameter issue I think Espaloma could be helpful. @madilynpaul you already typed p3ht, right? Do you have the xml for that by any chance so that we can add it to the flowermd ff library?

madilynpaul commented 1 month ago

Yes, I have! I have the typed mol2 file as well as the xml.

madilynpaul commented 1 month ago

I think I see the problem! @StephMcCallum If you are using the espaloma generated xml file, you have to load your molecule from the mols2 file that contains the correct atomtype names. I sent you a longer explanation on slack.