Skip to content

NaN charges in long-chain ITP when short reference chain has only 2 repeat units (mid_atoms empty) #9

Description

@Romarin87

Hi PEMD team, thank you for this excellent project.

I found a reproducible issue in polymer OPLS-AA generation with LigParGen-based charges.

I used:

  • homopolymer workflow
  • ff_source="ligpargen"
  • short reference chain length = 2 repeat units
  • long chain length = 71 repeat units
  • neutral polymer (charge=0)

Observed behavior:

  1. The short-chain LigParGen charge table is valid (no NaN).
  2. During charge transfer from short chain to long chain, most interior atoms in the long chain do not receive charges.
  3. The final bonded ITP contains many nan charges.
  4. GROMACS then fails at EM step 0 with:
    • System total charge: nan
    • total potential energy is nan

From code reading, this seems related to the logic that defines middle repeat units as:

  • mid_atoms = best_matches[1:-1]
    When there are only 2 repeat-unit matches, mid_atoms is empty, mid_mol becomes None, and interior assignment is skipped.

Question:
What is the intended behavior for short reference chains of length 1–2?

  • Should users be required to set short chain length >= 3 (with explicit validation/error)?
  • Or should there be a fallback rule to generate interior charges when mid_atoms is empty (e.g., average the two matched units)?

Happy to submit a PR once you confirm the preferred behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions