dpdata.formats.vasp package#

Submodules#

dpdata.formats.vasp.outcar module#

dpdata.formats.vasp.outcar.analyze_block(lines, ntot, nelm, ml=False)[source]#
dpdata.formats.vasp.outcar.atom_name_from_potcar_string(instr: str) → str[source]#

Get atom name from a potcar element name.

e.g. Sn_d -> Sn

Parameters:
instrstr

input potcar elemenet name

Returns:
name: str

name of atoms

dpdata.formats.vasp.outcar.check_outputs(coord, cell, force)[source]#
dpdata.formats.vasp.outcar.check_potcar_poscar_order(atom_names: list[str], atom_numbs: list[int], poscar_title: str | None) → None[source]#

Warn when POTCAR-paired counts contradict a POSCAR-title composition.

VASP pairs the ions per type counts, which come from the POSCAR, with the species order of the POTCAR. When the two files disagree, VASP neither reorders nor complains, so counts can silently land on the wrong elements and dpdata faithfully reports the mislabeled system. The POSCAR title is only a comment, however, so compare compositions rather than token order.

dpdata.formats.vasp.outcar.composition_from_poscar_title(title: str) → dict[str, int] | None[source]#

Read a composition from a POSCAR title when every count is explicit.

The title is free-form text, so this returns None unless every token reads as an element symbol with a count – Li3 F39 K3 yields {"Li": 3, "F": 39, "K": 3}, while both H C and POSCAR file written by OVITO yield None. Requiring counts avoids interpreting a comment that merely lists elements as a declaration of their order. A title filling the whole field is treated as truncated and its final token is dropped.

Parameters:
titlestr

the text following POSCAR = in the OUTCAR

Returns:
Optional[dict[str, int]]

element counts, or None if the title is not an explicit composition

dpdata.formats.vasp.outcar.get_frames(fname, begin=0, step=1, ml=False, convergence_check=True)[source]#
dpdata.formats.vasp.outcar.get_outcar_block(fp, ml=False)[source]#
dpdata.formats.vasp.outcar.system_info(lines: list[str], type_idx_zero: bool = False) → tuple[list[str], list[int], ndarray, int | None, int | None][source]#

Get system information from lines of an OUTCAR file.

Parameters:
lineslist[str]

the lines of the OUTCAR file

type_idx_zerobool

if true atom types starts from 0 otherwise from 1.

Returns:
atom_names: list[str]

name of atoms

atom_numbs: list[int]

number of atoms that have a certain name. same length as atom_names

atom_types: np.ndarray

type of each atom, the array has same lenght as number of atoms

nelm: optional[int]

the value of NELM parameter

nwrite: optional[int]

the value of NWRITE parameter

dpdata.formats.vasp.poscar module#

dpdata.formats.vasp.poscar.from_system_data(system, f_idx=0, skip_zeros=True)[source]#
dpdata.formats.vasp.poscar.to_system_data(lines)[source]#

dpdata.formats.vasp.xml module#

dpdata.formats.vasp.xml.analyze(fname, type_idx_zero=False, begin=0, step=1, convergence_check=True)[source]#

Deal with broken xml file.

dpdata.formats.vasp.xml.analyze_atominfo(atominfo_xml)[source]#
dpdata.formats.vasp.xml.analyze_calculation(cc: Any, nelm: int | None) → tuple[ndarray, ndarray, float, ndarray, ndarray | None, bool | None][source]#

Analyze a calculation block.

Parameters:
ccxml.etree.ElementTree.Element

The xml element for a ion step calculation

nelmOptional[int]

The number nelm, if it is not None, convergence check is performed.

Returns:
posinp.ndarray

The positions

cellnp.ndarray

The cell

enerfloat

The energy

forcenp.ndarray

The forces

strOptional[np.ndarray]

The stress

is_converged: Optional[bool]

If the scf calculation is converged. Only return boolean when nelm is not None. Otherwise return None.

dpdata.formats.vasp.xml.check_name(item, name)[source]#
dpdata.formats.vasp.xml.formulate_config(eles, types, posi, cell, ener, forc, strs_)[source]#
dpdata.formats.vasp.xml.get_varray(varray)[source]#