Skip to content

Instantly share code, notes, and snippets.

@mpkocher
Created May 31, 2012 17:51
Show Gist options
  • Save mpkocher/2845028 to your computer and use it in GitHub Desktop.
Save mpkocher/2845028 to your computer and use it in GitHub Desktop.
Pymatgen Composition Example
from pymatgen.core.structure import Composition
ds = []
ds.append(dict(Mn=20, O=20))
ds.append(dict(Fe=3, O=4))
ds.append(dict(Li=2, Co=2, O=4))
for d in ds:
c = Composition.from_dict(d)
print c.formula
print c.reduced_formula
print c.to_dict
print c.anonymized_formula
print c.to_reduced_dict
print c.num_atoms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment