io Package

io Package

This package provides the packages and modules to perform IO from various input file formats and pymatgen objects.

aseio Module

This module provides conversion between the Atomic Simulation Environment Atoms object and pymatgen Structure objects.

class AseAtomsAdaptor[source]

Bases: object

Adaptor serves as a bridge between ASE Atoms and pymatgen structure.

static get_atoms(structure)[source]

Returns ASE Atoms object from pymatgen structure.

Args:
structure:
pymatgen.core.structure.Structure
Returns:
ASE Atoms object
static get_structure(atoms)[source]

Returns pymatgen structure from ASE Atoms.

Args:
atoms:
ASE Atoms object
Returns:
Equivalent pymatgen.core.structure.Structure

babelio Module

OpenBabel interface module, which opens up access to the hundreds of file formats supported by OpenBabel. Requires openbabel with python bindings to be installed. Please consult the openbabel documentation.

class BabelMolAdaptor(*args, **kwargs)[source]

Bases: object

Adaptor serves as a bridge between OpenBabel’s Molecule and pymatgen’s Molecule.

Initializes with pymatgen Molecule or OpenBabel”s OBMol.

Args:
mol:
pymatgen”s Molecule or OpenBabel OBMol
static from_file(filename, file_format='xyz')[source]

Uses OpenBabel to read a molecule from a file in all supported formats.

Args:
filename:
Filename of input file
file_format:
String specifying any OpenBabel supported formats.
Returns:
BabelMolAdaptor object
static from_string(string_data, file_format='xyz')[source]

Uses OpenBabel to read a molecule from a string in all supported formats.

Args:
string_data:
String containing molecule data.
file_format:
String specifying any OpenBabel supported formats.
Returns:
BabelMolAdaptor object
localopt(forcefield='mmff94', steps=500)

A wrapper to pybel’s localopt method to optimize a Molecule.

Args:
forcefield:
Default is mmff94. Options are ‘gaff’, ‘ghemical’, ‘mmff94’, ‘mmff94s’, and ‘uff’.
steps:
Default is 500.
openbabel_mol[source]

Returns OpenBabel’s OBMol.

pybel_mol

Returns Pybel’s Molecule object.

pymatgen_mol[source]

Returns pymatgen Molecule object.

write_file(filename, file_format='xyz')[source]

Uses OpenBabel to output all supported formats.

Args:
filename:
Filename of file to output
file_format:
String specifying any OpenBabel supported formats.

cifio Module

Wrapper classes for Cif input and output from Structures.

class CifParser(filename, occupancy_tolerance=1.0)[source]

Bases: object

A wrapper class around PyCifRW to read Cif and convert into a pymatgen Structure object.

Args:
filename:
Cif filename. bzipped or gzipped cifs are fine too.
occupancy_tolerance:
If total occupancy of a site is between 1 and occupancy_tolerance, the occupancies will be scaled down to 1.
static from_string(cif_string, occupancy_tolerance=1.0)[source]

Creates a CifParser from a string.

Args:
cif_string:
String representation of a CIF.
occupancy_tolerance:
If total occupancy of a site is between 1 and occupancy_tolerance, the occupancies will be scaled down to 1.
Returns:
CifParser
get_structures(primitive=True)[source]

Return list of structures in CIF file. primitive boolean sets whether a conventional cell structure or primitive cell structure is returned.

Args:
primitive:
Set to False to return conventional unit cells. Defaults to True.
Returns:
List of Structures.
to_dict[source]
class CifWriter(struct)[source]

A wrapper around PyCifRW to write CIF files from pymatgen structures.

Args:
struct:
A pymatgen.core.structure.Structure object.
write_file(filename)[source]

Write the cif file.

float_from_str(text)[source]

Remove uncertainty brackets from strings and return the float.

parse_symmetry_operations(symmops_str_list)[source]

Help method to parse the symmetry operations.

Args:
symmops_str_list:
List of symmops strings of the form [‘x, y, z’, ‘-x, -y, z’, ‘-y+1/2, x+1/2, z+1/2’, ...]
Returns:
List of SymmOps

cssrio Module

This module provides input and output from the CSSR file format.

class Cssr(structure)[source]

Bases: object

Basic object for working with Cssr file. Right now, only conversion from a Structure to a Cssr file is supported.

Args:
structure:
A structure to create the Cssr object.
static from_file(filename)[source]

Reads a CSSR file to a Cssr object.

Args:
filename:
Filename to read from.
Returns:
Cssr object.
static from_string(string)[source]

Reads a string representation to a Cssr object.

Args:
string:
A string representation of a CSSR.
Returns:
Cssr object.
write_file(filename)[source]

