pymatgen icon indicating copy to clipboard operation
pymatgen copied to clipboard

Critic2Caller.from_path error

Open pjf295 opened this issue 4 years ago • 2 comments

Provide any example files that are needed to reproduce the error, especially if the bug pertains to parsing of a file.

Expected behavior Properly return with a Critic2Caller object.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: CentOS 7.9.2009
  • Version '2020.12.31'

Additional context The files in the example are quite large and it would be inappropriate to include them here. This is especially true in that hte error seems to prevent the files from being read at all. Note also that manually running Critic2 on the same files (constructing the sum of AECCAR0 and AECCAR2 within Critic2) works fine.

The Critic2Caller's from_path() method is a convenience method that aggregates CHGCAR AECCAR0 and AECCAR2. The method constructs the sum of the core and valence charge densities in a temporary file and then runs critic2 according to the documentation. When, however, I presented the from_path() method with a directory containing these files the following error occurred. Note that running critic2 manually worked without problem. In addition, the documentation claims that there is another method of Critic2Caller, namely from_chgcar() available, but in fact, it is not defined. Attempting to bring up the source results in an 404 error on github and, of course, a direct attempt to import the method also fails. The source also appears to be missing for Critic2Analysis.

The code was run under python 3.8.5/ipython 7.20.0 of anaconda.

In [1]: from pymatgen.command_line.critic2_caller import Critic2Analysis,Critic2Caller, CriticalPoint, CriticalPointType In [2]: critic2 = Critic2Caller.from_path('.') /home/paulfons/miniconda3/lib/python3.8/site-packages/pymatgen/command_line/bader_caller.py:458: UserWarning: Multiple files detected, using .


TypeError Traceback (most recent call last) in ----> 1 critic2 = Critic2Caller.from_path('.')

~/miniconda3/lib/python3.8/site-packages/pymatgen/command_line/critic2_caller.py in from_path(cls, path, suffix, zpsp) 299 chgcar_ref = aeccar0.linear_add(aeccar2) if (aeccar0 and aeccar2) else None 300 --> 301 return cls(chgcar.structure, chgcar, chgcar_ref, zpsp=zpsp) 302 303

~/miniconda3/lib/python3.8/site-packages/monty/dev.py in decorated(*args, **kwargs) 94 if not self.condition: 95 raise RuntimeError(self.message) ---> 96 return _callable(*args, **kwargs) 97 98 return decorated

~/miniconda3/lib/python3.8/site-packages/pymatgen/command_line/critic2_caller.py in init(self, structure, chgcar, chgcar_ref, user_input_settings, write_cml, write_json, zpsp) 189 190 if chgcar and isinstance(chgcar, VolumetricData): --> 191 chgcar.write_file("int.CHGCAR") 192 elif chgcar: 193 os.symlink(chgcar, "int.CHGCAR")

~/miniconda3/lib/python3.8/site-packages/pymatgen/io/vasp/outputs.py in write_file(self, file_name, vasp4_compatible) 3756 f.write("".join(self.data_aug.get(data_type, []))) 3757 -> 3758 write_spin("total") 3759 if self.is_spin_polarized and self.is_soc: 3760 write_spin("diff_x")

~/miniconda3/lib/python3.8/site-packages/pymatgen/io/vasp/outputs.py in write_spin(data_type) 3754 if count % 5 != 0: 3755 f.write(" " + "".join(lines) + " \n") -> 3756 f.write("".join(self.data_aug.get(data_type, []))) 3757 3758 write_spin("total")

TypeError: can only join an iterable

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

pjf295 avatar Mar 08 '21 06:03 pjf295

Thanks @pjf295, this is due to a recent change in #2080. The call on line 301 just needs to be changed to cls.from_chgcar(...).

mkhorton avatar Mar 08 '21 20:03 mkhorton

Actually, my mistake, this precedes that PR. Let me look into it

mkhorton avatar Mar 08 '21 20:03 mkhorton