From d91f79749590bb721d3e4c6def8044dce84f5039 Mon Sep 17 00:00:00 2001 From: Sebastian Kloth Date: Sat, 27 Jan 2024 14:49:58 +0100 Subject: [PATCH] Started example for free energy landscape calculations --- examples/free_energy_landscape.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 examples/free_energy_landscape.py diff --git a/examples/free_energy_landscape.py b/examples/free_energy_landscape.py new file mode 100644 index 0000000..994cc68 --- /dev/null +++ b/examples/free_energy_landscape.py @@ -0,0 +1,26 @@ +import numpy as np + +import mdevaluate as md +import mdevaluate.extra.free_energy_landscape as fel + + +data_dir = "/data/skloth/python_packages/mdevaluate_examples/plots" +path_to_sim = ( + "/data/skloth/sim/silica_pore/tip4p2005/D3_L6_S4.9_R0/T300_isochor/T250_nvt_long" +) +trajectory = md.open(path_to_sim, topology="run.tpr", trajectory="out/traj_full.xtc") + + +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) +maxima_matrix = fel.add_distances(maxima_matrix, "cylindrical", box / 2) +r_bins = np.arange(0, 2, 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 +) +result = fel.find_energy_maxima(energy_df, r_min=0.05, r_max=0.15)