Write out a CSSR file.

Args:
filename:
Filename to write to.

feffio Module

Classes for reading/manipulating/writing FEFF files. http://leonardo.phys.washington.edu/feff/ XANES and EXAFS input files, and the xmu.dat, ldos.dat output files are available, for non-spin case at this time. FEFF input file has parameter tags, potential definitions and atomic coordinates all in the feff.inp file. These are each developed separately with the Header, FeffAtoms, FeffPot, and FeffTags classes, then combined to produce the full feff.inp.

class FeffAtoms(struct, central_atom)[source]

Bases: pymatgen.serializers.json_coders.MSONable

Object for representing atomic positions, placed in feff.inp file These are oredered as expanding shells.

Args:
struct:
Structure object. See pymatgen.core.structure.Structure.
central_atom:
Symbol for absorbing atom
static atoms_string_from_file(filename)[source]

Reads atomic shells from file such as feff.inp or ATOMS file The lines are arranged as follows:

x y z ipot Atom Symbol Distance Number

with distance being the shell radius and ipot an integer identifying the potential used.

Args:
filename:
file name containing atomic coord data.
Returns:
Atoms string.
central_atom[source]

Returns central atom

static from_dict(d)[source]

Returns feffAtoms object from dictionary

static from_string(data)[source]

At the moment does nothing.

From atoms string data generates atoms object

get_string(radius=10.0)[source]

Returns a string representation of atomic shell coordinates to be used in the feff.inp file.

Args:
radius:
Maximum atomic shell radius to include in atoms list
Returns:
String representation of Atomic Coordinate Shells.
pot_dict[source]

returns dictionary for potential indexes

site_symbols[source]

Symbols for each site atomic coordinate for Feff list.

struct[source]

Structure associated with the atomic coordinates.

to_dict[source]

Return Dictionary representation of atoms oject

write_file(filename='ATOMS')[source]

Write Atoms list to filename

Args:
filename and path for file to be written
class FeffLdos(complete_dos, charge_transfer)[source]

Bases: pymatgen.serializers.json_coders.MSONable

Parser for ldos files ldos01, ldos02, .....

Args:
complete_dos:
complete_dos dictionary as defined in pymatgen.dos.CompleteDos
charge_transfer:
computed charge transfer between atoms dictionary
charge_transfer[source]

returns charge transfer between atoms dictionary

static charge_transfer_from_file(filename1, filename2)[source]
Args:
filename1:
name of feff.inp file for run
filename2:
ldos filename for run, assume consequetive order, .i.e., ldos01.dat, ldos02.dat....
Returns:
dictionary of dictionaries in order of potential sites ({“p”: 0.154, “s”: 0.078, “d”: 0.0, “tot”: 0.232}, ...)
charge_transfer_to_string()[source]

returns shrage transfer as string

complete_dos[source]

returns Complete Dos

static from_dict(d)[source]
Returns FeffLdos object from dict representation
Arg:
complete_dos:
dict representation of complete_dos
static from_file(filename1='feff.inp', filename2='ldos')[source]

” Creates FeffLdos object from raw Feff ldos files by by assuming they are numbered consequetively, i.e. ldos01.dat ldos02.dat...

Args:
filename1:
input file of run to obtain structure
filename2:
output ldos file of run to obtain dos info, etc.
to_dict[source]

returns Json-serializable dict representation of ompletedos

exception FeffParserError(msg)[source]

Bases: exceptions.Exception

Exception class for Structure. Raised when the structure has problems, e.g., atoms that are too close.

class FeffPot(struct, central_atom)[source]

Bases: pymatgen.serializers.json_coders.MSONable

Object for representing Atomic Potenitals, placed in feff.inp file

Args:
struct:
Structure object. See pymatgen.core.structure.Structure.
central_atom:
Absorbing atom symbol
central_atom[source]

Returns Central absorbing atom

static from_dict(d)[source]

Returns FeffPot object from dictionary

Args:
d:
dictionary of FeffPot input parameters
pot_dict[source]

Returns dictionary of potential indexes

static pot_dict_from_string(pot_data)[source]

Creates atomic symbol/potential number dictionary forward and reverse

Arg:
pot_data:
potential data in string format
Returns:
forward and reverse atom symbol and potential number dictionaries.
static pot_string_from_file(filename)[source]

Reads Potential parameters from a feff.inp or FEFFPOT file. The lines are arranged as follows:

ipot Z element lmax1 lmax2 stoichometry spinph
Args:
filename - file name containing potential data.
Returns:
FEFFPOT string.
site_symbols[source]

Symbols for each site.

struct[source]

Structure associated with the atomic coordinates.

