Skip to content

Commit 37bacff

Browse files
committed
build_covariance_matrices in EntropyManager now includes force partitioning argument
1 parent fc8d607 commit 37bacff

2 files changed

Lines changed: 23 additions & 7 deletions

File tree

CodeEntropy/entropy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def execute(self):
118118
end,
119119
step,
120120
number_frames,
121+
self._args.force_partitioning,
121122
)
122123
)
123124

@@ -548,6 +549,7 @@ def _process_vibrational_entropy(
548549
"""
549550
# Find the relevant force and torque matrices and tidy them up
550551
# by removing rows and columns that are all zeros
552+
print(highest)
551553
force_matrix = self._level_manager.filter_zero_rows_columns(force_matrix)
552554

553555
torque_matrix = self._level_manager.filter_zero_rows_columns(torque_matrix)

CodeEntropy/levels.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def get_matrices(
8383
highest_level,
8484
force_matrix,
8585
torque_matrix,
86+
force_partitioning,
8687
):
8788
"""
8889
Compute and accumulate force/torque covariance matrices for a given level.
@@ -94,6 +95,8 @@ def get_matrices(
9495
highest_level (bool): Whether this is the top (largest bead size) level.
9596
force_matrix, torque_matrix (np.ndarray or None): Accumulated matrices to add
9697
to.
98+
force_partitioning (float): Factor to adjust force contributions,
99+
default is 0.5.
97100
98101
Returns:
99102
force_matrix (np.ndarray): Accumulated force covariance matrix.
@@ -119,10 +122,14 @@ def get_matrices(
119122

120123
# Sort out coordinates, forces, and torques for each atom in the bead
121124
weighted_forces[bead_index] = self.get_weighted_forces(
122-
data_container, list_of_beads[bead_index], trans_axes, highest_level
125+
data_container,
126+
list_of_beads[bead_index],
127+
trans_axes,
128+
highest_level,
129+
force_partitioning,
123130
)
124131
weighted_torques[bead_index] = self.get_weighted_torques(
125-
data_container, list_of_beads[bead_index], rot_axes
132+
data_container, list_of_beads[bead_index], rot_axes, force_partitioning
126133
)
127134

128135
# Create covariance submatrices
@@ -571,7 +578,7 @@ def get_sphCoord_axes(self, arg_r):
571578
return spherical_basis
572579

573580
def get_weighted_forces(
574-
self, data_container, bead, trans_axes, highest_level, force_partitioning=0.5
581+
self, data_container, bead, trans_axes, highest_level, force_partitioning
575582
):
576583
"""
577584
Function to calculate the mass weighted forces for a given bead.
@@ -620,9 +627,7 @@ def get_weighted_forces(
620627

621628
return weighted_force
622629

623-
def get_weighted_torques(
624-
self, data_container, bead, rot_axes, force_partitioning=0.5
625-
):
630+
def get_weighted_torques(self, data_container, bead, rot_axes, force_partitioning):
626631
"""
627632
Function to calculate the moment of inertia weighted torques for a given bead.
628633
@@ -747,6 +752,7 @@ def build_covariance_matrices(
747752
end,
748753
step,
749754
number_frames,
755+
force_partitioning,
750756
):
751757
"""
752758
Construct average force and torque covariance matrices for all molecules and
@@ -770,6 +776,9 @@ def build_covariance_matrices(
770776
Step size for frame iteration.
771777
number_frames : int
772778
Total number of frames to process.
779+
force_partitioning : float
780+
Factor to adjust force contributions, default is 0.5.
781+
773782
774783
Returns
775784
-------
@@ -855,6 +864,7 @@ def build_covariance_matrices(
855864
force_avg,
856865
torque_avg,
857866
frame_counts,
867+
force_partitioning,
858868
)
859869

860870
progress.advance(task)
@@ -873,6 +883,7 @@ def update_force_torque_matrices(
873883
force_avg,
874884
torque_avg,
875885
frame_counts,
886+
force_partitioning,
876887
):
877888
"""
878889
Update the running averages of force and torque covariance matrices
@@ -913,7 +924,8 @@ def update_force_torque_matrices(
913924
frame_counts : dict
914925
Dictionary holding the count of frames processed for each molecule/level
915926
combination.
916-
927+
force_partitioning : float
928+
Factor to adjust force contributions, default is 0.5.
917929
Returns
918930
-------
919931
None
@@ -946,6 +958,7 @@ def update_force_torque_matrices(
946958
highest,
947959
None if key not in force_avg["ua"] else force_avg["ua"][key],
948960
None if key not in torque_avg["ua"] else torque_avg["ua"][key],
961+
force_partitioning,
949962
)
950963

951964
if key not in force_avg["ua"]:
@@ -979,6 +992,7 @@ def update_force_torque_matrices(
979992
if torque_avg[key][group_id] is None
980993
else torque_avg[key][group_id]
981994
),
995+
force_partitioning,
982996
)
983997

984998
if force_avg[key][group_id] is None:

0 commit comments

Comments
 (0)