Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always read topology types from GSD file. #1729

Merged
merged 1 commit into from Feb 29, 2024
Merged

Conversation

joaander
Copy link
Member

@joaander joaander commented Feb 29, 2024

Description

Read topology types from GSD files, even when there are no groups in that topology entry.

Motivation and context

The type names in the GSD file should be preserved.

Resolves #1722

How has this been tested?

This test script passes:

import hoomd
import gsd.hoomd

L = 5
frame = gsd.hoomd.Frame()
frame.particles.N = 1
frame.particles.position = [0, 0, 0]
frame.particles.typeid = [0]
frame.configuration.box = [L, L, L, 0, 0, 0]
frame.particles.types = ['A']

frame.bonds.types = ['A-A']
frame.dihedrals.types = ['dihedralA']
frame.impropers.types = ['improperA']
frame.angles.types = ['anglesA']
frame.pairs.types = ['pairA']

with gsd.hoomd.open(name='init.gsd', mode='w') as f:
    f.append(frame)

sim = hoomd.Simulation(device=hoomd.device.CPU(), seed=1)

sim.create_state_from_gsd(filename='init.gsd')

print(sim.state.bond_types)
print(sim.state.angle_types)
print(sim.state.dihedral_types)
print(sim.state.improper_types)
print(sim.state.special_pair_types)

Change log

Fixed:

* ``create_state_from_gsd`` reads bond/angle/dihedral/improper/pair types when there are no
  corresponding groups (`#1694 <https://github.com/glotzerlab/hoomd-blue/pull/1694>`__).

Checklist:

@joaander joaander requested review from a team as code owners February 29, 2024 13:31
@joaander joaander requested review from SchoeniPhlippsn, tommy-waltmann and AlainKadar and removed request for a team February 29, 2024 13:31
@joaander joaander added the validate Execute long running validation tests on pull requests label Feb 29, 2024
@joaander joaander merged commit da678fe into trunk-patch Feb 29, 2024
45 of 57 checks passed
@joaander joaander deleted the fix-topology-types branch February 29, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validate Execute long running validation tests on pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create_state_from_gsd doesn't read bond types when there are no bonds in the system
3 participants