ipyvasp 1.1.0__tar.gz → 1.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/PKG-INFO +1 -1
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp/_lattice.py +27 -15
- ipyvasp-1.1.1/ipyvasp/_version.py +1 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp/core/serializer.py +41 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp.egg-info/PKG-INFO +1 -1
- ipyvasp-1.1.0/ipyvasp/_version.py +0 -1
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/LICENSE +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/README.md +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp/__init__.py +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp/__main__.py +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp/_enplots.py +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp/bsdos.py +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp/cli.py +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp/core/__init__.py +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp/core/parser.py +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp/core/plot_toolkit.py +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp/core/spatial_toolkit.py +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp/evals_dataframe.py +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp/lattice.py +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp/misc.py +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp/potential.py +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp/utils.py +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp/widgets.py +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp.egg-info/SOURCES.txt +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp.egg-info/dependency_links.txt +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp.egg-info/entry_points.txt +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp.egg-info/requires.txt +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/ipyvasp.egg-info/top_level.txt +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/setup.cfg +0 -0
- {ipyvasp-1.1.0 → ipyvasp-1.1.1}/setup.py +0 -0
|
@@ -909,6 +909,7 @@ def splot_bz(
|
|
|
909
909
|
shade=True,
|
|
910
910
|
alpha=0.4,
|
|
911
911
|
zoffset=0,
|
|
912
|
+
center=(0,0,0),
|
|
912
913
|
**kwargs,
|
|
913
914
|
):
|
|
914
915
|
"""Plots matplotlib's static figure of BZ/Cell. You can also plot in 2D on a 3D axes.
|
|
@@ -937,8 +938,9 @@ def splot_bz(
|
|
|
937
938
|
alpha : float
|
|
938
939
|
Opacity of filling in range [0,1]. Increase for clear viewpoint.
|
|
939
940
|
zoffset : float
|
|
940
|
-
Only used if plotting in 2D over a 3D axis. Default is 0. Any plane 'xy','yz' etc.
|
|
941
|
-
|
|
941
|
+
Only used if plotting in 2D over a 3D axis. Default is 0. Any plane 'xy','yz' etc can be offset to it's own normal.
|
|
942
|
+
center : (3,) array_like
|
|
943
|
+
Translation of origin in *basis coordinates* (fractional along the plotted basis). Use this to tile BZ with help of ``BrZoneData.tile`` fuction.
|
|
942
944
|
|
|
943
945
|
kwargs are passed to `plt.plot` or `Poly3DCollection` if `fill=True`.
|
|
944
946
|
|
|
@@ -962,6 +964,17 @@ def splot_bz(
|
|
|
962
964
|
if v not in [0, 1, 2]:
|
|
963
965
|
raise ValueError(f"`vectors` expects values in [0,1,2], got {vectors!r}")
|
|
964
966
|
|
|
967
|
+
if not isinstance(center, (tuple, list, np.ndarray)) or len(center) != 3:
|
|
968
|
+
raise ValueError("`center` must be a 3-sequence like (0,0,0) in basis coordinates.")
|
|
969
|
+
try:
|
|
970
|
+
center = np.array(center, dtype=float).reshape(3)
|
|
971
|
+
except Exception as e:
|
|
972
|
+
raise ValueError(f"`center` must be numeric, got {center!r}") from e
|
|
973
|
+
|
|
974
|
+
origin = to_R3(bz_data.basis, [center])[0] # (3,) cartesian shift
|
|
975
|
+
bz_data = bz_data.copy()
|
|
976
|
+
bz_data.vertices[:,:] += origin # apply on view, assignment is restricted
|
|
977
|
+
|
|
965
978
|
name = kwargs.pop("label", None) # will set only on single line
|
|
966
979
|
kwargs.pop("zdir", None) # remove , no need
|
|
967
980
|
is_subzone = hasattr(bz_data, "_specials") # For subzone
|
|
@@ -1031,13 +1044,14 @@ def splot_bz(
|
|
|
1031
1044
|
|
|
1032
1045
|
if vectors and not is_subzone:
|
|
1033
1046
|
s_basis = to_plane(normals[plane], bz_data.basis[(vectors,)])
|
|
1047
|
+
s_origin = to_plane(normals[plane], [origin]*len(vectors))
|
|
1034
1048
|
|
|
1035
1049
|
for k, b in zip(vectors, s_basis):
|
|
1036
1050
|
x, y = b[idxs[plane]]
|
|
1037
1051
|
l = r" ${}_{} $".format(_label, k + 1)
|
|
1038
1052
|
l = l + "\n" if y < 0 else "\n" + l
|
|
1039
1053
|
ha = "right" if x < 0 else "left"
|
|
1040
|
-
xyz = 0.8 * b + z0 if is3d else np.array([0.8 * x, 0.8 * y])
|
|
1054
|
+
xyz = 0.8 * b + z0 + s_origin[0] if is3d else np.array([0.8 * x, 0.8 * y]) + s_origin[0, idxs[plane]]
|
|
1041
1055
|
ax.text(
|
|
1042
1056
|
*xyz, l, va="center", ha=ha, clip_on=True
|
|
1043
1057
|
) # must clip to have limits of axes working.
|
|
@@ -1045,7 +1059,7 @@ def splot_bz(
|
|
|
1045
1059
|
*(xyz / 0.8), color="w", s=0.0005
|
|
1046
1060
|
) # Must be to scale below arrow.
|
|
1047
1061
|
if is3d:
|
|
1048
|
-
XYZ, UVW = (np.ones_like(s_basis) * z0).T, s_basis.T
|
|
1062
|
+
XYZ, UVW = (np.ones_like(s_basis) * z0 + s_origin).T, s_basis.T
|
|
1049
1063
|
quiver3d(
|
|
1050
1064
|
*XYZ,
|
|
1051
1065
|
*UVW,
|
|
@@ -1056,10 +1070,8 @@ def splot_bz(
|
|
|
1056
1070
|
mutation_scale=7,
|
|
1057
1071
|
)
|
|
1058
1072
|
else:
|
|
1059
|
-
s_zero = [0 for _ in s_basis] # either 3 or 2.
|
|
1060
1073
|
ax.quiver(
|
|
1061
|
-
|
|
1062
|
-
s_zero,
|
|
1074
|
+
*s_origin[:, idxs[plane]].T,
|
|
1063
1075
|
*s_basis[:, idxs[plane]].T,
|
|
1064
1076
|
lw=0.7,
|
|
1065
1077
|
color=color,
|
|
@@ -1126,9 +1138,9 @@ def splot_bz(
|
|
|
1126
1138
|
|
|
1127
1139
|
if vectors and not is_subzone:
|
|
1128
1140
|
for k, v in enumerate(0.35 * bz_data.basis):
|
|
1129
|
-
ax.text(*v, r"${}_{}$".format(_label, k + 1), va="center", ha="center")
|
|
1141
|
+
ax.text(*(v + origin), r"${}_{}$".format(_label, k + 1), va="center", ha="center")
|
|
1130
1142
|
|
|
1131
|
-
XYZ, UVW = [
|
|
1143
|
+
XYZ, UVW = np.array([origin] * 3).T, 0.3 * bz_data.basis.T
|
|
1132
1144
|
quiver3d(
|
|
1133
1145
|
*XYZ, *UVW, C="k", L=0.7, ax=ax, arrowstyle="-|>", mutation_scale=7
|
|
1134
1146
|
)
|
|
@@ -1147,7 +1159,7 @@ def splot_bz(
|
|
|
1147
1159
|
ax.set_zlabel(label.format("z"))
|
|
1148
1160
|
|
|
1149
1161
|
if vname == "b": # These needed for splot_kpath internally
|
|
1150
|
-
type(bz_data)._splot_kws = dict(plane=plane, zoffset=zoffset, ax=ax)
|
|
1162
|
+
type(bz_data)._splot_kws = dict(plane=plane, zoffset=zoffset, ax=ax, shift=origin)
|
|
1151
1163
|
|
|
1152
1164
|
return ax
|
|
1153
1165
|
|
|
@@ -1155,7 +1167,7 @@ def splot_bz(
|
|
|
1155
1167
|
def splot_kpath(
|
|
1156
1168
|
bz_data, kpoints, labels=None, fmt_label=lambda x: (x, {"color": "blue"}), **kwargs
|
|
1157
1169
|
):
|
|
1158
|
-
"""Plot k-path over
|
|
1170
|
+
"""Plot k-path over last plotted BZ. It will take ``ax``, ``plane`` and ``zoffset`` internally from most recent call to ``splot_bz``/``bz.splot``.
|
|
1159
1171
|
|
|
1160
1172
|
Parameters
|
|
1161
1173
|
----------
|
|
@@ -1181,9 +1193,9 @@ def splot_kpath(
|
|
|
1181
1193
|
if not np.ndim(kpoints) == 2 and np.shape(kpoints)[-1] == 3:
|
|
1182
1194
|
raise ValueError("kpoints must be 2D array of shape (N,3)")
|
|
1183
1195
|
|
|
1184
|
-
plane, ax, zoffset = [
|
|
1196
|
+
plane, ax, zoffset, shift = [
|
|
1185
1197
|
bz_data._splot_kws.get(attr, default) # class level attributes
|
|
1186
|
-
for attr, default in zip(["plane", "ax", "zoffset"], [None, None, 0])
|
|
1198
|
+
for attr, default in zip(["plane", "ax", "zoffset", "shift"], [None, None, 0,np.array([0.0, 0.0, 0.0])])
|
|
1187
1199
|
]
|
|
1188
1200
|
|
|
1189
1201
|
ijk = [0, 1, 2]
|
|
@@ -1219,9 +1231,9 @@ def splot_kpath(
|
|
|
1219
1231
|
if fmt_label is None:
|
|
1220
1232
|
fmt_label = lambda x: (x, {"color": "blue"})
|
|
1221
1233
|
|
|
1222
|
-
_validate_label_func(fmt_label,labels[0])
|
|
1234
|
+
_validate_label_func(fmt_label,labels[0])
|
|
1223
1235
|
|
|
1224
|
-
coords = bz_data.to_cartesian(kpoints)
|
|
1236
|
+
coords = bz_data.to_cartesian(kpoints) + shift
|
|
1225
1237
|
if _zoffset and plane:
|
|
1226
1238
|
normal = (
|
|
1227
1239
|
[0, 0, 1] if plane in "xyx" else [0, 1, 0] if plane in "xzx" else [1, 0, 0]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.1.1"
|
|
@@ -765,10 +765,51 @@ class BrZoneData(Dict2Data):
|
|
|
765
765
|
d = self.copy().to_dict()
|
|
766
766
|
d.update({"faces": faces, "vertices": vertices, "_specials": specials})
|
|
767
767
|
return self.__class__(d)
|
|
768
|
+
|
|
769
|
+
def tile(self, nxyz, filter=None):
|
|
770
|
+
"""Create a tiled array of BZ centers for visualization.
|
|
771
|
+
|
|
772
|
+
Parameters
|
|
773
|
+
----------
|
|
774
|
+
nxyz : list or tuple of 3 ints
|
|
775
|
+
Number of tiles along each cartesian direction [nx, ny, nz].
|
|
776
|
+
Must be 3 positive integers.
|
|
777
|
+
filter : callable, optional
|
|
778
|
+
Function filter(x,y,z) that takes cartesian coordinates and returns bool.
|
|
779
|
+
|
|
780
|
+
Returns
|
|
781
|
+
-------
|
|
782
|
+
numpy.ndarray
|
|
783
|
+
Array of shape (N, 3) containing BZ center positions in fractional coordinates.
|
|
784
|
+
|
|
785
|
+
Examples
|
|
786
|
+
--------
|
|
787
|
+
>>> centers = bz_data.tile([3, 3, 3])
|
|
788
|
+
>>> centers = bz_data.tile([5, 5, 1], filter=lambda x,y,z: x**2 + y**2 <= 2**2)
|
|
789
|
+
"""
|
|
790
|
+
if not isinstance(nxyz, (list, tuple, np.ndarray)) or len(nxyz) != 3:
|
|
791
|
+
raise ValueError("nxyz must be a list/tuple/array of 3 integers")
|
|
792
|
+
|
|
793
|
+
for i, n in enumerate(nxyz):
|
|
794
|
+
if not isinstance(n, int) or n < 1:
|
|
795
|
+
raise ValueError(f"nxyz[{i}] must be a positive integer")
|
|
796
|
+
|
|
797
|
+
xyz = self.to_cartesian(np.indices(np.ceil(nxyz).astype(int)).reshape((3,-1)).T)
|
|
798
|
+
# Apply filter if provided
|
|
799
|
+
if filter is not None:
|
|
800
|
+
if not callable(filter):
|
|
801
|
+
raise TypeError("filter must be callable")
|
|
802
|
+
|
|
803
|
+
mask = np.array([filter(x, y, z) for x, y, z in xyz])
|
|
804
|
+
xyz = xyz[mask]
|
|
805
|
+
|
|
806
|
+
# Convert to fractional coordinates and return
|
|
807
|
+
return self.to_fractional(xyz)
|
|
768
808
|
|
|
769
809
|
|
|
770
810
|
class CellData(Dict2Data):
|
|
771
811
|
splot, iplot = _methods_imported()
|
|
812
|
+
tile = BrZoneData.tile
|
|
772
813
|
_req_keys = ("basis", "faces", "vertices")
|
|
773
814
|
|
|
774
815
|
def __init__(self, d):
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.1.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|