Skip to content

Commit ce77cef

Browse files
committed
feat(wE): update Sorient dict and include parallel as an arg
1 parent 49bfa69 commit ce77cef

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

‎CodeEntropy/config/argparse.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ class ArgSpec:
133133
default=True,
134134
help="If set to False, disables the calculation of water entropy",
135135
),
136+
"water_entropy_parallel": ArgSpec(
137+
type=bool,
138+
default=True,
139+
help="If set to False, disables the parallel calculation of water entropy and switches to serial",
140+
),
136141
"grouping": ArgSpec(
137142
type=str,
138143
default="molecules",

‎CodeEntropy/entropy/water.py‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class WaterEntropyInput:
3535
end: int
3636
step: int
3737
temperature: float
38+
parallel: bool
3839
group_id: int | None = None
3940

4041

@@ -53,7 +54,7 @@ def __init__(
5354
self,
5455
args: Any,
5556
reporter: Any,
56-
solver: Callable[..., tuple[dict, Any, Any, Any, Any]] = (
57+
solver: Callable[..., tuple[dict, Any, Any, Any, Any, Any]] = (
5758
GetSolvent.get_interfacial_water_orient_entropy
5859
),
5960
) -> None:
@@ -77,6 +78,7 @@ def calculate_and_log(
7778
start: int,
7879
end: int,
7980
step: int,
81+
parallel: bool,
8082
group_id: int | None = None,
8183
) -> None:
8284
"""Compute water entropy and write results to the data logger.
@@ -95,6 +97,7 @@ def calculate_and_log(
9597
step=step,
9698
temperature=float(self._args.temperature),
9799
group_id=group_id,
100+
parallel=parallel,
98101
)
99102
self._calculate_and_log_from_inputs(inputs)
100103

@@ -119,18 +122,19 @@ def _run_solver(self, inputs: WaterEntropyInput):
119122
Tuple of solver outputs.
120123
"""
121124
logger.info(
122-
"[WaterEntropy] Computing water entropy (start=%s, end=%s, step=%s)",
125+
"[WaterEntropy] Computing water entropy (start=%s, end=%s, step=%s, parallel=%s)",
123126
inputs.start,
124127
inputs.end,
125128
inputs.step,
129+
inputs.parallel,
126130
)
127131
return self._solver(
128132
inputs.universe,
129133
inputs.start,
130134
inputs.end,
131135
inputs.step,
132136
inputs.temperature,
133-
parallel=True,
137+
inputs.parallel,
134138
)
135139

136140
def _log_orientational_entropy(
@@ -144,8 +148,9 @@ def _log_orientational_entropy(
144148
"""
145149
for _resid, resname_dict in Sorient_dict.items():
146150
for resname, values in resname_dict.items():
147-
if isinstance(values, list) and len(values) == 2:
148-
entropy, count = values
151+
if isinstance(values, dict):
152+
entropy = values["Sorient_Nw_ave"]
153+
count = values["tot_count"]
149154
self._reporter.add_residue_data(
150155
group_id, resname, "Water", "Orientational", count, entropy
151156
)

‎CodeEntropy/entropy/workflow.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ def _compute_water_entropy(
394394
start=start,
395395
end=end,
396396
step=step,
397+
parallel=self._args.water_entropy_parallel,
397398
group_id=group_id,
398399
)
399400

0 commit comments

Comments
 (0)