to_dict[source]

Return Dictionary representation of FeffPot oject

write_file(filename='POTENTIALS')[source]

Write to a filename.

Args:
filename:
filename and path to write potential file to.
class FeffTags(params=None)[source]

Bases: dict

feff_tag object for reading and writing PARAMETER files

Creates a Feff_tag object.

Args:
params:
A set of input parameters as a dictionary.
diff(other)[source]

Diff function. Compares two PARAMETER files and indicates which parameters are the same and which are not. Useful for checking whether two runs were done using the same parameters.

Args:
other:
The other PARAMETER dictionary to compare to.
Returns:
Dict of the format {“Same” : parameters_that_are_the_same, “Different”: parameters_that_are_different} Note that the parameters are return as full dictionaries of values.
static from_dict(d)[source]

Creates FeffTags object from a dictionary.

Args:
d:
Dict of feff parameters and values.
Returns:
FeffTags object
static from_file(filename='feff.inp')[source]

Creates a Feff_tag dictionary from a PARAMETER or feff.inp file.

Args:
filename:
Filename for either PARAMETER or feff.inp file
Returns:
Feff_tag object
get_string(sort_keys=True, pretty=True)[source]

Returns a string representation of the Feff_tag file. The reason why this method is different from the __str__ method is to provide options for pretty printing.

Args:
sort_keys:
Set to True to sort the Feff parameters alphabetically. Defaults to False.
pretty:
Set to True for pretty aligned output, False for no.
Returns:
String representation of FeffTags.
static proc_val(key, val)[source]

Static helper method to convert Feff parameters to proper types, e.g. integers, floats, lists, etc.

Args:
key:
Feff parameter key
val:
Actual value of Feff parameter.
to_dict[source]
Returns:
Dictionary of parameters from fefftags object
write_file(filename='PARAMETERS')[source]

Write FeffTags to a Feff parameter tag file.

Args:
filename:
filename and path to write to.
class Header(struct, source='', comment='')[source]

Bases: pymatgen.serializers.json_coders.MSONable

Creates Header for feff.inp file generated by pymatgen. Has the following format:

* This feff.inp file generated by pymatgen, www.materialsproject.org
TITLE comment:
TITLE Source: CoO19128.cif
TITLE Structure Summary: (Co2 O2)
TITLE Reduced formula: CoO
TITLE space group: P1,   space number: 1
TITLE abc: 3.297078 3.297078 5.254213
TITLE angles: 90.0 90.0 120.0
TITLE sites: 4
* 1 Co     0.666666     0.333332     0.496324
* 2 Co     0.333333     0.666667     0.996324
* 3 O     0.666666     0.333332     0.878676
* 4 O     0.333333     0.666667     0.378675
Args:
struct:
Structure object, See pymatgen.core.structure.Structure.
source:
User supplied identifier, i.e. for Materials Project this would be the material ID number
comment:
comment for first header line
formula[source]

Formula of structure

static from_cif_file(cif_file, source='', comment='')[source]

Static method to create Header object from cif_file

Args:
cif_file:
cif_file path and name
source:
User supplied identifier, i.e. for Materials Project this would be the material ID number
comment:
user comment that goes in header
Returns:
Header Object
static from_dict(hdict)[source]

Returns header object from a dictionary representation

static from_file(filename)[source]

Returns Header object from file

static from_string(header_str)[source]

Reads Header string and returns Header object if header was generated by pymatgen.

Args:
header_str:
pymatgen generated feff.inp header
Returns:
structure object.
static header_string_from_file(filename)[source]

Reads Header string from either a HEADER file or feff.inp file Will also read a header from a non-pymatgen generated feff.inp file

Args:
filename:
File name containing the Header data.
Returns:
Reads header string.
site_symbols[source]

Symbols for each site in unit cell.

source[source]

Property method to return source string.

space_group[source]

Returns Space Group symbol

space_number[source]

Returns Space group number

struct[source]

Structure associated with the atomic coordinates.

structure_symmetry[source]

Returns space number and space group

Returns:
Space number and space group list
to_dict[source]

Returns Dictionary representation of Header Object

write_file(filename='HEADER')[source]

Writes Header into filename on disk.

Args:
filename:
Filename and path for file to be written to disk
class Xmu(header, parameters, central_atom, data)[source]

Bases: pymatgen.serializers.json_coders.MSONable

Parser for data in xmu.dat
Reads in data from xmu Feff file for plotting This file contains the absorption cross-sections for the single absorber and absorber in solid.

Default attributes:

