Giter Club home page Giter Club logo

materialsproject / pymatgen Goto Github PK

View Code? Open in Web Editor NEW
1.4K 113.0 825.0 994.15 MB

Python Materials Genomics (pymatgen) is a robust materials analysis code that defines classes for structures and molecules with support for many electronic structure codes. It powers the Materials Project.

Home Page: https://pymatgen.org

License: Other

Python 99.53% Cython 0.45% Jupyter Notebook 0.02%
materials science materials-science materials-informatics python

pymatgen's People

Contributors

andrew-s-rosen avatar awvio avatar cedergroupclusters avatar comprhys avatar computron avatar davidwaroquiers avatar dbroberg avatar espottesmith avatar fraricci avatar gmatteo avatar hautierg avatar jageo avatar janosh avatar jmmshn avatar matk86 avatar mbkumar avatar mkhorton avatar montoyjh avatar nisse3000 avatar nwinner avatar pre-commit-ci[bot] avatar rkingsbury avatar samblau avatar sdacek avatar setten avatar shyamd avatar shyuep avatar utf avatar wmdrichards avatar xhqu1981 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pymatgen's Issues

remove_species() behavior

It seems these two methods don't do the same thing:

(rs1 is a StructureEditor)

rs1.remove_species([Element('Li')])

rs1.remove_species([Specie('Li', 0)])

Why is this the case? It makes it difficult to use remove_species()

StructurePrediction code should not assume existence of tests or unittests.

The substitutor predictor has code that is meant to do unittests. Furthermore, it assumes that the test_data directory is present.

This assumption is not valid. Esp when releasing packages, the tests directories are all excluded from the final package. The code base should stand on its own without the tests directory. The tests directory should purely be used for unittesting only. Also, there shouldn't be code in substitutor_predictor.py purely for the sake of helping unittesting.

common oxidation states of Vanadium

It looks like only +5 is listed as a common oxidation state of Vanadium:
el = Element('V')
print el.common_oxidation_states

(5,)

Should +2, +3, and +4 also be on the list?

Note that some of the BatteryAnalyzer code in a different Materials Project repo needs to know how far you can reduce a metal. Currently it was using min(a.common_oxidation_states), but this fails spectacularly for V as it doesn't realize you can go down to 3+ and even 2+. It also fails a bit more silently for Cr, Ti, and Mo. Note that you can't use the min_oxidation_state property of an Element, that usually goes all the way negative

ionic radii labeled as pm when they are Angstroms?

myval
pymatgen.analysis.defects.point_defects.ValenceIonicRadiusEvaluator instance at 0x7841560
myval.radii
{'Mn': 0.785 pm, 'O': 1.26 pm, 'La': 1.172 pm}

I like working with Angstroms better anyway, but it was a little confusing.

VERSION
2.8.0

DATE
Sep 6 2013

pymatgen.analysis.diffraction.xrd XRDCalculator.get_xrd_plot error

Here is an error
File "/usr/local/lib/python2.7/dist-packages/pymatgen/analysis/diffraction/xrd.py", line 298, in get_xrd_plot
for two_theta, i, hkls in self.get_xrd_data(structure):
ValueError: too many values to unpack

Correction :
for two_theta, i, hkls, d in self.get_xrd_data(structure):

get_xrd_data returns also d_hkl (interplanar spacing) which must be read in the list at line 298
http://pymatgen.org/_modules/pymatgen/analysis/diffraction/xrd.html#XRDCalculator.get_xrd_data

test suite has 3 failures

I get some failure in running the test on the main branch:

======================================================== FAILURES =========================================================
_______________________________________ EwaldElectrostaticModelTest.test_get_energy _______________________________________

self = <pymatgen.analysis.tests.test_energy_models.EwaldElectrostaticModelTest testMethod=test_get_energy>

  self.assertAlmostEqual(m.get_energy(s), 44.1070954178)

E AssertionError: 661.64440945223498 != 44.1070954178 within 7 places

pymatgen/analysis/tests/test_energy_models.py:45: AssertionError
______________________________________________ EwaldSummationTest.test_init _______________________________________________

self = <pymatgen.analysis.tests.test_ewald.EwaldSummationTest testMethod=test_init>

                         "Real space energy incorrect!")

E AssertionError: Real space energy incorrect!

pymatgen/analysis/tests/test_ewald.py:22: AssertionError

self = <pymatgen.transformations.tests.test_standard_transformations.OrderDisorderedStructureTransformationTest testMethod=test_best_first>

                         'got incorrect energy')

E AssertionError: got incorrect energy

pymatgen/transformations/tests/test_standard_transformations.py:341: AssertionError

Issue with symmetryfinder

When trying to get the unit cell from symmetry.finder.SymmetryFinder for the structure with mpid "mp-25145", I am getting error.

Code:
struct = mp.get_structure_by_material_id("mp-25145")
uc = SymmetryFinder(struct).get_conventional_standard_structure()

Error:

ValueError Traceback (most recent call last)
in ()
7 continue
8
----> 9 uc = SymmetryFinder(struct).get_conventional_standard_structure()

/home/mbkumar/lbnl/pymatgen/pymatgen/symmetry/finder.pyc in get_conventional_standard_structure(self)
683 for c in range(len(sorted_dic)):
684 transf[c][sorted_dic[c]['orig_index']] = 1
--> 685 latt = Lattice(new_matrix)
686
687 elif latt_type == "triclinic":

