In [1]:
from exa.util import isotopes
import exatomic
from exatomic.core.two import compute_atom_two_out_of_core # If we need to compute atom_two out of core (low RAM)
from exatomic.algorithms.neighbors import periodic_nearest_neighbors_by_atom # Only valid for simple cubic periodic cells
from exatomic.base import resource # Helper function to find the path to an example file
In [2]:
xyzpath = resource("rh2.traj.xyz")
In [3]:
xyz = exatomic.XYZ(xyzpath) # Editor that can parse the XYZ file and build a universe!
In [4]:
u = xyz.to_universe() # Parse the XYZ data to a universe
In [5]:
u.info() # Current tables
Out[5]:
In [6]:
# Add the unit cell dimensions to the frame table of the universe
a = 37.08946302
for i, q in enumerate(("x", "y", "z")):
for j, r in enumerate(("i", "j", "k")):
if i == j:
u.frame[q+r] = a
else:
u.frame[q+r] = 0.0
u.frame["o"+q] = 0.0
u.frame['periodic'] = True
In [7]:
len(u) # Number of steps in this trajectory (small for example purposes)
Out[7]:
In [8]:
isotopes.Rh.radius # Default Rh (covalent) radius
Out[8]:
In [9]:
u.atom.head()
Out[9]:
In [10]:
%%time
dct = periodic_nearest_neighbors_by_atom(u, # Universe with all frames from which we want to extract clusters
"Rh", # Source atom from which we will search for neighbors
a, # Cubic cell dimension
# Cluster sizes we want
[0, 1, 2, 3, 4, 8, 12, 16],
# Additional arguments to be passed to the atomic two body calculation
# Note that it is critical to increase dmax (in compute_atom_two)!!!
Rh=2.6, dmax=a/2)
In [11]:
dct.keys() # 'dct' is a dictionary containing our clustered universes as well as the sorted neighbor list (per frame)
Out[11]:
In [12]:
dct['nearest'].head() # Table of sorted indexes of nearest molecules to "Rh" in each frame
Out[12]:
In [ ]:
exatomic.UniverseWidget(dct[0]) # Just the analyte
In [ ]:
exatomic.UniverseWidget(dct[16]) # View the universe with 16 nearest molecules
In [15]:
%time u.compute_atom_two(Rh=2.6) # Compute atom two body data with slightly larger Rh radius
# OR
#%time compute_atom_two_out_of_core("atom_two.hdf", u, a, Rh=2.6) # Writes the two body data to "atom_two.hdf" with keys "frame_{index}/atom_two"
In [16]:
u.memory_usage().sum()/1024**2 # RAM usage (MB)
Out[16]:
In [ ]:
exatomic.UniverseWidget(u)
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: