Skip to content

Commit

Permalink
Merge branch 'master' into pmg4
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep committed Jun 19, 2016
2 parents 571c052 + 468c0b4 commit ee6afcf
Show file tree
Hide file tree
Showing 28 changed files with 2,625 additions and 558 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Change log
==========

v3.7.0
------
* Last version before pymatgen 4.0, where deprecated modules will be removed!
* Massive update to LAMMPS (Kiran Matthews).
* New input sets with a different interface that replaces old input sets.
* Massive update to elastic properties.

v3.6.1
------
* Massive cleanup to Boltztrap interface (Anubhav Jain)
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**Official docs:** http://www.pymatgen.org

.. image:: https://coveralls.io/repos/github/materialsproject/pymatgen/badge.svg?branch=master :target: https://coveralls.io/github/materialsproject/pymatgen?branch=master
.. image:: https://coveralls.io/repos/github/materialsproject/pymatgen/badge.svg?branch=master

Pymatgen (Python Materials Genomics) is a robust, open-source Python library
for materials analysis. These are some of the main features:
Expand Down
7 changes: 7 additions & 0 deletions docs/change_log.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Change log
==========

v3.7.0
------
* Last version before pymatgen 4.0, where deprecated modules will be removed!
* Massive update to LAMMPS (Kiran Matthews).
* New input sets with a different interface that replaces old input sets.
* Massive update to elastic properties.

v3.6.1
------
* Massive cleanup to Boltztrap interface (Anubhav Jain)
Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Introduction
============

.. image:: https://coveralls.io/repos/github/materialsproject/pymatgen/badge.svg?branch=master

Pymatgen (Python Materials Genomics) is a robust, open-source Python library
for materials analysis. These are some of the main features:

Expand Down
9 changes: 5 additions & 4 deletions docs/latest_changes.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Change log
==========

v3.6.1
v3.7.0
------
* Massive cleanup to Boltztrap interface (Anubhav Jain)
* Refactor of piezoelectric analysis to use tensor base class (Joey)
* More robust CIF parsing.
* Last version before pymatgen 4.0, where deprecated modules will be removed!
* Massive update to LAMMPS (Kiran Matthews).
* New input sets with a different interface that replaces old input sets.
* Massive update to elastic properties.
8 changes: 8 additions & 0 deletions docs/pymatgen.io.vasp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ pymatgen.io.vasp.sets module
:undoc-members:
:show-inheritance:

pymatgen.io.vasp.sets_deprecated module
---------------------------------------

.. automodule:: pymatgen.io.vasp.sets_deprecated
:members:
:undoc-members:
:show-inheritance:


Module contents
---------------
Expand Down
4 changes: 2 additions & 2 deletions pymatgen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
__email__ ="pymatgen@googlegroups.com"
__maintainer__ = "Shyue Ping Ong"
__maintainer_email__ ="shyuep@gmail.com"
__date__ = "May 25 2016"
__version__ = "3.6.1"
__date__ = "Jun 19 2016"
__version__ = "3.7.0"


# Useful aliases for commonly used objects and modules.
Expand Down
175 changes: 89 additions & 86 deletions pymatgen/analysis/defects/tests/test_dilute_solution_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from monty.json import MontyDecoder
from pymatgen.analysis.defects.dilute_solution_model import *
import random

try:
import sympy
Expand All @@ -31,92 +32,94 @@
# monstrously slow. It takes more than 10 mins to get through this test alone.


