Code Monkey home page Code Monkey logo

Comments (5)

mattwthompson avatar mattwthompson commented on July 3, 2024

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,)

from openff-interchange.

mattwthompson avatar mattwthompson commented on July 3, 2024

For my error, anyway, here's a hint (which is strongly reminiscent of #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')>}

from openff-interchange.

mattwthompson avatar mattwthompson commented on July 3, 2024

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']

from openff-interchange.

pbuslaev avatar pbuslaev commented on July 3, 2024

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

from openff-interchange.

mattwthompson avatar mattwthompson commented on July 3, 2024

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

from openff-interchange.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.