xmu:
Photon absorption cross section of absorber atom in material
mu:
Photon absorption cross section of single absorber atom
Energies:
Energies of data point
Edge:
Aborption Edge
Absorbing atom:
Species of absorbing atom
Material:
Formula of material
Source:
Source of structure
Calculation:
Type of Feff calculation performed

to_dict: creates a dictionary representation of attributes and data

Args:
header:
Header object
parameters:
FeffTags object
pots:
FeffPot string
data:
numpy data array of cross_sections
absorbing_atom[source]

Returns absorbing atom symbol from feff.inp file

across_section[source]

Returns absobtion cross-section of absorbing atom in solid

calc[source]

Returns type of Feff calculation, XANES or EXAFS from feff.inp file

data[source]

returns numpy data array

edge[source]

Returns excitation edge from feff.inp file

energies[source]

Returns energies for cross-section plots

static from_dict(xdict)[source]

Returns Xmu object from dictionary

static from_file(filename='xmu.dat', input_filename='feff.inp')[source]
Args:
filename:
filename and path for xmu.dat
input_filename:
filname and path of feff.inp input file
Returns:
Xmu object
material_formula[source]

Returns chemical formula of material from feff.inp file

scross_section[source]

Returns aborption cross-section for absorbing atom

source[source]

Returns source identification from Header file

to_dict[source]

Returns Dictionary of attributes and to reproduce object using from dictionary staticmethod

feffio_set Module

This module defines the FeffInputSet abstract base class and a concrete implementation for the Materials Project. The basic concept behind an input set is to specify a scheme to generate a consistent set of Feff inputs from a structure without further user intervention. This ensures comparability across runs.

class AbstractFeffInputSet[source]

Bases: object

Abstract base class representing a set of Feff input parameters. The idea is that using a FeffInputSet, a complete set of input files (feffPOT,feffXANES, feffEXAFS, ATOMS, feff.inp)set_ can be generated in an automated fashion for any structure.

static from_dict(d)[source]

Return feff.inp from a dictionary string representation

get_all_feff_input(structure, calc_type, source, central_atom, comment='')[source]

Returns all input files as a dict of {filename: feffio object}

Args:
structure:
Structure object
calc_type:
at this time either ‘XANES’ or ‘EXAFS’ string is supported for K shell excitation. In the future this will be expanded to inlude other shells and material class differentiation.
source:
source identifier used to create structure, can be defined however user wants to organize structures, calculations, etc. example would be Materials Project material ID number.
central _atom:
atom symbol string for absorbing atom
comment:
Comment to appear in Header.
Returns:
dict of objects used to create feff.inp file i.e. Header, FeffTags, FeffPot, FeffAtoms
get_feff_atoms(structure, central_atom)[source]

Returns Atoms string from a structure that goes in feff.inp file.

Args:
structure:
pymatgen structure object
central_atom:
atom symbol string for absorbing atom
Returns:
FeffAtoms object.
get_feff_pot(structure, central_atom)[source]

Returns POTENTIAL section used in feff.inp from a structure.

Args:
structure:
pymatgen structure object
central _atom:
atom symbol string for absorbing atom
get_feff_tags(calc_type)[source]

Returns standard calculation paramters for either an FEFF XANES or EXAFS input.

Args:
calc_type:
at this time either ‘XANES’ or ‘EXAFS’ string is supported for K shell excitation. In the future this will be expanded to inlude other shells and material class differentiation.
get_header(structure, source, comment)[source]

Returns header to be used in feff.inp file from a pymatgen structure

Args:
structure:
A pymatgen structure object
source:
source identifier used to create structure, can be defined however user wants to organize structures, calculations, etc. example would be Materials Project material ID number.
to_dict(structure, calc_type, source, central_atom, comment='')[source]

Creates a feff.inp dictionary as a string

write_input(structure, calc_type, source, central_atom, comment='', output_dir='.', make_dir_if_not_present=True)[source]

Writes a set of FEFF input to a directory.

Args:
structure:
Structure object
calc_type:
at this time either ‘XANES’ or ‘EXAFS’ string is supported for K shell excitation. In the future this will be expanded to inlude other shells and material class differentiation.
source:
source identifier used to create structure, can be defined however user wants to organize structures, calculations, etc. example would be Materials Project material ID number.
central _atom:
atom symbol string for absorbing atom output_dir: Directory to output the FEFF input files
comment:
comment for Header
make_dir_if_not_present:
Set to True if you want the directory (and the whole path) to be created if it is not present.
class FeffInputSet(name)[source]

Bases: pymatgen.io.feffio_set.AbstractFeffInputSet

Standard implementation of FeffInputSet, which can be extended by specific implementations.

Args:
name:
The name of a grouping of input parameter sets such as “MaterialsProject”.
get_feff_atoms(structure, central_atom)[source]

Creates string representation of atomic shell coordinates using in ATOMS file and feff.inp.

Args:
structure:
pymatgen structure object
central_atom:
atom symbol string for absorbing atom
Returns:
FeffAtoms object
get_feff_pot(structure, central_atom)[source]

Creates string representation of potentials used in POTENTIAL file and feff.inp.

Args:
structure:
pymatgen structure object
central _atom:
atom symbol string for absorbing atom
Returns:
FeffPot object
get_feff_tags(calc_type)[source]

Reads standard parameters for XANES or EXAFS calculation from FeffInputSets.cfg file.

Args:
calc_type:
at this time either ‘XANES’ or ‘EXAFS’ string is supported for K shell excitation. In the future this will be expanded to inlude other shells and material class differentiation.
Returns:
FeffTags object
get_header(structure, source='', comment='')[source]

Creates header string from structure object

Args:
structure:
A pymatgen structure object
source:
source identifier used to create structure, can be defined however user wants to organize structures, calculations, etc. example would be Materials Project material ID number.
comment:
comment to include in header
Returns:
Header object to be used in feff.inp file from a pymatgen structure
class MaterialsProjectFeffInputSet[source]

Bases: pymatgen.io.feffio_set.FeffInputSet

Implementation of FeffInputSet utilizing parameters in the public Materials Project.

gaussianio Module

This module implements input and output processing from Gaussian.

class GaussianInput(mol, charge=None, spin_multiplicity=None, title=None, functional='HF', basis_set='6-31G(d)', route_parameters=None, input_parameters=None, link0_parameters=None)[source]

Bases: object

An object representing a Gaussian input file.

Args:
mol:
Input molecule. If molecule is a single string, it is used as a direct input to the geometry section of the Gaussian input file.
charge:
Charge of the molecule. If None, charge on molecule is used. Defaults to None. This allows the input file to be set a charge independently from the molecule itself.
spin_multiplicity:
Spin multiplicity of molecule. Defaults to None, which means that the spin multiplicity is set to 1 if the molecule has no unpaired electrons and to 2 if there are unpaired electrons.
title:
Title for run. Defaults to formula of molecule if None.
functional:
Functional for run.
basis_set:
Basis set for run.
route_parameters:
Additional route parameters as a dict. For example, {‘SP’:””, “SCF”:”Tight”}
input_parameters:
Additional input parameters for run as a dict. Used for example, in PCM calculations. E.g., {“EPS”:12}
link0_parameters:
Link0 parameters as a dict. E.g., {“%mem”: “1000MW”}
static from_file(filename)[source]

Creates GaussianInput from a file.

Args:
filename:
Gaussian input filename
Returns:
GaussianInput object
static from_string(contents)[source]

Creates GaussianInput from a string.

Args:
contents:
String representing an Gaussian input file.
Returns:
GaussianInput object
get_zmatrix()[source]

Returns a z-matrix representation of the molecule.

molecule[source]

Returns molecule associated with this GaussianInput.

static parse_coords(coord_lines)[source]

Helper method to parse coordinates.

write_file(filename)
xyz_patt = <_sre.SRE_Pattern object at 0x101fe72b0>
zmat_patt = <_sre.SRE_Pattern object at 0x101fe5460>
class GaussianOutput(filename)[source]

Bases: object

Parser for Gaussian output files.

Note

Still in early beta.

Attributes:

structures

All structures from the calculation.

energies

All energies from the calculation.

properly_terminated

True if run has properly terminated

is_pcm

True if run is a PCM run.

stationary_type

If it is a relaxation run, indicates whether it is a minimum (Minimum) or a saddle point (“Saddle”).

corrections

Thermochemical corrections if this run is a Freq run as a dict. Keys are “Zero-point”, “Thermal”, “Enthalpy” and “Gibbs Free Energy”

functional

Functional used in the run.

basis_set

Basis set used in the run

charge

Charge for structure

spin_mult

Spin multiplicity for structure

num_basis_func

Number of basis functions in the run.

pcm

PCM parameters and output if available.

Args:
filename:
Filename of Gaussian output file.
final_energy[source]
final_structure[source]
to_dict[source]

Json-serializable dict representation.

smartio Module

This class implements smart io classes that performs intelligent io based on file extensions.

read_mol(filename)

