ipyvasp 0.9.5__py2.py3-none-any.whl → 0.9.7__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.5"
1
+ __version__ = "0.9.7"
ipyvasp/bsdos.py CHANGED
@@ -35,7 +35,8 @@ from ._enplots import (
35
35
  def _format_input(projections, sys_info):
36
36
  """
37
37
  Format input spins, atoms, orbs and labels according to selected `projections`.
38
- For example: {'Ga-s':(0,[1]),'Ga-p':(0,[1,2,3]),'Ga-d':(0,[4,5,6,7,8])} #for Ga in GaAs, to pick Ga-1, use [0] instead of 0 at first place
38
+ For example: {'Ga-s':(0,[0]),'Ga-px+py':(0,[2,3]),'Ga-all':(0,'all')} #for Ga in GaAs, to pick Ga-1, use [0] instead of 0 at first place
39
+ or {'Ga-s':('Ga','s'),'Ga-px+py':(0,'px+py'),'all-d':('all','d')}
39
40
  In case of 3 items in tuple, the first item is spin index, the second is atoms, the third is orbs.
40
41
  """
41
42
  if not isinstance(projections, dict):
@@ -53,6 +54,11 @@ def _format_input(projections, sys_info):
53
54
  ) # will be error if two ranges there to compare for max
54
55
  norbs = len(sys_info.orbs)
55
56
 
57
+ orbs_map = {} # total if components given
58
+ if 'px' in sys_info.orbs: orbs_map['p'] = range(1,4)
59
+ if 'dxy' in sys_info.orbs: orbs_map['d'] = range(4,9)
60
+ if 'f0' in sys_info.orbs: orbs_map['f'] = range(9,16)
61
+
56
62
  # Set default values for different situations
57
63
  spins, atoms, orbs, labels = [], [], [], []
58
64
 
@@ -78,6 +84,24 @@ def _format_input(projections, sys_info):
78
84
  )
79
85
 
80
86
  spins.append(S) # Only add spins if given
87
+
88
+ if isinstance(A,str):
89
+ if A.lower() == 'all':
90
+ A = range(max_ind + 1)
91
+ else:
92
+ if not A in sys_info.types.keys():
93
+ raise KeyError(f"type {A!r} not found. Available are {list(sys_info.types.keys())}, 'all', or indexing with integeres/list of intergers.")
94
+ A = sys_info.types[A]
95
+
96
+ if isinstance(B,str):
97
+ if B.lower() == 'all':
98
+ B = range(norbs)
99
+ else:
100
+ B = {b:[sys_info.orbs.index(b)] if b in sys_info.orbs else orbs_map.get(b,[]) for b in (a.strip() for a in B.split('+'))}
101
+ for key, value in B.items():
102
+ if not value:
103
+ raise KeyError(f"orbital {key!r} not found. Available are {sys_info.orbs}, 'all' or indexing with integers/list of intergers")
104
+ B = list(sorted(set([i for b in B.values() for i in b]))) # flatten
81
105
 
82
106
  if not isinstance(A, (int, np.integer, list, tuple, range)):
83
107
  raise TypeError(f"{A!r} is not an integer or list/tuple/range of integers.")
@@ -129,7 +153,7 @@ def _format_input(projections, sys_info):
129
153
 
130
154
  if spins and len(atoms) != len(spins):
131
155
  raise ValueError(
132
- "You should provide spin for each projection or none at all. If not provided, spin is picked from corresponding eigenvalues (up/down) for all projections."
156
+ "You should provide spin for each projection or none at all. If not provided, spin is picked from corresponding eigenvalues (up/down) for all projections using 'spin' parameter explicity."
133
157
  )
134
158
 
