kinisi icon indicating copy to clipboard operation
kinisi copied to clipboard

`ConductivityAnalyzer` with multiple species

Open PythonFZ opened this issue 7 months ago • 10 comments

When computing the Einstein Helfand ionic conductivity e.g. in my case for an ionic liquid BMIM BF4 I need to compute the MSD of the translational dipole of the system

$$ M(t) = q \sum z_i \vec{r}_i(t) $$

over all charged species $i$ with their charge $z_i$ and position $\vec{r}_i(t)$.

Can you provide me with an example on how to compute this? I have only found this test line for a single ionic species

https://github.com/kinisi-dev/kinisi/blob/29e4c616b6091a3201a68c288c0ded6c55665f54/kinisi/tests/test_conductivity_analyzer.py#L25

but I need to compute the COM translational dipole from all ionic species in my system.

Is this possible, because the documentation https://kinisi.readthedocs.io/en/latest/ase_COG.html states

Only identical molecules are supported.

for computing the diffusion.

PythonFZ avatar Sep 10 '25 12:09 PythonFZ

I think I understand the question, though correct me if I am wrong.

The ConductivityAnalyzer computes the centre-of-mass of all species defined as specie and then calculates the mean-squared displacement of this (and hence the diffusion coefficient of that). So I think, if you have run a simulation and you want to see how the dipole over all the ionic species is moving, then you need to pass all of the species in BMIM BF4 as specie (I think this takes a list or scipp.array of strings).

However, if your simulation has only BMIM BF4 in it and you have some drift correction on the simulation, I think you will end up with a lot of 0s...

Please let me know if that makes any sense at all.

arm61 avatar Sep 10 '25 14:09 arm61

The issue I am facing is, that both my species are composed of multiple atoms, i.e. $[BF_4]^{-1}$ and $[BMIM]^{+1}$ thus I think I can't use specie but need to use specie_indices?

The simulation is NVT and, unless this is somewhere implict, no drift correction has been applied and thus the dipole moment of the system should move over time.

I am referring to Eq. 1 and 2 here https://doi.org/10.1021/acs.jctc.3c00562 - this is what the ConductivityAnalyzer does, or am I understanding it wrong?

I'd also be happy to add documentation for this feature once I fully understand how to use it correctly.

PythonFZ avatar Sep 10 '25 14:09 PythonFZ

I think you just need to name all the elements in BMIM BF4 as specie.

arm61 avatar Sep 11 '25 08:09 arm61

That would be difficult, because I only know the charge per molecule. I am also not sure, if that would be entirely correct, because the charge distribution over the molecule can also change in time and assigning the charge to the COM might introduce some artifacts.

I think for now, I'll compute the COM per molecule and create species A for BF4 and B for BMIM and then assign the charges of +/- 1. In this case, I probably can't use the unwrapping code you provide with kinisi but need to use my own though.

PythonFZ avatar Sep 11 '25 11:09 PythonFZ

Writing your own COM code was @jd15489's suggestion. It may be possible to do something fun with unpacking the kinisi API, it you really want to. This would involve (https://github.com/kinisi-dev/kinisi/blob/2429fc5e45212a05cb9bd498c1954bc543ba8fed/kinisi/conductivity_analyzer.py#L91C9-L103C10):

  • Running the super()._from_* method once for the BF4 and again for the BMIM to obtain two parser objects.
  • Combine the Parser.trajectory scipp arrays and feed these into the calculate_mstd function

arm61 avatar Sep 11 '25 11:09 arm61

Sorry we can't be more helpful, you really are at the bleeding edge of kinisi use.

arm61 avatar Sep 11 '25 11:09 arm61

@arm61 I've taken your suggestion into the draft PR https://github.com/kinisi-dev/kinisi/pull/179 and would be very happy, if you could give feedback if this is of interest for kinisi and if the API, which is a bit different to the kinisi API up until now, would be good or if you have a suggestion on how to update it.

PythonFZ avatar Sep 11 '25 12:09 PythonFZ

Very interesting. Thanks for the draft. I have asked @jd15489 to take a look at it, as well as myself.

arm61 avatar Sep 11 '25 12:09 arm61

Your feedback is appreciated. It's a very fast draft and gives reasonable results but there are some parts of the kinisi code I have to admit I do not fully understand and thus could give wrong results.

PythonFZ avatar Sep 11 '25 12:09 PythonFZ

This would be addressed by #186

arm61 avatar Oct 16 '25 09:10 arm61