diff --git a/docs/changelog.rst b/docs/changelog.rst index 05d59a1f4dd..e20b9ee7480 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,29 @@ Change log ========== +v2.9.14 +------- +1. Implements Structure.sort method. Both Structure.sort and the + get_sorted_structure methods now supports all arguments supported by list + .sort(). +2. VaspInputSets configs, as well as several other configs now uses yaml. Note + the new dependency on pyyaml. It is highly recommended that you install + pyyaml with the libyaml C bindings. +3. Fix missing spglib dependency. +4. Use monty.serialization for transparent handling of JSON vs YAML. + Requirements updated to monty>=0.3.1. + +v2.9.13 +------- +1. Urgent bug fix for missing compatibility yamls. + +v2.9.12 +------- +1. Defect transformations (Bharat). +2. Support for optical properties (Geoffroy Hautier and David Waroquiers). +3. Improved support for some VASP output files (XDATCAR and OSZICAR). +4. Refactored compatibilities now uses YAML for ease of reading. + v2.9.11 ------- 1. Bug fix for get_xrd_plot. diff --git a/docs/index.rst b/docs/index.rst index 8ee58186e31..4e7c764d010 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -72,35 +72,24 @@ several advantages over other codes out there: Latest Change Log ================= -v2.9.15 +v2.10.1 ------- -1. Major update: MPRester now uses Materials API v2! Also major refactoring - of MPRester. -2. Bug fix for XYZ parsing for scientific notation. -3. Update numpy requirements to 1.8+. Fixes memory leak. +1. Minor fix for monty requirements in setup.py. -v2.9.14 +v2.10.0 ------- -1. Implements Structure.sort method. Both Structure.sort and the - get_sorted_structure methods now supports all arguments supported by list - .sort(). -2. VaspInputSets configs, as well as several other configs now uses yaml. Note - the new dependency on pyyaml. It is highly recommended that you install - pyyaml with the libyaml C bindings. -3. Fix missing spglib dependency. -4. Use monty.serialization for transparent handling of JSON vs YAML. - Requirements updated to monty>=0.3.1. - -v2.9.13 -------- -1. Urgent bug fix for missing compatibility yamls. - -v2.9.12 -------- -1. Defect transformations (Bharat). -2. Support for optical properties (Geoffroy Hautier and David Waroquiers). -3. Improved support for some VASP output files (XDATCAR and OSZICAR). -4. Refactored compatibilities now uses YAML for ease of reading. +1. Major update: MPRester now uses Materials API v2! Also major refactoring + of MPRester. +2. Vastly improved Vasprun parser using cElementTree. Twice as fast, + half as much code and easier to maintain. +3. Vast improvements to Qchem functionality (Xiaohui Qu). +4. Improved handling of Structure manipulations for extremely large + structures (particularly in terms of memory consumption). +5. Bug fix for XYZ parsing for scientific notation. +6. Improve monty.serialization for transparent handling of JSON vs YAML. + Requirements updated to monty>=0.3.3. +7. Update numpy requirements to 1.8+. Fixes memory leak. +8. Other minor bug fixes. :doc:`Older versions ` diff --git a/examples/Explanation of Corrections.ipynb b/examples/Explanation of Corrections.ipynb new file mode 100644 index 00000000000..1b89da560c6 --- /dev/null +++ b/examples/Explanation of Corrections.ipynb @@ -0,0 +1,115 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1b0762dea41bd3b1b6224430bfd0661f6a71ee0df8e3f375cec94e2e5dacbca3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This notebook illustrates how to obtain an explaination of the different corrections being applied in the Materials Project." + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import re\n", + "from pymatgen.entries.computed_entries import ComputedEntry\n", + "from pymatgen.entries.compatibility import MaterialsProjectCompatibility" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from pymatgen import MPRester\n", + "\n", + "#To do our testing, let's use the MPRester to get a sample computed entry from the Materials Project.\n", + "m = MPRester()\n", + "entries = m.get_entries(\"LiFePO4\")\n", + "entry = entries[0]" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "compat = MaterialsProjectCompatibility()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 3 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "compat.explain(entry)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The uncorrected value of the energy of P4 Fe4 O16 Li4 is -191.338121 eV\n", + "The following corrections / screening are applied for MaterialsProjectCompatibility:\n", + "\n", + "MP Potcar Correction correction: Checks that POTCARs are valid within a pre-defined input set. This\n", + " ensures that calculations performed using different InputSets are not\n", + " compared against each other.\n", + "\n", + " Entry.parameters must contain a \"potcar_symbols\" key that is a list of\n", + " all POTCARs used in the run. Again, using the example of an Fe2O3 run\n", + " using Materials Project parameters, this would look like\n", + " entry.parameters[\"potcar_symbols\"] = ['PAW_PBE Fe_pv 06Sep2000',\n", + " 'PAW_PBE O 08Apr2002'].\n", + "\n", + "This correction does not make any changes to the energy.\n", + "------------------------------\n", + "MP Gas Correction correction: Correct gas energies to obtain the right formation energies. Note that\n", + " this depends on calculations being run within the same input set.\n", + "\n", + "For the entry, this correction has the value -11.236640 eV.\n", + "------------------------------\n", + "MP Advanced Correction correction: This class implements the GGA/GGA+U mixing scheme, which allows mixing of\n", + " entries. Entry.parameters must contain a \"hubbards\" key which is a dict\n", + " of all non-zero Hubbard U values used in the calculation. For example,\n", + " if you ran a Fe2O3 calculation with Materials Project parameters,\n", + " this would look like entry.parameters[\"hubbards\"] = {\"Fe\": 5.3}\n", + " If the \"hubbards\" key is missing, a GGA run is assumed.\n", + "\n", + " It should be noted that ComputedEntries assimilated using the\n", + " pymatgen.apps.borg package and obtained via the MaterialsProject REST\n", + " interface using the pymatgen.matproj.rest package will automatically have\n", + " these fields populated.\n", + "\n", + "For the entry, this correction has the value -10.932000 eV.\n", + "------------------------------\n", + "The final energy after corrections is -213.506761\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/pymatgen/__init__.py b/pymatgen/__init__.py index 4fe83e33c6d..89c62155dad 100644 --- a/pymatgen/__init__.py +++ b/pymatgen/__init__.py @@ -3,8 +3,8 @@ "Sai Jayaraman", "Michael Kocher", "Dan Gunter", "Shreyas Cholia", "Vincent L Chevrier", "Rickard Armiento"]) -__date__ = "Aug 5 2014" -__version__ = "2.9.14" +__date__ = "Aug 15 2014" +__version__ = "2.10.1" #Useful aliases for commonly used objects and modules. diff --git a/pymatgen/entries/compatibility.py b/pymatgen/entries/compatibility.py index 6f243fd18a2..371a377025c 100644 --- a/pymatgen/entries/compatibility.py +++ b/pymatgen/entries/compatibility.py @@ -366,6 +366,33 @@ def process_entries(self, entries): """ return filter(None, map(self.process_entry, entries)) + def explain(self, entry): + """ + Prints an explanation of the corrections that are being applied for a + given compatibility scheme. Inspired by the "explain" methods in many + database methodologies. + + Args: + entry: A ComputedEntry. + """ + entry = self.process_entry(entry) + print "The uncorrected value of the energy of %s is %f eV" % ( + entry.composition, entry.uncorrected_energy) + print "The following corrections / screening are applied for %s:\n" %\ + self.__class__.__name__ + corr_dict = self.get_corrections_dict(entry) + for c in self.corrections: + desc = c.__doc__.split("Args")[0].strip() + print "%s correction: %s\n" % (str(c), desc.strip()) + if str(c) in corr_dict: + print "For the entry, this correction has the value %f eV." % \ + corr_dict[str(c)] + else: + print "This correction does not make any changes to the energy." + print "-" * 30 + + print "The final energy after corrections is %f" % entry.energy + @cached_class class MaterialsProjectCompatibility(Compatibility): diff --git a/pymatgen/io/vaspio/tests/test_vasp_output.py b/pymatgen/io/vaspio/tests/test_vasp_output.py index d6a4cce0d07..98cbad909dd 100644 --- a/pymatgen/io/vaspio/tests/test_vasp_output.py +++ b/pymatgen/io/vaspio/tests/test_vasp_output.py @@ -30,6 +30,13 @@ class VasprunTest(unittest.TestCase): def test_properties(self): filepath = os.path.join(test_dir, 'vasprun.xml') vasprun = Vasprun(filepath) + + #test pdos parsing + pdos0 = vasprun.complete_dos.pdos[vasprun.final_structure[0]] + self.assertAlmostEqual(pdos0[Orbital.s][1][16], 0.0026) + self.assertAlmostEqual(pdos0[Orbital.pz][-1][16], 0.0012) + self.assertEqual(pdos0[Orbital.s][1].shape, (301, )) + filepath2 = os.path.join(test_dir, 'lifepo4.xml') vasprun_ggau = Vasprun(filepath2, parse_projected_eigen=True) totalscsteps = sum([len(i['electronic_steps']) diff --git a/pymatgen/io/vaspio/vasp_output.py b/pymatgen/io/vaspio/vasp_output.py index e6fbf623ef0..77935f8412b 100644 --- a/pymatgen/io/vaspio/vasp_output.py +++ b/pymatgen/io/vaspio/vasp_output.py @@ -820,7 +820,7 @@ def _parse_dos(self, elem): data = np.array(_parse_varray(ss)) nrow, ncol = data.shape for j in xrange(1, ncol): - pdos[Orbital.from_vasp_index(j - 1)][spin] = data + pdos[Orbital.from_vasp_index(j - 1)][spin] = data[:, j] pdoss.append(pdos) elem.clear() return Dos(efermi, energies, tdensities), \ diff --git a/pymatgen/vis/structure_vtk.py b/pymatgen/vis/structure_vtk.py index 26c06658546..53b21bdafbe 100644 --- a/pymatgen/vis/structure_vtk.py +++ b/pymatgen/vis/structure_vtk.py @@ -832,17 +832,17 @@ def keyPressEvent(self, obj, event): def make_movie(structures, output_filename="movie.mp4", zoom=1.0, fps=20, - bitrate=10000, quality=5): + bitrate="10000k", quality=1): """ Generate a movie from a sequence of structures using vtk and ffmpeg. Args: structures: sequence of structures output_filename: filename for structure output. defaults to movie.mp4 - zoom: A zoom to be applied to the visulizer. Defaults to 1.0 + zoom: A zoom to be applied to the visualizer. Defaults to 1.0. fps: Frames per second for the movie. Defaults to 20. - bitrate: Video bitate. Defaults to 10000 (fairly high quality). - quality: A quality scale. Defaults to 5. + bitrate: Video bitate. Defaults to 10000k (fairly high quality). + quality: A quality scale. Defaults to 1. """ vis = StructureVis() vis.show_help = False @@ -854,6 +854,7 @@ def make_movie(structures, output_filename="movie.mp4", zoom=1.0, fps=20, vis.set_structure(s) vis.write_image(filename.format(i), 3) filename = "image%0" + str(sigfig) + "d.png" - args = ["ffmpeg", "-y", "-qscale", str(quality), "-r", str(fps), "-b", - str(bitrate), "-i", filename, output_filename] + args = ["ffmpeg", "-y", "-i", filename, + "-qscale", str(quality), "-r", str(fps), "-b", str(bitrate), + output_filename] subprocess.Popen(args) diff --git a/setup.py b/setup.py index 27cf11d6939..43c5f1206d7 100644 --- a/setup.py +++ b/setup.py @@ -42,10 +42,10 @@ def get_spglib_ext(): setup( name="pymatgen", packages=find_packages(), - version="2.9.14", + version="2.10.1", install_requires=["numpy>=1.8", "pyhull>=1.4.3", "PyCifRW>=3.3", "requests>=1.0", "pybtex>=0.16", "pyyaml>=3.0", - "monty>=0.3.1"], + "monty>=0.3.3"], extras_require={"electronic_structure": ["scipy>=0.10"], "plotting": ["matplotlib>=1.1"], "ase_adaptor": ["ase>=3.3"],