2023-12-06 09:55:55 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
import mdevaluate
|
2024-01-10 11:41:18 +00:00
|
|
|
import mdevaluate.extra.free_energy_landscape as fel
|
2023-12-06 09:55:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def trajectory(request):
|
2023-12-08 16:20:06 +00:00
|
|
|
return mdevaluate.open(os.path.join(os.path.dirname(__file__), "data/pore"))
|
2023-12-06 09:55:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_get_fel(trajectory):
|
2024-05-02 14:17:54 +00:00
|
|
|
test_array = np.array([210., 214., 209., 192., 200., 193., 230., 218., 266.])
|
2023-12-06 09:55:55 +00:00
|
|
|
|
2024-01-10 11:41:18 +00:00
|
|
|
OW = trajectory.subset(atom_name="OW")
|
2024-02-08 16:24:22 +00:00
|
|
|
box = trajectory[0].box
|
|
|
|
box_voxels = (np.diag(box) // [0.05, 0.05, 0.05] + [1, 1, 1]) * [0.05, 0.05, 0.05]
|
2024-02-26 13:14:29 +00:00
|
|
|
occupation_matrix = fel.occupation_matrix(OW, skip=0, segments=10)
|
2024-02-08 16:24:22 +00:00
|
|
|
radius_maxima = 0.05 * 3 ** (1 / 2) + 0.05 / 100
|
|
|
|
maxima_matrix = fel.find_maxima(
|
|
|
|
occupation_matrix,
|
|
|
|
box=box_voxels,
|
|
|
|
radius=radius_maxima,
|
2024-02-26 13:14:29 +00:00
|
|
|
pore_geometry="cylindrical",
|
2024-02-08 16:24:22 +00:00
|
|
|
)
|
|
|
|
maxima_matrix = fel.add_distances(maxima_matrix, "cylindrical", np.diag(box) / 2)
|
2024-02-26 13:14:29 +00:00
|
|
|
r_bins = np.arange(0, 0.5, 0.02)
|
|
|
|
distance_bins = np.arange(1.8, 1.9, 0.01)
|
2024-01-10 11:41:18 +00:00
|
|
|
energy_df = fel.distance_resolved_energies(
|
2024-02-08 16:24:22 +00:00
|
|
|
maxima_matrix, distance_bins, r_bins, box, "cylindrical", 225
|
2023-12-06 09:55:55 +00:00
|
|
|
)
|
2024-01-10 11:41:18 +00:00
|
|
|
result = fel.find_energy_maxima(energy_df, r_min=0.05, r_max=0.15)
|
|
|
|
assert (np.round(np.array(result["energy"])) == np.round(test_array)).all()
|