ipyvasp 0.9.81__py2.py3-none-any.whl → 0.9.82__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/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.9.81"
1
+ __version__ = "0.9.82"
@@ -315,6 +315,9 @@ def get_bz(basis, loop=True, primitive=False):
315
315
  "vertices": verts,
316
316
  "faces": idx_faces,
317
317
  "primitive": primitive,
318
+ "edges": np.unique(
319
+ np.sort([[i,j] for f in idx_faces for i,j in zip(f[:-1],f[1:])], axis=1),
320
+ axis=0)
318
321
  }
319
322
  from .serializer import BrZoneData # to avoid circular import
320
323
 
ipyvasp/lattice.py CHANGED
@@ -18,11 +18,13 @@ from contextlib import suppress
18
18
  import numpy as np
19
19
  from pandas.io.clipboard import clipboard_get, clipboard_set
20
20
  import matplotlib.colors as mcolors
21
+ from mpl_toolkits.mplot3d.art3d import Poly3DCollection
22
+ import plotly.graph_objects as go
21
23
 
22
24
 
23
25
  from .core import serializer
24
26
  from .core import spatial_toolkit as stk
25
- from .core.plot_toolkit import iplot2widget
27
+ from .core.plot_toolkit import get_axes, iplot2widget
26
28
  from .utils import _sig_kwargs, _sub_doc
27
29
  from . import _lattice as plat
