Skip to content

Commit 922b058

Browse files
committed
changed axes topology to be obtained when topology argument is used
1 parent 730c1fc commit 922b058

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

‎CodeEntropy/levels/nodes/axes_topology.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class BuildAxesTopologyNode:
8282
def run(self, shared_data: dict[str, Any]) -> dict[str, Any]:
8383
"""Build cached axes topology and write it into shared data.
8484
85-
The cache is only populated when ``args.customised_axes`` is true. When
85+
The cache is only populated when ``args.axes`` is equal to ``topology``. When
8686
customised axes are disabled, an empty cache is still written so later
8787
stages can read ``shared_data["axes_topology"]`` safely.
8888
@@ -97,7 +97,7 @@ def run(self, shared_data: dict[str, Any]) -> dict[str, Any]:
9797
args = shared_data["args"]
9898
topology = AxesTopology()
9999

100-
if not bool(getattr(args, "customised_axes", False)):
100+
if str(getattr(args, "axes", "topology")):
101101
shared_data["axes_topology"] = topology
102102
return {"axes_topology": topology}
103103

‎CodeEntropy/levels/nodes/covariance.py‎

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,6 @@ def _build_ua_vectors(
472472
"""
473473
force_vecs: list[np.ndarray] = []
474474
torque_vecs: list[np.ndarray] = []
475-
print(f"The axes are: {axes}")
476475
for ua_i, bead in enumerate(bead_groups):
477476
if res_position == -1:
478477
residue = residue_group.residues[0]
@@ -484,6 +483,7 @@ def _build_ua_vectors(
484483
ua_topology = None
485484
if axes == "topology":
486485
ua_topology = axes_topology.ua.get((mol_id, local_res_i, ua_i))
486+
print(f"The ua topology is: {ua_topology}")
487487
if ua_topology is not None:
488488
trans_axes, rot_axes, center, moi = (
489489
axes_manager.get_UA_axes_from_topology(
@@ -493,6 +493,7 @@ def _build_ua_vectors(
493493
box=box,
494494
)
495495
)
496+
print("We used the topology axes!")
496497
else:
497498
# custom local axes if no topology
498499
make_whole(residue_group)
@@ -508,8 +509,7 @@ def _build_ua_vectors(
508509
residue_group, ua_i, res_position
509510
)
510511

511-
else:
512-
print("principal axes? :(")
512+
elif axes == "principal":
513513
# principal axes
514514
make_whole(residue.atoms)
515515
make_whole(bead)
@@ -640,33 +640,36 @@ def _get_residue_axes(
640640
Returns:
641641
A tuple of translation axes, rotation axes, centre, and moments of inertia.
642642
"""
643-
if axes != "principal":
643+
if axes == "topology" or axes == "local":
644644
res = mol.residues[local_res_i]
645+
print(f"The axes topology is: {axes_topology}")
645646
residue_topology = None
646-
if axes == "topology":
647+
if axes == "topology" and axes_topology is not None:
648+
# can use the cached axes topology
647649
residue_topology = axes_topology.residue.get((mol_id, local_res_i))
648650

649651
if residue_topology is not None:
650652
return axes_manager.get_residue_axes_from_topology(
651653
u=u, mol=mol, residue_atoms=res.atoms, topology=residue_topology
652654
)
653-
655+
# no topology or local axes argument
654656
return axes_manager.get_residue_axes(
655657
mol, local_res_i, relative_res_i, residue=res.atoms
656658
)
657659

658660
make_whole(mol.atoms)
659661
make_whole(bead)
660662

661-
trans_axes = axes_manager.get_principal_axes_from_group(mol.atoms)
662-
rot_axes, moi = axes_manager.get_molecule_axes(bead)
663-
center = bead.center_of_mass(unwrap=True)
664-
return (
665-
np.asarray(trans_axes),
666-
np.asarray(rot_axes),
667-
np.asarray(center),
668-
np.asarray(moi),
669-
)
663+
if axes == "principal":
664+
trans_axes = axes_manager.get_principal_axes_from_group(mol.atoms)
665+
rot_axes, moi = axes_manager.get_molecule_axes(bead)
666+
center = bead.center_of_mass(unwrap=True)
667+
return (
668+
np.asarray(trans_axes),
669+
np.asarray(rot_axes),
670+
np.asarray(center),
671+
np.asarray(moi),
672+
)
670673

671674
def _get_polymer_axes(
672675
self,

0 commit comments

Comments
 (0)