def test_funcs(self): l = [0, 1, 2, 3, 4] self.assertEqual(index(l, 1), 1) self.assertEqual(find_lt(l, 1), 0) self.assertEqual(find_gt(l, 1), 2) self.assertEqual(find_le(l, 1), 1) self.assertEqual(find_ge(l, 2), 2)
def plot_ffspl(self, ax=None, ecut_ffnl=None, ders=(0,), with_qn=0, with_fact=False, **kwargs): """ Plot the nonlocal part of the pseudopotential in q space. Args: ax: matplotlib :class:`Axes` or None if a new figure should be created. ecut_ffnl: Max cutoff energy for ffnl plot (optional) ders: Tuple used to select the derivatives to be plotted. with_qn: Returns: matplotlib figure. """ ax, fig, plt = get_ax_fig_plt(ax) color = kwargs.pop("color", "black") linewidth = kwargs.pop("linewidth", 2.0) color_l = {-1: "black", 0: "red", 1: "blue", 2: "green", 3: "orange"} linestyles_n = ["solid", '-', '--', '-.', ":"] scale = None l_seen = set() qmesh, vlspl = self.reader.read_vlspl() all_projs = self.reader.read_projectors() for itypat, projs_type in enumerate(all_projs): # Loop over the projectors for this atom type. for p in projs_type: for der, values in enumerate(p.data): if der == 1: der = 2 if der not in ders: continue #yvals, fact = rescale(values, scale=scale) label = None if p.l not in l_seen: l_seen.add(p.l) label = mklabel("v_{nl}", der, "q") + ", l=%d" % p.l stop = len(p.ecuts) if ecut_ffnl is not None: stop = find_gt(p.ecuts, ecut_ffnl) #values = p.ekb * p.values - vlspl[itypat, 0, :] values = vlspl[itypat, 0, :] + p.sign_sqrtekb * p.values #print(values.min(), values.max()) ax.plot(p.ecuts[:stop], values[:stop], color=color_l[p.l], linewidth=linewidth, linestyle=linestyles_n[p.n], label=label) ax.grid(True) ax.set_xlabel("Ecut [Hartree]") ax.set_title("ffnl(q)") if kwargs.get("with_legend", True): ax.legend(loc="best") ax.axhline(y=0, linewidth=linewidth, color='k', linestyle="solid") return fig
def plot_ffspl(self, ax=None, ecut_ffnl=None, ders=(0,), with_qn=0, with_fact=False, **kwargs): """ Plot the nonlocal part of the pseudopotential in q-space. Args: ax: |matplotlib-Axes| or None if a new figure should be created. ecut_ffnl: Max cutoff energy for ffnl plot (optional) ders: Tuple used to select the derivatives to be plotted. with_qn: Returns: |matplotlib-Figure| """ ax, fig, plt = get_ax_fig_plt(ax=ax) color = kwargs.pop("color", "black") linewidth = kwargs.pop("linewidth", 2.0) color_l = {-1: "black", 0: "red", 1: "blue", 2: "green", 3: "orange"} linestyles_n = ["solid", '-', '--', '-.', ":"] scale = None l_seen = set() qmesh, vlspl = self.reader.read_vlspl() all_projs = self.reader.read_projectors() for itypat, projs_type in enumerate(all_projs): # Loop over the projectors for this atom type. for p in projs_type: for der, values in enumerate(p.data): if der == 1: der = 2 if der not in ders: continue #yvals, fact = rescale(values, scale=scale) label = None if p.l not in l_seen: l_seen.add(p.l) label = mklabel("v_{nl}", der, "q") + ", l=%d" % p.l stop = len(p.ecuts) if ecut_ffnl is not None: stop = find_gt(p.ecuts, ecut_ffnl) #values = p.ekb * p.values - vlspl[itypat, 0, :] values = vlspl[itypat, 0, :] + p.sign_sqrtekb * p.values #print(values.min(), values.max()) ax.plot(p.ecuts[:stop], values[:stop], color=color_l[p.l], linewidth=linewidth, linestyle=linestyles_n[p.n], label=label) ax.grid(True) ax.set_xlabel("Ecut [Hartree]") ax.set_title("ffnl(q)") if kwargs.get("with_legend", False): ax.legend(loc="best") ax.axhline(y=0, linewidth=linewidth, color='k', linestyle="solid") fig.tight_layout() return fig