ipyvasp 1.1.0__py2.py3-none-any.whl → 1.1.1__py2.py3-none-any.whl

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/_lattice.py CHANGED
@@ -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
- s_zero,
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 = [[0, 0, 0], [0, 0, 0], [0, 0, 0]], 0.3 * bz_data.basis.T
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 existing BZ. It will take ``ax``, ``plane`` and ``zoffset`` internally from most recent call to ``splot_bz``/``bz.splot``.
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]
ipyvasp/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.1.0"
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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ipyvasp
3
- Version: 1.1.0
3
+ Version: 1.1.1
4
4
  Summary: A processing tool for VASP DFT input/output processing in Jupyter Notebook.
5
5
  Home-page: https://github.com/massgh/ipyvasp
6
6
  Author: Abdul Saboor
@@ -1,8 +1,8 @@
1
1
  ipyvasp/__init__.py,sha256=pzTqeKuf6sN2GQmaexmMgG677ggT3sxIFyQDXq_2whU,1422
2
2
  ipyvasp/__main__.py,sha256=eJV1TZSiT8mC_VqAeksNnBI2I8mKMiPkEIlwikbtOjI,216
3
3
  ipyvasp/_enplots.py,sha256=gJ7S9WBmrxvDEbmoccDRaJG01kpx9oNlRf7mozigbgY,37872
4
- ipyvasp/_lattice.py,sha256=-JQaIdB2e6yFh5j_U2343FH2aM_c3cSdqSC19cJINq4,107218
5
- ipyvasp/_version.py,sha256=Zrv57EzpjdsuSPqsYvFkVsQKKRUOHFG7yURCf7qN-Tk,23
4
+ ipyvasp/_lattice.py,sha256=Lh-ip60M6APUckR4I0bQ6GMN2aaY7gpkA1Z0uuFt1A4,108117
5
+ ipyvasp/_version.py,sha256=KGJQJ23MnEKMR2yQigWuN5Fj9B4JRjsenwhmGe0cwAA,23
6
6
  ipyvasp/bsdos.py,sha256=hVHpxkdT2ImRsxwFvMSMHxRSo4LqDM90DnUhwTP8vcs,32192
7
7
  ipyvasp/cli.py,sha256=-Lf-qdTvs7WyrA4ALNLaoqxMjLsZkXdPviyQps3ezqg,6880
8
8
  ipyvasp/evals_dataframe.py,sha256=n2iSH4D4ZbrxlAV4yDTVHbcl3ycfD0zfQYmTBcxjfkE,20789
@@ -15,11 +15,11 @@ ipyvasp/widgets.py,sha256=Bpa4Y3Eopk_ZPFsVetfysClZP2q_2ONvmOwUol9vVGI,53154
15
15
  ipyvasp/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  ipyvasp/core/parser.py,sha256=o-uHyL_w9W0pmxoSt3JmLwwmmT3WRHlHSs_NoiHO-hs,39401
17
17
  ipyvasp/core/plot_toolkit.py,sha256=aURiPAu0tWTNctuA9LMEL3CfraRgAOyTJURzDrrO0r0,36232
18
- ipyvasp/core/serializer.py,sha256=aEc7K5jVga8gxm9Tt2OgBw8wnsmWZGtODBnwRJ_5sf0,38423
18
+ ipyvasp/core/serializer.py,sha256=9xuLfl9LtUXPxTX2_zRs7nvfZsZOZN00bnxErAxDA5w,40065
19
19
  ipyvasp/core/spatial_toolkit.py,sha256=dXowREhiFzBvvr5f_bApzFhf8IzjH2E2Ix90oCBUetY,14885
20
- ipyvasp-1.1.0.dist-info/LICENSE,sha256=F3SO5RiAZOMfmMGf1KOuk2g_c4ObvuBJhd9iBLDgXoQ,1263
21
- ipyvasp-1.1.0.dist-info/METADATA,sha256=DCZLpgRjMRdVVJqT23OoP4AVFf_HeLUICtdBdSYa4_I,3218
22
- ipyvasp-1.1.0.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
23
- ipyvasp-1.1.0.dist-info/entry_points.txt,sha256=aU-gGjQG2Q8XfxDlNc_8__cwfp8WG2K5ZgFPInTm2jg,45
24
- ipyvasp-1.1.0.dist-info/top_level.txt,sha256=ftziWlMWu_1VpDP1sRTFrkfBnWxAi393HYDVu4wRhUk,8
25
- ipyvasp-1.1.0.dist-info/RECORD,,
20
+ ipyvasp-1.1.1.dist-info/LICENSE,sha256=F3SO5RiAZOMfmMGf1KOuk2g_c4ObvuBJhd9iBLDgXoQ,1263
21
+ ipyvasp-1.1.1.dist-info/METADATA,sha256=WVjTyiCpM9SmXs2S9u6CTtwdrfWhSYaY8-S4fY7EiSU,3218
22
+ ipyvasp-1.1.1.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
23
+ ipyvasp-1.1.1.dist-info/entry_points.txt,sha256=aU-gGjQG2Q8XfxDlNc_8__cwfp8WG2K5ZgFPInTm2jg,45
24
+ ipyvasp-1.1.1.dist-info/top_level.txt,sha256=ftziWlMWu_1VpDP1sRTFrkfBnWxAi393HYDVu4wRhUk,8
25
+ ipyvasp-1.1.1.dist-info/RECORD,,