mdevaluate_examples/examples/selector.py

44 lines
1.3 KiB
Python
Raw Normal View History

2024-01-19 16:12:39 +00:00
from functools import partial
import matplotlib.pyplot as plt
from matplotlib import cm
import mdevaluate as md
data_dir = "/data/skloth/python_packages/mdevaluate_examples/plots"
2024-01-20 11:52:30 +00:00
path_to_sim = (
"/data/skloth/sim/silica_pore/tip4p2005/D3_L6_S4.9_R0/T300_isochor/T250_nvt_short"
)
2024-01-19 16:12:39 +00:00
trajectory = md.open(path_to_sim, topology="run.tpr", trajectory="out/traj_full.xtc")
oxygen_water = trajectory.subset(atom_name="OW", residue_name="SOL")
time, result_all = md.correlation.shifted_correlation(
2024-01-20 11:52:30 +00:00
partial(md.correlation.isf, q=22.7), oxygen_water, segments=100, skip=0.1
)
time, result_wall = md.correlation.shifted_correlation(
2024-01-19 16:12:39 +00:00
partial(md.correlation.isf, q=22.7),
oxygen_water,
2024-01-20 11:52:30 +00:00
selector=partial(md.coordinates.selector_radial_cylindrical, r_min=1.0, r_max=1.5),
segments=100,
skip=0.1,
)
time, result_center = md.correlation.shifted_correlation(
partial(md.correlation.isf, q=22.7),
oxygen_water,
selector=partial(md.coordinates.selector_radial_cylindrical, r_min=0.0, r_max=0.5),
segments=100,
skip=0.1,
)
2024-01-19 16:12:39 +00:00
plt.figure()
2024-01-20 11:52:30 +00:00
plt.plot(time, result_all, "k-", label="all")
plt.plot(time, result_wall, "r.", label="wall")
plt.plot(time, result_center, "b.", label="center")
plt.legend()
2024-01-19 16:12:39 +00:00
plt.xscale("log")
2024-01-20 11:52:30 +00:00
plt.xlabel(r"$t$ / ps")
plt.ylabel(r"S_q(t)")
2024-01-19 16:12:39 +00:00
plt.savefig(f"{data_dir}/selector.png", dpi=300, bbox_inches="tight")
2024-01-20 11:52:30 +00:00
plt.show()