/home/mbkumar/lbnl/pymatgen/pymatgen/core/lattice.pyc in init(self, matrix)
52 lattice vectors [10,0,0], [20,10,0] and [0,0,30].
53 """
---> 54 m = np.array(matrix, dtype=np.float64).reshape((3, 3))
55 lengths = np.sqrt(np.sum(m ** 2, axis=1))
56 angles = np.zeros(3)

ValueError: total size of new array must be unchanged

Bug in Lattice.get_most_compact_basis

It appears that get_most_compact_basis has a anychange local variable that is effectively unused. Right before the final part of the "while" loop, it sets anychange=True followed by if anychange: break.

Also, unittests are needed to know what is the expected output of this method.

periodic_table.json not found

After installing the package the "periodic_table.json" file is moved to [base]/data whereas the periodic_table.py file in [base]/pymatgen/core expects it to be in [base]/pymatgen/core

Therefore the _load__pt_data function fails with a "IOError: [Errno 2] No such file or directory:"

JSON question

Hi,

I'm trying to get tasks JSON reply.

First I go to https://www.materialsproject.org/rest/v1/materials/Fe2O3/vasp?API_KEY=MYAPIKEY

There I get (added newlines for clarity)

{"created_at": "2014-02-16T09:34:09.995518", "valid_response": true, "version": {"pymatgen": "2.9.1", "db": "2014.02.13", "rest": "1.0"},
"response": [{"energy": -67.16532048, "unit_cell_formula": {"Fe": 4.0, "O": 6.0},
"hubbards": {"Fe": 5.3, "O": 0.0},
"task_ids": ["mp-602261", "mp-714977", "mp-24972"]...

Then I try to go to: https://www.materialsproject.org/rest/v1/tasks/mp-714977?API_KEY=MYAPIKEY

I get "Page Not Found".

My ultimate goal is to get VASP incar/poscar/kpoints/potcar to run phonon calculation on top of the relaxed geometry of a material.

Any help will be appreciated,
thanks,
Alexandr.

Selective dynamics in Poscar does not work?

(mastenv)$ python test_selectivedynamics.py
Traceback (most recent call last):
File "test_selectivedynamics.py", line 9, in
mypos.selective_dynamics=mysd
File "/share/apps/virtualenv/mastenv/lib/python2.7/site-packages/pymatgen/io/vaspio/vasp_input.py", line 141, in setattr
if value:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

test_selectivedynamics.py>>>>>>>>>>>>>>
import pymatgen
import numpy as np
mypos=pymatgen.io.vaspio.Poscar.from_file("CONTCAR")
mypos.write_file("write_once_POSCAR")
mysd=np.zeros([sum(mypos.natoms),3],bool)
mysd[3][1]=True
mysd[3][0]=True
mysd[3][2]=True
mypos.selective_dynamics=mysd
mypos.write_file("write_sd_POSCAR")

These two changes fixed the problem on my local install. Changes in two spots....

CHANGE 1>>>>>>>>>>>>>>>
def setattr(self, name, value):
if name in ("selective_dynamics", "velocities"):
#2013-03-19 enclosing within a "try" statement:
try:
if value:
dim = np.array(value).shape
if dim[1] != 3 or dim[0] != len(self.structure):
raise ValueError(name + " array must be same length as" +
" the structure.")
except (ValueError):

CHANGE 2>>>>>>>>>>
for (i, site) in enumerate(self.structure):
coords = site.frac_coords if direct else site.coords
line = " ".join([format_str.format(c) for c in coords])
if not (self.selective_dynamics == None): #2013-03-19 "not none"
sd = ["T" if j else "F" for j in self.selective_dynamics[i]]
line += " %s %s %s" % (sd[0], sd[1], sd[2])
line += " " + site.species_string
lines.append(line)

Having trouble with matplotlib and band structures

I am trying to plot band structures using the following code:

from pymatgen import MPRester
from pymatgen.electronic_structure.plotter import BSPlotter

if __name__ == "__main__":
    MAPI_KEY = None  # You must change this to your Materials API key! (or set MAPI_KEY env variable)
    MP_ID = "mp-19017"  # You must change this to the mp-id of your compound of interest

    mpr = MPRester(MAPI_KEY)  # object for connecting to MP Rest interface

    my_bs = mpr.get_bandstructure_by_material_id(MP_ID)
    BSPlotter(my_bs).show()

Something seems to be wrong with my matplotlib configuration and the code trips over the tight_layout, giving me the following error:

tight_layout : falling back to Agg renderer
Traceback (most recent call last):
  File "/Users/ajain/Documents/code_testing/aj_scratch/aj_play/scratch.py", line 12, in <module>
    BSPlotter(my_bs).show()
  File "/Users/ajain/Documents/code_matgen/pymatgen_repo/pymatgen/electronic_structure/plotter.py", line 508, in show
    plt = self.get_plot(zero_to_efermi, ylim, smooth)
  File "/Users/ajain/Documents/code_matgen/pymatgen_repo/pymatgen/electronic_structure/plotter.py", line 492, in get_plot
    plt.tight_layout()
  File "/Library/Python/2.7/site-packages/matplotlib/pyplot.py", line 1055, in tight_layout
    fig.tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad)
  File "/Library/Python/2.7/site-packages/matplotlib/figure.py", line 1414, in tight_layout
    pad=pad, h_pad=h_pad, w_pad=w_pad)
  File "/Library/Python/2.7/site-packages/matplotlib/tight_layout.py", line 117, in auto_adjust_subplotpars
    tight_bbox_raw = union([ax.get_tightbbox(renderer) for ax in subplots])
  File "/Library/Python/2.7/site-packages/matplotlib/axes.py", line 8362, in get_tightbbox
    bb_xaxis = self.xaxis.get_tightbbox(renderer)
  File "/Library/Python/2.7/site-packages/matplotlib/axis.py", line 1008, in get_tightbbox
    ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw, renderer)
  File "/Library/Python/2.7/site-packages/matplotlib/axis.py", line 993, in _get_tick_bboxes
    extent = tick.label1.get_window_extent(renderer)
  File "/Library/Python/2.7/site-packages/matplotlib/text.py", line 747, in get_window_extent
    bbox, info = self._get_layout(self._renderer)
  File "/Library/Python/2.7/site-packages/matplotlib/text.py", line 300, in _get_layout
    ismath=False)
  File "/Library/Python/2.7/site-packages/matplotlib/backends/backend_agg.py", line 188, in get_text_width_height_descent
    renderer=self)
  File "/Library/Python/2.7/site-packages/matplotlib/texmanager.py", line 608, in get_text_width_height_descent
    page = iter(dvi).next()
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 65, in __iter__
    have_page = self._read()
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 121, in _read
    self._dispatch(byte)
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 209, in _dispatch
    self._fnt_def(k, c, s, d, a, l, n)
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 362, in _fnt_def
    tfm = _tfmfile(n[-l:])
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 872, in _tfmfile
    return _fontfile(texname, Tfm, '.tfm', _tfmcache)
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 862, in _fontfile
    filename = find_tex_file(texname + suffix)
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 843, in find_tex_file
    stderr=subprocess.PIPE)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1228, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

I can turn off tight layout (manually commenting it out), and the main portion of the band structure plot renders fine, but the x-labels and y-labels do not render and I get the following error:

Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib/figure.py", line 898, in draw
    func(*args)
  File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib/axes.py", line 1997, in draw
    a.draw(renderer)
  File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib/axis.py", line 1042, in draw
    ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw, renderer)
  File "/Library/Python/2.7/site-packages/matplotlib/axis.py", line 993, in _get_tick_bboxes
    extent = tick.label1.get_window_extent(renderer)
  File "/Library/Python/2.7/site-packages/matplotlib/text.py", line 747, in get_window_extent
    bbox, info = self._get_layout(self._renderer)
  File "/Library/Python/2.7/site-packages/matplotlib/text.py", line 309, in _get_layout
    ismath=ismath)
  File "/Library/Python/2.7/site-packages/matplotlib/backends/backend_macosx.py", line 153, in get_text_width_height_descent
    renderer=self)
  File "/Library/Python/2.7/site-packages/matplotlib/texmanager.py", line 608, in get_text_width_height_descent
    page = iter(dvi).next()
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 65, in __iter__
    have_page = self._read()
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 121, in _read
    self._dispatch(byte)
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 209, in _dispatch
    self._fnt_def(k, c, s, d, a, l, n)
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 362, in _fnt_def
    tfm = _tfmfile(n[-l:])
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 872, in _tfmfile
    return _fontfile(texname, Tfm, '.tfm', _tfmcache)
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 862, in _fontfile
    filename = find_tex_file(texname + suffix)
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 843, in find_tex_file
    stderr=subprocess.PIPE)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1228, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib/figure.py", line 898, in draw
    func(*args)
  File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib/axes.py", line 1997, in draw
    a.draw(renderer)
  File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib/axis.py", line 1042, in draw
    ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw, renderer)
  File "/Library/Python/2.7/site-packages/matplotlib/axis.py", line 993, in _get_tick_bboxes
    extent = tick.label1.get_window_extent(renderer)
  File "/Library/Python/2.7/site-packages/matplotlib/text.py", line 747, in get_window_extent
    bbox, info = self._get_layout(self._renderer)
  File "/Library/Python/2.7/site-packages/matplotlib/text.py", line 309, in _get_layout
    ismath=ismath)
  File "/Library/Python/2.7/site-packages/matplotlib/backends/backend_macosx.py", line 153, in get_text_width_height_descent
    renderer=self)
  File "/Library/Python/2.7/site-packages/matplotlib/texmanager.py", line 608, in get_text_width_height_descent
    page = iter(dvi).next()
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 65, in __iter__
    have_page = self._read()
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 121, in _read
    self._dispatch(byte)
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 209, in _dispatch
    self._fnt_def(k, c, s, d, a, l, n)
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 362, in _fnt_def
    tfm = _tfmfile(n[-l:])
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 872, in _tfmfile
    return _fontfile(texname, Tfm, '.tfm', _tfmcache)
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 862, in _fontfile
    filename = find_tex_file(texname + suffix)
  File "/Library/Python/2.7/site-packages/matplotlib/dviread.py", line 843, in find_tex_file
    stderr=subprocess.PIPE)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1228, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Procar will not read in?

pymatgen version is 2.6.3 (pip install pymatgen --upgrade, at 17:30 2013-04-02)

import pymatgen
myprocar=pymatgen.io.vaspio.vasp_output.Procar('PROCAR')
Traceback (most recent call last):
File "", line 1, in
File "/share/apps/virtualenv/mastenv/lib/python2.7/site-packages/pymatgen/io/vaspio/vasp_output.py", line 1795, in init
self._read_file(filename)
File "/share/apps/virtualenv/mastenv/lib/python2.7/site-packages/pymatgen/io/vaspio/vasp_output.py", line 1805, in _read_file
self.name = lines[0]
TypeError: 'generator' object has no attribute 'getitem'

(mastenv)$ head PROCAR
PROCAR new format

of k-points: 32 # of bands: 234 # of ions: 39

k-point 1 : 0.12500000 0.12500000 0.12500000 weight = 0.03125000

band 1 # energy -44.06734077 # occ. 1.00000000

ion s p d f tot
1 0.000 0.000 0.000 0.000 0.000
2 0.000 0.000 0.000 0.000 0.000

Some MPRester queries return "local variable 'doc' referenced before assignment"

Okay:

a.get_dos_by_material_id("mp-24972")
<pymatgen.electronic_structure.dos.CompleteDos object at 0x15b74710>

Strange error - does this mean there is no dos for that material ID?:

a.get_dos_by_material_id("mp-510408")
Traceback (most recent call last):
File "", line 1, in
File "/home/tam/.local/lib/python2.7/site-packages/pymatgen/matproj/rest.py", line 254, in get_dos_by_material_id
data = self.get_data(material_id, prop="dos")
File "/home/tam/.local/lib/python2.7/site-packages/pymatgen/matproj/rest.py", line 146, in get_data
raise MPRestError(str(ex))
pymatgen.matproj.rest.MPRestError: local variable 'doc' referenced before assignment

Bug in pymatgen.core.lattice.py?

When trying to initialize Structure in core/structure.py, I am getting an error message.
Input to initializer:

  1. lattice of type "pymatgen.core.lattice.Lattice"
  2. species of type "List of strings"
  3. coords of type "List of numpy arrays of size 3"
  4. coords_are_cartesian=True
  5. site_properties=dict{"property_name":List of numbers}

Error Message:
File "voronoi_node_symmetry.py", line 34, in
voronoi_struct = Structure(voronoi_lattice, s, c, coords_are_cartesian=True, site_properties={"voronoi_data":p})
File "/Library/Python/2.7/site-packages/pymatgen/core/structure.py", line 297, in init
properties=prop))
File "/Library/Python/2.7/site-packages/pymatgen/core/sites.py", line 312, in init
self._fcoords = self._lattice.get_fractional_coords(coords)
File "/Library/Python/2.7/site-packages/pymatgen/core/lattice.py", line 104, in get_fractional_coords
return dot(cart_coords, self.inv_matrix)
ValueError: data type must provide an itemsize

the undefined behavior when calling function sprintf(symbol, "%s (%d)", symbol, num_spg) in _spglib.c

In pymatgen/dependencies/spglib-1.6.0/_spglib.c, the line 191:
sprintf(symbol, "%s (%d)", symbol, num_spg);
this function call will have undefined behavior because the source buff and target buff have an overlap.

That will lead to the wrong results when calling get_spacegroup_symbol() in some systems. For example, for spacegroup "Cmcm (63)", call get_spacegroup_symbol() will give only the number "(63)", not the Symbol "Cmcm", which will lead further error when building HighSymmKpath.

The author of spglib have fixed this problem in its newest version on github.
Please also fix it in pymatgen, thank you very much.

Trivial fitting in StructureFitter does not work.

I am not sure whether to classify this as a bug. But it is a very odd thing.
Try the following code

logging.basicConfig(level=logging.DEBUG)

Use the POSCAR.LiFePO4 from the test_files.

p = Poscar.from_file("test_files/POSCAR.LiFePO4", check_for_POTCAR=False)
s = p.structure
from pymatgen.analysis.structure_fitter import StructureFitter
fitter = StructureFitter(s, s)
print fitter.fit_found

This code should be fitting two identical structures (trivial case). Symmetry is turned off. In this case, simple_fit should result in an immediate fit.

Instead, it takes a full 5 secs to fit. And I get the following which shows that somehow, the initial identity fitting procedure has failed to produce a match. Eyeballing the debug output tells me that the sites seem to be in the exact same position, but the closest distance is somehow computed to be 1.3 A. Note that if I turn on symmetry, this problem disappears and the fit is done within 0.5secs. It does indicate that something is wrong in the test_rotations which is causing a problem.

DEBUG:pymatgen.analysis.structure_fitter:Trying candidate rotation :
Rot:
[[ 1.00000000e+00 0.00000000e+00 1.35525272e-20]
[ -1.69406589e-21 1.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 -4.37102915e-21 1.00000000e+00]]
tau
[ 0. 0. 0.]
DEBUG:pymatgen.analysis.structure_fitter:[ 0. 0. 0.] Li fits on [ 0. 0. 0.] Li
DEBUG:pymatgen.analysis.structure_fitter:[ 1.04101920e+01 3.03176700e+00 -6.86500000e-04] Li fits on [ 1.04101920e+01 3.03176700e+00 -6.86500000e-04] Li
DEBUG:pymatgen.analysis.structure_fitter:[ 5.20528000e+00 -9.35000000e-05 -2.37789150e+00] Li fits on [ 5.20528000e+00 -9.35000000e-05 -2.37789150e+00] Li
DEBUG:pymatgen.analysis.structure_fitter:[ 5.205318 3.0315435 -2.377689 ] Li fits on [ 5.205318 3.0315435 -2.377689 ] Li
DEBUG:pymatgen.analysis.structure_fitter:[ 2.27690836 4.54731145 -2.49612443] Fe fits on [ 2.27690836 4.54731145 -2.49612443] Fe
DEBUG:pymatgen.analysis.structure_fitter:[ 2.92874895 1.5159624 -0.11830796] Fe fits on [ 2.92874895 1.5159624 -0.11830796] Fe
DEBUG:pymatgen.analysis.structure_fitter:[ 7.48188705 4.5471246 -4.63707004] Fe fits on [ 7.48188705 4.5471246 -4.63707004] Fe
DEBUG:pymatgen.analysis.structure_fitter:[ 8.13372764 1.51577555 -2.25925357] Fe fits on [ 8.13372764 1.51577555 -2.25925357] Fe
DEBUG:pymatgen.analysis.structure_fitter:[ 0.98624255 1.51607687 -2.7664278 ] P fits on [ 0.98624255 1.51607687 -2.7664278 ] P
DEBUG:pymatgen.analysis.structure_fitter:[ 4.21854487 4.54796731 -0.38900679] P fits on [ 4.21854487 4.54796731 -0.38900679] P
DEBUG:pymatgen.analysis.structure_fitter:[ 6.19209113 1.51511969 -4.36637121] P fits on [ 6.19209113 1.51511969 -4.36637121] P
DEBUG:pymatgen.analysis.structure_fitter:[ 9.42439345 4.54701013 -1.9889502 ] P fits on [ 9.42439345 4.54701013 -1.9889502 ] P
DEBUG:pymatgen.analysis.structure_fitter:[ 0.45134146 4.54744114 -1.39103578] O fits on [ 0.45134146 4.54744114 -1.39103578] O
DEBUG:pymatgen.analysis.structure_fitter:[ 1.00649435 1.51570063 -1.22899166] O fits on [ 1.00649435 1.51570063 -1.22899166] O
DEBUG:pymatgen.analysis.structure_fitter:[ 1.72451712 0.2800334 -3.39894578] O fits on [ 1.72451712 0.2800334 -3.39894578] O
DEBUG:pymatgen.analysis.structure_fitter:[ 1.72442314 2.75091459 -3.39848116] O fits on [ 1.72442314 2.75091459 -3.39848116] O
DEBUG:pymatgen.analysis.structure_fitter:[ 3.481076 3.31200243 -1.02125134] O fits on [ 3.481076 3.31200243 -1.02125134] O
DEBUG:pymatgen.analysis.structure_fitter:[ 3.48114862 5.78239853 -1.02120044] O fits on [ 3.48114862 5.78239853 -1.02120044] O
DEBUG:pymatgen.analysis.structure_fitter:[ 4.1993318 4.54721898 -3.60672277] O fits on [ 4.1993318 4.54721898 -3.60672277] O
DEBUG:pymatgen.analysis.structure_fitter:[ 4.75374206 1.51577817 -3.76931419] O fits on [ 4.75374206 1.51577817 -3.76931419] O
DEBUG:pymatgen.analysis.structure_fitter:[ 5.65689394 4.54730883 -0.98606381] O fits on [ 5.65689394 4.54730883 -0.98606381] O
DEBUG:pymatgen.analysis.structure_fitter:[ 6.2113042 1.51586802 -1.14865523] O fits on [ 6.2113042 1.51586802 -1.14865523] O
DEBUG:pymatgen.analysis.structure_fitter:[ 6.92948738 0.28068847 -3.73417756] O fits on [ 6.92948738 0.28068847 -3.73417756] O
DEBUG:pymatgen.analysis.structure_fitter:[ 6.92956 2.75108457 -3.73412666] O fits on [ 6.92956 2.75108457 -3.73412666] O
DEBUG:pymatgen.analysis.structure_fitter:[ 8.68621286 3.31217241 -1.35689684] O fits on [ 8.68621286 3.31217241 -1.35689684] O
DEBUG:pymatgen.analysis.structure_fitter:[ 8.68611888 5.7830536 -1.35643222] O fits on [ 8.68611888 5.7830536 -1.35643222] O
DEBUG:pymatgen.analysis.structure_fitter:[ 9.40414165 4.54738637 -3.52638634] O fits on [ 9.40414165 4.54738637 -3.52638634] O
DEBUG:pymatgen.analysis.structure_fitter:[ 9.95929454 1.51564586 -3.36434222] O fits on [ 9.95929454 1.51564586 -3.36434222] O
DEBUG:pymatgen.analysis.structure_fitter:Closest dist too large! Closest dist = 1.31858818396
DEBUG:pymatgen.analysis.structure_fitter:Closest dist too large! Closest dist = 0.75949840042
DEBUG:pymatgen.analysis.structure_fitter:No candidates found.

use_external_qhull from PDAnalyzer

When generating a "profile" through the pdanalyzer it internally generates GrandPotentialPhaseDiagram that uses the default "use_external_qhull" which is True. There is no way of setting the use_external_qhull.

On systems without a functional scipy.spatial.Delaunay this will always fail.

Maybe use_external_qhull could be accessible through a kwarg on get_element_profile

XYZ file reader doesn't work for scientific notations in coordinates

Hi Shyue,

I am troubled by XYZ reader now. For the attached XYZ text, if I use smartio.read_mol to read it. All the exponents in the last column will be removed, which leads to very strange structures.

20
6_methyl_12cyano
C 2.39132145462 -0.700993488928 -7.22293142224e-06
C 1.16730636786 -1.38166622735 -2.77112970359e-06
C -0.0462078447832 -0.703253621312 7.25763973975e-06
C -0.0446745627711 0.715145777585 1.28599208666e-05
C 1.17063702541 1.3856617784 7.03984717718e-06
C 2.3835501347 0.693474260302 -2.75869204339e-06
H 1.14848963649 -2.46975173501 -6.2363287689e-06
H 1.17463663825 2.47337182313 1.10803379569e-05
H 3.31762811486 1.25180237659 -6.13629049593e-06
C -2.34243441853 0.705226646945 3.09963750684e-05
C -2.34471786848 -0.675897822192 2.47523176497e-05
H -3.264017739 -1.25260911129 3.00395200288e-05
N -1.19280872262 1.42229526752 2.46478341936e-05
N -1.20107794012 -1.40090704068 1.26672582223e-05
C 3.69216275092 -1.44795920242 -1.50462841396e-05
H 3.5334671294 -2.53131484452 -1.77090479454e-05
H 4.27277978214 -1.19364282351 0.892474148419
H 4.27277269957 -1.19363719569 -0.892507208765
C -3.56979943858 1.44201645038 4.6841037937e-05
N -4.58834672516 2.00150591825 6.02899938044e-05

Thanks.

Best regards,

Xiaohui

Failures in test_dilute_solution_model (sympy 0.7.5)

Hi all,

I have 3 unit tests failing in my branch in test_dilute_solution_model.
All of them use simpy so I guess it's due to a portability problem in sympy.
I'm using Python 2.7.3, sympy 0.7.5 and numpy 1.8..1

ERROR: test_plot_data_with_chem_pot (pymatgen.analysis.defects.tests.test_dilute_solution_model.DiluteSolutionModelTest)

Traceback (most recent call last):
File "/Users/gmatteo/Coding/git_branches/pymatgen/pymatgen/analysis/defects/tests/test_dilute_solution_model.py", line 66, in test_plot_data_with_chem_pot
trial_chem_pot=self.trial_mu,generate='plot')
File "/Users/gmatteo/Coding/git_branches/monty/monty/dev.py", line 88, in decorated
return _callable(_args, *_kwargs)
File "/Users/gmatteo/Coding/git_branches/pymatgen/pymatgen/analysis/defects/dilute_solution_model.py", line 372, in dilute_solution_model
x = nsolve(vector_func,mu,mu_vals,module="numpy")
File "/Users/gmatteo/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/sympy/solvers/solvers.py", line 2475, in nsolve
x = findroot(f, x0, J=J, **kwargs)
File "/Users/gmatteo/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/sympy/mpmath/calculus/optimization.py", line 975, in findroot
% (norm(f(*xl))**2, tol))
ValueError: Could not find root within given tolerance. (1.43144e-12 > 2.1684e-19)
Try another starting point or tweak arguments.

ERROR: test_plot_data_without_chem_pot (pymatgen.analysis.defects.tests.test_dilute_solution_model.DiluteSolutionModelTest)

Traceback (most recent call last):
File "/Users/gmatteo/Coding/git_branches/pymatgen/pymatgen/analysis/defects/tests/test_dilute_solution_model.py", line 59, in test_plot_data_without_chem_pot
self.struct,self.e0,self.vac,self.asites,self.T,generate='plot')
File "/Users/gmatteo/Coding/git_branches/monty/monty/dev.py", line 88, in decorated
return _callable(_args, *_kwargs)
File "/Users/gmatteo/Coding/git_branches/pymatgen/pymatgen/analysis/defects/dilute_solution_model.py", line 372, in dilute_solution_model
x = nsolve(vector_func,mu,mu_vals,module="numpy")
File "/Users/gmatteo/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/sympy/solvers/solvers.py", line 2475, in nsolve
x = findroot(f, x0, J=J, **kwargs)
File "/Users/gmatteo/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/sympy/mpmath/calculus/optimization.py", line 975, in findroot
% (norm(f(*xl))**2, tol))
ValueError: Could not find root within given tolerance. (1.43144e-12 > 2.1684e-19)
Try another starting point or tweak arguments.
-------------------- >> begin captured stdout << ---------------------
[-7.952002320183595, -6.118608940188247]

--------------------- >> end captured stdout << ----------------------

ERROR: test_plot_data_without_chem_pot (pymatgen.analysis.defects.tests.test_dilute_solution_model.SoluteSiteFinderTest)

Traceback (most recent call last):
File "/Users/gmatteo/Coding/git_branches/pymatgen/pymatgen/analysis/defects/tests/test_dilute_solution_model.py", line 88, in test_plot_data_without_chem_pot
solute_concen=0.01)
File "/Users/gmatteo/Coding/git_branches/monty/monty/dev.py", line 88, in decorated
return _callable(_args, *_kwargs)
File "/Users/gmatteo/Coding/git_branches/pymatgen/pymatgen/analysis/defects/dilute_solution_model.py", line 916, in solute_site_preference_finder
mu_vals = compute_mus()
File "/Users/gmatteo/Coding/git_branches/pymatgen/pymatgen/analysis/defects/dilute_solution_model.py", line 897, in compute_mus
m0 = mu_red[mu[0]].subs([(mu[1],m1),(mu[2],m2)])
TypeError: list indices must be integers, not Symbol
-------------------- >> begin captured stdout << ---------------------
(u'mult', [1, 1])
(u'c0', array([[1, 0, 0],
[0, 1, 0],
[0, 0, 0]]))
(u'site_specie', [u'Al', u'Ni', u'Fe'])
(u'site_mu_map', [0, 1, 2])
(u'specie_site_index_map', [(0, 1), (1, 2), (2, 3)])
[[[-1 1]
[-1 0]
[-1 0]]

[[ 0 -1]
[ 1 -1]
[ 0 -1]]

[[ 0 0]
[ 0 0]
[ 1 1]]]
(u'Ni', u'Al')
(u'Al', u'Al')
(1, 1)
(u'se', -2.08)
(u'Al', u'Ni')
(u'Al', u'Ni')
(1, 2)
(u'Ni', u'Ni')
(2, 2)
(u'se', -1.674)
(u'dE', array([[ 6.56 , 3.98 ],
[-0.41 , 7.101],
[-2.08 , -1.674]]))
1
-mu0
(1, -1, 6.5599999999999996)
-mu0 + mu1
(1, -1, -0.40999999999999998)
-mu0 + mu2
(1, -1, -2.0800000000000001)
0
mu0 - mu1
(1, 1, 3.98)
-mu1
(1, 0, 7.101)
-mu1 + mu2
(1, 0, -1.6739999999999999)
0
-mu0
(1, 0, 6.5599999999999996)
-mu0 + mu1
(1, 1, -0.40999999999999998)
-mu0 + mu2
(1, 0, -2.0800000000000001)
1
mu0 - mu1
(1, -1, 3.98)
-mu1
(1, -1, 7.101)
-mu1 + mu2
(1, -1, -1.6739999999999999)
0
-mu0
(1, 0, 6.5599999999999996)
-mu0 + mu1
(1, 0, -0.40999999999999998)
-mu0 + mu2
(1, 1, -2.0800000000000001)
0
mu0 - mu1
(1, 0, 3.98)
-mu1
(1, 0, 7.101)
-mu1 + mu2
(1, 1, -1.6739999999999999)
--------c---------
Matrix([[-8.69064072818453e-34_exp(-11.6045192825566_mu0) - 116.495530311892_exp(-11.6045192825566_mu0 + 11.6045192825566_mu1) - 30390627980.6672_exp(-11.6045192825566_mu0 + 11.6045192825566_mu2) + 1, 8.74340942767173e-21_exp(11.6045192825566_mu0 - 11.6045192825566_mu1)]])
Matrix([[116.495530311892_exp(-11.6045192825566_mu0 + 11.6045192825566_mu1), -1.63129132051346e-36_exp(-11.6045192825566_mu1) - 8.74340942767173e-21_exp(11.6045192825566_mu0 - 11.6045192825566_mu1) - 273268470.678974_exp(-11.6045192825566_mu1 + 11.6045192825566_mu2) + 1]])
Matrix([[30390627980.6672_exp(-11.6045192825566_mu0 + 11.6045192825566_mu2), 273268470.678974_exp(-11.6045192825566_mu1 + 11.6045192825566_mu2)]])
--------c---------
-------c_ratio-------------
(-8.69064072818453e-34_exp(-11.6045192825566_mu0) - 116.495530311892_exp(-11.6045192825566_mu0 + 11.6045192825566_mu1) - 30390627980.6672_exp(-11.6045192825566_mu0 + 11.6045192825566_mu2) + 8.74340942767173e-21_exp(11.6045192825566_mu0 - 11.6045192825566_mu1) + 1)/(-8.69064072818453e-34_exp(-11.6045192825566_mu0) - 1.63129132051346e-36_exp(-11.6045192825566_mu1) + 2)
(-1.63129132051346e-36_exp(-11.6045192825566_mu1) + 116.495530311892_exp(-11.6045192825566_mu0 + 11.6045192825566_mu1) - 8.74340942767173e-21_exp(11.6045192825566_mu0 - 11.6045192825566_mu1) - 273268470.678974_exp(-11.6045192825566_mu1 + 11.6045192825566_mu2) + 1)/(-8.69064072818453e-34_exp(-11.6045192825566_mu0) - 1.63129132051346e-36_exp(-11.6045192825566_mu1) + 2)
(30390627980.6672_exp(-11.6045192825566_mu0 + 11.6045192825566_mu2) + 273268470.678974_exp(-11.6045192825566_mu1 + 11.6045192825566_mu2))/(-8.69064072818453e-34_exp(-11.6045192825566_mu0) - 1.63129132051346e-36_exp(-11.6045192825566_mu1) + 2)
(u'mu_red', [])
(u'y_vect', [0.0, 0.0, 0.01])
[-(-8.69064072818453e-34_exp(-11.6045192825566_mu0) - 116.495530311892_exp(-11.6045192825566_mu0 + 11.6045192825566_mu1) - 30390627980.6672_exp(-11.6045192825566_mu0 + 11.6045192825566_mu2) + 8.74340942767173e-21_exp(11.6045192825566_mu0 - 11.6045192825566_mu1) + 1)/(-8.69064072818453e-34_exp(-11.6045192825566_mu0) - 1.63129132051346e-36_exp(-11.6045192825566_mu1) + 2), -(-1.63129132051346e-36_exp(-11.6045192825566_mu1) + 116.495530311892_exp(-11.6045192825566_mu0 + 11.6045192825566_mu1) - 8.74340942767173e-21_exp(11.6045192825566_mu0 - 11.6045192825566_mu1) - 273268470.678974_exp(-11.6045192825566_mu1 + 11.6045192825566_mu2) + 1)/(-8.69064072818453e-34_exp(-11.6045192825566_mu0) - 1.63129132051346e-36_exp(-11.6045192825566_mu1) + 2), -mu0 - mu1 - 7.48901399237441e-35_exp(-11.6045192825566_mu0) - 1.40573795500994e-37_exp(-11.6045192825566_mu1) - 10.0388070781185_exp(-11.6045192825566_mu0 + 11.6045192825566_mu1) - 7.53448653475411e-22_exp(11.6045192825566_mu0 - 11.6045192825566_mu1) - 10.65875]

--------------------- >> end captured stdout << ----------------------


Ran 787 tests in 232.675s

FAILED (SKIP=128, errors=3)

LDA Potcar.from_file() doesn't work on some LDA potcars

The first line of LDA POTCARs are inconsistent. E.g. for POTCAR.La_s, the line is
La: PAW 5s5p 6s5d4f valence
There is actually no occurance of La_s in the file, making it impossible to retrieve the Potcar.symbol from a generated POTCAR file. The only solution is to manually change the POTCAR files in the VASP_PSP directory to conform to the standard used in POT_GGA_PAW_PBE.

Do we want to explicitly check for this issue when generating potcars? Otherwise, if the issue is missed, VASP will run and pymatgen will read the POTCAR without complaint, but will try to set the species to PAW (which will obviously fail) when doing any further analysis.

Python3.2 or PEP414?

unicode literals (i.e. u"foo") have been reintegrated in python3.3 (See http://legacy.python.org/dev/peps/pep-0414/) but python3.2 does not support them and the interpreter raises a SyntaxError exception.

There are two tests that are failing in my branch due to unicode literals (see https://travis-ci.org/materialsproject/pymatgen/jobs/35144219).

How do we handle this issue? Do we avoid unicode literals so that we are compatible with python3.2 or do we assume PEP414 and hence python >= 3.3?

Primitive cell transformation affects StructureMatcher

Here's an example - note that git won't let me upload the JSON files, so you can obtain those here:
https://groups.google.com/forum/#!topic/pymatgen/HvqV79HQPHE

from pymatgen import Structure
from pymatgen.analysis.structure_matcher import StructureMatcher

s1 = Structure.from_file("s1.json")
s2 = Structure.from_file("s2.json")

sm = StructureMatcher(primitive_cell=True)
print sm.fit(s1, s2)

sm = StructureMatcher(primitive_cell=False)
print sm.fit(s1, s2)

Error installing pymatgen with easyinstall

Hello, I had this problem while installing pymatgen

error: Setup script exited with error: SandboxViolation: os.open('/tmp/tmpqlHrBT/hZfPbu', 131266, 384) {}

The package setup script has attempted to modify files on your system
that are not within the EasyInstall build area, and has been aborted.

This package cannot be safely installed by EasyInstall, and may not
support alternate installation locations even if you run its setup
script by hand. Please inform the package's author and the EasyInstall
maintainers to find out if a fix or workaround is available.

How can I resolve this problem?
Thanks and regards.

pymatgen/electronic_structure/bandstructure.py conditional logic bug

Line 191 of pymatgen/electronic_structure/bandstructure.py in installation tree has a conditional line

    if len(projections) != 0 and self._structure is None:

that will fail (crash) when projections is NoneType. This line is preceded by the line 187

    self._projections = projections if projections else {}

perhaps the conditional len(projections) should be len(self._projections) ?

I have built this from pymatgen-2.2.6 tar/gz source package

Issue with supercells in new StructureMatcher

Go to "test_files" and do

../scripts/matgenie.py compare Li2O.cif POSCAR.Li2O

Both are Li2O. Second one is a big-ish supercell. The code fails with a TypeError after a while, given below:

Traceback (most recent call last):
File "../scripts/matgenie.py", line 423, in
args.func(args)
File "../scripts/matgenie.py", line 282, in compare_structures
for i, grp in enumerate(m.group_structures(structures)):
File "/Users/shyuepingong/Documents/Aptana Studio 3 Workspace/pymatgen/pymatgen/analysis/structure_matcher.py", line 271, in group_structures
if s2_ind == -1 and self.fit(s_list[i], s_list[j]):
File "/Users/shyuepingong/Documents/Aptana Studio 3 Workspace/pymatgen/pymatgen/analysis/structure_matcher.py", line 202, in fit
if s2_cart[ind] != []:
TypeError: list indices must be integers, not NoneType

This is likely the issue of finding the primitive cell of the supercell.

Add Support for Multiple Fields theory_directives

Hi Shyue,

Currently, space is not allowed in the value of theory_directives. Because, NwInput use "theory_directives[theory][toks[0]] = toks[-1]" to parse the theory_directives in the NwInput.from_string().

For example, Lei uses "vectors input atomic". After NwInput.from_string() it will become "vectors atomic".

Luckily, "vector atomic" is also a correct grammar in NWChem, but if it is not what robust code should do.

Furthermore, it will completely fail for more complicated guess options.

This bug will break the NWChem custodian code.

Best regards,

Xiaohui

issue with _parse_dos method in Vasprun for only total DOS

I noticed that the _parse_dos method in the Vasprun class (which is in the pymatgen.io.vaspio.vasp_output module) only works if projected (or partial) DOS are written during the VASP calculation. If only the total DOS is calculated and written by VASP, the _parse_dos method throws an exception while trying to parse the partial DOS from the vasprun.xml file because the vasprun.xml file doesn't contain any partial DOS values.

having trouble generating POTCAR with sym_potcar_map set

Code version is apparently 2.7.0b, pulled today at 11:17.

Below I have compared sym_potcar_map=None with sym_potcar_map set.

mypotcar = pymatgen.io.vaspio.Potcar(symbols=['Si','C','O'], functional="PBE", sym_potcar_map=None)
mypotcar[0].enmax
245.345
mypotcar = pymatgen.io.vaspio.Potcar(symbols=['Si','C','O'], functional="PBE", sym_potcar_map={"Si":"Si","C":"C","O":"O_s"})
mypotcar[0].enmax
Traceback (most recent call last):
File "", line 1, in
File "/share/apps/virtualenv/mastenv/lib/python2.7/site-packages/pymatgen-2.7.0b-py2.7-linux-x86_64.egg/pymatgen/io/vaspio/vasp_input.py", line 1170, in getattr
raise AttributeError(a)
AttributeError: enmax
mypotcar[0].data
'Si'

Thanks,
Tam

Behavior of read_structure is inconsistent

As it stands, only .cif files have the primitive cell taken after structure import. It appears as though they also have their sites sorted. To achieve consistency across structure file types, I suggest we add primitive_cell and sort_structure tags to the read_structure method. The CifParser may also need this flag added.

Failure to get the coordination number

Shyue,
For mpid mp-559848, I am getting the following error when trying to calculate the coordination number for the sites in the structure.

Code:

import MPRester
from pymatgen.analysis.defects.point_defects import ValenceIonicRadiusEvaluator
mpid = "mp-559848"
struct = MPRester().get_structure_by_material_id(mpid)
vire = ValenceIonicRadiusEvaluator(struct)

Error:

Traceback (most recent call last):

File "vor_site_gen_2.py", line 110, in
vire = ValenceIonicRadiusEvaluator(struct)
File "/Users/mbkumar/Research/Defects/pymatgen/pymatgen/analysis/defects/point_defects.py", line 41, in init
self._ionic_radii = self._get_ionic_radii()
File "/Users/mbkumar/Research/Defects/pymatgen/pymatgen/analysis/defects/point_defects.py", line 100, in _get_ionic_radii
coord_no = int(round(coord_finder.get_coordination_number(i)))
File "/Users/mbkumar/Research/Defects/pymatgen/pymatgen/analysis/structure_analyzer.py", line 97, in get_coordination_number
return sum(self.get_voronoi_polyhedra(n).values())
File "/Users/mbkumar/Research/Defects/pymatgen/pymatgen/analysis/structure_analyzer.py", line 79, in get_voronoi_polyhedra
results[neighbors[nn[1]]] = solid_angle(center.coords, facets)
File "/Users/mbkumar/Research/Defects/pymatgen/pymatgen/analysis/structure_analyzer.py", line 323, in solid_angle
for i in range(len(n) - 1)])
ValueError: math domain error

Get_primitive_standard_structure changes atom positions

Repeatedly calling symmetryfinder().get_primitive_standard_structure gives the same structure, but for some structures, the atom positions change. For example, calling Y2S3 would reflect the structure along the x-y axis.

from pymatgen.matproj.rest import MPRester
from pymatgen.symmetry.finder import SymmetryFinder
from pymatgen.io.vaspio import Poscar
mpr = MPRester(api_key="", host="www.materialsproject.org")

structure=mpr.get_structure_by_material_id("mp-541289")
s1= structure
s2=SymmetryFinder(s1, symprec=0.01).get_primitive_standard_structure(False)
s3=SymmetryFinder(s2, symprec=0.01).get_primitive_standard_structure(False)
print Poscar(s1)
print Poscar(s2)
print Poscar(s3)

Output:Y12 S18
1.0
4.044194 0.000000 0.000000
0.000000 10.117887 -1.537590
0.000000 -0.005597 17.671811
Y S
12 18
direct
0.250000 0.189168 0.020666 Y
0.750000 0.810832 0.979334 Y
0.250000 0.124510 0.430144 Y
0.750000 0.875490 0.569856 Y
0.250000 0.829185 0.781067 Y
0.750000 0.170815 0.218933 Y
0.250000 0.187265 0.720466 Y
0.750000 0.812735 0.279534 Y
0.250000 0.486438 0.398811 Y
0.750000 0.513562 0.601189 Y
0.250000 0.549553 0.115085 Y
0.750000 0.450447 0.884915 Y
0.250000 0.051400 0.575160 S
0.750000 0.948600 0.424840 S
0.250000 0.268217 0.873161 S
0.750000 0.731783 0.126839 S
0.250000 0.615017 0.966618 S
0.750000 0.384983 0.033382 S
0.250000 0.638270 0.281569 S
0.750000 0.361730 0.718431 S
0.250000 0.007476 0.268105 S
0.750000 0.992524 0.731895 S
0.250000 0.710472 0.630232 S
0.750000 0.289528 0.369768 S
0.250000 0.950664 0.924267 S
0.750000 0.049336 0.075733 S
0.250000 0.320461 0.183433 S
0.750000 0.679539 0.816567 S
0.250000 0.367714 0.531931 S
0.750000 0.632286 0.468069 S

Y12 S18
1.0
4.044194 0.000000 0.000000
0.000000 10.234052 0.000000
0.000000 2.660591 17.470381
Y S
12 18
direct
0.750000 0.810832 0.020666 Y
0.250000 0.189168 0.979334 Y
0.750000 0.875490 0.430144 Y
0.250000 0.124510 0.569856 Y
0.750000 0.170815 0.781067 Y
0.250000 0.829185 0.218933 Y
0.750000 0.812735 0.720466 Y
0.250000 0.187265 0.279534 Y
0.750000 0.513562 0.398811 Y
0.250000 0.486438 0.601189 Y
0.750000 0.450447 0.115085 Y
0.250000 0.549553 0.884915 Y
0.750000 0.948600 0.575160 S
0.250000 0.051400 0.424840 S
0.750000 0.731783 0.873161 S
0.250000 0.268217 0.126839 S
0.750000 0.384983 0.966618 S
0.250000 0.615017 0.033382 S
0.750000 0.361730 0.281569 S
0.250000 0.638270 0.718431 S
0.750000 0.992524 0.268105 S
0.250000 0.007476 0.731895 S
0.750000 0.289528 0.630232 S
0.250000 0.710472 0.369768 S
0.750000 0.049336 0.924267 S
0.250000 0.950664 0.075733 S
0.750000 0.679539 0.183433 S
0.250000 0.320461 0.816567 S
0.750000 0.632286 0.531931 S
0.250000 0.367714 0.468069 S

Y12 S18
1.0
4.044194 0.000000 0.000000
0.000000 10.234052 0.000000
0.000000 2.660591 17.470381
Y S
12 18
direct
0.750000 0.189168 0.979334 Y
0.250000 0.810832 0.020666 Y
0.750000 0.124510 0.569856 Y
0.250000 0.875490 0.430144 Y
0.750000 0.829185 0.218933 Y
0.250000 0.170815 0.781067 Y
0.750000 0.187265 0.279534 Y
0.250000 0.812735 0.720466 Y
0.750000 0.486438 0.601189 Y
0.250000 0.513562 0.398811 Y
0.750000 0.549553 0.884915 Y
0.250000 0.450447 0.115085 Y
0.750000 0.051400 0.424840 S
0.250000 0.948600 0.575160 S
0.750000 0.268217 0.126839 S
0.250000 0.731783 0.873161 S
0.750000 0.615017 0.033382 S
0.250000 0.384983 0.966618 S
0.750000 0.638270 0.718431 S
0.250000 0.361730 0.281569 S
0.750000 0.007476 0.731895 S
0.250000 0.992524 0.268105 S
0.750000 0.710472 0.369768 S
0.250000 0.289528 0.630232 S
0.750000 0.950664 0.075733 S
0.250000 0.049336 0.924267 S
0.750000 0.320461 0.816567 S
0.250000 0.679539 0.183433 S
0.750000 0.367714 0.468069 S
0.250000 0.632286 0.531931 S

Unable to get xrd for some compounds

struct=mpr.get_structure_by_material_id("mp-8654")
print XRDCalculator(symprec=0.1).get_xrd_data(struct)

The error message is:
line 235, in get_xrd_data
coeffs[:, :, 0] * np.exp(-coeffs[:, :, 1] * s2), axis=1)
IndexError: too many indices

Inconsistency in ionic radii evaluation

Hi,

I have been trying to use pymatgen to automatically charge decorate structures, so that I can evaluate their ionic radius. I have considered two ways.

  1. Using AutoOxiStateDecorationTransformation to first charge decorate a structure and then use specie.ionic_radius to evaluate the ionic radius for each unique specie in the structure.
  2. Using ValenceIonicRadiusEvaluator.

I understand that both these approaches use the bond valence analyzer to assign the oxidation states, and the resulting charge decorated structure is the same (this also sometimes creates weird oxidation states like S- or P4+ etc).

The resulting radii dictionaries in the two cases look like this,

1 . {'Ge4+': 0.67, 'P4+': None, 'P5+': 0.52, 'S2-': 1.7, 'S-': None, 'Li+': 0.9}
2. {'Ge4+': 0.67, 'P4+': 0.43, 'P5+': 0.31, 'S2-': 1.7, 'S-': 0.51, 'Li+': 0.9}

In the second case, you can see that the ionic radii have been assigned to P4+ and S- these elements are not known have such oxidation states. Also, how does the coordination of the sites affect the radius in both these cases? I assume in the first case, the "most common" radius is assigned, but in the second case I see the radii assigned to S- and P4+ are actually the same as the radii of S4+ in coordination VI (http://abulafia.mt.ic.ac.uk/shannon/radius.php?Element=S) and P5+ in coordination V (http://abulafia.mt.ic.ac.uk/shannon/radius.php?Element=P).

The reason I ask is because I want to use zeo++ to calculate channel sizes of these structures, and I need to assign a radius. If there is a better way to do this please let me know.

EnumerateStructureTransformation misses some enumerations

When lattice periodicity of ordered sites doesn't match the periodicity of disordered sites (but when they have the same spacegroup), the wrong periodicity is used by spglib, missing some valid enumerations.

Example structure that should have 2 distinct orderings:

#\#CIF1.1
##########################################################################
#               Crystallographic Information Format file 
#               Produced by PyCifRW module
# 
#  This is a CIF file.  CIF has been adopted by the International
#  Union of Crystallography as the standard for data archiving and 
#  transmission.
#
#  For information on this file format, follow the CIF links at
#  http://www.iucr.org
##########################################################################

data_He(Li3H)3
_symmetry_space_group_name_H-M          'P 1'
_cell_length_a                          5.0
_cell_length_b                          5.0
_cell_length_c                          5.0
_cell_angle_alpha                       90.0
_cell_angle_beta                        90.0
_cell_angle_gamma                       90.0
_chemical_name_systematic               'Generated by pymatgen'
_symmetry_Int_Tables_number             1
_chemical_formula_structural            He(Li3H)3
_chemical_formula_sum                   'He1 Li9 H3'
_cell_volume                            125.0
_cell_formula_units_Z                   1
loop_
  _symmetry_equiv_pos_site_id
  _symmetry_equiv_pos_as_xyz
   1  'x, y, z'

loop_
  _atom_site_type_symbol
  _atom_site_label
  _atom_site_symmetry_multiplicity
  _atom_site_fract_x
  _atom_site_fract_y
  _atom_site_fract_z
  _atom_site_attached_hydrogens
  _atom_site_B_iso_or_equiv
  _atom_site_occupancy
   Li  Li1  1  0.250000  0.250000  0.250000  0  .  1.0
   Li  Li2  1  0.250000  0.750000  0.750000  0  .  1.0
   Li  Li3  1  0.750000  0.250000  0.750000  0  .  1.0
   Li  Li4  1  0.750000  0.750000  0.250000  0  .  1.0
   Li  Li5  1  0.750000  0.750000  0.750000  0  .  1.0
   Li  Li6  1  0.750000  0.250000  0.250000  0  .  1.0
   Li  Li7  1  0.250000  0.750000  0.250000  0  .  1.0
   Li  Li8  1  0.250000  0.250000  0.750000  0  .  1.0
   Li  Li9  1  0.500000  0.500000  0.500000  0  .  1.0
   H  H10  1  0.000000  0.000000  0.000000  0  .  0.75
   He  He11  1  0.000000  0.000000  0.000000  0  .  0.25
   H  H12  1  0.000000  0.500000  0.500000  0  .  0.75
   He  He13  1  0.000000  0.500000  0.500000  0  .  0.25
   H  H14  1  0.500000  0.000000  0.500000  0  .  0.75
   He  He15  1  0.500000  0.000000  0.500000  0  .  0.25
   H  H16  1  0.500000  0.500000  0.000000  0  .  0.75
   He  He17  1  0.500000  0.500000  0.000000  0  .  0.25

OrderDisorderTransformation breaks with unintuitive error when number of sites insufficient to perform ordering

The OrderDisorderTransformation fails with an non-intuitive error when the actual cell is too small to perform ordering. E.g., if you use a primitive cell of a NMC material, the cell only contains one atom with a 0.33 Ni, 0.33 Co, 0.33 Mn occu. This has not enough atoms to perform ordering.

The transformation should check that the cell does not contain enough atoms and present an error message to request for a SupercellTransformation to be performed first.

Conversion battery data does not match its phase diagram?

I'd like to generate conversion data starting for CoO2 and lithiating. The phase diagram indicates there should be several steps as per the image below - first to Li0.5CoO2, then LiCoO2, then a mixture of CoO and Li6CoO4, and so on. These are indicated by the numbers in the image.

The problem is that when I run the code to do the conversion electrode, the step with a mixture of CoO and Li6CoO4 (step #4) is not represented properly. Similarly with some of the subsequent steps. Basically CoO seems to "disappear".

Here is the code I am using - the phase diagram prints just like the image I sent, but the output from the summary dict (e.g. the "reactions" key) does not match the image. This is the output I get:

['0.500 Li + 1.000 CoO2 -> 0.500 Li(CoO2)2', '0.500 Li + 0.500 Li(CoO2)2 -> 1.000 LiCoO2', '2.000 Li + 1.000 LiCoO2 -> 0.500 Co + 0.500 Li6CoO4', '1.000 Li + 0.500 Li6CoO4 -> 0.500 Co + 2.000 Li2O']

and here is the code:

from pymatgen import MPRester, Composition
from pymatgen.apps.battery.conversion_battery import ConversionElectrode
from pymatgen.phasediagram.pdmaker import PhaseDiagram
from pymatgen.phasediagram.plotter import PDPlotter

mpr = MPRester()
chemsys = "-".join(["Co","O","Li"])
entries = mpr.get_entries(chemsys, inc_structure=True)
pd = PhaseDiagram(entries)

# plot the Phase Diagram (optional)
plotter = PDPlotter(pd, show_unstable=False)  # you can also try show_unstable=True
plotter.show()

# get conversion data
a = ConversionElectrode.from_composition_and_pd(Composition("CoO2"), pd, working_ion_symbol="Li")
print a.get_summary_dict()["reactions"]

1

Options to specify data range in get_xrd_data

XRD calculator takes very long time to generate patterns for targets with short wavelength. Adding limits of calculation range will accelerate data production, such as 2-theta range or highest index.

struct=mpr.get_structure_by_material_id("mp-19017")
for target in ["Fe", "Cu", "Cr", "Co", "Mo", "Ag"]:
t=datetime.datetime.now()
d=XRDCalculator(wavelength="".join([target, "Ka"]), symprec=0.1).get_xrd_data(struct)
print datetime.datetime.now()-t

Output:
0:00:00.220564
0:00:00.439401
0:00:00.130629
0:00:00.264712
0:00:08.290305
0:00:25.969561

VASP KPOINTS file with Line_mode

Hi !
I am new in pymatgen and I try to use it to produce KPOINTS file for band structure calculations with VASP. I use HighSymmKpath and Kpoints classes to produces the kpoints file.

Here is the source code

import pymatgen as mg
from pymatgen.symmetry.bandstructure import HighSymmKpath
from pymatgen.io.vaspio.vasp_input import Kpoints

struct = mg.read_structure("POSCAR.vasp")

# First brillouin zone
ibz = HighSymmKpath(struct)
print("ibz type     : {0}".format(ibz.name))

# suggested path
print("paths in first brillouin zone :")
for path in ibz.kpath["path"]:
    print(path)

kpoints = list()
labels = list()
for path in ibz.kpath["path"]:
    for kpts in path:
        kpoints.append(ibz.kpath["kpoints"][kpts])
        labels.append(kpts)

# print kpoints file
Kpoints(comment = "band diagram for monoclinic cell, unique axes a",
        num_kpts = 100,
        style = Kpoints.supported_modes.Line_mode,
        coord_type = "Reciprocal",
        kpts = kpoints,
        labels = labels,
        ).write_file("KPOINTS")

And this is the KPOINTS file produced

band diagram for monoclinic cell, unique axes a
100
Line_mode
0.0 0.0 0.0            ! \Gamma
0.0 0.0 0.5            ! Y
0.0 0.491941 0.525184  ! H
0.0 0.5 0.5            ! C
0.5 0.5 0.5            ! E
0.5 0.508059 0.474816  ! M_1
0.5 0.5 0.0            ! A
0.0 0.5 0.0            ! X
0.0 0.508059 0.474816  ! H_1
0.5 0.491941 0.525184  ! M
0.5 0.0 0.5            ! D
0.5 0.0 0.0            ! Z
0.0 0.0 0.5            ! Y
0.5 0.0 0.5            ! D

After the line Line_mode in the KPOINTS file, the coord_type should be written.

Looking at

http://pymatgen.org/_modules/pymatgen/io/vaspio/vasp_input.html#Kpoints

in the __str__ method there is these lines

style = self.style.lower()[0]
        if style == "Line-mode":
            lines.append(self.coord_type)

but line_mode is not written with an underscore as in the supported mode enum and I think this is the bug (or maybe the mistake for only one character ...)

supported_modes = Enum(("Gamma", "Monkhorst", "Automatic", "Line_mode",
                            "Cartesian", "Reciprocal"))

The following is maybe a request more than a bug. Using VASP, in Line_mode the KPOINTS file should be

band diagram for monoclinic cell, unique axes a
100
Line_mode
Reciprocal
0.0 0.0 0.0            ! \Gamma
0.0 0.0 0.5            ! Y

0.0 0.0 0.5            ! Y
0.0 0.491941 0.525184  ! H

0.0 0.491941 0.525184  ! H
0.0 0.5 0.5            ! C

0.0 0.5 0.5            ! C
0.5 0.5 0.5            ! E

0.5 0.5 0.5            ! E
0.5 0.508059 0.474816  ! M_1

0.5 0.508059 0.474816  ! M_1
0.5 0.5 0.0            ! A

0.5 0.5 0.0            ! A
0.0 0.5 0.0            ! X

0.0 0.5 0.0            ! X
0.0 0.508059 0.474816  ! H_1

0.5 0.491941 0.525184  ! M
0.5 0.0 0.5            ! D

0.5 0.0 0.5            ! D
0.5 0.0 0.0            ! Z

0.0 0.0 0.5            ! Y
0.5 0.0 0.5            ! D

I have ever talk about the line with "Reciprocal". Then each line of the reciprocal space is defined by 2 k-points separated by a blank line. Is there a way to obtain this directly from pymatgen without postprocessing the KPOITNS file ?
A solution migth be to give the kpath attribute of the HighSymmKpath to a Kpoints class constructor or directely the HighSymmKpath object. But the __str__ method must be also slithly modified.
I cloned the git repository and did the few changes.
Here is a patch file created with git diff > patch.txt

www.pastebin.com/5n6aniLv

I am sorry but I am a beginner with git. I do not know how to make the development version and the stable version of pymatgen to cohabit in the same PC. Thus I did not test my changes ... If you prefer and explain I can commit and push somewhere ?

Thanks

SandboxViolation while installing pyhull-1.3.8

Hi,

I've just merged mpmaster in my private branch. I ran the unit tests
and many tests were failing in phasediagram due to the fact that now we
require pyhull >=1.3.8.
I tried to install the new version of pyhull via setup.py but the installation fails
with the following error

sudo python setup.py install
...

Processing dependencies for pymatgen==2.7.2b
Searching for pyhull>=1.3.8
Reading http://pypi.python.org/simple/pyhull/
Reading https://github.com/shyuep/pyhull
Best match: pyhull 1.3.8
Downloading http://pypi.python.org/packages/source/p/pyhull/pyhull-1.3.8.tar.gz#md5=f8175f0ecb4b85fb26123481019d9f7c
Processing pyhull-1.3.8.tar.gz
Writing /tmp/easy_install-LIekCW/pyhull-1.3.8/setup.cfg
Running pyhull-1.3.8/setup.py -q bdist_egg --dist-dir /tmp/easy_install-LIekCW/pyhull-1.3.8/egg-dist-tmp-nsVEGi
warning: no files found matching '.c'
no previously-included directories found matching '
*/tests'
error: Setup script exited with error: SandboxViolation: os.open('/tmp/tmpZfTvDd/jrTBn3', 2818, 384) {}

The package setup script has attempted to modify files on your system
that are not within the EasyInstall build area, and has been aborted.

This package cannot be safely installed by EasyInstall, and may not
support alternate installation locations even if you run its setup
script by hand. Please inform the package's author and the EasyInstall
maintainers to find out if a fix or workaround is available.

Band gap issue with static run

Some band gap output analyzed from static run is not correct.
This may be related to the definition of valence band maximum and conduction band minimum with occupation of "occu > 1e-8" in vasp_output.py
For example. In a static run. band gap occurs between band 96 and 97 for one calculation.
The occupation and energy of these two bands at different KPOINT is
band 97 # energy 5.34588712 # occ. 0.00024002
band 97 # energy 5.67445169 # occ. 0.00000000
band 97 # energy 5.49090544 # occ. 0.00000313
band 97 # energy 5.34589837 # occ. 0.00023995
band 97 # energy 5.67446456 # occ. 0.00000000
band 97 # energy 5.49091742 # occ. 0.00000313
band 96 # energy 4.34996188 # occ. 0.99980782
band 96 # energy 4.00965011 # occ. 1.00000000
band 96 # energy 3.78252682 # occ. 1.00000000
band 96 # energy 4.34993175 # occ. 0.99980798
band 96 # energy 4.00962333 # occ. 1.00000000
band 96 # energy 3.78250168 # occ. 1.00000000

The real band gap shall be 5.3459-4.3499 which is ~ 1eV
The band gap in analysis in database is 5.4909-5.3459 which is 0.145 eV. This is some energy difference in CB rather than a band gap.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.