mosdef-hub / mbuild

A hierarchical, component based molecule builder
https://mbuild.mosdef.org
Other
171 stars 79 forks source link

combining rule not read from xml file when saving a .top file #1152

Closed GuiLingfeng closed 9 months ago

GuiLingfeng commented 9 months ago

Bug summary

I was using mbuild.Compound().save() to generate a Gromacs topology file using the oplsaa xml file in which the geometic combining rule is specified <ForceField name="OPLS-AA" version="0.0.3" combining_rule="geometric"> but in the generated toplogy file the comb-rule is 2, i.e., Lorentz-Berthelot rules. ; nbfunc comb-rule gen-pairs fudgeLJ fudgeQQ 1 2 yes 0.5 0.5 This issue should be related to https://github.com/mosdef-hub/mbuild/blob/b30ceff677781e83a55d5da2fdf000675a54b58b/mbuild/conversion.py#L1122.

Code to reproduce the behavior

Please include a code snippet that can be used to reproduce this bug.

import mbuild as mb
molecule = mb.load('CCCCCC', smiles = True)
molecule.save('hexane.top', forcefield_files='./ff_xml/oplsaa.xml', overwrite=True)

Software versions

daico007 commented 9 months ago

Since this is going through the Compound.save method, the combining rule is actually an option/parameter that need to be specified (and is actually default to lorentz, i.e., what's being written out). I can open a PR to make a new default option using that pulled from the force field XML instead. In the mean time, you can specify the combining_rule="geometric" in the save() call.

GuiLingfeng commented 9 months ago

Sounds good! Thanks!

CalCraven commented 9 months ago

As Griffin and I were discussing, this issue as whole raises the concern that the mBuild tutorials are out of date. I think we need to raise this issue higher to either go through and update them or archive them altogether.

daico007 commented 9 months ago

I lean toward updating the old tutorials (and maybe append the newer one we created for CECAM to it too), just because those have a very solid instruction for the very basic of mbuild.