File types

Miscellaneous

Reading

Electrum.readXYZFunction
readXYZ(io::IO) -> AtomList{3}

Reads an XYZ file into an AtomList{3}.

Electrum.readCPcoeffFunction
readCPcoeff(file, Lmax::Val{L}=Val{6}()) -> SphericalComponents{L}

Reads in the spherical harmonic projection coefficients from a CPpackage2 calculation.

By default, CPpackage2 gives the coefficients for spherical harmonics up to a maximum l value of 6.

Electrum.readCPgeoFunction
readCPgeo(file) -> Vector{AtomPosition{3}}

Reads the atomic positions used for a CPpackage2 calculation.

Electrum.readCPcellFunction
readCPcell(file) -> RealBasis{3}

Reads the basis vectors of the unit cell used for a CPpackage2 calculation.

Writing

Electrum.writeXYZFunction
writeXYZ(io::IO, data)
writeXYZ(filename, data)

Write an XYZ file based on a set of atomic coordinate data. This data may be provided in any type that subtypes AbstractVector{<:AbstractAtomPosition}, or types convertible to AtomList.

Electrum.writeTOMLFunction
writeTOML(file, x; sorted=false, by=identity)

Writes x, an Electrum data type, to a file. Currently, x may be either an AbstractAtomList or a Crystal.

The sorted and by keywords are passed through from TOML.print and allow for sorting of the keys in the file output.

XCrysDen XSF files

Reading

Electrum.readXSFFunction
readXSF(
    file;
    spgrp::Integer = 0,
    origin::AbstractVector{<:Real} = [0, 0, 0]
) -> CrystalWithDatasets

Generic function for reading XSF data of arbitrary dimensionality. Currently, only 3D data is supported, as this name is an alias for readXSF3D. This will change in the future.

For more information, see the documentation for readXSF3D.

Electrum.readXSF3DFunction
readXSF3D(
    file;
    spgrp::Integer = 0,
    origin::AbstractVector{<:Real} = [0, 0, 0]
) -> CrystalWithDatasets{3}

Reads in an XCrysDen XSF file from an input stream and returns a CrystalWithDatasets{3} with all datasets that have been included within the file. The XSF file must contain 3D crystal data; data of other dimensionalities (such as slab data) will fail.

Space group and origin information are not supplied in XSF files, but they can be supplied using the spgrp and origin keyword arguments.

Writing

Electrum.writeXSFFunction
writeXSF(io, xtal::PeriodicAtomList{D})

Writes the crystal component of an XCrysDen XSF file.

writeXSF(io::IO, key, data::RealDataGrid{D}; periodic=true)

Writes the crystal component of an XCrysDen XSF file. By default, automatic wrapping of the datagrid occurs (values are repeated at the end of each dimension).

writeXSF(io::IO, xtaldata::CrystalWithDatasets{D,K,V})

Writes a CrystalWithDatasets to an XCrysDen XSF file.

ABINIT files

Reading

Electrum.read_abinit_DENFunction
read_abinit_DEN(file)
    -> CrystalWithDatasets{3,String,RealDataGrid{3,Float64}}

Reads a FORTRAN binary formatted abinit density file. By default, abinit density files will have the suffix DEN, but no assumptions are made about suffixes.

The header is used to automatically determine the file format, so this should read in any abinit density output (provided a function exists to parse that header).

The number of datasets returned depends on the value of nsppol in the header, as calculations with explicit treatment of spin will return spin densities.

Depending on the value of cplex, the datagrid(s) returned may be real or complex-valued.

Electrum.read_abinit_POTFunction
read_abinit_POT(file)
    -> CrystalWithDatasets{3,String,RealDataGrid{3,T<:Number}}

Reads a FORTRAN binary formatted abinit potential file.

By default, abinit potential files will end in POT for the external potential, VHA for the Hartree potential, VXC for the exchange-correlation potential, and VHXC for the sum of both the Hartree and exchange-correlation potentials.

The header is used to automatically determine the file format, so this should read in any abinit density output (provided a function exists to parse that header).

The number of datasets returned depends on the value of nsppol in the header, as calculations with explicit treatment of spin will return spin-dependent potentials.

Depending on the value of cplex, the datagrid(s) returned may be real or complex-valued.

Electrum.read_abinit_WFKFunction
read_abinit_WFK(file; quiet = false)
    -> CrystalWithDatasets{3,String,PlanewaveWavefunction{3,Complex{Float64}}}

Reads a FORTRAN binary formatted abinit wavefunction file.

By default, abinit returns wavefunction data in Complex{Float64} entries, and this is maintained in the return type.

The header is used to automatically determine the file format, so this should read in any abinit density output (provided a function exists to parse that header).

By default, the function is verbose, with output printed for every k-point parsed, due to the large size of the wavefunction files. If this behavior is undesirable, the quiet keyword argument may be set to true.

VASP files

Reading

Electrum.readCONTCARFunction
readPOSCAR(file) -> PeriodicAtomList{3}
readCONTCAR(file) -> PeriodicAtomList{3}

Reads a VASP POSCAR or CONTCAR file. A POSCAR contains the basis vectors of the system (potentially given with a scaling factor), the positions of all atoms as either Cartesian or reduced coordinates, and potentially information needed to perform an ab initio MD run (currently ignored). The similarly formatted CONTCAR file is the geometry output generated after a VASP run.

Regardless of whether the coordinates are Cartesian or fractional, this function always returns a PeriodicAtomList{3}, and the units are converted from angstroms to bohr.

By default, if the provided file path is a directory, readPOSCAR() will read from a file named POSCAR in that directory. If no argument is provided, a file named POSCAR in the current working directory is read. readCONTCAR() will search for a file named CONTCAR in an analogous manner.

Electrum.readDOSCARFunction
readDOSCAR(file) -> Tuple{DensityOfStates, Vector{ProjectedDensityOfStates}}

Reads a DOSCAR file from VASP and returns its data as a tuple containing the total and projected density of states (if present).

Electrum.readPOSCARFunction
readPOSCAR(file) -> PeriodicAtomList{3}
readCONTCAR(file) -> PeriodicAtomList{3}

Reads a VASP POSCAR or CONTCAR file. A POSCAR contains the basis vectors of the system (potentially given with a scaling factor), the positions of all atoms as either Cartesian or reduced coordinates, and potentially information needed to perform an ab initio MD run (currently ignored). The similarly formatted CONTCAR file is the geometry output generated after a VASP run.

Regardless of whether the coordinates are Cartesian or fractional, this function always returns a PeriodicAtomList{3}, and the units are converted from angstroms to bohr.

By default, if the provided file path is a directory, readPOSCAR() will read from a file named POSCAR in that directory. If no argument is provided, a file named POSCAR in the current working directory is read. readCONTCAR() will search for a file named CONTCAR in an analogous manner.

Electrum.readPROCARFunction
readPROCAR(file) -> FatBands{3}

Reads an lm-decomposed PROCAR file from VASP and returns its data as a FatBands{3}.

Electrum.readWAVECARFunction
readWAVECAR(file) -> PlanewaveWavefunction{3,Complex{Float32}}

Reads a WAVECAR file output from a VASP 4.6 calcuation to a PlanewaveWavefunction.

Information about VASP WAVECAR files and much of the code was adapted from WaveTrans (originally written in FORTRAN): https://www.andrew.cmu.edu/user/feenstra/wavetrans/

This function is limited to WAVECAR files which have an RTAG value of 45200 (meaning the data is given as a Complex{Float32}) and have only a collinear magnetic field applied, like WaveTrans. It should also be noted that the weights of the k-points are not present in the WAVECAR file, and are set to 1 by default.

By default, the function is verbose, with output printed for every k-point parsed, due to the large size of the wavefunction files. If this behavior is undesirable, the quiet keyword argument may be set to true.

Electrum.get_fermiFunction
get_fermi(file) -> NamedTuple{(:fermi, :alphabeta), NTuple{2,Float64}}

Reads a VASP OUTCAR file and returns the Fermi energy and alpha+beta value.

Writing

Electrum.writeCONTCARFunction
writePOSCAR([file = "POSCAR"], data; names = true, dummy = false, comment)
writeCONTCAR([file = "CONTCAR"], data; names = true, dummy = false, comment)

Writes crystal data to a VASP POSCAR or CONTCAR output. The data can be a PeriodicAtomList or an AbstractCrystal. If a directory name is given instead of a file name, the data will be written to a file named POSCAR or CONTCAR in the provided directory, depending on the function used. If no argument is provided, it is written to POSCAR or CONTCAR in the current directory.

By default, atom names are written, but this is known to break VASP 4.6. This may be overridden by setting names to false, but this is known to cause its own incompatibility issues: it is known that VESTA, for instance, will crash if the line containing the atomic names is missing.

Dummy atoms are not are not written by default, but they may be written by setting dummy=true.

The first line, normally used to describe the system, may be altered by passing a printable object to comment.

Electrum.writePOSCARFunction
writePOSCAR([file = "POSCAR"], data; names = true, dummy = false, comment)
writeCONTCAR([file = "CONTCAR"], data; names = true, dummy = false, comment)

Writes crystal data to a VASP POSCAR or CONTCAR output. The data can be a PeriodicAtomList or an AbstractCrystal. If a directory name is given instead of a file name, the data will be written to a file named POSCAR or CONTCAR in the provided directory, depending on the function used. If no argument is provided, it is written to POSCAR or CONTCAR in the current directory.

By default, atom names are written, but this is known to break VASP 4.6. This may be overridden by setting names to false, but this is known to cause its own incompatibility issues: it is known that VESTA, for instance, will crash if the line containing the atomic names is missing.

Dummy atoms are not are not written by default, but they may be written by setting dummy=true.

The first line, normally used to describe the system, may be altered by passing a printable object to comment.

LAMMPS

Reading

Electrum.read_lammps_dataFunction
read_lammps_data(io::IO; atoms::AbstractVector = NamedAtom[]) -> PeriodicAtomList{3}

Reads a LAMMPS data file containing atomic coordinates. Currently, this function only supports 3D crystal data.

If set, the atom_types keyword can be used to define the types of atoms being read in. This can be and AbstractVector{NamedAtom}, AbstractVector{<:AbstractString}, or AbstractVector{<:Integer}. If it is not set or empty, then all atoms will be read in as dummy atoms.

Writing

Electrum.write_lammps_dataFunction
write_lammps_data(io::IO, list::PeriodicAtomList, [transform]; dummy::Bool = false)

Writes crystal information to a LAMMPS data format that can be used to define a simulation box for running a molecular dynamics simulation.

If transform is supplied, the list of atoms will be converted to a supercell with the associated transformation (either a matrix, vector, or scalar). The dummy keyword determines whether dummy atoms are included in the output (false by default).

This function currently only works for 3D systems, and outputs data for the LAMMPS metal unit system - most importantly, lengths are in angstrom.

write_lammps_data(io::IO, xtal::AbstractCrystal, [transform]; dummy::Bool = false)

Writes crystal information to a LAMMPS data format that can be used to define a simulation box for for running a molecular dynamics simulation.

The list of atoms that is written is given by converting xtal to a PeriodicAtomList, which uses the supplied transformation matrix to generate all atomic positions. If transform is supplied, the transformation will be applied to the PeriodicAtomList - it does not replace the transform provided with xtal.

This function currently only works for 3D systems.

write_lammps_data(file, data, [transform]; dummy::Bool = false)

Writes a LAMMPS data file to the path given by filename.