pymatgen icon indicating copy to clipboard operation
pymatgen copied to clipboard

ValueError: zero-size array to reduction operation maximum which has no identity

Open Arindamsannyal opened this issue 3 years ago • 2 comments

Dear Sir

I am trying to calculate the diffusivity of Li ions on a Li metal surface from the VASP AIMD output files (XDATCAR, vasprun.xml) by using the pymatgen. I have used the following code:


%matplotlib inline

import numpy as np import pickle import matplotlib.pyplot as plt import collections import os

from pymatgen.core.trajectory import Trajectory from pymatgen.core import Structure from pymatgen.io.vasp.outputs import Xdatcar from pymatgen.analysis.diffusion_analyzer import DiffusionAnalyzer,
get_arrhenius_plot, get_extrapolated_conductivity from pymatgen_diffusion.aimd.pathway import ProbabilityDensityAnalysis #from pymatgen_diffusion.aimd.van_hove import VanHoveAnalysis from pymatgen.io.vasp.outputs import Vasprun

traj = Trajectory.from_file("XDATCAR")

diff = DiffusionAnalyzer.from_structures(traj, 'Li', 298, 1, 1)

diff.plot_msd()

However, running the code in Jupyter notebook, I got the following error:

ValueError: zero-size array to reduction operation maximum which has no identity

I have checked the code for other system such as water. In that case the code works fine, however for a system of only one type of ions, the code gave me that error. Can you please suggest me the reason of this error and way to solve this issue. Thank you very much.

Best Regards Arindam Sannyal VASP-Output.zip

Arindamsannyal avatar Jan 11 '22 05:01 Arindamsannyal

I think the reason is that you only have one species in your trajectory, therefore, your framework_indices is empty. A quick fix could be the following:

if len(framework_indices) == 0:
    dc = displacements
else:
    framework_disp = displacements[framework_indices]
    drift = np.average(framework_disp, axis=0)[None, :, :]
    dc = displacements - drift

It looks like no one is maintaining the DiffusionAnalyzer module anymore. I asked a question about the drift and why it is required, but got no reply. If you know anything about it, I would like to hear your opinion.

jic198 avatar Jan 12 '22 20:01 jic198

Dear Sir

I am extremely sorry for being late. Sir, thank you very much for your kind reply. Sir, your suggestion solved the ValueError problem, however, now the following AttributeError is raised for the system of having a singly type species.

AttributeError: 'DiffusionAnalyzer' object has no attribute 'dt'

Sir, can you please suggest how to solve this error. Thank you very much, Sir.

And, Sir, regarding the drift, I am sorry that I have no idea about it.

Arindamsannyal avatar Jan 19 '22 09:01 Arindamsannyal