openforcefield / openff-interchange

A project (and object) for storing, manipulating, and converting molecular mechanics data.
https://docs.openforcefield.org/projects/interchange
MIT License
69 stars 22 forks source link

GROMACS writer chokes without unique molecule names #974

Closed pbuslaev closed 4 months ago

pbuslaev commented 5 months ago

Description

While playing around with Interchange.combine I noticed a strange behaviour. Combined interchanges loaded from json or gromacs, can't be exported to gromacs. This follows from discussion in #908

Reproduction

from openff.toolkit import Topology, Molecule, ForceField
from openff.interchange import Interchange

m1 = Molecule.from_smiles("c1ccccc1")
m2 = Molecule.from_smiles("CCC")
m1.generate_conformers()
m2.generate_conformers()

ff = ForceField("openff-2.2.0.offxml")

i1 = Interchange.from_smirnoff(ff, m1.to_topology())
i2 = Interchange.from_smirnoff(ff, m2.to_topology())

i1.to_gromacs("test1")
i2.to_gromacs("test2")

i3 = i1.combine(i2)
i3.to_gromacs("test")  # works fine

# Does not work
i1_upd = Interchange.parse_raw(i1.json())
i2_upd = Interchange.parse_raw(i2.json())
i3_upd = i1_upd.combine(i2_upd)

i3_upd.to_gromacs("test3")  # Fails

# Also does not work

i1_from = Interchange.from_gromacs("test1.top", "test1.gro")
i2_from = Interchange.from_gromacs("test2.top", "test2.gro")
i3_from = i1_from.combine(i2_from)

i3_from.to_gromacs("test6")

Output

Both my attempts fail at to_gromacs step, but it seems that the reason is than molecule dictionary is not correctly filled.

The output is as following:

/home/pbuslaev/conda_env/interchange-combine/lib/python3.11/site-packages/openff/interchange/components/interchange.py:954: UserWarning: Interchange object combination is experimental and likely to produce strange results. Any workflow using this method is not guaranteed to be suitable for production. Use with extreme caution and thoroughly validate results!
  return _combine(self, other)
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
Cell In[9], line 5
      2 i2_from = Interchange.from_gromacs("test2.top", "test2.gro")
      3 i3_from = i1_from.combine(i2_from)
----> 5 i3_from.to_gromacs("test6")

File ~/conda_env/interchange-combine/lib/python3.11/site-packages/openff/interchange/components/interchange.py:451, in Interchange.to_gromacs(self, prefix, decimal, hydrogen_mass)
    444 writer = GROMACSWriter(
    445     system=_convert(self, hydrogen_mass=hydrogen_mass),
    446     top_file=prefix + ".top",
    447     gro_file=prefix + ".gro",
    448 )
    450 writer.to_top()
--> 451 writer.to_gro(decimal=decimal)

File ~/conda_env/interchange-combine/lib/python3.11/site-packages/openff/interchange/interop/gromacs/export/_export.py:48, in GROMACSWriter.to_gro(self, decimal)
     45     raise ValueError("No GRO file specified.")
     47 with open(self.gro_file, "w") as gro:
---> 48     self._write_gro(gro, decimal)

File ~/conda_env/interchange-combine/lib/python3.11/site-packages/openff/interchange/interop/gromacs/export/_export.py:341, in GROMACSWriter._write_gro(self, gro, decimal)
    335 print(self.system.molecules, self.system.molecule_types)
    336 n_particles = sum(
    337     len(molecule_type.atoms) * self.system.molecules[molecule_name]
    338     for molecule_name, molecule_type in self.system.molecule_types.items()
    339 )
--> 341 assert n_particles == self.system.positions.shape[0], (
    342     n_particles,
    343     self.system.positions.shape[0],
    344 )
    346 # Explicitly round here to avoid ambiguous things in string formatting
    347 positions = numpy.round(self.system.positions, decimal).m_as(unit.nanometer)

AssertionError: (11, 23)

From my brief exploration, I noticed that self.system.molecules in _write_gro method, only has one molecule for some reason.

What makes the issue even stranger, if I run the following bit of code (without first dumping i1 and i2 to gromacs), everything works fine.

from openff.toolkit import Topology, Molecule, ForceField
from openff.interchange import Interchange

m1 = Molecule.from_smiles("c1ccccc1")
m2 = Molecule.from_smiles("CCC")
m1.generate_conformers()
m2.generate_conformers()

ff = ForceField("openff-2.2.0.offxml")

i1 = Interchange.from_smirnoff(ff, m1.to_topology())
i2 = Interchange.from_smirnoff(ff, m2.to_topology())

i3 = i1.combine(i2)
i3.to_gromacs("test")  # works fine

i1_upd = Interchange.parse_raw(i1.json())
i2_upd = Interchange.parse_raw(i2.json())
i3_upd = i1_upd.combine(i2_upd)

i3_upd.to_gromacs("test3") 

Software versions

CENTOS_MANTISBT_PROJECT="CentOS-7" CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7"

- How did you install Interchange?

mamba install -c conda-forge openff-interchange

- What is the output of running `conda list`?

<details>

packages in environment at /home/pbuslaev/conda_env/interchange-combine:

#

Name Version Build Channel

_libgcc_mutex 0.1 conda_forge conda-forge _openmp_mutex 4.5 2_gnu conda-forge ambertools 23.3 py311h9fea076_6 conda-forge amberutils 21.0 pypi_0 pypi annotated-types 0.6.0 pypi_0 pypi anyio 4.3.0 pypi_0 pypi argon2-cffi 23.1.0 pypi_0 pypi argon2-cffi-bindings 21.2.0 pypi_0 pypi arpack 3.8.0 nompi_h0baa96a_101 conda-forge arrow 1.3.0 pypi_0 pypi asttokens 2.4.1 pypi_0 pypi astunparse 1.6.3 pypi_0 pypi async-lru 2.0.4 pypi_0 pypi attrs 23.2.0 pypi_0 pypi babel 2.14.0 pypi_0 pypi beautifulsoup4 4.12.3 pypi_0 pypi bleach 6.1.0 pypi_0 pypi blosc 1.21.5 hc2324a3_1 conda-forge brotli 1.1.0 pypi_0 pypi brotli-bin 1.1.0 hd590300_1 conda-forge brotli-python 1.1.0 py311hb755f60_1 conda-forge bson 0.5.9 pypi_0 pypi bzip2 1.0.8 h5eee18b_5
c-ares 1.28.1 hd590300_0 conda-forge c-blosc2 2.14.4 hb4ffafa_1 conda-forge ca-certificates 2024.3.11 h06a4308_0
cached-property 1.5.2 pypi_0 pypi cached_property 1.5.2 pyha770c72_1 conda-forge cachetools 5.3.3 pypi_0 pypi cairo 1.18.0 h3faef2a_0 conda-forge certifi 2024.2.2 pypi_0 pypi cffi 1.16.0 pypi_0 pypi chardet 5.2.0 pypi_0 pypi charset-normalizer 3.3.2 pypi_0 pypi colorama 0.4.6 pypi_0 pypi comm 0.2.2 pypi_0 pypi contourpy 1.2.1 pypi_0 pypi cudatoolkit 11.8.0 h4ba93d1_13 conda-forge cycler 0.12.1 pypi_0 pypi debugpy 1.8.1 pypi_0 pypi decorator 5.1.1 pypi_0 pypi defusedxml 0.7.1 pypi_0 pypi edgembar 0.2 pypi_0 pypi entrypoints 0.4 pypi_0 pypi exceptiongroup 1.2.0 pypi_0 pypi executing 2.0.1 pypi_0 pypi expat 2.6.2 h59595ed_0 conda-forge fastjsonschema 2.19.1 pypi_0 pypi fftw 3.3.10 nompi_hc118613_108 conda-forge font-ttf-dejavu-sans-mono 2.37 hab24e00_0 conda-forge font-ttf-inconsolata 3.000 h77eed37_0 conda-forge font-ttf-source-code-pro 2.038 h77eed37_0 conda-forge font-ttf-ubuntu 0.83 h77eed37_1 conda-forge fontconfig 2.14.2 h14ed4e7_0 conda-forge fonts-conda-ecosystem 1 0 conda-forge fonts-conda-forge 1 0 conda-forge fonttools 4.51.0 pypi_0 pypi fqdn 1.5.1 pypi_0 pypi freetype 2.12.1 h267a509_2 conda-forge freetype-py 2.3.0 pypi_0 pypi greenlet 3.0.3 pypi_0 pypi h11 0.14.0 pypi_0 pypi h2 4.1.0 pypi_0 pypi hdf4 4.2.15 h2a13503_7 conda-forge hdf5 1.14.3 nompi_h4f84152_100 conda-forge hpack 4.0.0 pypi_0 pypi httpcore 1.0.5 pypi_0 pypi httpx 0.27.0 pypi_0 pypi hyperframe 6.0.1 pypi_0 pypi icu 73.2 h59595ed_0 conda-forge idna 3.7 pypi_0 pypi importlib-metadata 7.1.0 pypi_0 pypi importlib-resources 6.4.0 pypi_0 pypi importlib_metadata 7.1.0 hd8ed1ab_0 conda-forge importlib_resources 6.4.0 pyhd8ed1ab_0 conda-forge ipykernel 6.29.3 pypi_0 pypi ipython 8.22.2 pypi_0 pypi ipywidgets 8.1.2 pypi_0 pypi isoduration 20.11.0 pypi_0 pypi jedi 0.19.1 pypi_0 pypi jinja2 3.1.3 pypi_0 pypi joblib 1.4.0 pypi_0 pypi json5 0.9.25 pypi_0 pypi jsonpointer 2.4 pypi_0 pypi jsonschema 4.21.1 pypi_0 pypi jsonschema-specifications 2023.12.1 pypi_0 pypi jsonschema-with-format-nongpl 4.21.1 pyhd8ed1ab_0 conda-forge jupyter-client 8.6.1 pypi_0 pypi jupyter-core 5.7.2 pypi_0 pypi jupyter-events 0.10.0 pypi_0 pypi jupyter-lsp 2.2.5 pypi_0 pypi jupyter-server 2.14.0 pypi_0 pypi jupyter-server-terminals 0.5.3 pypi_0 pypi jupyter_client 8.6.1 pyhd8ed1ab_0 conda-forge jupyter_core 5.7.2 py311h38be061_0 conda-forge jupyter_events 0.10.0 pyhd8ed1ab_0 conda-forge jupyter_server 2.14.0 pyhd8ed1ab_0 conda-forge jupyter_server_terminals 0.5.3 pyhd8ed1ab_0 conda-forge jupyterlab 4.1.6 pypi_0 pypi jupyterlab-pygments 0.3.0 pypi_0 pypi jupyterlab-server 2.27.1 pypi_0 pypi jupyterlab-widgets 3.0.10 pypi_0 pypi jupyterlab_pygments 0.3.0 pyhd8ed1ab_1 conda-forge jupyterlab_server 2.27.1 pyhd8ed1ab_0 conda-forge jupyterlab_widgets 3.0.10 pyhd8ed1ab_0 conda-forge keyutils 1.6.1 h166bdaf_0 conda-forge kiwisolver 1.4.5 pypi_0 pypi krb5 1.21.2 h659d440_0 conda-forge lcms2 2.16 hb7c19ff_0 conda-forge ld_impl_linux-64 2.38 h1181459_1
lerc 4.0.0 h27087fc_0 conda-forge libaec 1.1.3 h59595ed_0 conda-forge libblas 3.9.0 22_linux64_openblas conda-forge libboost 1.82.0 h6fcfa73_6 conda-forge libboost-python 1.82.0 py311h92ebd52_6 conda-forge libbrotlicommon 1.1.0 hd590300_1 conda-forge libbrotlidec 1.1.0 hd590300_1 conda-forge libbrotlienc 1.1.0 hd590300_1 conda-forge libcblas 3.9.0 22_linux64_openblas conda-forge libcurl 8.7.1 hca28451_0 conda-forge libdeflate 1.20 hd590300_0 conda-forge libedit 3.1.20191231 he28a2e2_2 conda-forge libev 4.33 hd590300_2 conda-forge libexpat 2.6.2 h59595ed_0 conda-forge libffi 3.4.4 h6a678d5_0
libgcc-ng 13.2.0 hc881cc4_6 conda-forge libgfortran-ng 13.2.0 h69a702a_6 conda-forge libgfortran5 13.2.0 h43f5ff8_6 conda-forge libglib 2.80.0 hf2295e7_6 conda-forge libgomp 13.2.0 hc881cc4_6 conda-forge libiconv 1.17 hd590300_2 conda-forge libjpeg-turbo 3.0.0 hd590300_1 conda-forge liblapack 3.9.0 22_linux64_openblas conda-forge libnetcdf 4.9.2 nompi_h9612171_113 conda-forge libnghttp2 1.58.0 h47da74e_1 conda-forge libnsl 2.0.1 hd590300_0 conda-forge libopenblas 0.3.27 pthreads_h413a1c8_0 conda-forge libpng 1.6.43 h2797004_0 conda-forge libsodium 1.0.18 h36c2ea0_1 conda-forge libsqlite 3.45.3 h2797004_0 conda-forge libssh2 1.11.0 h0841786_0 conda-forge libstdcxx-ng 13.2.0 h95c4c6d_6 conda-forge libtiff 4.6.0 h1dd3fc0_3 conda-forge libuuid 2.38.1 h0b41bf4_0 conda-forge libwebp-base 1.4.0 hd590300_0 conda-forge libxcb 1.15 h0b41bf4_0 conda-forge libxcrypt 4.4.36 hd590300_1 conda-forge libxml2 2.12.6 h232c23b_2 conda-forge libzip 1.10.1 h2629f0a_3 conda-forge libzlib 1.2.13 hd590300_5 conda-forge lz4-c 1.9.4 hcb278e6_0 conda-forge lzo 2.10 hd590300_1001 conda-forge markupsafe 2.1.5 pypi_0 pypi matplotlib 3.8.4 pypi_0 pypi matplotlib-base 3.8.4 py311h54ef318_0 conda-forge matplotlib-inline 0.1.7 pypi_0 pypi mda-xdrlib 0.2.0 pypi_0 pypi mdtraj 1.9.9 pypi_0 pypi mistune 3.0.2 pypi_0 pypi mmpbsa-py 16.0 pypi_0 pypi munkres 1.1.4 pypi_0 pypi nbclient 0.10.0 pypi_0 pypi nbconvert 7.16.3 pypi_0 pypi nbconvert-core 7.16.3 pyhd8ed1ab_1 conda-forge nbformat 5.10.4 pypi_0 pypi ncurses 6.4 h6a678d5_0
ndfes 1.8 pypi_0 pypi nest-asyncio 1.6.0 pypi_0 pypi netcdf-fortran 4.6.1 nompi_hacb5139_103 conda-forge networkx 3.3 pypi_0 pypi nomkl 1.0 h5ca1d4c_0 conda-forge notebook 7.1.3 pypi_0 pypi notebook-shim 0.2.4 pypi_0 pypi numexpr 2.9.0 pypi_0 pypi numpy 1.26.4 pypi_0 pypi ocl-icd 2.3.2 hd590300_1 conda-forge ocl-icd-system 1.0.0 1 conda-forge openff-amber-ff-ports 0+untagged.32.g809f411.dirty pypi_0 pypi openff-forcefields 2024.04.0 pyhca7485f_0 conda-forge openff-interchange 0.3.26 pypi_0 pypi openff-interchange-base 0.3.26 pyhd8ed1ab_0 conda-forge openff-models 0.1.2 pypi_0 pypi openff-toolkit 0.16.0 pypi_0 pypi openff-toolkit-base 0.16.0 pyhd8ed1ab_0 conda-forge openff-units 0.2.2 pypi_0 pypi openff-utilities 0.1.12 pypi_0 pypi openforcefields 2024.4.0 pypi_0 pypi openjpeg 2.5.2 h488ebb8_0 conda-forge openmm 8.1.1 pypi_0 pypi openssl 3.2.1 hd590300_1 conda-forge overrides 7.7.0 pypi_0 pypi packaging 24.0 pypi_0 pypi packmol 20.010 h86c2bf4_0 conda-forge packmol-memgen 2023.2.24 pypi_0 pypi pandas 2.1.4 pypi_0 pypi pandocfilters 1.5.0 pypi_0 pypi panedr 0.8.0 pypi_0 pypi parmed 4.2.2 pypi_0 pypi parso 0.8.4 pypi_0 pypi pcre2 10.43 hcad00b1_0 conda-forge pdb4amber 22.0 pypi_0 pypi perl 5.32.1 7_hd590300_perl5 conda-forge pexpect 4.9.0 pypi_0 pypi pickleshare 0.7.5 pypi_0 pypi pillow 10.3.0 pypi_0 pypi pint 0.23 pypi_0 pypi pip 23.3.1 pypi_0 pypi pixman 0.43.2 h59595ed_0 conda-forge pkgutil-resolve-name 1.3.10 pypi_0 pypi platformdirs 4.2.1 pypi_0 pypi prometheus-client 0.20.0 pypi_0 pypi prometheus_client 0.20.0 pyhd8ed1ab_0 conda-forge prompt-toolkit 3.0.42 pypi_0 pypi psutil 5.9.8 pypi_0 pypi pthread-stubs 0.4 h36c2ea0_1001 conda-forge ptyprocess 0.7.0 pypi_0 pypi pure-eval 0.2.2 pypi_0 pypi pure_eval 0.2.2 pyhd8ed1ab_0 conda-forge py-cpuinfo 9.0.0 pypi_0 pypi pycairo 1.26.0 pypi_0 pypi pycparser 2.22 pypi_0 pypi pydantic 2.7.1 pypi_0 pypi pydantic-core 2.18.2 pypi_0 pypi pyedr 0.8.0 pypi_0 pypi pygments 2.17.2 pypi_0 pypi pymsmt 22.0 pypi_0 pypi pyparsing 3.1.2 pypi_0 pypi pysocks 1.7.1 pypi_0 pypi pytables 3.9.2 py311h3e8b7c9_2 conda-forge python 3.11.8 hab00c5b_0_cpython conda-forge python-constraint 1.4.0 pypi_0 pypi python-dateutil 2.9.0 pypi_0 pypi python-fastjsonschema 2.19.1 pyhd8ed1ab_0 conda-forge python-json-logger 2.0.7 pypi_0 pypi python-tzdata 2024.1 pyhd8ed1ab_0 conda-forge python_abi 3.11 4_cp311 conda-forge pytraj 2.0.6 pypi_0 pypi pytz 2024.1 pypi_0 pypi pyyaml 6.0.1 pypi_0 pypi pyzmq 26.0.2 pypi_0 pypi rdkit 2023.9.6 pypi_0 pypi readline 8.2 h5eee18b_0
referencing 0.34.0 pypi_0 pypi reportlab 4.1.0 pypi_0 pypi requests 2.31.0 pypi_0 pypi rfc3339-validator 0.1.4 pypi_0 pypi rfc3986-validator 0.1.1 pypi_0 pypi rlpycairo 0.2.0 pypi_0 pypi rpds-py 0.18.0 pypi_0 pypi sander 22.0 pypi_0 pypi scipy 1.13.0 pypi_0 pypi send2trash 1.8.3 pypi_0 pypi setuptools 68.2.2 pypi_0 pypi six 1.16.0 pypi_0 pypi smirnoff99frosst 0+unknown pypi_0 pypi snappy 1.2.0 hdb0a2a9_1 conda-forge sniffio 1.3.1 pypi_0 pypi soupsieve 2.5 pypi_0 pypi sqlalchemy 2.0.29 pypi_0 pypi sqlite 3.41.2 h5eee18b_0
stack-data 0.6.2 pypi_0 pypi stack_data 0.6.2 pyhd8ed1ab_0 conda-forge tables 3.9.2 pypi_0 pypi terminado 0.18.1 pypi_0 pypi tinycss2 1.3.0 pypi_0 pypi tk 8.6.13 noxft_h4845f30_101 conda-forge tomli 2.0.1 pypi_0 pypi tornado 6.4 pypi_0 pypi tqdm 4.66.2 pypi_0 pypi traitlets 5.14.3 pypi_0 pypi types-python-dateutil 2.9.0.20240316 pypi_0 pypi typing-extensions 4.11.0 pypi_0 pypi typing-utils 0.1.0 pypi_0 pypi typing_extensions 4.11.0 pyha770c72_0 conda-forge typing_utils 0.1.0 pyhd8ed1ab_0 conda-forge tzdata 2024.1 pypi_0 pypi uri-template 1.3.0 pypi_0 pypi urllib3 2.2.1 pypi_0 pypi wcwidth 0.2.13 pypi_0 pypi webcolors 1.13 pypi_0 pypi webencodings 0.5.1 pypi_0 pypi websocket-client 1.8.0 pypi_0 pypi wheel 0.41.2 pypi_0 pypi widgetsnbextension 4.0.10 pypi_0 pypi xmltodict 0.13.0 pypi_0 pypi xorg-kbproto 1.0.7 h7f98852_1002 conda-forge xorg-libice 1.1.1 hd590300_0 conda-forge xorg-libsm 1.2.4 h7391055_0 conda-forge xorg-libx11 1.8.9 h8ee46fc_0 conda-forge xorg-libxau 1.0.11 hd590300_0 conda-forge xorg-libxdmcp 1.1.3 h7f98852_0 conda-forge xorg-libxext 1.3.4 h0b41bf4_2 conda-forge xorg-libxrender 0.9.11 hd590300_0 conda-forge xorg-libxt 1.3.0 hd590300_1 conda-forge xorg-renderproto 0.11.1 h7f98852_1002 conda-forge xorg-xextproto 7.3.0 h0b41bf4_1003 conda-forge xorg-xproto 7.0.31 h7f98852_1007 conda-forge xz 5.4.6 h5eee18b_0
yaml 0.2.5 h7f98852_2 conda-forge zeromq 4.3.5 h59595ed_1 conda-forge zipp 3.17.0 pypi_0 pypi zlib 1.2.13 hd590300_5 conda-forge zlib-ng 2.0.7 h0b41bf4_0 conda-forge zstd 1.5.5 hfc55251_0 conda-forge


