Skip to content

Commit

Permalink
Update model example plotting scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mcbal committed Oct 12, 2021
1 parent b15d6f8 commit 99bec96
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions examples/model_beta_sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,26 @@ def simple_update(frame, fig, axs):

axs[0].clear()
axs[0].set_title(
f"beta = {frame:.4f}, t = {t_star:.4f}, afe = {afe_star:.4f}")
f"$\\beta$ = {frame:.4f}, t = {t_star:.4f}, afe = {afe_star:.4f}")
axs[0].plot(t_range.numpy().squeeze(), filter_array(phis), 'r-')
axs[0].axvline(x=out.t_star[0].detach().numpy())
axs[0].set_ylim([-plot_values_cutoff, plot_values_cutoff])
axs[0].set_ylabel("phi(t)")
axs[0].set_ylabel("$\\varphi$(t)")

axs[1].clear()
axs[1].plot(t_range.numpy().squeeze(), filter_array(grad_phis), 'r-')
axs[1].axvline(x=out.t_star[0].detach().numpy())
axs[1].axhline(y=0.0)
axs[1].set_ylim([-plot_values_cutoff, 100])
axs[1].set_ylabel("phi'(t)")
axs[1].set_ylabel("$\\varphi$'(t)")

axs[2].clear()
axs[2].plot(t_range.numpy().squeeze(), filter_array(grad_grad_phis, 2*plot_values_cutoff), 'r-')
axs[2].axvline(x=out.t_star[0].detach().numpy())
axs[2].set_xlim([t_min, t_max])
axs[2].set_xlabel('t')
axs[2].set_ylim([0, 2*plot_values_cutoff])
axs[2].set_ylabel("phi''(t)")
axs[2].set_ylabel("$\\varphi$''(t)")

fig.align_ylabels(axs)

Expand Down
14 changes: 7 additions & 7 deletions examples/model_fwd_bwd.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
# Run backward on sum of free energies across batch dimension.
out.afe.sum().backward()

#########################################################################################
# Plot internally-used function `phi(t)` and its derivatives for first element in batch. #
#########################################################################################
###############################################################
# Plot internally-used function `phi(t)` and its derivatives. #
###############################################################

if x.size(0) == 1 and t0.numel() == 1:

Expand All @@ -56,10 +56,10 @@ def filter_array(a, threshold=250):
fig, axs = plt.subplots(3, 1, sharex=True)

axs[0].set_title(
f"Found root of phi'(t) at t = {t_star:.4f} (afe = {afe_star:.4f})")
f"Found root of $\\varphi$'(t) at t = {t_star:.4f} (afe = {afe_star:.4f})")
axs[0].plot(t_range.numpy().squeeze(), filter_array(phis), 'r-')
axs[0].axvline(x=out.t_star[0].detach().numpy())
axs[0].set_ylabel("phi(t)")
axs[0].set_ylabel("$\\varphi$(t)")

axs[1].plot(t_range.numpy().squeeze(), filter_array(grad_phis), 'r-')
axs[1].axvline(x=out.t_star[0].detach().numpy())
Expand All @@ -74,13 +74,13 @@ def filter_array(a, threshold=250):
axs1_inset.set_xticklabels('')
axs1_inset.set_yticklabels('')
axs[1].indicate_inset_zoom(axs1_inset, edgecolor="black")
axs[1].set_ylabel("phi'(t)")
axs[1].set_ylabel("$\\varphi$'(t)")

axs[2].plot(t_range.numpy().squeeze(), filter_array(grad_grad_phis), 'r-')
axs[2].axvline(x=out.t_star[0].detach().numpy())
axs[2].set_xlim([t_min, t_max])
axs[2].set_xlabel('t')
axs[2].set_ylabel("phi''(t)")
axs[2].set_ylabel("$\\varphi$''(t)")

fig.align_ylabels(axs)
# plt.savefig('plot.png', bbox_inches='tight')
Expand Down
2 changes: 1 addition & 1 deletion examples/model_two_spins.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from afem.models import VectorSpinModel

num_spins, dim = 2, 64
plot_3d = False

# Setup vector-spin model.
model = VectorSpinModel(
Expand Down Expand Up @@ -56,4 +55,5 @@ def filter_array(a, threshold=50):
ax.set_xlabel('$t_0$')
ax.set_ylabel('$t_1$')
plt.colorbar(artist)
# plt.savefig('plot.png', bbox_inches='tight')
plt.show()

0 comments on commit 99bec96

Please sign in to comment.