Skip to content

Commit

Permalink
Merge branch 'main' of github.com:rinikerlab/reeds into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Candide Champion committed Sep 4, 2023
2 parents 99d600f + 208749a commit 5e79089
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 28 deletions.
8 changes: 6 additions & 2 deletions reeds/function_libs/input_prep/hybrid_topology_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,10 +912,14 @@ def find_14_neighbours(atomID, bonds, neigh12, neigh13):

# Now we need to remove any potential "false" 3rd neighbour
# which occur for cyclic systems.

to_remove = []
for neigh in neigh14:
if neigh in neigh13 or neigh in neigh12: neigh14.remove(neigh)
if neigh in neigh13 or neigh in neigh12:
to_remove.append(neigh)

for atom in to_remove:
neigh14.remove(atom)

return sorted(list(set(neigh14)))


Expand Down
62 changes: 36 additions & 26 deletions reeds/function_libs/visualization/sampling_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ def plot_stateOccurence_matrix(data: dict,
[np.array([data[replica]["max_contributing_state"][key] for key in sorted(data[replica]["max_contributing_state"])])
for replica in sorted(data)]).T

# Plot occurence:
# Plot occurrence:
##Title setting
title = "occurence sampling"
title = "occurrence sampling"
if title_suffix is not None:
title += title_suffix

Expand All @@ -295,14 +295,24 @@ def plot_stateOccurence_matrix(data: dict,

mappable = ax.matshow(occurrence_sampling_matrix, cmap="Blues")

## set ticks
## add title for axes
ax.set_title(title)

## set y-ticks, tick labels, label axis
ax.set_yticks(range(0, states_num))
ax.set_yticklabels(range(1, states_num + 1))

# nice s-value x-axis
ax.set_ylabel("states")

## set x-ticks, tick labels, label axis
ax.xaxis.set_ticks_position("bottom")
if (not s_values is None):
ax.set_xticks(np.arange(0, len(s_values) - 0.25))
ax.set_xticklabels(nice_s_vals(s_values), rotation=45)
if len(set(s_values)) == 1: # change labels to number of states if in step a
ax.set_xticklabels(range(1, states_num + 1))
ax.set_xlabel("simulation biased to")
else:
ax.set_xticklabels(nice_s_vals(s_values), rotation=45) # else add s-values as labels
ax.set_xlabel("s-values")

##set colorbar
cax = fig.add_axes([ax.get_position().x1 + 0.1, ax.get_position().y0, 0.02, ax.get_position().height])
Expand All @@ -314,36 +324,42 @@ def plot_stateOccurence_matrix(data: dict,
if (data[undersampling_ind]["undersampling"]):
break
ax.vlines(x=undersampling_ind - 1.5, ymin=-0.5, ymax=states_num - 0.5, color="red", lw=3, label="undersampling")

##labelling
ax.set_title(title)
ax.set_xlabel("s-values")
ax.set_ylabel("states")
ax.xaxis.set_ticks_position("bottom")


#fig.tight_layout()

if (not out_dir is None):
fig.savefig(out_dir + '/sampling_undersample_matrix.png', bbox_inches='tight')
plt.close()


# Plot MaxContrib:
##Title setting
title = "maxContrib Sampling"
if title_suffix is not None:
title += title_suffix

fig = plt.figure(figsize=ps.figsize_doubleColumn)
ax = fig.add_subplot(111)

mappable = ax.matshow(maxcontrib_sampling_matrix, cmap="Reds")

## set ticks

## add title for axes
ax.set_title(title)

## set y-ticks, tick labels, label axis
ax.set_yticks(range(0, states_num))
ax.set_yticklabels(range(1, states_num + 1))

ax.set_ylabel("states")

## set x-ticks, tick labels, label axis
ax.xaxis.set_ticks_position("bottom")
if (not s_values is None):
ax.set_xticks(range(0, len(s_values)))
ax.set_xticklabels(nice_s_vals(s_values), rotation=45)
if len(set(s_values)) == 1: # change labels to number of states if in step a
ax.set_xticklabels(range(1, states_num + 1))
ax.set_xlabel("simulation biased to")
else:
ax.set_xticklabels(nice_s_vals(s_values), rotation=45)
ax.set_xlabel("s-values")

##set colorbar
cax = fig.add_axes([ax.get_position().x1 + 0.1, ax.get_position().y0, 0.02, ax.get_position().height])
Expand All @@ -356,14 +372,8 @@ def plot_stateOccurence_matrix(data: dict,
break
ax.vlines(x=undersampling_ind - 1.5, ymin=-0.5, ymax=states_num - 0.5, color="k", lw=3, label="undersampling")

##labelling
ax.set_title(title)
ax.set_xlabel("s-values")
ax.set_ylabel("states")
ax.xaxis.set_ticks_position("bottom")

#fig.tight_layout()

if (not out_dir is None):
fig.savefig(out_dir + '/sampling_minstate_matrix.png', bbox_inches='tight')
fig.savefig(out_dir + '/sampling_maxContrib_matrix.png', bbox_inches='tight')
plt.close()

0 comments on commit 5e79089

Please sign in to comment.