</details>
mattwthompson commented 5 months ago

This is either an interesting bug or a combination of a few happening at once. The error you're getting is from positions not being interpreted accurately. I actually get a different error running your code from a fresh environment:


---> 18 i3.to_gromacs("test")  # works fine
     20 # Does not work
     21 i1_upd = Interchange.parse_raw(i1.json())

File ~/software/openff-interchange/openff/interchange/components/interchange.py:449, in Interchange.to_gromacs(self, prefix, decimal, hydrogen_mass, _merge_atom_types)
    445 from openff.interchange.interop.gromacs.export._export import GROMACSWriter
    446 from openff.interchange.smirnoff._gromacs import _convert
    448 writer = GROMACSWriter(
--> 449     system=_convert(self, hydrogen_mass=hydrogen_mass),
    450     top_file=prefix + ".top",
    451     gro_file=prefix + ".gro",
    452 )
    454 writer.to_top(_merge_atom_types=_merge_atom_types)
    455 writer.to_gro(decimal=decimal)

File ~/software/openff-interchange/openff/interchange/smirnoff/_gromacs.py:131, in _convert(interchange, hydrogen_mass)
    127 key = TopologyKey(atom_indices=(topology_index,))
    128 vdw_parameters = vdw_collection.potentials[
    129     vdw_collection.key_map[key]
    130 ].parameters
