Skip to content

Commit

Permalink
Merge pull request #322 from frantropy/main
Browse files Browse the repository at this point in the history
make_mat user pairs
fixes #306
  • Loading branch information
carlocamilloni authored Jan 12, 2024
2 parents 2bd51fe + b614fd8 commit 76c806e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions tools/make_mat/make_mat.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ def c12_avg(values, weights, callback=allfunction):
if np.sum(w) == 0:
return 0
r = np.where(w > 0.0)
v = v[r[0][0]:v.size]
w = w[r[0][0]:w.size]
v = v[r[0][0] : v.size]
w = w[r[0][0] : w.size]

res = np.maximum(cutoff / 4.5, 0.1)
exp_aver = (1.0 / res) / np.log(np.sum(w * np.exp(1.0 / v / res)) / norm)
Expand Down Expand Up @@ -480,6 +480,14 @@ def calculate_intra_probabilities(args):
topology_df["c12"] = topology_df["mego_type"].map(d)

types = type_definitions.lj14_generator(topology_df)
# read user pairs
user_pairs = [(pair.atom1.name, pair.atom2.name, pair.type.epsilon * 4.184) for pair in topology_mego.adjusts]
user_pairs = [
(topology_df[topology_df["name"] == ai].index[0], topology_df[topology_df["name"] == aj].index[0], c12)
for ai, aj, c12 in user_pairs
]

# create Datarame with the pairs and the c12 values
c12_values = generate_c12_values(topology_df, types, type_definitions.atom_type_combinations)

# consider special cases
Expand All @@ -493,6 +501,13 @@ def calculate_intra_probabilities(args):
# define all cutoff
c12_cutoff = CUTOFF_FACTOR * np.power(np.where(oxygen_mask, 11.4 * c12_values, c12_values), 1.0 / 12.0)

# apply the user pairs (overwrite all other rules)
for ai, aj, c12 in user_pairs:
ai = int(ai)
aj = int(aj)
c12_cutoff[ai][aj] = CUTOFF_FACTOR * np.power(c12, 1.0 / 12.0)
c12_cutoff[aj][ai] = CUTOFF_FACTOR * np.power(c12, 1.0 / 12.0)

if np.any(c12_cutoff > args.cutoff):
warning_cutoff_histo(args.cutoff, np.max(c12_cutoff))

Expand Down

0 comments on commit 76c806e

Please sign in to comment.