# @unittest.skipIf(not sympy, "sympy not present.")
# class DiluteSolutionModelTest(unittest.TestCase):
# def setUp(self):
# """
# Setup mandatory inputs for dilute_solution_model
# """
# self.e0 = raw_energy_dict['bulk_energy']
# self.asites = raw_energy_dict['antisites']
# self.vac = raw_energy_dict['vacancies']
# self.struct = raw_energy_dict['structure']
# self.T = 600
# self.trial_mu = formation_energy_dict[str(self.T)]['chemical_potential']
#
# def test_formation_energies_without_chem_pot(self):
# """
# Should generate formation energies without input chempot
# """
# energies, chem_pot = dilute_solution_model(
# self.struct, self.e0, self.vac, self.asites, self.T,
# generate='energy')
# self.assertIsNotNone(energies)
# self.assertIsNotNone(chem_pot)
#
# def test_formation_energies_with_chem_pot(self):
# energies, chem_pot = dilute_solution_model(
# self.struct, self.e0, self.vac, self.asites, self.T,
# trial_chem_pot=self.trial_mu, generate='energy')
# self.assertIsNotNone(energies)
# self.assertIsNotNone(chem_pot)
#
# def test_plot_data_without_chem_pot(self):
# conc_data, en_data, mu_data = dilute_solution_model(
# self.struct, self.e0, self.vac, self.asites, self.T,
# generate='plot')
# self.assertIsNotNone(conc_data)
# self.assertIsNotNone(en_data)
# self.assertIsNotNone(mu_data)
# for key, value in conc_data.items():
# self.assertIsNotNone(value)
# for key, value in mu_data.items():
# self.assertIsNotNone(value)
# for key, value in en_data.items():
# self.assertIsNotNone(value)
#
# def test_plot_data_with_chem_pot(self):
# conc_data, en_data, mu_data = dilute_solution_model(
# self.struct, self.e0, self.vac, self.asites, self.T,
# trial_chem_pot=self.trial_mu, generate='plot')
# self.assertIsNotNone(conc_data)
# self.assertIsNotNone(en_data)
# self.assertIsNotNone(mu_data)
# for key, value in conc_data.items():
# self.assertIsNotNone(value)
# for key, value in mu_data.items():
# self.assertIsNotNone(value)
# for key, value in en_data.items():
# self.assertIsNotNone(value)
# # print(plot_data['y'])
#
#
# @unittest.skipIf(not sympy, "sympy not present.")
# class SoluteSiteFinderTest(unittest.TestCase):
# def setUp(self):
# """
# Setup mandatory inputs for dilute_solution_model
# """
# self.e0 = mp1487_raw_energy_dict['bulk_energy']
# self.asites = mp1487_raw_energy_dict['antisites']
# self.vac = mp1487_raw_energy_dict['vacancies']
# self.solutes = mp1487_raw_energy_dict['solutes']
# self.struct = mp1487_raw_energy_dict['structure']
# self.T = 1000
#
# def test_plot_data_without_chem_pot(self):
# plot_data = solute_site_preference_finder(
# self.struct, self.e0, self.T, self.vac, self.asites, self.solutes,
# solute_concen=0.01)
# self.assertIsNotNone(plot_data)
#
# def still_wait_plot_data_with_chem_pot(self):
# plot_data = dilute_solution_model(
# self.struct, self.e0, self.vac, self.asites, self.T,
# trial_chem_pot=self.trial_mu, generate='plot')
# self.assertIsNotNone(plot_data)
# for key, value in plot_data.items():
# self.assertIsNotNone(value)
@unittest.skipIf((not sympy) or random.randint(0, 10) % 10 != 0,
"sympy not present or random skip.")
class DiluteSolutionModelTest(unittest.TestCase):
def setUp(self):
"""
Setup mandatory inputs for dilute_solution_model
"""
self.e0 = raw_energy_dict['bulk_energy']
self.asites = raw_energy_dict['antisites']
self.vac = raw_energy_dict['vacancies']
self.struct = raw_energy_dict['structure']
self.T = 600
self.trial_mu = formation_energy_dict[str(self.T)]['chemical_potential']

def test_formation_energies_without_chem_pot(self):
"""
Should generate formation energies without input chempot
"""
energies, chem_pot = dilute_solution_model(
self.struct, self.e0, self.vac, self.asites, self.T,
generate='energy')
self.assertIsNotNone(energies)
self.assertIsNotNone(chem_pot)

def test_formation_energies_with_chem_pot(self):
energies, chem_pot = dilute_solution_model(
self.struct, self.e0, self.vac, self.asites, self.T,
trial_chem_pot=self.trial_mu, generate='energy')
self.assertIsNotNone(energies)
self.assertIsNotNone(chem_pot)

def test_plot_data_without_chem_pot(self):
conc_data, en_data, mu_data = dilute_solution_model(
self.struct, self.e0, self.vac, self.asites, self.T,
generate='plot')
self.assertIsNotNone(conc_data)
self.assertIsNotNone(en_data)
self.assertIsNotNone(mu_data)
for key, value in conc_data.items():
self.assertIsNotNone(value)
for key, value in mu_data.items():
self.assertIsNotNone(value)
for key, value in en_data.items():
self.assertIsNotNone(value)

def test_plot_data_with_chem_pot(self):
conc_data, en_data, mu_data = dilute_solution_model(
self.struct, self.e0, self.vac, self.asites, self.T,
trial_chem_pot=self.trial_mu, generate='plot')
self.assertIsNotNone(conc_data)
self.assertIsNotNone(en_data)
self.assertIsNotNone(mu_data)
for key, value in conc_data.items():
self.assertIsNotNone(value)
for key, value in mu_data.items():
self.assertIsNotNone(value)
for key, value in en_data.items():
self.assertIsNotNone(value)
# print(plot_data['y'])


