Replies: 1 comment
-
Use the PBC-enabled distance functions in MDAnalysis.lib.distances (or for very simple calculations, analysis.distances.AtomicDistances) and do not use The important part is to calculate distances under minimum image convention by providing the Below is what I would try — not tested, take it as a starting point for exploring. COM distanceCalculate the COM (as in your question) and the compute the min-image distance between COM1 and COM1: u = mda.Universe("prod.gro", "prod.xtc")
group1 = u.select_atoms("resname MCD")
group2 = u.select_atoms("resname UNL")
distances = []
for ts in u.trajectory:
com1 = group1.center_of_mass(pbc=True) # COM of MCD
com2 = group2.center_of_mass(pbc=True) # COM of UNL
d = MDAnalysis.lib.distances.calc_bonds(com1, com2, box=ts.dimensions)
distances.append(d) closest interatomic distanceCalculate all pairwise distances ( u = mda.Universe("prod.gro", "prod.xtc")
group1 = u.select_atoms("resname MCD")
group2 = u.select_atoms("resname UNL")
distances = []
for ts in u.trajectory:
all_d = MDAnalysis.lib.distances.distance_array(group1, group2, box=ts.dimensions)
shortest_d = all_d.min()
distances.append(shortest_d) |
Beta Was this translation helpful? Give feedback.
-
Hi!
I have a simulation containing water and two solutes and I want to compute the distance between these solutes over time. I have accounted for PBC effects with GROMACS. A screenshot of the simulation box:
Because of PBC effects, the two molecules are actually close, but when I compute the distances with MDAnalysis I get bigger distances than expected. Is there a way to compute the "smallest" distance between these two solutes?
My code is:
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions