diff --git a/CHANGES.rst b/CHANGES.rst index 91e12e3d35b..97eadc6e96f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,28 @@ Change log ========== +v3.0.0 +------ +* Pymatgen is now completely Python 2.7 and Python 3.x compatible! +* Spglib and pyhull have been updated to support Python 3.x. +* Completely rewritten pure python cifio module (courtesy of William Davidson + Richards) removed dependency on PyCIFRW, which has been causing many issues + with installation. +* Structure and Molecule now supports a very convenient to() and from_str and + from_file functionality. Instead of trying to load the appropriate parser, + you can output and read from the appropriate formats directly. See example + usage. +* ~50% speedup to LinearAssignment code. +* Continuous integration and contribution guidelines now include Python 3. +* **Backwards incompatible changes** +* matgenie.py has now been renamed simply "pmg" for brevity. +* All deprecated methods in pymatgen 2.x have been removed. E.g., + pymatgen.core.structure_modifier is no longer available. +* Pymatgen classes now uses the as_dict() method protocol implemented in the + Monty package. The to_dict property is now deprecated and will be removed + in pymatgen v3.1. +* Update main docs page examples with the new Structure to, from formats. + v2.10.6 ------- * Bug fix for np1.9 incompatibility. Now works. diff --git a/docs/_static/Basic functionality.html b/docs/_static/Basic functionality.html index 2f79442646c..16c5394c587 100644 --- a/docs/_static/Basic functionality.html +++ b/docs/_static/Basic functionality.html @@ -1737,9 +1737,9 @@
si = mg.Element("Si")
-print "Atomic mass of Si is {}".format(si.atomic_mass)
-print "Si has a melting point of {}".format(si.melting_point)
-print "Ionic radii for Si: {}".format(si.ionic_radii)
+print("Atomic mass of Si is {}".format(si.atomic_mass))
+print("Si has a melting point of {}".format(si.melting_point))
+print("Ionic radii for Si: {}".format(si.ionic_radii))
print "Atomic mass of Si in kg: {}".format(si.atomic_mass.to("kg"))
+print("Atomic mass of Si in kg: {}".format(si.atomic_mass.to("kg")))
fe2 = mg.Specie("Fe", 2)
-print fe2.atomic_mass
-print fe2.ionic_radius
+print(fe2.atomic_mass)
+print(fe2.ionic_radius)
comp = mg.Composition("Fe2O3")
-print "Weight of Fe2O3 is {}".format(comp.weight)
-print "Amount of Fe in Fe2O3 is {}".format(comp["Fe"])
-print "Atomic fraction of Fe is {}".format(comp.get_atomic_fraction("Fe"))
-print "Weight fraction of Fe is {}".format(comp.get_wt_fraction("Fe"))
+print("Weight of Fe2O3 is {}".format(comp.weight))
+print("Amount of Fe in Fe2O3 is {}".format(comp["Fe"]))
+print("Atomic fraction of Fe is {}".format(comp.get_atomic_fraction("Fe")))
+print("Weight fraction of Fe is {}".format(comp.get_wt_fraction("Fe")))
# Creates cubic Lattice with lattice parameter 4.2
lattice = mg.Lattice.cubic(4.2)
-print lattice.lengths_and_angles
+print(lattice.lengths_and_angles)
structure = mg.Structure(lattice, ["Cs", "Cl"], [[0, 0, 0], [0.5, 0.5, 0.5]])
-print "Unit cell vol = {}".format(structure.volume)
-print "First site of the structure is {}".format(structure[0])
+print("Unit cell vol = {}".format(structure.volume))
+print("First site of the structure is {}".format(structure[0]))
#Determining the symmetry from pymatgen.symmetry.finder import SymmetryFinder finder = SymmetryFinder(structure) -print "The spacegroup is {}".format(finder.get_spacegroup_symbol()) +print("The spacegroup is {}".format(finder.get_spacegroup_symbol()))
#Convenient IO to various formats. Format is intelligently determined from file name and extension.
-mg.write_structure(structure, "POSCAR")
-mg.write_structure(structure, "CsCl.cif")
+structure.to(filename="POSCAR")
+structure.to(filename="CsCl.cif")
-#Reading a structure from a file.
-structure = mg.read_structure("POSCAR")
+#Or if you just supply fmt, you simply get a string.
+print(structure.to(fmt="poscar"))
+print(structure.to(fmt="cif"))
+
#Reading a structure from a file.
+structure = mg.Structure.from_file("POSCAR")
# A Molecule is simply a list of Sites.
-print mol[0]
-print mol[1]
+print(mol[0])
+print(mol[1])
# Break a Molecule into two by breaking a bond.
for frag in mol.break_bond(0, 1):
- print frag
+ print(frag)
# Getting neighbors that are within 3 angstroms from C atom.
-print mol.get_neighbors(mol[0], 3)
+print(mol.get_neighbors(mol[0], 3))
#Detecting bonds
-print mol.get_covalent_bonds()
+print(mol.get_covalent_bonds())
# If you need to run the molecule in a box with a periodic boundary condition
# code, you can generate the boxed structure as follows (in a 10Ax10Ax10A box)
structure = mol.get_boxed_structure(10, 10, 10)
-print structure
+print(structure)
Pymatgen has built-in support for Gaussian and Nwchem, two commonly used computational chemistry programs.
+Pymatgen has built-in support for the XYZ and Gaussian, NWchem file formats. It also has support for most other file formats if you have openbabel with Python bindings installed.
print(mol.to(fmt="xyz"))
+print(mol.to(fmt="g09"))
+print(mol.to(fmt="pdb")) #Needs Openbabel.
+
+mol.to(filename="methane.xyz")
+mol.to(filename="methane.pdb") #Needs Openbabel.
+
+print(Molecule.from_file("methane.pdb"))
+
For more fine-grained control over output, you can use the underlying IO classes Gaussian and Nwchem, two commonly used computational chemistry programs.
+from pymatgen.io.gaussianio import GaussianInput
@@ -2112,7 +2213,7 @@ Input/Output
functional="B3LYP", basis_set="6-31G(d)",
route_parameters={'Opt': "", "SCF": "Tight"},
link0_parameters={"%mem": "1000MW"})
-print gau
+print(gau)