135
159
  uatoms = np.unique(
@@ -139,7 +163,7 @@ def _format_input(projections, sys_info):
139
163
  uorbs = tuple(uorbs) if len(uorbs) < norbs else -1 # -1 means all orbitals
140
164
  uatoms = tuple(uatoms) if len(uatoms) == (max_ind + 1) else -1 # -1 means all atoms
141
165
  uspins = tuple(spins)
142
-
166
+
143
167
  return (spins, uspins), (atoms, uatoms), (orbs, uorbs), labels
144
168
 
145
169
 
@@ -154,8 +178,8 @@ bands : list/tuple
154
178
  List of indices of bands. If given, this ovverides elim."""
155
179
  _proj_doc = """projections : dict
156
180
  Mapping from str -> [atoms, orbs]. Use dict to select specific projections,
157
- e.g. {'Ga-s': (0,[0]), 'Ga1-p': ([0],[1,2,3])} in case of GaAs. If values of the dict
158
- are callable, they must accept two arguments evals/tdos, occs/idos of from data and
181
+ e.g. {'Ga-s':(0,[0]),'Ga-px+py':(0,[2,3]),'Ga-all':(0,'all')} or {'Ga-s':('Ga','s'),'Ga-px+py':(0,'px+py'),'all-d':('all','d')}.
182
+ If values of the dict are callable, they must accept two arguments evals/tdos, occs/idos of from data and
159
183
  should return array of shape[1:] (all but spin dimension)."""
160
184
 
161
185
 
@@ -329,6 +329,23 @@ class PoscarData(Dict2Data):
329
329
  "Returns the symbols of the atoms in the poscar data without numbers"
330
330
  return np.array([lab.split()[0] for lab in self.labels])
331
331
 
332
+ @property
333
+ def G(self):
334
+ """Return metric tensor to be used with fractional coordinates.
335
+
336
+ >>> D2 = points @ self.G @ points.T # assuming points is Nx3 numpy array, D2 is NxN matrix whose elements are dot product of coordinates in 3D space.
337
+ >>> assert (self.metric(points) == np.sqrt(np.diag(D2))).all()
338
+
339
+ Note: You can use `self.metric(points)` instead of doing a long operation like `np.sqrt(np.diag(points @ self.G @ points.T))`.
340
+ """
341
+ return self.basis @ self.basis.T # becuase our vectors are row, transpose comes later
342
+
343
+ def metric(self, points):
344
+ """Shortcut for `np.linalg.norm(self.to_cartesian(points),axis=<1 or 0>)`. `points` are assumed as fractional coordinates in `self.basis`.
345
+ You can compute metric from any point other than origin by just subtracting that point, e.g. `points - 0.5` will get metric from center of cell (1/2,1/2,1/2).
346
+ """
347
+ return np.linalg.norm(self.to_cartesian(points),axis=1 if np.ndim(points) == 2 else 0)
348
+
332
349
  def get_sites(self, type_or_indices, as_coords=False):
333
350
  "Shortcut method for `POSCAR.data.positions[POSCAR.data.types['name']]` or with regular indexing."
334
351
  points = self.coords if as_coords else self.positions
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ipyvasp
3
- Version: 0.9.5
3
+ Version: 0.9.7
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,8 +2,8 @@ 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=GxG0C4lwVGvBYIy3jwR1kahWR7L6kJlqjIiQGgESjcM,104135
5
- ipyvasp/_version.py,sha256=UvB3IZAWAs7vV6H9dpZvZPryrSNIyF5_bowVS4_YGFA,23
6
- ipyvasp/bsdos.py,sha256=1rG68S-dLEYveIWGK7r8CRa7Qqlqno0l1ncfo2ocihk,30424
5
+ ipyvasp/_version.py,sha256=83qFJMFAgvdHV5e8Nh9ByUaQinNxBUPlTKjxfpge3xM,23
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
9
  ipyvasp/lattice.py,sha256=t4s1qh6IJsoeXcCa9M9IhjAQp2s78lqiGhOfEkCW19s,30638
@@ -15,11 +15,11 @@ ipyvasp/widgets.py,sha256=hwCviQn5NmxFz15DTS2nKKJ0kdBq8taGude46KNDOtU,46605
15
15
  ipyvasp/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  ipyvasp/core/parser.py,sha256=C3CaZsJbPME_ttYlYy4DXeOdL7dnkXs-cHRwFZL6bio,38058
17
17
  ipyvasp/core/plot_toolkit.py,sha256=3RoPsND5gPssBSfS5H4TjoZ2Qz7B97vpxeKadc2cRRs,36046
18
- ipyvasp/core/serializer.py,sha256=XpqnfVGsUXiN2CuVRPyqsSVouxRBO-UH6AnsHnPYvZY,36729
18
+ ipyvasp/core/serializer.py,sha256=gghH1VK-LytzyRDast0Ko-ueBklWyp9mp6dkvPxI95g,37791
19
19
  ipyvasp/core/spatial_toolkit.py,sha256=8DBYTiBFWJ7OBKuvOPw7UoEVCyNjJhSW0OcudjYZvAw,14748
20
- ipyvasp-0.9.5.dist-info/LICENSE,sha256=F3SO5RiAZOMfmMGf1KOuk2g_c4ObvuBJhd9iBLDgXoQ,1263
21
- ipyvasp-0.9.5.dist-info/METADATA,sha256=Vfq6b9vA2i5LjHBcUTb8KkXkkCK3jldhXPNUm27MvsQ,2420
22
- ipyvasp-0.9.5.dist-info/WHEEL,sha256=iYlv5fX357PQyRT2o6tw1bN-YcKFFHKqB_LwHO5wP-g,110
23
- ipyvasp-0.9.5.dist-info/entry_points.txt,sha256=C7m0Sjmr14wFjflCkWXLzr5N6-cQj8uJC9n82mUtzt8,44
24
- ipyvasp-0.9.5.dist-info/top_level.txt,sha256=ftziWlMWu_1VpDP1sRTFrkfBnWxAi393HYDVu4wRhUk,8
25
- ipyvasp-0.9.5.dist-info/RECORD,,
20
+ ipyvasp-0.9.7.dist-info/LICENSE,sha256=F3SO5RiAZOMfmMGf1KOuk2g_c4ObvuBJhd9iBLDgXoQ,1263
21
+ ipyvasp-0.9.7.dist-info/METADATA,sha256=5qUCLJfVl_yy9LGkgFmKaEKHU6HMrkRvZ2leqAERUJE,2420
22
+ ipyvasp-0.9.7.dist-info/WHEEL,sha256=iYlv5fX357PQyRT2o6tw1bN-YcKFFHKqB_LwHO5wP-g,110
23
+ ipyvasp-0.9.7.dist-info/entry_points.txt,sha256=C7m0Sjmr14wFjflCkWXLzr5N6-cQj8uJC9n82mUtzt8,44
24
+ ipyvasp-0.9.7.dist-info/top_level.txt,sha256=ftziWlMWu_1VpDP1sRTFrkfBnWxAi393HYDVu4wRhUk,8
25
+ ipyvasp-0.9.7.dist-info/RECORD,,