@@ -736,35 +736,28 @@ def vacuum_free_energy_difference_overlap(self):
736
736
737
737
def plot_free_energy_overlap (self , env : str ):
738
738
plt .figure (figsize = [8 , 8 ], dpi = 300 )
739
- if env == "vacuum" :
740
- ax = sns .heatmap (
741
- self .vacuum_free_energy_difference_overlap ,
742
- cmap = "Blues" ,
743
- linewidth = 0.5 ,
744
- annot = True ,
745
- fmt = "0.2f" ,
746
- annot_kws = {"size" : "small" },
747
- )
748
- elif env == "waterbox" :
749
- ax = sns .heatmap (
750
- self .waterbox_free_energy_difference_overlap ,
751
- cmap = "Blues" ,
752
- linewidth = 0.5 ,
753
- annot = True ,
754
- fmt = "0.2f" ,
755
- annot_kws = {"size" : "small" },
756
- )
757
- elif env == "complex" :
758
- ax = sns .heatmap (
759
- self .complex_free_energy_difference_overlap ,
760
- cmap = "Blues" ,
761
- linewidth = 0.5 ,
762
- annot = True ,
763
- fmt = "0.2f" ,
764
- annot_kws = {"size" : "small" },
765
- )
766
- else :
767
- raise RuntimeError ()
739
+
740
+ overlap_matrix = self .free_energy_overlap (env )
741
+ ax = sns .heatmap (
742
+ overlap_matrix ,
743
+ cmap = "Reds" ,
744
+ cbar = False ,
745
+ linewidth = 0.5 ,
746
+ annot = True ,
747
+ fmt = "0.2f" ,
748
+ annot_kws = {"size" : "small" },
749
+ )
750
+
751
+ ax = sns .heatmap (
752
+ overlap_matrix ,
753
+ mask = overlap_matrix < 0.009 ,
754
+ cmap = "Blues" ,
755
+ linewidth = 0.5 ,
756
+ annot = True ,
757
+ fmt = "0.2f" ,
758
+ annot_kws = {"size" : "small" },
759
+ )
760
+
768
761
plt .title (f"Overlap of lambda states for ligand in { env } " , fontsize = 15 )
769
762
plt .xlabel ("lambda state (0 to 1)" , fontsize = 15 )
770
763
plt .ylabel ("lambda state (0 to 1)" , fontsize = 15 )
@@ -864,15 +857,36 @@ def show_summary(self):
864
857
self .plot_waterbox_free_energy_overlap ()
865
858
self .plot_vacuum_free_energy ()
866
859
self .plot_waterbox_free_energy ()
860
+ self .detailed_overlap ("waterbox" )
861
+ self .detailed_overlap ("vacuum" )
867
862
else :
868
863
if isnotebook :
869
864
# only show this if we are in a notebook
870
865
self .plot_complex_free_energy_overlap ()
871
866
self .plot_waterbox_free_energy_overlap ()
872
867
self .plot_complex_free_energy ()
873
868
self .plot_waterbox_free_energy ()
869
+ self .detailed_overlap ("complex" )
870
+ self .detailed_overlap ("waterbox" )
874
871
875
872
energy_estimate , uncertainty = self .end_state_free_energy_difference
876
873
print (
877
874
f"Free energy to common core: { energy_estimate } [kT] with uncertainty: { uncertainty } [kT]."
878
875
)
876
+
877
+
878
+ def detailed_overlap (self , env ):
879
+
880
+ mbar_matrix = self .free_energy_overlap (env = env )
881
+ upper = np .diagonal (mbar_matrix , offset = 1 )
882
+ lower = np .diagonal (mbar_matrix , offset = - 1 )
883
+ av_upper = sum (upper / (len (mbar_matrix )- 1 ))
884
+ av_lower = sum (lower / (len (mbar_matrix )- 1 ))
885
+
886
+ print (f"The average overlap in { env } between the states is { round (av_upper ,3 )} and { round (av_lower ,3 )} " )
887
+
888
+ all = np .concatenate ((upper ,lower ))
889
+ for state , i in enumerate (all ):
890
+ if i < 0.01 :
891
+ print (f" WARNINING: In state { state } , the overlap is { round (i ,3 )} " )
892
+
0 commit comments