def get_rdf_figure(self, isite, normalized=True, figsize=None, step_function=None): """ Get the Radial Distribution Figure for a given site. Args: isite: Index of the site. normalized: Whether to normalize distances. figsize: Size of the figure. step_function: Type of step function to be used for the RDF. Returns: Matplotlib figure. """ def dp_func(dp): return 1.0 - 1.0 / np.power(dp, 3.0) import matplotlib.pyplot as plt if step_function is None: step_function = {"type": "normal_cdf", "scale": 0.0001} # Initializes the figure if figsize is None: fig = plt.figure() else: fig = plt.figure(figsize=figsize) subplot = fig.add_subplot(111) if normalized: dists = self.neighbors_normalized_distances[isite] else: dists = self.neighbors_distances[isite] if step_function["type"] == "step_function": isorted = np.argsort([dd["min"] for dd in dists]) sorted_dists = [dists[ii]["min"] for ii in isorted] dnb_dists = [len(dists[ii]["dnb_indices"]) for ii in isorted] xx = [0.0] yy = [0.0] for idist, dist in enumerate(sorted_dists): xx.append(dist) xx.append(dist) yy.append(yy[-1]) yy.append(yy[-1] + dnb_dists[idist]) xx.append(1.1 * xx[-1]) yy.append(yy[-1]) elif step_function["type"] == "normal_cdf": scale = step_function["scale"] mydists = [dp_func(dd["min"]) for dd in dists] mydcns = [len(dd["dnb_indices"]) for dd in dists] xx = np.linspace(0.0, 1.1 * max(mydists), num=500) yy = np.zeros_like(xx) for idist, dist in enumerate(mydists): yy += mydcns[idist] * normal_cdf_step(xx, mean=dist, scale=scale) else: raise ValueError(f"Step function of type \"{step_function['type']}\" is not allowed") subplot.plot(xx, yy) return fig
def get_sadf_figure(self, isite, normalized=True, figsize=None, step_function=None): """ Get the Solid Angle Distribution Figure for a given site. Args: isite: Index of the site. normalized: Whether to normalize angles. figsize: Size of the figure. step_function: Type of step function to be used for the SADF. Returns: Matplotlib figure. """ def ap_func(ap): return np.power(ap, -0.1) import matplotlib.pyplot as plt if step_function is None: step_function = {"type": "step_function", "scale": 0.0001} # Initializes the figure if figsize is None: fig = plt.figure() else: fig = plt.figure(figsize=figsize) subplot = fig.add_subplot(111) if normalized: angs = self.neighbors_normalized_angles[isite] else: angs = self.neighbors_angles[isite] if step_function["type"] == "step_function": isorted = np.argsort([ap_func(aa["min"]) for aa in angs]) sorted_angs = [ap_func(angs[ii]["min"]) for ii in isorted] dnb_angs = [len(angs[ii]["dnb_indices"]) for ii in isorted] xx = [0.0] yy = [0.0] for iang, ang in enumerate(sorted_angs): xx.append(ang) xx.append(ang) yy.append(yy[-1]) yy.append(yy[-1] + dnb_angs[iang]) xx.append(1.1 * xx[-1]) yy.append(yy[-1]) elif step_function["type"] == "normal_cdf": scale = step_function["scale"] myangs = [ap_func(aa["min"]) for aa in angs] mydcns = [len(dd["dnb_indices"]) for dd in angs] xx = np.linspace(0.0, 1.1 * max(myangs), num=500) yy = np.zeros_like(xx) for iang, ang in enumerate(myangs): yy += mydcns[iang] * normal_cdf_step(xx, mean=ang, scale=scale) else: raise ValueError(f"Step function of type \"{step_function['type']}\" is not allowed") subplot.plot(xx, yy) return fig
def get_rdf_figure(self, isite, normalized=True, figsize=None, step_function=None): def dp_func(dp): return 1.0 - 1.0 / np.power(dp, 3.0) import matplotlib.pyplot as plt if step_function is None: step_function = {'type': 'normal_cdf', 'scale': 0.0001} # Initializes the figure if figsize is None: fig = plt.figure() else: fig = plt.figure(figsize=figsize) subplot = fig.add_subplot(111) if normalized: dists = self.neighbors_normalized_distances[isite] else: dists = self.neighbors_distances[isite] if step_function['type'] == 'step_function': isorted = np.argsort([dd['min'] for dd in dists]) sorted_dists = [dists[ii]['min'] for ii in isorted] dnb_dists = [len(dists[ii]['dnb_indices']) for ii in isorted] xx = [0.0] yy = [0.0] for idist, dist in enumerate(sorted_dists): xx.append(dist) xx.append(dist) yy.append(yy[-1]) yy.append(yy[-1] + dnb_dists[idist]) xx.append(1.1 * xx[-1]) yy.append(yy[-1]) elif step_function['type'] == 'normal_cdf': scale = step_function['scale'] mydists = [dp_func(dd['min']) for dd in dists] mydcns = [len(dd['dnb_indices']) for dd in dists] xx = np.linspace(0.0, 1.1 * max(mydists), num=500) yy = np.zeros_like(xx) for idist, dist in enumerate(mydists): yy += mydcns[idist] * normal_cdf_step( xx, mean=dist, scale=scale) else: raise ValueError( 'Step function of type "{}" is not allowed'.format( step_function['type'])) subplot.plot(xx, yy) return fig
def get_sadf_figure(self, isite, normalized=True, figsize=None, step_function=None): def ap_func(ap): return np.power(ap, -0.1) import matplotlib.pyplot as plt if step_function is None: step_function = {'type': 'step_function', 'scale': 0.0001} # Initializes the figure if figsize is None: fig = plt.figure() else: fig = plt.figure(figsize=figsize) subplot = fig.add_subplot(111) if normalized: angs = self.neighbors_normalized_angles[isite] else: angs = self.neighbors_angles[isite] if step_function['type'] == 'step_function': isorted = np.argsort([ap_func(aa['min']) for aa in angs]) sorted_angs = [ap_func(angs[ii]['min']) for ii in isorted] dnb_angs = [len(angs[ii]['dnb_indices']) for ii in isorted] xx = [0.0] yy = [0.0] for iang, ang in enumerate(sorted_angs): xx.append(ang) xx.append(ang) yy.append(yy[-1]) yy.append(yy[-1] + dnb_angs[iang]) xx.append(1.1 * xx[-1]) yy.append(yy[-1]) elif step_function['type'] == 'normal_cdf': scale = step_function['scale'] myangs = [ap_func(aa['min']) for aa in angs] mydcns = [len(dd['dnb_indices']) for dd in angs] xx = np.linspace(0.0, 1.1 * max(myangs), num=500) yy = np.zeros_like(xx) for iang, ang in enumerate(myangs): yy += mydcns[iang] * normal_cdf_step(xx, mean=ang, scale=scale) else: raise ValueError( 'Step function of type "{}" is not allowed'.format( step_function['type'])) subplot.plot(xx, yy) return fig
def get_sadf_figure(self, isite, normalized=True, figsize=None, step_function=None): def ap_func(ap): return np.power(ap, -0.1) import matplotlib.pyplot as plt if step_function is None: step_function = {'type': 'step_function', 'scale': 0.0001} # Initializes the figure if figsize is None: fig = plt.figure() else: fig = plt.figure(figsize=figsize) subplot = fig.add_subplot(111) if normalized: angs = self.neighbors_normalized_angles[isite] else: angs = self.neighbors_angles[isite] if step_function['type'] == 'step_function': isorted = np.argsort([ap_func(aa['min']) for aa in angs]) sorted_angs = [ap_func(angs[ii]['min']) for ii in isorted] dnb_angs = [len(angs[ii]['dnb_indices']) for ii in isorted] xx = [0.0] yy = [0.0] for iang, ang in enumerate(sorted_angs): xx.append(ang) xx.append(ang) yy.append(yy[-1]) yy.append(yy[-1]+dnb_angs[iang]) xx.append(1.1*xx[-1]) yy.append(yy[-1]) elif step_function['type'] == 'normal_cdf': scale = step_function['scale'] myangs = [ap_func(aa['min']) for aa in angs] mydcns = [len(dd['dnb_indices']) for dd in angs] xx = np.linspace(0.0, 1.1*max(myangs), num=500) yy = np.zeros_like(xx) for iang, ang in enumerate(myangs): yy += mydcns[iang] * normal_cdf_step(xx, mean=ang, scale=scale) else: raise ValueError('Step function of type "{}" is not allowed'.format(step_function['type'])) subplot.plot(xx, yy) return fig
def get_rdf_figure(self, isite, normalized=True, figsize=None, step_function=None): def dp_func(dp): return 1.0 - 1.0 / np.power(dp, 3.0) import matplotlib.pyplot as plt if step_function is None: step_function = {'type': 'normal_cdf', 'scale': 0.0001} # Initializes the figure if figsize is None: fig = plt.figure() else: fig = plt.figure(figsize=figsize) subplot = fig.add_subplot(111) if normalized: dists = self.neighbors_normalized_distances[isite] else: dists = self.neighbors_distances[isite] if step_function['type'] == 'step_function': isorted = np.argsort([dd['min'] for dd in dists]) sorted_dists = [dists[ii]['min'] for ii in isorted] dnb_dists = [len(dists[ii]['dnb_indices']) for ii in isorted] xx = [0.0] yy = [0.0] for idist, dist in enumerate(sorted_dists): xx.append(dist) xx.append(dist) yy.append(yy[-1]) yy.append(yy[-1]+dnb_dists[idist]) xx.append(1.1*xx[-1]) yy.append(yy[-1]) elif step_function['type'] == 'normal_cdf': scale = step_function['scale'] mydists = [dp_func(dd['min']) for dd in dists] mydcns = [len(dd['dnb_indices']) for dd in dists] xx = np.linspace(0.0, 1.1*max(mydists), num=500) yy = np.zeros_like(xx) for idist, dist in enumerate(mydists): yy += mydcns[idist] * normal_cdf_step(xx, mean=dist, scale=scale) else: raise ValueError('Step function of type "{}" is not allowed'.format(step_function['type'])) subplot.plot(xx, yy) return fig