mosdef-hub / foyer

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

Getting an error when using Porebuilder and foyer/mbuild, maybe in the box vectors. #497

Closed bc118 closed 11 months ago

bc118 commented 2 years ago

Bug summary

When running mbuild/foyer with the graphene pore builder, it is producing the following error, suggesting that is is something with the box vectors. This error did only appeared in the last 2 months. The pore builder file was modified to work with the new mbuild box structure and is attached in the example below, so you can run the code and see the error directly.

Error: "No force field name found in force field XML file." /Users/brad/Programs/anaconda3/envs/mbuild-dev/lib/python3.7/site-packages/foyer/forcefield.py:645: UserWarning: No combining rule found in force field XML file. "No combining rule found in force field XML file." Traceback (most recent call last): File "/Users/brad/Desktop/Error_on_mbuild_porebuilder/example_pore_builder.py", line 116, in reorder_res_in_pdb_psf=True, File "/Users/brad/Programs/anaconda3/envs/mbuild-dev/lib/python3.7/site-packages/mbuild/formats/charmm_writer.py", line 1784, in init boxes_for_simulation=self.boxes_for_simulation, File "/Users/brad/Programs/anaconda3/envs/mbuild-dev/lib/python3.7/site-packages/mbuild/utils/specific_ff_to_residue.py", line 394, in specific_ff_to_residue new_compound_iteration, residues=[residues[i]] File "/Users/brad/Programs/anaconda3/envs/mbuild-dev/lib/python3.7/site-packages/foyer/forcefield.py", line 786, in apply **kwargs, File "/Users/brad/Programs/anaconda3/envs/mbuild-dev/lib/python3.7/site-packages/foyer/forcefield.py", line 846, in parametrize_system structure, self.non_element_types File "/Users/brad/Programs/anaconda3/envs/mbuild-dev/lib/python3.7/site-packages/foyer/forcefield.py", line 225, in _topology_from_parmed topology.setPeriodicBoxVectors(structure.box_vectors) File "/Users/brad/Programs/anaconda3/envs/mbuild-dev/lib/python3.7/site-packages/openmm/app/topology.py", line 252, in setPeriodicBoxVectors raise ValueError("Periodic box vectors must be in reduced form."); ValueError: Periodic box vectors must be in reduced form.

Code to reproduce the behavior

Attached is code to reproduce the issue. Run the example_pore_builder.py code. The included porebuilder.py file lines 115 to 133 print out the box vector and reduced box vectors for more information.

Error_on_mbuild_porebuilder.zip

Software versions

stevenkbennett commented 11 months ago

I'm not sure if this will fix work for your issue specifically, but I encountered the same error when converting to an OpenMM topology. One of the checks that confirms if the box vectors are in reduced form was failing due to a precision issue when creating the vectors of the Box in mbuild. For me, reducing the precision of the box in mbuild from the default 6 to 5 fixed the issue.