Skip to content

Commit 81d6721

Browse files
committed
changed moi to all atoms and residue custom principal axes to vanilla principal axes
1 parent b9f7fad commit 81d6721

1 file changed

Lines changed: 10 additions & 36 deletions

File tree

‎CodeEntropy/levels/axes.py‎

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,14 @@ def get_residue_axes(
8282
* Translational axes are principal axes of data_container.
8383
* Find edge heavy atom (i.e. heavy atoms bonded to neighbour residue).
8484
Compute rotation centre and axes as in get_terminal_axes.
85-
Compute custom MOI, using heavy atom positions and
86-
heavy atom + hydrogen masses.
85+
Compute custom MOI, using all atoms positions and masses.
8786
8887
- If bonded to at least two other residues:
8988
* Translational axes are principal axes of data_container.
9089
* Find edge heavy atoms (i.e. heavy atoms bonded to neighbour residues).
9190
Compute rotation centre and axes as in get_non_terminal_axes.
92-
Compute a custom MOI, using heavy atom positions and
93-
heavy atom + hydrogen masses.
91+
Compute custom MOI, using all atoms positions and masses.
92+
9493
9594
Args:
9695
data_container (MDAnalysis.Universe or AtomGroup):
@@ -134,19 +133,8 @@ def get_residue_axes(
134133
f"resindex {index_next})"
135134
)
136135

137-
uas = residue.select_atoms("mass 2 to 999")
138-
ua_masses = self.get_UA_masses(residue)
139-
140136
if len(edge_atom_set) == 0:
141-
moi_tensor = self.get_moment_of_inertia_tensor(
142-
center_of_mass=np.array(residue.center_of_mass()),
143-
positions=uas.positions,
144-
masses=ua_masses,
145-
dimensions=data_container.dimensions[:3],
146-
)
147-
rot_axes, moment_of_inertia = self.get_principal_axes_from_tensor(
148-
moi_tensor
149-
)
137+
rot_axes, moment_of_inertia = self.get_molecule_axes(residue)
150138
trans_axes = rot_axes # per original convention
151139
rot_center = np.array(residue.center_of_mass())
152140
else:
@@ -167,8 +155,8 @@ def get_residue_axes(
167155
)
168156
moment_of_inertia = self.get_custom_residue_moment_of_inertia(
169157
center_of_mass=rot_center,
170-
positions=uas.positions,
171-
masses=ua_masses,
158+
positions=residue.atoms.positions,
159+
masses=residue.atoms.masses,
172160
custom_rot_axes=rot_axes,
173161
dimensions=data_container.dimensions[:3],
174162
)
@@ -204,24 +192,10 @@ def get_residue_axes_from_topology(
204192
- center: Residue centre, shape ``(3,)``.
205193
- moment_of_inertia: Principal moments, shape ``(3,)``.
206194
"""
207-
dimensions = (
208-
np.asarray(box, dtype=float)
209-
if box is not None
210-
else np.asarray(u.dimensions[:3], dtype=float)
211-
)
212195
center = residue_atoms.center_of_mass(unwrap=True)
213196

214197
if not topology.has_neighbor_bonds:
215-
heavy_atoms = u.atoms[topology.residue_heavy_indices]
216-
moment_of_inertia_tensor = self.get_moment_of_inertia_tensor(
217-
center_of_mass=center,
218-
positions=heavy_atoms.positions,
219-
masses=topology.residue_ua_masses,
220-
dimensions=dimensions,
221-
)
222-
rot_axes, moment_of_inertia = self.get_principal_axes_from_tensor(
223-
moment_of_inertia_tensor
224-
)
198+
rot_axes, moment_of_inertia = self.get_molecule_axes(residue_atoms)
225199
trans_axes = rot_axes
226200
else:
227201
make_whole(mol.atoms)
@@ -277,7 +251,7 @@ def get_UA_axes(self, data_container, index: int, res_position):
277251

278252
index = int(index) # UA bead index
279253
heavy_atoms = data_container.select_atoms("mass 2 to 999")
280-
# use the same customPI trans axes as the residue level
254+
# use the same trans axes as the residue level
281255
if len(heavy_atoms) > 1:
282256
if len(data_container.residues) == 1:
283257
# only the one residue => use principal axes
@@ -921,8 +895,8 @@ def get_custom_residue_moment_of_inertia(
921895
922896
Args:
923897
center_of_mass: (3, ) COM for bead
924-
positions: (N,3) positions of the UAs in the bead
925-
masses: (N,) masses of the UAs in the bead
898+
positions: (N,3) positions of the atoms in the bead
899+
masses: (N,) masses of the atoms in the bead
926900
custom_rot_axes: (3,3) array of residue rotation axes
927901
dimensions: (3,) simulation_box_dimensions
928902

0 commit comments

Comments
 (0)