From bbb65c3eacdc2177fe834225aca7d84aee739c02 Mon Sep 17 00:00:00 2001 From: chrisjonesBSU Date: Tue, 17 Sep 2024 14:06:15 -0600 Subject: [PATCH] move rigid_id property to abstract_site from atom, write out rigid_id in to_mbuild --- gmso/abc/abstract_site.py | 11 +++++++++++ gmso/core/atom.py | 11 ----------- gmso/external/convert_mbuild.py | 1 + 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/gmso/abc/abstract_site.py b/gmso/abc/abstract_site.py index 399a2b6d..abbc6862 100644 --- a/gmso/abc/abstract_site.py +++ b/gmso/abc/abstract_site.py @@ -209,6 +209,12 @@ class Site(GMSOBase): alias="position", ) + rigid_id_: Optional[int] = Field( + None, + description="Rigid body ID used to assign rigid body contraints in HOOMD-Blue topologies.", + alias="rigid_id", + ) + model_config = ConfigDict( alias_to_fields={ "name": "name_", @@ -250,6 +256,11 @@ def residue(self): """Return the residue assigned to the site.""" return self.__dict__.get("residue_") + @property + def rigid_id(self): + """Return the rigid body ID for this atom.""" + return self.__dict__.get("rigid_id_") + @field_serializer("position_") def serialize_position(self, position_: PositionType): return unyt_to_dict(position_) diff --git a/gmso/core/atom.py b/gmso/core/atom.py index 46d4e559..dfdcc2de 100644 --- a/gmso/core/atom.py +++ b/gmso/core/atom.py @@ -73,12 +73,6 @@ class Atom(Site): alias="restraint", ) - rigid_id_: Optional[int] = Field( - None, - description="Rigid body ID used to assign rigid body contraints in HOOMD-Blue topologies.", - alias="rigid_id", - ) - model_config = ConfigDict( alias_to_fields=dict( **Site.model_config["alias_to_fields"], @@ -131,11 +125,6 @@ def restraint(self): """Return the restraint of this atom.""" return self.__dict__.get("restraint_") - @property - def rigid_id(self): - """Return the rigid body ID for this atom.""" - return self.__dict__.get("rigid_id_") - @field_serializer("charge_") def serialize_charge(self, charge_: Union[u.unyt_quantity, None]): if charge_ is None: diff --git a/gmso/external/convert_mbuild.py b/gmso/external/convert_mbuild.py index fc6323a9..c8ca1e50 100644 --- a/gmso/external/convert_mbuild.py +++ b/gmso/external/convert_mbuild.py @@ -251,6 +251,7 @@ def _parse_particle(particle_map, site): charge=charge, mass=mass, ) + particle.rigid_id = site.rigid_id particle_map[site] = particle return particle