--> 131 charge = electrostatics_collection.charges[key]
    133 # Build atom types
    134 system.atom_types[atom_type_name] = LennardJonesAtomType(
    135     name=_atom_atom_type_map[atom],
    136     bonding_type="",
   (...)
    142     epsilon=vdw_parameters["epsilon"].to(unit.kilojoule_per_mole),
    143 )

KeyError: TopologyKey with atom indices (12,)
mattwthompson commented 5 months ago

For my error, anyway, here's a hint (which is strongly reminiscent of https://github.com/openforcefield/openff-interchange/issues/935 that I think my computer must be stuck in a time machine ...):


In [9]: i1['Electrostatics'].charges
Out[9]:
{TopologyKey with atom indices (0,): -0.1301600026587645 <Unit('elementary_charge')>,
 TopologyKey with atom indices (1,): -0.1300999956826369 <Unit('elementary_charge')>,
 TopologyKey with atom indices (2,): -0.1300999956826369 <Unit('elementary_charge')>,
 TopologyKey with atom indices (3,): -0.1300999956826369 <Unit('elementary_charge')>,
 TopologyKey with atom indices (4,): -0.1300999956826369 <Unit('elementary_charge')>,
 TopologyKey with atom indices (5,): -0.1300999956826369 <Unit('elementary_charge')>,
 TopologyKey with atom indices (6,): 0.13010999684532484 <Unit('elementary_charge')>,
 TopologyKey with atom indices (7,): 0.13010999684532484 <Unit('elementary_charge')>,
 TopologyKey with atom indices (8,): 0.13010999684532484 <Unit('elementary_charge')>,
 TopologyKey with atom indices (9,): 0.13010999684532484 <Unit('elementary_charge')>,
 TopologyKey with atom indices (10,): 0.13010999684532484 <Unit('elementary_charge')>,
 TopologyKey with atom indices (11,): 0.13010999684532484 <Unit('elementary_charge')>}

In [10]: i2['Electrostatics'].charges
Out[10]:
{TopologyKey with atom indices (0,): -0.09263999895616011 <Unit('elementary_charge')>,
 TopologyKey with atom indices (1,): -0.08175999806685881 <Unit('elementary_charge')>,
 TopologyKey with atom indices (2,): -0.09263999895616011 <Unit('elementary_charge')>,
 TopologyKey with atom indices (3,): 0.03214000029997392 <Unit('elementary_charge')>,
 TopologyKey with atom indices (4,): 0.03214000029997392 <Unit('elementary_charge')>,
 TopologyKey with atom indices (5,): 0.03214000029997392 <Unit('elementary_charge')>,
 TopologyKey with atom indices (6,): 0.037099997089667755 <Unit('elementary_charge')>,
 TopologyKey with atom indices (7,): 0.037099997089667755 <Unit('elementary_charge')>,
 TopologyKey with atom indices (8,): 0.03214000029997392 <Unit('elementary_charge')>,
 TopologyKey with atom indices (9,): 0.03214000029997392 <Unit('elementary_charge')>,
 TopologyKey with atom indices (10,): 0.03214000029997392 <Unit('elementary_charge')>}

In [11]: i3['Electrostatics'].charges
Out[11]:
{TopologyKey with atom indices (0,): -0.1301600026587645 <Unit('elementary_charge')>,
 TopologyKey with atom indices (1,): -0.1300999956826369 <Unit('elementary_charge')>,
 TopologyKey with atom indices (2,): -0.1300999956826369 <Unit('elementary_charge')>,
 TopologyKey with atom indices (3,): -0.1300999956826369 <Unit('elementary_charge')>,
 TopologyKey with atom indices (4,): -0.1300999956826369 <Unit('elementary_charge')>,
 TopologyKey with atom indices (5,): -0.1300999956826369 <Unit('elementary_charge')>,
 TopologyKey with atom indices (6,): 0.13010999684532484 <Unit('elementary_charge')>,
 TopologyKey with atom indices (7,): 0.13010999684532484 <Unit('elementary_charge')>,
 TopologyKey with atom indices (8,): 0.13010999684532484 <Unit('elementary_charge')>,
 TopologyKey with atom indices (9,): 0.13010999684532484 <Unit('elementary_charge')>,
 TopologyKey with atom indices (10,): 0.13010999684532484 <Unit('elementary_charge')>,
 TopologyKey with atom indices (11,): 0.13010999684532484 <Unit('elementary_charge')>}
mattwthompson commented 5 months ago

Haha, this is the cause


In [6]: i1.topology.molecule(0).name
Out[6]: 'MOL0'

In [7]: i2.topology.molecule(0).name
Out[7]: 'MOL0'

In [8]: [molecule.name for molecule in i3.topology.molecules]
Out[8]: ['MOL0', 'MOL0']
pbuslaev commented 5 months ago

Yes, I was expecting smth like this. But was not able to detect it promtly

mattwthompson commented 4 months ago

Please re-open if this is still smelly - but I bet you're going to run into #978 first