picometer 0.4.0__tar.gz → 0.5.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.
@@ -1,8 +1,9 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: picometer
3
- Version: 0.4.0
3
+ Version: 0.5.1
4
4
  Summary: Precisely define and calculate measurements across multiple crystal structures
5
5
  License: MIT
6
+ License-File: LICENSE
6
7
  Author: Daniel Tchoń
7
8
  Requires-Python: >=3.10
8
9
  Classifier: License :: OSI Approved :: MIT License
@@ -11,6 +12,7 @@ Classifier: Programming Language :: Python :: 3.10
11
12
  Classifier: Programming Language :: Python :: 3.11
12
13
  Classifier: Programming Language :: Python :: 3.12
13
14
  Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
14
16
  Requires-Dist: hikari-toolkit (>=0.2.3)
15
17
  Requires-Dist: numpy (>=2)
16
18
  Requires-Dist: pandas (>=2)
@@ -141,8 +143,7 @@ The following instructions are currently supported by picometer:
141
143
  - fit `plane` to the currect atom / centroid selection;
142
144
  - **Evaluation instructions**
143
145
  - write out fractional `coordinates` of currently selected centroids or atoms.
144
- - write out `displacement` parameters of currently selected centroids or atoms
145
- (note: currently does not correctly handle symmetry transformations).
146
+ - write out `displacement` parameters of currently selected centroids or atoms.
146
147
  - measure `distance` between 2 selected objects; if the selection includes
147
148
  groups of atoms, measure closes distance to the group of atoms.
148
149
  - measure `angle` between 2–3 selected objects: planes, lines, or (ordered) atoms.
@@ -121,8 +121,7 @@ The following instructions are currently supported by picometer:
121
121
  - fit `plane` to the currect atom / centroid selection;
122
122
  - **Evaluation instructions**
123
123
  - write out fractional `coordinates` of currently selected centroids or atoms.
124
- - write out `displacement` parameters of currently selected centroids or atoms
125
- (note: currently does not correctly handle symmetry transformations).
124
+ - write out `displacement` parameters of currently selected centroids or atoms.
126
125
  - measure `distance` between 2 selected objects; if the selection includes
127
126
  groups of atoms, measure closes distance to the group of atoms.
128
127
  - measure `angle` between 2–3 selected objects: planes, lines, or (ordered) atoms.
@@ -0,0 +1,8 @@
1
+ # read version from installed package
2
+ from importlib.metadata import PackageNotFoundError, version
3
+
4
+
5
+ try:
6
+ __version__ = version('picometer')
7
+ except PackageNotFoundError:
8
+ __version__ = '0+unknown'
@@ -176,7 +176,9 @@ class AtomSet(Shape):
176
176
  uij = self.fract_uij # shape: (n_atoms, 3, 3)
177
177
  mask = ~np.isnan(uij).all(axis=(1, 2)) # atoms with defined Uij
178
178
  if np.any(mask):
179
- uij_rot = (s := symm_op.tf) @ uij[mask] @ s.T
179
+ abc_r = [self.base.a_r, self.base.b_r, self.base.c_r]
180
+ k = np.diag([1 / a for a in abc_r]) @ symm_op.tf @ np.diag(abc_r)
181
+ uij_rot = k @ uij[mask] @ k.T
180
182
  data.loc[mask, 'U11'] = uij_rot[:, 0, 0]
181
183
  data.loc[mask, 'U22'] = uij_rot[:, 1, 1]
182
184
  data.loc[mask, 'U33'] = uij_rot[:, 2, 2]
@@ -185,6 +187,21 @@ class AtomSet(Shape):
185
187
  data.loc[mask, 'U23'] = uij_rot[:, 1, 2]
186
188
  return self.__class__(self.base, data)
187
189
 
190
+ @property
191
+ def u_cartesian_eigenvalues(self):
192
+ u_columns = ['U11', 'U12', 'U13', 'U22', 'U23', 'U33']
193
+ eigenvalues = np.full((len(self), 3), np.nan)
194
+ if not set(u_columns).issubset(self.table.keys()):
195
+ return eigenvalues
196
+ u_fract = self.fract_uij # Nx3n3 stack of abc-normalized U_cif tensors
197
+ a_mat = self.base.A_d.T # fractional to orthogonal cartesian metric
198
+ n_mat = np.diag([self.base.a_r, self.base.b_r, self.base.c_r])
199
+ u_star = (n_mat @ u_fract) @ n_mat # eq. 4b @ S0021889802008580
200
+ u_cart = (a_mat @ u_star) @ a_mat.T # eq. 3a @ S0021889802008580
201
+ mask = ~self.table[u_columns].isna().any(axis=1)
202
+ eigenvalues[mask, :] = np.linalg.eigh(u_cart[mask, :, :])[0]
203
+ return eigenvalues
204
+
188
205
  @property
189
206
  def centroid(self) -> np.ndarray:
190
207
  """A 3-vector with average atom position."""
@@ -225,7 +225,8 @@ class LoadInstructionHandler(BaseInstructionHandler):
225
225
  if 'Uiso' not in atoms.table.columns:
226
226
  atoms.table['Uiso'] = pd.NA
227
227
  u_equiv = atoms.table[['U11', 'U22', 'U33']].mean(axis=1)
228
- atoms.table['Uiso'].fillna(u_equiv, inplace=True)
228
+ mask = atoms.table['Uiso'].isna()
229
+ atoms.table.loc[mask, 'Uiso'] = u_equiv[mask]
229
230
 
230
231
  if self.processor.settings['complete_umatrix_from_uiso']:
231
232
  u_columns = ['U11', 'U12', 'U13', 'U22', 'U23', 'U33']
@@ -359,6 +360,11 @@ class DisplacementInstructionHandler(SerialInstructionHandler):
359
360
  value = getattr(displacements, suffix, None)
360
361
  if value is not None:
361
362
  self.processor.evaluation_table.loc[ms_key, label_] = value
363
+ if self.processor.settings['displacement_get_cartesian_eigenvalues']:
364
+ for label, es in zip(focus.table.index, focus.u_cartesian_eigenvalues):
365
+ for e, suffix in zip(es, ['Uce1', 'Uce2', 'Uce3']):
366
+ label_ = label + '_' + suffix
367
+ self.processor.evaluation_table.loc[ms_key, label_] = e
362
368
  logger.info(f'Noted displacement for current selection in model state {ms_key}')
363
369
 
364
370
 
@@ -19,6 +19,7 @@ class DefaultSettings:
19
19
  """Store default values of all settings. Use `AnyValue` if no default."""
20
20
  auto_write_unit_cell: bool = True
21
21
  clear_selection_after_use: bool = True
22
+ displacement_get_cartesian_eigenvalues: bool = False
22
23
  complete_uiso_from_umatrix: bool = False
23
24
  complete_umatrix_from_uiso: bool = False
24
25
 
@@ -1,5 +1,6 @@
1
1
  settings:
2
2
  auto_write_unit_cell: True
3
3
  clear_selection_after_use: True
4
+ displacement_get_cartesian_eigenvalues: False
4
5
  complete_uiso_from_umatrix: False
5
6
  complete_umatrix_from_uiso: False
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "picometer"
3
- version = "0.4.0"
3
+ version = "0.5.1"
4
4
  description = "Precisely define and calculate measurements across multiple crystal structures"
5
5
  authors = ["Daniel Tchoń"]
6
6
  license = "MIT"
@@ -1,4 +0,0 @@
1
- # read version from installed package
2
- from importlib.metadata import version
3
-
4
- __version__ = version("picometer")
File without changes
File without changes
File without changes