@@ -28,17 +28,71 @@ def compute(self, inp, volume=True, area=True, facets=False, projections=False)
2828 :param bool facets : compute facets areas and normals
2929 :param bool projections: compute projected areas and volumes
3030 :returns:
31- a tuple with volumes (ndarray), areas (ndarray) and facets (dictionary) and projections (dictionary)
32- as selected by the corresponding options.
31+ tuple (volumes, areas, info)
3332
34- The arrays volumes and areas have shape equal to len(inp)
33+ - **volumes** (ndarray): total volume(s) of the polyhedron(s).
34+ - **areas** (ndarray): total surface area(s).
35+ - **info** (dict, optional): contains additional per-facet and per-axis data:
3536
36- The facets dictionary has keys 'facet_areas' and 'facet_normals', and the corresponding values are
37- lists of length len(inp), each one containing a list of variable length, depending on the number of
38- facet associated to the point.
37+ * ``facet_areas`` – list of facet areas :math:`A_f`
38+ * ``facet_normals`` – list of outward unit normals :math:`n_f`
39+ * ``projected_areas`` – per-axis contributions
3940
40- The projections dictionary has keys 'projected_areas' and 'projected_volumes', and the corresponding values
41- are ndarrays of shape (len(inp),3 ) for each of the three Cartesian directions x,y,z.
41+ .. math::
42+
43+ A_i = \sum_f A_f (n_f \cdot e_i)^2
44+
45+ where :math:`e_i` is the Cartesian unit vector in direction
46+ :math:`i \in \{x, y, z\}`
47+
48+ * ``projected_volumes`` – per-axis contributions
49+
50+ .. math::
51+
52+ V_i = \sum_f \f rac{A_f h_f}{3} (n_f \cdot e_i)^2
53+
54+ with :math:`h_f` the height of the pyramid defined by facet
55+ :math:`f` and the chosen reference point.
56+
57+ Notes
58+ -----
59+ - The projected area/volume decomposition uses the squared direction cosine
60+ of each facet normal, so that the three components sum to the total area
61+ or volume.
62+
63+
64+ Example:
65+
66+ >>> import numpy as np
67+ >>> import MDAnalysis as mda
68+ >>> import pytim
69+ >>> from pytim.datafiles import WATER_GRO
70+ >>> from pytim.observables import Voronoi
71+ >>> def rprint(x,n=3): print(np.around(x,n))
72+ >>>
73+ >>> u = mda.Universe(WATER_GRO)
74+ >>> ox = u.select_atoms('name OW')
75+ >>> # just a slice to compute the observable faster
76+ >>> ox = ox [ox.positions[:,2] < u.dimensions[2]/10]
77+ >>> voro = Voronoi(u)
78+ >>> volumes, areas, dic = voro.compute(ox, facets=True,projections=True)
79+ >>> rprint([volumes[0],areas[0]])
80+ [28.708 54.081]
81+
82+ >>> print(dic.keys())
83+ dict_keys(['facet_areas', 'facet_normals', 'projected_areas', 'projected_volumes'])
84+
85+ >>> # The first atom's polyhedra has 48 facets.
86+ >>> # The projected areas and volumes are the
87+ >>> # amount of area pointing along x,y,z
88+ >>> print([len(dic[k][0]) for k in dic.keys()])
89+ [48, 48, 3, 3]
90+
91+ >>> rprint(dic['projected_areas'][0])
92+ [17.962 18.882 17.237]
93+
94+ >>> rprint(dic['projected_volumes'][0])
95+ [9.803 9.877 9.029]
4296
4397 """
4498
0 commit comments