Base class for a database entry.
The core model for typical database entries. An Entry model represents an input structure to the database, and can be created from any input file. The Entry also ties together all of the associated Structures, Calculations, References, FormationEnergies, and other associated database entries.
Database fields: calculation, composition, dos, duplicate_of, duplicates, element_set, formationenergy, id, job, label, meta_data, natoms, ntypes, path, project_set, prototype, reference, species_set, structure, task
Dictionary of label:Calculation pairs.
Attempts to load the charge density of the final calculation, if it is done. If not, returns False.
Create an Entry object from a provided input file.
Looks for a computing script matching the first argument, and attempts to run it with itself as the first argument. Sends args and kwargs to the script. Should return a Calculation object, or list of Calculation objects.
Example: >>> e = Entry.objects.get(id=123) >>> e.do(‘relaxation’) <Calculation: 523 @ relaxation settings>
List of Elements
If the structure has been relaxed, returns the formation energy of the final relaxed structure. Otherwise, returns None.
List of errors encountered in all calculations.
Return list of holds
A note indicating a reason the entry should not be calculated
HTML formatted name
Return list of keywords
Descriptive keyword for looking up entries
LaTeX formatted name
Return the mass of the entry, normalized to per atom.
Moves all calculation files to the specified path.
Unformatted name
List of Projects
Composition dictionary, in reduced form.
Deletes all calculations, removes all associated structures - returns the entry to a pristine state.
Saves the Entry, as well as all associated objects.
Return the set of elements in the input structure.
Example: >>> e = Entry.create(“fe2o3/POSCAR”) # an input containing Fe2O3 >>> e.space set([“Fe”, “O”])
Composition dictionary, using species (element + oxidation state) instead of just the elements.
List of Species
If the structure has been relaxed, returns the formation energy of the final relaxed structure. Otherwise, returns None.
Composition dictionary, normalized to 1 atom.
Attempts to open the input structure for visualization using VESTA
If the entry has gone through relaxation, returns the relaxed volume. Otherwise, returns the input volume.
Structure model. Principal attributes are a lattice and basis set.
Database fields: atom_set, calculated, composition, delta_e, element_set, energy, energy_pa, entry, fit, id, label, magmom, magmom_pa, measured, meta_data, meta_stability, natoms, nsites, ntypes, prototype, reference, site, source, spacegroup, species_set, step, sxx, sxy, syy, syz, szx, szz, volume, volume_pa, x1, x2, x3, y1, y2, y3, z1, z2, z3
List of atomic symbols, length equal to number of atoms.
List of atomic numbers, length equal to number of atoms.
Return atomic positions in cartesian coordinates.
Lattice vectors, 3x3 numpy.ndarray.
Return list of comments
Composition dictionary.
numpy.ndarray of atom coordinates of shape (3, natoms).
Create a complete copy of the structure, with any primary keys removed, so it is not associated with the original.
List of Elements
numpy.ndarray of forces on atoms.
Return the shorted distance between two atoms in the structure.
From self.atoms, creates a list of Sites. Atoms which are closer than tol from one another are considered on the same site.
Calculates the volume from the triple product of self.cell
Sort self.atoms according to the site they occupy.
Precalculates the inverse of the lattice, for faster conversion between cartesian and direct coordinates.
Randomly displace all atoms in each direction by a distance up to +/- the distance keyword argument.
Examples: >>> s = io.read(‘POSCAR’) >>> s2, trans = s.joggle_atoms(in_place=False) >>> trans = s.joggle_atoms(1e-1) >>> trans = s.joggle_atoms(distance=1e-1)
Return list of keywords
Dictionary of lattice parameters.
Tuple of lattice parameters (a, b, c, alpha, beta, gamma).
numpy.ndarray of magnetic moments of shape (natoms,).
Uses spglib to convert to the conventional cell.
Uses spglib to convert to the primitive cell.
Note: does not handle partial occupancy. If the cell is partially occupied, it is returned as is.
np.dot(self.cell.T, self.cell)
Unformatted name.
Translate the internal coordinates to center the specified atom. Atom can be an actual Atom from the Structure.atoms list, or can be identified by index.
Examples: >>> s = io.read(‘POSCAR’) >>> s.recenter(s[2]) >>> s2 = s.recenter(s[0], in_place=False) >>> s2.recenter(2) >>> s == s2 True
Reciprocal lattice of the structure.
Get the transformation matrix from unit to reduced cell Acta. Cryst. (1976) A32, 297 Acta. Cryst. (2003) A60, 1
Examples: >>> s = io.read(‘POSCAR’) >>> s.reduce() >>> s.reduce(in_place=False, get_transform=False)
Assigns magnetic moments to all atoms in accordance with the specified magnetism scheme.
Schemes:
Keyword | Description |
---|---|
None | all magnetic moments = None |
“ferro” | atoms with partially filled d and f shells are assigned a magnetic moment of 5 mu_b |
“anti” | finds a highly ordererd arrangement arrangement of up and down spins. If only 1 magnetic atom is found a ferromagnetic arrangment is used. raises NotImplementedError |
Set self.atoms to n blank Atoms.
Rescales the unit cell to the specified volume, keeping the direction and relative magnitudes of all lattice vectors the same.
numpy.ndarray of site coordinates of shape (3, nsites).
Labels for all sites. For sites with single occupancy returns the atomic symbol, for sites with multiple occupancies returns “(A,B)”.
Species composition dictionary.
List of species
List of species, length equal to number of atoms.
Calculated stresses, a numpy.ndarray of shape (6,)
Replace atoms, as specified in a dict of pairs.
Example: >>> s = io.read(‘POSCAR-Fe2O3’) >>> s2 = s.substitute({‘Fe’:’Ni’, ‘O’:’F’} rescale=True) >>> s2.substitute({‘Ni’:’Co’}, in_place=True, rescale=False)
Analyze the symmetry of the structure. Uses spglib to find the symmetry.
Apply lattice transform to the structure. Accepts transformations of shape (3,) and (3,3).
Examples: >>> s = io.read(‘POSCAR’) >>> s.transform([2,2,2]) # 2x2x2 supercell >>> s.transform([[0,1,0],[1,0,0],[0,0,1]]) # swap axis 1 for 2 >>> s2 = s.transform([2,2,2], in_place=False)
Shifts the contents of the structure by a vector.
Examples: >>> s = io.read(‘POSCAR’) >>> s.translate([1,2,3]) >>> s.translate([0.5,0.5, 0.5], cartesian=False) >>> s2 = s.translate([-1,2,1], in_place=False)
Composition dict, where sum(self.unit_comp.values()) == 1
Model for an Atom.
Database fields: charge, direct, element, fx, fy, fz, id, magmom, occupancy, ox, site, structure, volume, wyckoff, x, y, z
Creates an exact copy of the atom, only without the matching primary key.
Example: >>> a = Atom.get(‘Fe’, [0,0,0]) >>> a.save() >>> a.id 1 >>> a.copy() >>> a <Atom: Fe @ [0.000, 0.000, 0.000]> >>> a.id None
Creates a new Atom object.
coord (iterable of floats): Specifies the coordinate of the Atom.
forces (floats): Specifies the forces on the atom. magmom (float): The magnitude of the magnetic moment on the atom. charge (float): The charge on the Atom. volume (float): The atomic volume of the atom (Angstroms^3).
Examples: >>> Atom.create(‘Fe’, [0,0,0]) >>> Atom.create(‘Ni’, [0.5, 0.5, 0.5], ox=2, magmom=5, >>> forces=[0.2, 0.2, 0.2], >>> volume=101, charge=1.8, >>> occupancy=1)
Tests whether or not the Atom is on the specified Site.
Examples: >>> a = Atom.create(‘Fe’, [0,0,0]) >>> s = a.as_site() >>> a2 = Atom.create(‘Ni’, [0,0,0]) >>> a2.is_on(s) True
A lattice site.
Database fields: atom_set, id, structure, wyckoff, x, y, z
A site can be occupied by one Atom, many Atoms or no Atoms.
Adds Atom to Site.atoms.
Tests whether the atom belongs to different Structure and if it is within tol of the Site.
If the Site being assigned to doens’t have a coordinate, it is assigned the coordinate of atom.
Examples: >>> s = Site.create([0,0,0]) >>> a = Atom.create(‘Fe’, [0,0,0]) >>> s.add_atom(a) >>> s2 = Site() >>> s2.add_atom(a)
List of Atoms on the Site.
Composition dictionary of the Site.
Examples: >>> a1 = Atom(‘Fe’, [0,0,0], occupancy=0.2) >>> a2 = Atom(‘Ni’, [0,0,0], occupancy=0.8) >>> s = Site.from_atoms([a1,a2]) >>> s.comp {‘Fe’:0.2, ‘Ni’:0.8}
[Site.x, Site.y, Site.z]
Constructs a Site from a coordinate.
Examples: >>> s = Site.create([0.5,0.5,0.5])
Constructs a Site from an iterable of Atoms.
Site.coord is set as the average coord of all assigned Atoms.
Checks that the Atoms are close together. If the Atoms are further apart than tol, raises a SiteError
Examples: >>> a1 = Atom.create(‘Fe’, [0,0,0]) >>> a2 = Atom.create(‘Ni’, [1e-5, -1e-5, 0]) >>> s = Site.from_atoms([a1,a1])
Evaluates whether the Site is fully occupied.
Assigns a human friendly label for the Site, based on its atomic composition. If singly occupied, returns the symbol of the atom on the site. If multiply occupied, returns a comma seperated string
Examples: >>> s = Site.create({
Calculates the composition weighted average magnetic moment of the atoms on the Site.
Calculates the total occupancy of the site.
Calculates the composition weighted average oxidation state of the atoms on the Site.
Base class for storing a VASP calculation.
Database fields: attempt, band_gap, composition, configuration, converged, dos, element_set, energy, energy_pa, entry, fit, formationenergy, hubbard_set, id, input, irreducible_kpoints, label, magmom, magmom_pa, meta_data, natoms, nsteps, output, path, potential_set, runtime, settings
Return list of errors
Sets the calculations outcar attribute to a list of lines from the outcar.
Example: >>> calc = Calculation.read(‘calculation_path’) >>> print calc.outcar None >>> calc.get_outcar() >>> len(calc.outcar) 12345L
Reads the outcar specified by the objects path. Populates input field values, as well as outputs, in addition to finding errors and confirming convergence.
Example: >>> calc = Calculation.read(‘/path/to/calculation’)
Reads and returns VASP’s calculated charges for each atom. Returns the RAW charge, not NET charge.
Example: >>> calc = Calculation.read(‘path_to_calculation’) >>> calc.read_charges()
Reads the elements of the atoms in the structure. Returned as a list of atoms of shape (natoms,).
Example: >>> calc = Calculation.read(‘path_to_calculation’) >>> calc.read_elements() [‘Fe’, ‘Fe’, ‘O’, ‘O’, ‘O’]
Returns a numpy.ndarray of energies over all ionic steps.
Example: >>> calc = Calculation.read(‘calculation_path’) >>> calc.read_energies() array([-12.415236, -12.416596, -12.416927])
Reads and returns a numpy ndarray of lattice vectors for every ionic step of the calculation.
Example: >>> calc = Calculation.read(‘path_to_calculation’) >>> calc.read_lattice_vectors() array([[[ 4.17458823, 0. , 0. ],
[-2.08729412, 3.61529939, 0. ], [ 0. , 0. , 5.20720757]],
- [[ 4.17458823, 0. , 0. ],
- [-2.08729412, 3.61529939, 0. ], [ 0. , 0. , 5.20720757]],
- [[ 4.15950113, 0. , 0. ],
- [-2.07975057, 3.60223358, 0. ], [ 0. , 0. , 5.18670694]],
- [[ 4.16254664, 0. , 0. ],
- [-2.08127332, 3.60487107, 0. ], [ 0. , 0. , 5.18394359]]])
Reads the number of ionic steps, and assigns the value to nsteps.
Reads the number of atoms, and assigns the value to natoms.
Return list of warnings
Model for a Task to be done. A Task consists of a module, which is the name of a computing script.
Database fields: created, entry, finished, id, job, kwargs, module, priority, project_set, state
Task codes:
Code | Description |
---|---|
-2 | being held |
-1 | encountered error |
0 | ready to run |
1 | jobs running |
2 | completed |
Sets the Task state to 2 and populates the finished field.
List of errors encountered by related calculations.
Calls the task’s entry’s “do” method, with first argument as the tasks module, and subsequent arguments as the args list. If there is nothing left to do, returns an empty sequence. Cases:
given a project given an allocation
List of jobs related to the task.
List of related projects.
Base class for job submitted to a compute cluster.
Database fields: account, allocation, created, entry, finished, id, ncpus, path, qid, run_path, state, task, walltime
Job codes
Code | Description |
---|---|
-1 | encountered error |
0 | ready to submit |
1 | currently running |
2 | completed |