Skip to content

Dimensionality in DiffusionAnalyzer #193

Description

@shinichinishimura

Dear kinisi developers,

DiffusionAnalyzer in kinisi-2.0.2 raises a KeyError when the dimensionality is specified as 1D.
The three- and two-dimensional cases are ok.

OS: Rocky Linux 5.14.0-503.40.1.el9_5.x86_64
Python: 3.12.10
kinisi: 2.0.2
Scipp: 25.8.0

Reading Trajectory: 100%|████████████████████████████████████████████████████████████████████████████████████| 1000[/1000](http://localhost:24619/1000) [00:00<00:00, 2876.32it[/s](http://localhost:24619/s)]
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[55], line 6
      4 params_y = params.copy()
      5 params_y['dimension'] = 'y'
----> 6 diff_y = DiffusionAnalyzer.from_ase(traj, **params_y)

File ~/.pyenv/versions/3.12.10/lib/python3.12/site-packages/kinisi/diffusion_analyzer.py:206, in DiffusionAnalyzer.from_ase(cls, trajectory, specie, time_step, step_skip, dtype, dt, dimension, distance_unit, specie_indices, masses, progress)
    162 @classmethod
    163 def from_ase(
    164     cls,
   (...)    175     progress: bool = True,
    176 ) -> 'DiffusionAnalyzer':
    177     """
    178     Constructs the necessary :py:mod:`kinisi` objects for analysis from an ASE trajectory.
    179 
   (...)    204     :returns: The :py:class:`DiffusionAnalyzer` object with the mean-squared displacement calculated.
    205     """
--> 206     p = super()._from_ase(
    207         trajectory=trajectory,
    208         specie=specie,
    209         time_step=time_step,
    210         step_skip=step_skip,
    211         dtype=dtype,
    212         dt=dt,
    213         dimension=dimension,
    214         distance_unit=distance_unit,
    215         specie_indices=specie_indices,
    216         masses=masses,
    217         progress=progress,
    218     )
    219     p._da = calculate_msd(p.trajectory, progress)
    220     return p

File ~/.pyenv/versions/3.12.10/lib/python3.12/site-packages/kinisi/analyzer.py:253, in Analyzer._from_ase(cls, trajectory, specie, time_step, step_skip, dtype, dt, dimension, distance_unit, specie_indices, masses, progress)
    248 """
    249 Constructs the necessary :py:mod:`kinisi` objects for analysis from a single or a list of
    250 :py:class:`ase.io.trajectory.Trajectory` objects.
    251 """
    252 if dtype is None:
--> 253     p = ASEParser(
    254         atoms=trajectory,
    255         specie=specie,
    256         time_step=time_step,
    257         step_skip=step_skip,
    258         dt=dt,
    259         dimension=dimension,
    260         distance_unit=distance_unit,
    261         specie_indices=specie_indices,
    262         masses=masses,
    263         progress=progress,
    264     )
    265     return cls(p)
    266 elif dtype == 'identical':

File ~/.pyenv/versions/3.12.10/lib/python3.12/site-packages/kinisi/ase.py:82, in ASEParser.__init__(self, atoms, specie, time_step, step_skip, dt, dimension, distance_unit, specie_indices, drift_indices, masses, progress)
     76 atoms, coords, latt = self.get_structure_coords_latt(atoms, distance_unit, progress)
     78 specie_indices, drift_indices = super().get_specie_and_drift_indices(
     79     specie, specie_indices, drift_indices, atoms
     80 )
---> 82 super().__init__(
     83     coords=coords,
     84     latt=latt,
     85     time_step=time_step,
     86     step_skip=step_skip,
     87     dt=dt,
     88     specie_indices=specie_indices,
     89     drift_indices=drift_indices,
     90     masses=masses,
     91     dimension=dimension,
     92 )

File ~/.pyenv/versions/3.12.10/lib/python3.12/site-packages/kinisi/parser.py:116, in Parser.__init__(self, coords, latt, time_step, step_skip, dt, specie_indices, drift_indices, masses, dimension)
    114 self._slice = DIMENSIONALITY[dimension.lower()]
    115 drift_corrected = drift_corrected['dimension', self._slice]
--> 116 self.dimensionality = drift_corrected.sizes['dimension'] * sc.units.dimensionless
    118 self.displacements = drift_corrected['particle', indices]
    119 self._volume = np.prod(latt.values[0].diagonal()) * latt.unit**3

KeyError: 'dimension'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions