vestacrystparser.convert

Create VESTA files from structural data files (POSCAR, etc.).

vestacrystparser.convert.attach_vectors(vfile: VestaFile, vectors: list[list[float]], mode: str = 'absolute', scale: float = 1, cutoff: float = 0, sites: list[int] = None, color: tuple[int, int, int] = (255, 0, 0), radius: float = 0.5, polar: bool = False, penetrate_atoms: bool = True, add_atom_radius: bool = False)

Bulk attaches a list of vectors to atomic sites.

Does not modify any existing vectors. Modifies vfile in-place.

Parameters:
  • vfile – VestaFile with atoms in it.

  • vectors – list of Cartesian vector values, one for each site in vfile

  • mode – “relative”, “fixed”, or “absolute”. How to scale the magnitude of vectors. absolute: use magnitudes as-is. relative: scale magnitudes to be normalised to the largest (used) vector. fixed: set all magnitudes to 1.

  • scale – Global scale factor for vectors.

  • cutoff – Ignore vectors with absolute magnitude less than this.

  • sites – If not None, include only sites with these indices (1-based).

  • color – Colour of the vectors. Default red.

  • radius – Radius of the vectors. Default 0.5.

  • polar – Whether this is a polar vector (rather than axial). Default False.

  • penetrate_atoms – Whether the vector penetrates the atom, such that it sticks out on both sides. Default True.

  • add_atom_radius – Whether to add the atomic radius to the length of the vector. Default False.

vestacrystparser.convert.magnetic_moments_from_outcar(outcar: Outcar | str) ndarray

From a VASP OUTCAR calculated with orbital projection (e.g. LORBIT=11), return the array of magnetic moments.

Accepts either the Outcar object or a filename

vestacrystparser.convert.vesta_from_chgcar(fname: str, n: float = 2) VestaFile

Return a VestaFile from VASP CHGCAR.

Isosurface level is determined by (Vesta Manual section 16.7)

\[d(iso) = \langle \vert \rho \vert \rangle + n \times \sigma(\vert \rho \vert)\]

A caution, though. It would appear that VESTA uses a slightly strange method of calculating the standard deviation. As such, the isosurface level set by this method may be off by an amount (e.g. 5%).

Parameters:
  • fname – Filename of the CHGCAR

  • n – Parameter for setting the default isosurface level.

vestacrystparser.convert.vesta_from_poscar(fname: str) VestaFile

Return a VestaFile from a POSCAR file at fname

vestacrystparser.convert.vesta_from_structure(stru: Structure) VestaFile

Return a VestaFile from pymatgen.core.Structure

vestacrystparser.convert.vesta_from_volumetric(volu: VolumetricData, fname: str, n: float = 2, chgcar_like: bool = True) VestaFile

Return a VestaFile from pymatgen VolumetricData

Assumes the Volumetric data is in units of Angstrom, not Bohr.

Isosurface level is determined by (Vesta Manual section 16.7)

\[d(iso) = \langle \vert \rho \vert \rangle + n \times \sigma(\vert \rho \vert)\]
Parameters:
  • volu – VolumetricData object, with structure and volumetric data

  • fname – Filename where the volumetric data lives.

  • n – Parameter for setting the default isosurface level.

  • chgcar_like – If True, divides out the volume.

vestacrystparser.convert.vesta_vectors_from_poscar_outcar(poscar: str, outcar: str, mode: str = 'absolute', scale: float = 1, cutoff: float = 0, sites: list[int] = None, color: tuple[int, int, int] = (255, 0, 0), radius: float = 0.5, polar: bool = False, penetrate_atoms: bool = True, add_atom_radius: bool = False) VestaFile

Loads a POSCAR and a matching OUTCAR with magnetic moments computed (LORBIT, NSPIN). Creates a VestaFile with vectors.

Parameters:
  • poscar – Path to POSCAR.

  • outcar – Path to OUTCAR.

  • mode – “relative”, “fixed”, or “absolute”. How to scale the magnitude of vectors. absolute: use magnitudes as-is. relative: scale magnitudes to be normalised to the largest (used) vector. fixed: set all magnitudes to 1.

  • scale – Global scale factor for vectors.

  • cutoff – Ignore vectors with absolute magnitude less than this.

  • sites – If not None, include only sites with these indices (1-based).

  • color – Colour of the vectors. Default red.

  • radius – Radius of the vectors. Default 0.5.

  • polar – Whether this is a polar vector (rather than axial). Default False.

  • penetrate_atoms – Whether the vector penetrates the atom, such that it sticks out on both sides. Default True.

  • add_atom_radius – Whether to add the atomic radius to the lengths of the vector. Default False.