28
30
  from ._lattice import (
@@ -354,11 +356,11 @@ class POSCAR:
354
356
 
355
357
  @property
356
358
  def last(self):
357
- """Points to last created POSCAR instance during chained operations! You don't need to store results
359
+ """Points to last created POSCAR instance during chained operations! You don't need to store results.
358
360
 
359
361
  ```python
360
362
  pc = POSCAR()
361
- pc.filter_atoms(lambda a: a.index in pc.data.types.Ga) # FINE
363
+ pc.filter_atoms(lambda a: a.index in pc.data.types.Ga) # FINE, can use a.symbol == 'Ga' too, but we need to show a point below
362
364
  pc.set_boundary([-2,2]).filter_atoms(lambda a: a.index in pc.data.types.Ga) # INCORRECT sites picked
363
365
  pc.set_boundary([-2,2]).filter_atoms(lambda a: a.index in pc.last.data.types.Ga) # PERFECT, pc.last is output of set_boundary
364
366
  ```
@@ -626,6 +628,57 @@ class POSCAR:
626
628
  if not hasattr(self, "_cell"):
627
629
  self._cell = self.get_cell()
628
630
  return self._cell
631
+
632
+ def get_plane(self, hkl, d=1/2,tol=1e-2):
633
+ """Returns Nx3 vertices of a plane bound inside cell. .
634
+ hkl should be list of three miller indices. d is fractional distance in range 0,1 in direction of hkl.
635
+ e.g. if there are 8 planes of atoms in a cubic cell, d = 0, 1/8,...7/8, 1 match position of those planes.
636
+ """
637
+ from sympy import Point3D, Line3D, Plane
638
+ V = self.data.rec_basis.dot(hkl)
639
+ normal = V/np.linalg.norm(V)
640
+ point = d*normal*np.linalg.norm(self.data.basis.dot(hkl)) # to make d 0-1
641
+ P = Plane(Point3D(*point),normal_vector=normal)
642
+
643
+ pts = []
644
+ for e in self.cell.vertices[self.cell.edges]:
645
+ L = Line3D(Point3D(*e[0]),Point3D(*e[1]))
646
+ if (isc := P.intersection(L)) and isinstance(isc[0],Point3D):
647
+ pts.append(isc[0])
648
+
649
+ pts = np.unique(np.array(pts,dtype=float),axis=0)
650
+ pts = pts[stk.order(pts,)]
651
+ qts = self.cell.to_fractional(pts)
652
+ qts = qts[(qts >= -tol).all(axis=1) & (qts <= 1 + tol).all(axis=1)]
653
+ pts = self.cell.to_cartesian(qts)
654
+ return pts
655
+
656
+ def splot_plane(self, hkl, d=1/2,tol=1e-2,ax=None, **kwargs):
657
+ """Provide hkl and a 3D axes to plot plane. kwargs are passed to `mpl_toolkits.mplot3d.art3d.Poly3DCollection`
658
+ Note: You may get wrong plane if your basis are not aligned to axes. So you can use `transpose` or `set_zdir` methods before plottling cell.
659
+ """
660
+ P = self.get_plane(hkl,d=d,tol=tol)
661
+ if ax is None:
662
+ ax = get_axes(axes_3d=True)
663
+ ax.set( # it does not show otherwise
664
+ xlim=[P[:,0].min(),P[:,0].max()],
665
+ ylim=[P[:,1].min(),P[:,1].max()],
666
+ zlim=[P[:,2].min(),P[:,2].max()]
667
+ )
668
+ kwargs = {'alpha':0.5,'color':'#898','shade': False, **kwargs}
669
+ ax.add_collection(Poly3DCollection([P],**kwargs))
670
+ ax.autoscale_view()
671
+ return ax
672
+
673
+ def iplot_plane(self, hkl, d = 1/2, tol=1e-3, fig=None,**kwargs):
674
+ "Plot plane on a plotly Figure. kwargs are passed to `plotly.graph_objects.Mesh3d`."
675
+ if fig is None:
676
+ fig = go.Figure()
677
+
678
+ P = self.get_plane(hkl,d=d,tol=tol)
679
+ kwargs = {**dict(color='#8a8',opacity=0.7,alphahull=0, showlegend=True,name=str(hkl)),**kwargs}
680
+ fig.add_trace(go.Mesh3d({k:v for v,k in zip(P.T, 'xyz')},**kwargs))
681
+ return fig
629
682
 
630
683
  @_sub_doc(stk.get_bz, {"basis :.*loop :": "loop :"})
631
684
  @_sig_kwargs(stk.get_bz, ("basis",))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ipyvasp
3
- Version: 0.9.81
3
+ Version: 0.9.82
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
@@ -2,11 +2,11 @@ ipyvasp/__init__.py,sha256=rlorju9arMtHw1QRYPljday-PyZWJdSCxg4lw3g6t0Q,1409
2
2
  ipyvasp/__main__.py,sha256=eJV1TZSiT8mC_VqAeksNnBI2I8mKMiPkEIlwikbtOjI,216
3
3
  ipyvasp/_enplots.py,sha256=D38paN8zqZgluNAwmCwcocd7-_h_T0HTGolI1eBkDes,37484
4
4
  ipyvasp/_lattice.py,sha256=8jaiSBz0cKfAwzkLQTCOvPNOBVeWtL5tahgp-LIoDdk,105571
5
- ipyvasp/_version.py,sha256=CTUf1M5sj6XFicmUC1ATWl8zxY86WlKZLcC7FUJ7tEs,24
5
+ ipyvasp/_version.py,sha256=Oukmd6D0UJTqAdg4-8VB8ZHKeAiTHoyIqdUQToKmrkg,24
6
6
  ipyvasp/bsdos.py,sha256=JvYvHLqMp3eVaJ0amD-9kxp7FehQIFq3WFUxsO5dj0Q,31794
7
7
  ipyvasp/cli.py,sha256=aWFEVhNmnW8eSOp5uh95JaDwLQ9K9nlCQcbnOSuhWgw,6844
8
8
  ipyvasp/evals_dataframe.py,sha256=-sqxK7LPV6sYDO_XXmZ80FznOaXTkVdbqJKKvTUtMak,20637
9
- ipyvasp/lattice.py,sha256=r53Vpa4jmP3zyu4LDR7uSYtYN27nbbtbtqG1235xw74,30735
9
+ ipyvasp/lattice.py,sha256=sibDi_3rzMRVzwRNmF0rE1qLFWZdMKs9VCu66NLOmQM,33389
10
10
  ipyvasp/misc.py,sha256=SZJ_ePUR2-HEKYTEpDHVRVE7zpIQVTCjiuw0BCC9UTU,2349
11
11
  ipyvasp/potential.py,sha256=tzA73c5lkp6ahLSJchMrU043-QWaOV0nIOUA7VMmfKQ,11408
12
12
  ipyvasp/surface.py,sha256=MjE5oB0wW6Pca_C-xu8rN6OMH7lUEeNPNyM7Kz_Im-8,23766
@@ -16,10 +16,10 @@ ipyvasp/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  ipyvasp/core/parser.py,sha256=TmRoIhyIGJ4nr32tb1MAAy5clUZh0CQh-2hP8mnTaVc,38221
17
17
  ipyvasp/core/plot_toolkit.py,sha256=3RoPsND5gPssBSfS5H4TjoZ2Qz7B97vpxeKadc2cRRs,36046
18
18
  ipyvasp/core/serializer.py,sha256=-PvCDXZqaCTnwBY5CS_B7_cmnbKy3g6cfEOr_Nrbde8,38415
19
- ipyvasp/core/spatial_toolkit.py,sha256=8DBYTiBFWJ7OBKuvOPw7UoEVCyNjJhSW0OcudjYZvAw,14748
20
- ipyvasp-0.9.81.dist-info/LICENSE,sha256=F3SO5RiAZOMfmMGf1KOuk2g_c4ObvuBJhd9iBLDgXoQ,1263
21
- ipyvasp-0.9.81.dist-info/METADATA,sha256=ki2crXrujbpJ8e7hkfA6AJOFq4BxV-6S1dNozy45nA0,2421
22
- ipyvasp-0.9.81.dist-info/WHEEL,sha256=iYlv5fX357PQyRT2o6tw1bN-YcKFFHKqB_LwHO5wP-g,110
23
- ipyvasp-0.9.81.dist-info/entry_points.txt,sha256=C7m0Sjmr14wFjflCkWXLzr5N6-cQj8uJC9n82mUtzt8,44
24
- ipyvasp-0.9.81.dist-info/top_level.txt,sha256=ftziWlMWu_1VpDP1sRTFrkfBnWxAi393HYDVu4wRhUk,8
25
- ipyvasp-0.9.81.dist-info/RECORD,,
19
+ ipyvasp/core/spatial_toolkit.py,sha256=dXowREhiFzBvvr5f_bApzFhf8IzjH2E2Ix90oCBUetY,14885
20
+ ipyvasp-0.9.82.dist-info/LICENSE,sha256=F3SO5RiAZOMfmMGf1KOuk2g_c4ObvuBJhd9iBLDgXoQ,1263
21
+ ipyvasp-0.9.82.dist-info/METADATA,sha256=QoQeGuDqagJcuMNorpZL9w8qW2IivoxL-5I_JvdOHWs,2421
22
+ ipyvasp-0.9.82.dist-info/WHEEL,sha256=iYlv5fX357PQyRT2o6tw1bN-YcKFFHKqB_LwHO5wP-g,110
23
+ ipyvasp-0.9.82.dist-info/entry_points.txt,sha256=C7m0Sjmr14wFjflCkWXLzr5N6-cQj8uJC9n82mUtzt8,44
24
+ ipyvasp-0.9.82.dist-info/top_level.txt,sha256=ftziWlMWu_1VpDP1sRTFrkfBnWxAi393HYDVu4wRhUk,8
25
+ ipyvasp-0.9.82.dist-info/RECORD,,