refactor: restructure dice environment handling and update Python version requirement
This commit is contained in:
@@ -2,7 +2,6 @@ from __future__ import annotations
|
||||
|
||||
from diceplayer.environment import Atom
|
||||
from diceplayer.logger import logger
|
||||
from diceplayer.utils.cache import invalidate_computed_properties
|
||||
from diceplayer.utils.misc import BOHR2ANG, EA_2_DEBYE
|
||||
from diceplayer.utils.ptable import GHOST_NUMBER
|
||||
|
||||
@@ -15,7 +14,6 @@ from typing_extensions import List, Self, Tuple
|
||||
import math
|
||||
from copy import deepcopy
|
||||
from dataclasses import field
|
||||
from functools import cached_property
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -34,11 +32,11 @@ class Molecule:
|
||||
molname: str
|
||||
atom: List[Atom] = field(default_factory=list)
|
||||
|
||||
@cached_property
|
||||
@property
|
||||
def total_mass(self) -> float:
|
||||
return sum(atom.mass for atom in self.atom)
|
||||
|
||||
@cached_property
|
||||
@property
|
||||
def com(self) -> npt.NDArray[np.float64]:
|
||||
com = np.zeros(3)
|
||||
|
||||
@@ -49,7 +47,7 @@ class Molecule:
|
||||
|
||||
return com
|
||||
|
||||
@cached_property
|
||||
@property
|
||||
def inertia_tensor(self) -> npt.NDArray[np.float64]:
|
||||
"""
|
||||
Calculates the inertia tensor of the molecule.
|
||||
@@ -79,7 +77,6 @@ class Molecule:
|
||||
|
||||
return inertia_tensor
|
||||
|
||||
@invalidate_computed_properties()
|
||||
def add_atom(self, a: Atom) -> None:
|
||||
"""
|
||||
Adds Atom instance to the molecule.
|
||||
@@ -90,7 +87,6 @@ class Molecule:
|
||||
|
||||
self.atom.append(a)
|
||||
|
||||
@invalidate_computed_properties()
|
||||
def remove_atom(self, a: Atom) -> None:
|
||||
"""
|
||||
Removes Atom instance from the molecule.
|
||||
@@ -101,7 +97,6 @@ class Molecule:
|
||||
|
||||
self.atom.remove(a)
|
||||
|
||||
@invalidate_computed_properties()
|
||||
def move_center_of_mass_to_origin(self) -> None:
|
||||
"""
|
||||
Updated positions based on the center of mass of the molecule
|
||||
@@ -111,7 +106,6 @@ class Molecule:
|
||||
atom.ry -= self.com[1]
|
||||
atom.rz -= self.com[2]
|
||||
|
||||
@invalidate_computed_properties()
|
||||
def rotate_to_standard_orientation(self) -> None:
|
||||
"""
|
||||
Rotates the molecule to the standard orientation
|
||||
@@ -315,3 +309,12 @@ class Molecule:
|
||||
diff = coords_a[:, None, :] - coords_b[None, :, :]
|
||||
d2 = np.sum(diff**2, axis=-1)
|
||||
return np.sqrt(d2.min())
|
||||
|
||||
def signature(self) -> List[int]:
|
||||
"""
|
||||
Returns the signature of the molecule, which is a list of the number of atoms of each type in the molecule.
|
||||
|
||||
Returns:
|
||||
List[int]: signature of the molecule
|
||||
"""
|
||||
return [a.lbl for a in self.atom]
|
||||
|
||||
Reference in New Issue
Block a user