Started example for free energy landscape calculations

This commit is contained in:
Sebastian Kloth 2024-01-27 14:49:58 +01:00
parent 5fab24877d
commit d91f797495

View File

@ -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)