From 6b99ed67ff451d5ed3f9343bce4f79c945f975a4 Mon Sep 17 00:00:00 2001 From: Sebastian Kloth Date: Sat, 10 Feb 2024 13:48:58 +0100 Subject: [PATCH] Updated free_energy_landscape.py to reflect code changes in mdevaluate --- examples/free_energy_landscape.py | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/examples/free_energy_landscape.py b/examples/free_energy_landscape.py index 994cc68..6b162e1 100644 --- a/examples/free_energy_landscape.py +++ b/examples/free_energy_landscape.py @@ -1,3 +1,4 @@ +#%% import numpy as np import mdevaluate as md @@ -13,14 +14,32 @@ trajectory = md.open(path_to_sim, topology="run.tpr", trajectory="out/traj_full. OW = trajectory.subset(atom_name="OW") -box = np.diag(trajectory[0].box) -box_voxels = (box // [0.05, 0.05, 0.05] + [1, 1, 1]) * [0.05, 0.05, 0.05] -occupation_matrix = fel.occupation_matrix(OW, skip=0, segments=len(OW)) -maxima_matrix = fel.find_maxima(occupation_matrix, box=box_voxels, edge_length=0.05) +box = trajectory[0].box +box_voxels = (np.diag(box) // [0.05, 0.05, 0.05] + [1, 1, 1]) * [0.05, 0.05, 0.05] +occupation_matrix = fel.occupation_matrix(OW, skip=0, segments=1000) +radius_maxima = 0.05 * 3 ** (1 / 2) + 0.05 / 100 +maxima_matrix = fel.find_maxima( + occupation_matrix, + box=box_voxels, + radius=radius_maxima, + pore_geometry="cylindrical" +) maxima_matrix = fel.add_distances(maxima_matrix, "cylindrical", box / 2) -r_bins = np.arange(0, 2, 0.02) +r_bins = np.arange(0, 1, 0.02) distance_bins = np.arange(0.05, 1.55, 0.1) energy_df = fel.distance_resolved_energies( - maxima_matrix, distance_bins, r_bins, box, 225 + maxima_matrix, distance_bins, r_bins, box, "cylindrical", 225 ) result = fel.find_energy_maxima(energy_df, r_min=0.05, r_max=0.15) + + +#%% +print(sum(maxima_matrix["maxima"] == True)) + +#%% +energy_df = fel.distance_resolved_energies( + maxima_matrix, distance_bins, r_bins, box, temperature=250 +) + +# %% +print(energy_df)