mosdef-hub / foyer

A package for atom-typing as well as applying and disseminating forcefields
https://foyer.mosdef.org
MIT License
118 stars 77 forks source link

`foyer.forcefield.apply` does not carry over atomic_number information from the input structure #466

Open jennyfothergill opened 2 years ago

jennyfothergill commented 2 years ago

Bug summary

I am using mbuild/foyer in a workflow in planckton. We have a couple older input mol2 files which were typed with antechamber, and for these the particle name will match the type name in a gaff (custom) forcefield. The element in the compound is manually set, and this transfers to the parmed structure, but when the apply function is used, the atomic number is not carried over from the input structure.

Code to reproduce the behavior

I'm using the example I described from planckton--if needed, I can work up a simpler example.

from planckton.compounds import COMPOUND
from planckton.forcefields import FORCEFIELD
from planckton.init import Compound

p3ht = Compound(COMPOUND["P3HT-16-gaff"])
gaff = FORCEFIELD["gaff-custom"]
residues = [p3ht.name]
pmd = p3ht.to_parmed(residues=residues)
s = gaff.apply(pmd, assert_dihedral_params=False)

p0 = [p for p in p3ht.particles()][0]
a0 = [a for a in pmd.atoms][0]
s0 = [a for a in s.atoms][0]
print(p0.name, p0.element.atomic_number)
print(a0.name, a0.atomic_number)
print(s0.name, s0.atomic_number)

output:

_cc 6
_cc 6
_cc 0

Software versions

NOTE: The below template should have dunder around version: