dpdata.formats.vasp package#
Submodules#
dpdata.formats.vasp.outcar module#
- 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_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 typecounts, 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
Noneunless every token reads as an element symbol with a count –Li3 F39 K3yields{"Li": 3, "F": 39, "K": 3}, while bothH CandPOSCAR file written by OVITOyieldNone. 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.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.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_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.