Reads a molecule based on file extension. For example, anything ending in a “xyz” is assumed to be a XYZ file. Supported formats include xyz, gaussian input (gjf|g03|g09|com|inp), Gaussian output (.out|and pymatgen’s JSON serialized molecules. Using openbabel, many more extensions are supported but requires openbabel to be installed.

Args:
filename:
A filename to read from.
Returns:
A Molecule object.
read_structure(filename)[source]

Reads a structure based on file extension. For example, anything ending in a “cif” is assumed to be a Crystallographic Information Format file. Supported formats include CIF, POSCAR/CONTCAR, CHGCAR, LOCPOT, vasprun.xml, CSSR and pymatgen’s JSON serialized structures.

Args:
filename:
A filename to read from.
Returns:
A Structure object.
write_mol(mol, filename)

Write a molecule to a file based on file extension. For example, anything ending in a “xyz” is assumed to be a XYZ file. Supported formats include xyz, Gaussian input (gjf|g03|g09|com|inp), and pymatgen’s JSON serialized molecules.

Args:
mol:
Molecule to write
filename:
A filename to write to.
write_structure(structure, filename)[source]

Write a structure to a file based on file extension. For example, anything ending in a “cif” is assumed to be a Crystallographic Information Format file. Supported formats include CIF, POSCAR, CSSR and pymatgen’s JSON serialized structures.

Args:
structure:
Structure to write
filename:
A filename to write to.

vaspio_set Module

This module defines the VaspInputSet abstract base class and a concrete implementation for the parameters used by the Materials Project and the MIT high throughput project. The basic concept behind an input set is to specify a scheme to generate a consistent set of Vasp inputs from a structure without further user intervention. This ensures comparability across runs.

class AbstractVaspInputSet[source]

Bases: pymatgen.serializers.json_coders.MSONable

Abstract base class representing a set of Vasp input parameters. The idea is that using a VaspInputSet, a complete set of input files (INPUT, KPOINTS, POSCAR and POTCAR) can be generated in an automated fashion for any structure.

get_all_vasp_input(structure, generate_potcar=True)[source]

Returns all input files as a dict of {filename: vaspio object}

Args:
structure:
Structure object
generate_potcar:
Set to False to generate a POTCAR.spec file instead of a POTCAR, which contains the POTCAR labels but not the actual POTCAR. Defaults to True.
Returns:
dict of {filename: file_as_string}, e.g., {‘INCAR’:’EDIFF=1e-4...’}
get_incar(structure)[source]

Returns Incar from a structure.

Args:
structure:
Structure object
Returns:
Incar object
get_kpoints(structure)[source]

Returns Kpoints from a structure.

Args:
structure:
Structure object
Returns:
Kpoints object
get_poscar(structure)[source]

Returns Poscar from a structure.

get_potcar(structure)[source]

Returns Potcar from a structure.

Args:
structure:
Structure object
Returns:
Potcar object
get_potcar_symbols(structure)[source]

Returns list of POTCAR symbols from a structure.

Args:
structure:
Structure object
Returns:
List of POTCAR symbols
write_input(structure, output_dir, make_dir_if_not_present=True)[source]

Writes a set of VASP input to a directory.

Args:
structure:
Structure object
output_dir:
Directory to output the VASP input files
make_dir_if_not_present:
Set to True if you want the directory (and the whole path) to be created if it is not present.
class DictVaspInputSet(name, config_dict, constrain_total_magmom=False)[source]

Bases: pymatgen.io.vaspio_set.AbstractVaspInputSet

Concrete implementation of VaspInputSet that is initialized from a dict settings. This allows arbitrary settings to be input. In general, this is rarely used directly unless there is a source of settings in JSON format (e.g., from a REST interface). It is typically used by other VaspInputSets for initialization.

Special consideration should be paid to the way the MAGMOM initialization for the INCAR is done. The initialization differs depending on the type of structure and the configuration settings. The order in which the magmom is determined is as follows:

  1. If the site itself has a magmom setting, that is used.
  2. If the species on the site has a spin setting, that is used.
  3. If the species itself has a particular setting in the config file, that is used, e.g., Mn3+ may have a different magmom than Mn4+.
  4. Lastly, the element symbol itself is checked in the config file. If there are no settings, VASP’s default of 0.6 is used.
Args:
name:
The name in the config file.
config_dict:
The config dictionary to use.
user_incar_settings:
User INCAR settings. This allows a user to override INCAR settings, e.g., setting a different MAGMOM for various elements or species.
constrain_total_magmom:
Whether to constrain the total magmom (NUPDOWN in INCAR) to be the sum of the expected MAGMOM for all species. Defaults to False.
static from_dict(d)[source]
get_incar(structure)[source]
get_kpoints(structure)[source]

Writes out a KPOINTS file using the fully automated grid method. Uses Gamma centered meshes for hexagonal cells and Monk grids otherwise.

Algorithm:
Uses a simple approach scaling the number of divisions along each reciprocal lattice vector proportional to its length.
get_potcar(structure)[source]
get_potcar_symbols(structure)[source]
to_dict[source]
class MITGGAVaspInputSet(user_incar_settings=None, constrain_total_magmom=False)[source]

Bases: pymatgen.io.vaspio_set.VaspInputSet

Typical implementation of input set for a GGA run based on MIT parameters.

static from_dict(d)[source]
to_dict[source]
class MITHSEVaspInputSet(user_incar_settings=None, constrain_total_magmom=False)[source]

Bases: pymatgen.io.vaspio_set.VaspInputSet

Typical implementation of input set for a HSE run.

static from_dict(d)[source]
to_dict[source]
class MITMDVaspInputSet(start_temp, end_temp, nsteps, time_step=2, prec='Low', ggau=False, user_incar_settings=None)[source]

Bases: pymatgen.io.vaspio_set.VaspInputSet

Class for writing a vasp md run. This DOES NOT do multiple stage runs.

Args:
start_temp:
Starting temperature.
end_temp:
Final temperature.
nsteps:
Number of time steps for simulations. The NSW parameter.
time_step:
The time step for the simulation. The POTIM parameter. Defaults to 2fs.
prec:
precision - Normal or LOW. Defaults to Low.
ggau:
whether to use +U or not. Defaults to False.
user_incar_settings:
dictionary of incar settings to override
static from_dict(d)[source]
get_kpoints(structure)[source]
to_dict[source]
class MITVaspInputSet(user_incar_settings=None, constrain_total_magmom=False)[source]

Bases: pymatgen.io.vaspio_set.VaspInputSet

Standard implementation of VaspInputSet utilizing parameters in the MIT High-throughput project. The parameters are chosen specifically for a high-throughput project, which means in general pseudopotentials with fewer electrons were chosen.

Please refer to A Jain, G. Hautier, C. Moore, S. P. Ong, C. Fischer, T. Mueller, K. A. Persson, G. Ceder. A high-throughput infrastructure for density functional theory calculations. Computational Materials Science, 2011, 50(8), 2295-2310. doi:10.1016/j.commatsci.2011.02.023 for more information.

static from_dict(d)[source]
to_dict[source]
class MPGGAVaspInputSet(user_incar_settings=None, constrain_total_magmom=False)[source]

Bases: pymatgen.io.vaspio_set.DictVaspInputSet

Same as the MaterialsProjectVaspInput set, but the +U is enforced to be turned off.

static from_dict(d)[source]
to_dict[source]
class MPNonSCFVaspInputSet(user_incar_settings, mode='Line', constrain_total_magmom=False)[source]

Bases: pymatgen.io.vaspio_set.MPStaticVaspInputSet

Implementation of VaspInputSet overriding MaterialsProjectVaspInputSet for non self-consistent field (NonSCF) calculation that follows a static run to calculate bandstructure, density of states(DOS) and etc. It is recommended to use the NonSCF from_previous_run method to construct the input set to inherit most of the functions.

Args:
user_incar_settings:
A dict specify customized settings for INCAR. Must contain a NBANDS value, suggest to use 1.2*(NBANDS from static run).
mode:
Line: Generate k-points along symmetry lines for bandstructure Uniform: Generate uniform k-points grids for DOS
static from_previous_vasp_run(previous_vasp_dir, output_dir='.', mode='Uniform', user_incar_settings=None, copy_chgcar=True, make_dir_if_not_present=True)[source]

Generate a set of Vasp input files for NonSCF calculations from a directory of previous static Vasp run.

Args:
previous_vasp_dir:
The directory contains the outputs(vasprun.xml and OUTCAR) of previous vasp run.
output_dir:
The directory to write the VASP input files for the NonSCF calculations. Default to write in the current directory.
copy_chgcar:
Default to copy CHGCAR from SC run
make_dir_if_not_present:
Set to True if you want the directory (and the whole path) to be created if it is not present.
static get_incar_settings(vasp_run, outcar=None)[source]

Helper method to get necessary user_incar_settings from previous run.

get_kpoints(structure, kpoints_density=1000)[source]

Get a KPOINTS file for NonSCF calculation. In “Line” mode, kpoints are generated along high symmetry lines. In “Uniform” mode, kpoints are Gamma-centered mesh grid. Kpoints are written explicitly in both cases.

Args:
kpoints_density:
kpoints density for the reciprocal cell of structure. Suggest to use a large kpoints_density. Might need to increase the default value when calculating metallic materials.
class MPStaticVaspInputSet(user_incar_settings=None, constrain_total_magmom=False)[source]

Bases: pymatgen.io.vaspio_set.MPVaspInputSet

Implementation of VaspInputSet overriding MaterialsProjectVaspInputSet for static calculations that typically follow relaxation runs. It is recommended to use the static from_previous_run method to construct the input set to inherit most of the functions.

Args:
user_incar_settings:
A dict specify customized settings for INCAR
static from_previous_vasp_run(previous_vasp_dir, output_dir='.', user_incar_settings=None, make_dir_if_not_present=True)[source]

Generate a set of Vasp input files for static calculations from a directory of previous Vasp run.

Args:
previous_vasp_dir:
The directory contains the outputs(vasprun.xml and OUTCAR) of previous vasp run.
output_dir:
The directory to write the VASP input files for the static calculations. Default to write in the current directory.
make_dir_if_not_present:
Set to True if you want the directory (and the whole path) to be created if it is not present.
get_kpoints(structure, kpoints_density=90)[source]

Get a KPOINTS file using the fully automated grid method. Uses Gamma centered meshes for hexagonal cells and Monk grids otherwise.

Args:
kpoints_density:
kpoints density for the reciprocal cell of structure. Might need to increase the default value when calculating metallic materials.
static get_structure(vasp_run, outcar=None, initial_structure=False, refined_structure=False)[source]

Process structure for static calculations from previous run.

Args:
vasp_run:
Vasprun object that contains the final structure from previous run.
outcar:
Outcar object that contains the magnetization info from previous run.
initial_structure:
Whether to return the structure from previous run. Default is False.
refined_structure:
Whether to return the refined structure (conventional cell)
Returns:
Returns the magmom-decorated structure that can be passed to get Vasp input files, e.g. get_kpoints.
class MPVaspInputSet(user_incar_settings=None, constrain_total_magmom=False)[source]

Bases: pymatgen.io.vaspio_set.DictVaspInputSet

Implementation of VaspInputSet utilizing parameters in the public Materials Project. Typically, the pseudopotentials chosen contain more electrons than the MIT parameters, and the k-point grid is ~50% more dense. The LDAUU parameters are also different due to the different psps used, which result in different fitted values (even though the methodology of fitting is exactly the same as the MIT scheme).

static from_dict(d)[source]
to_dict[source]
class VaspInputSet(name, config_file, user_incar_settings=None, constrain_total_magmom=False)[source]

Bases: pymatgen.io.vaspio_set.DictVaspInputSet

Standard implementation of VaspInputSet that uses a config file to initialize settings. See DictVaspInputSet for specific details regarding how MAGMOM, LDAU settings are set.

Args:
name:
The name in the config file.
config_file:
The config file to use. If None (the default), a default config file containing Materials Project and MIT parameters is used.
user_incar_settings:
User INCAR settings. This allows a user to override INCAR settings, e.g., setting a different MAGMOM for various elements or species.
constrain_total_magmom:
Whether to constrain the total magmom (NUPDOWN in INCAR) to be the sum of the expected MAGMOM for all species. Defaults to False.
static from_dict(d)[source]
to_dict[source]
batch_write_vasp_input(structures, vasp_input_set, output_dir, make_dir_if_not_present=True, subfolder=None, sanitize=False, include_cif=False)[source]

Batch write vasp input for a sequence of structures to output_dir, following the format output_dir/{group}/{formula}_{number}.

Args:
structures:
Sequence of Structures.
vasp_input_set:
pymatgen.io.vaspio_set.VaspInputSet like object that creates vasp input files from structures
output_dir:
Directory to output files
make_dir_if_not_present:
Create the directory if not present. Defaults to True.
subfolder:
function to create subdirectory name from structure. Defaults to simply “formula_count”.
sanitize:
Boolean indicating whether to sanitize the structure before writing the VASP input files. Sanitized output are generally easier for viewing and certain forms of analysis. Defaults to False.
include_cif:
Boolean indication whether to output a CIF as well. CIF files are generally better supported in visualization programs.

xyzio Module

Module implementing an XYZ file object class.

class XYZ(mol, coord_precision=6)[source]

Bases: object

Basic class for importing and exporting Molecules or Structures in XYZ format.

Note

Exporting periodic structures in the XYZ format will lose information about the periodicity. Essentially, only cartesian coordinates are written in this format and no information is retained about the lattice.

Args:
mol:
Input molecule
static from_file(filename)[source]

Creates XYZ object from a file.

Args:
filename:
XYZ filename
Returns:
XYZ object
static from_string(contents)[source]

Creates XYZ object from a string.

Args:
contents:
String representing an XYZ file.
Returns:
XYZ object
molecule[source]

Returns molecule associated with this XYZ.

write_file(filename)[source]

Writes XYZ to file.

Args:
filename:
File name of output file.