@unittest.skipIf((not sympy) or random.randint(0, 10) % 10 != 0,
"sympy not present or random skip.")
class SoluteSiteFinderTest(unittest.TestCase):
def setUp(self):
"""
Setup mandatory inputs for dilute_solution_model
"""
self.e0 = mp1487_raw_energy_dict['bulk_energy']
self.asites = mp1487_raw_energy_dict['antisites']
self.vac = mp1487_raw_energy_dict['vacancies']
self.solutes = mp1487_raw_energy_dict['solutes']
self.struct = mp1487_raw_energy_dict['structure']
self.T = 1000

def test_plot_data_without_chem_pot(self):
plot_data = solute_site_preference_finder(
self.struct, self.e0, self.T, self.vac, self.asites, self.solutes,
solute_concen=0.01)
self.assertIsNotNone(plot_data)

def still_wait_plot_data_with_chem_pot(self):
plot_data = dilute_solution_model(
self.struct, self.e0, self.vac, self.asites, self.T,
trial_chem_pot=self.trial_mu, generate='plot')
self.assertIsNotNone(plot_data)
for key, value in plot_data.items():
self.assertIsNotNone(value)


if __name__ == "__main__":
Expand Down
22 changes: 14 additions & 8 deletions pymatgen/core/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,9 @@ def find_all_mappings(self, other_lattice, ltol=1e-5, atol=1,
max(lengths) * (1 + ltol),
zip_results=False)
cart = self.get_cartesian_coords(frac)

# this can't be broadcast because they're different lengths
inds = [np.abs(dist - l) / l <= ltol for l in lengths]
inds = [np.logical_and(dist / l < 1 + ltol,
dist / l > 1 / (1 + ltol)) for l in lengths]
c_a, c_b, c_c = (cart[i] for i in inds)
f_a, f_b, f_c = (frac[i] for i in inds)
l_a, l_b, l_c = (np.sum(c ** 2, axis=-1) ** 0.5 for c in (c_a, c_b, c_c))
Expand Down Expand Up @@ -955,15 +955,21 @@ def get_points_in_sphere(self, frac_points, center, r, zip_results=True):

shifted_coords = fcoords[:, None, None, None, :] + \
images[None, :, :, :, :]
coords = self.get_cartesian_coords(shifted_coords)
dists = np.sqrt(np.sum((coords - center[None, None, None, None, :]) ** 2,
axis=4))
within_r = np.where(dists <= r)

cart_coords = self.get_cartesian_coords(fcoords)
cart_images = self.get_cartesian_coords(images)
coords = cart_coords[:, None, None, None, :] + \
cart_images[None, :, :, :, :]
coords -= center[None, None, None, None, :]
coords **= 2
d_2 = np.sum(coords, axis=4)

within_r = np.where(d_2 <= r ** 2)
if zip_results:
return list(zip(shifted_coords[within_r], dists[within_r],
return list(zip(shifted_coords[within_r], np.sqrt(d_2[within_r]),
indices[within_r[0]]))
else:
return shifted_coords[within_r], dists[within_r], \
return shifted_coords[within_r], np.sqrt(d_2[within_r]), \
indices[within_r[0]]

def get_all_distances(self, fcoords1, fcoords2):
Expand Down
9 changes: 9 additions & 0 deletions pymatgen/core/tests/test_lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,15 @@ def test_find_all_mappings(self):
for l, _, _ in latt.find_all_mappings(latt, ltol=0.05, atol=11):
self.assertTrue(isinstance(l, Lattice))

def test_mapping_symmetry(self):
l = Lattice.cubic(1)
l2 = Lattice.orthorhombic(1.1001, 1, 1)
self.assertEqual(l.find_mapping(l2, ltol=0.1), None)
self.assertEqual(l2.find_mapping(l, ltol=0.1), None)
l2 = Lattice.orthorhombic(1.0999, 1, 1)
self.assertNotEqual(l2.find_mapping(l, ltol=0.1), None)
self.assertNotEqual(l.find_mapping(l2, ltol=0.1), None)

def test_to_from_dict(self):
d = self.tetragonal.as_dict()
t = Lattice.from_dict(d)
Expand Down

0 comments on commit ee6afcf

Please sign in to comment.