Skip to content

Commit c01e785

Browse files
committed
update levels/level_manager.py to coordinate the DAG approach
1 parent 6ceb4a0 commit c01e785

1 file changed

Lines changed: 51 additions & 15 deletions

File tree

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,62 @@
11
import logging
2+
from typing import Any, Dict
3+
4+
from CodeEntropy.levels.hierarchy_graph import HierarchyGraph
25

36
logger = logging.getLogger(__name__)
47

58

69
class LevelManager:
710
"""
8-
Manages the structural and dynamic levels involved in entropy calculations. This
9-
includes selecting relevant levels, computing axes for translation and rotation,
10-
and handling bead-based representations of molecular systems. Provides utility
11-
methods to extract averaged positions, convert coordinates to spherical systems,
12-
compute weighted forces and torques, and manipulate matrices used in entropy
13-
analysis.
11+
Coordinates the DAG-based computation of molecular levels and beads.
12+
All physics/maths are delegated to lower-level classes and DAG nodes.
1413
"""
1514

16-
def __init__(self):
15+
def __init__(self, universe, run_manager, args):
16+
"""
17+
Parameters
18+
----------
19+
universe : MDAnalysis.Universe
20+
The MD system being analysed.
21+
run_manager : RunManager
22+
Provides selection helpers and unit conversions.
23+
args : Namespace
24+
Parsed CLI arguments.
25+
"""
26+
self.universe = universe
27+
self.run_manager = run_manager
28+
self.args = args
29+
30+
def run_hierarchy(self) -> Dict[str, Any]:
31+
"""
32+
Execute the structural hierarchy DAG (levels → beads).
33+
34+
Returns
35+
-------
36+
dict
37+
Contains:
38+
- number_molecules
39+
- levels
40+
- beads_by_mol_level
41+
"""
42+
43+
shared_data = {
44+
"universe": self.universe,
45+
"args": self.args,
46+
"run_manager": self.run_manager,
47+
}
48+
49+
graph = HierarchyGraph().build(self.run_manager)
50+
results = graph.execute(shared_data)
51+
52+
logger.debug("[LevelManager] Hierarchy DAG results:")
53+
logger.debug(results)
54+
55+
return results
56+
57+
def run(self):
1758
"""
18-
Initializes the LevelManager with placeholders for level-related data,
19-
including translational and rotational axes, number of beads, and a
20-
general-purpose data container.
59+
Placeholder: eventually will run all DAGs (hierarchy, matrices, entropy).
60+
For now, only run the hierarchy graph.
2161
"""
22-
self.data_container = None
23-
self._levels = None
24-
self._trans_axes = None
25-
self._rot_axes = None
26-
self._number_of_beads = None
62+
return self.run_hierarchy()

0 commit comments

Comments
 (0)