Utility

Some simple convenience functions for development.

Lattice

Types

WannierIO.FortranBinaryStreamType

Fortran unformatted IO with stream access.

For example, file written using these Fortran code:

OPEN(UNIT=11, FILE="ustream.demo", STATUS="NEW", ACCESS="STREAM", FORM="UNFORMATTED")
source
WannierIO.Wannier90TextType

Plain text format for Wannier90 win and nnkp files.

The W90 default win or nnkp are plain text files but are not simple arrays of numbers that can be read by readdlm, therefore this struct is used to indicate that the file is plain text but need to be handled by corresponding functions, e.g., read_win, read_nnkp, etc.

This somewhat overlaps with FortranText, but this one is only used for small input parameter files e.g. win and nnkp (in comparison with the Wannier90Toml format), while the FortranText (in comparison with the FortranBinary format) is used for large matrices e.g. amn, mmn, eig, etc.

source
WannierIO.Wannier90TomlType

TOML file format for Wannier90 win and nnkp files.

Here we introduce a TOML format for win and nnkp, so that once the win or nnkp files are converted into TOML, the TOML files can be loaded by standard TOML parsers without the headache of writing custom parsers in other Julia packages.

See also write_win, write_nnkp, etc.

source

Constants

WannierIO.BohrConstant

Bohr radius in Angstrom unit.

This is the default CODATA2006 value in W90 src/constants.F90.

source
WannierIO.Bohr_QEConstant

Bohr radius in Angstrom unit.

This is the default (Physical constants, SI (NIST 2018)) value in QE Modules/constants.f90.

source

Misc

WannierIO.write_tomlMethod
write_toml(io; kwargs...)

Write kwargs into io as a TOML file.

Do some type conversion before writing.

source
WannierIO.parse_boolMethod
parse_bool(s)

Parse a string as bool.

This is capable of parsing Fortran outputs, e.g., .true., .false., true, T.

source
WannierIO.parse_floatMethod
parse_float(s)

Parse a string as Float64.

The is capable of parsing Fortran outputs, e.g. 1.0D-10, to the ordinary 1e-10.

source
WannierIO.parse_indicesMethod
parse_indices(str)

Parse a string of comma-separated indices or range into a vector of integers.

E.g., the exclude_bands tag of win file.

Examples

julia> parse_indices("1-2, 5,8 -10")
6-element Vector{Int64}:
  1
  2
  5
  8
  9
 10
source
WannierIO.parse_vectorMethod
parse_vector(io, T, n_elements)

Parse a vector of n_elements elements of type T from io.

Arguments

  • io: input stream
  • T: type of elements
  • n_elements::Int: total number of elements

Examples

Suppose a file demo.txt has the following content:

1  2  3  4  5  6  7  8  9  10
11 12 13 14 15 16 17 18 19 20
21 22 23

Then the following code parses the file and return a vector filled with 1 to 23:

julia> vector = open("demo.txt") do io
    parse_vector(io, Int, 23)
end

The number of elements in each line can be different.

source
WannierIO.WannierIOModule

WannierIO.jl: a package for reading and writing Wannier90 file formats.


WannierIO.jl

Stable Dev CI codecov

A Julia package for reading/writing Wannier90 file formats.

The package is designed to be minimalistic to allow easy reuse in other packages.

Quick examples

using WannierIO

A = read_amn("silicon.amn")
write_amn("silicon_2.amn", A)

chk = read_chk("silicon.chk")
write_chk("silicon_2.chk", chk; binary=true)

Related packages

  • Wannier.jl: Wannierization and Wannier interpolation. The IO part of Wannier.jl was isolated and moved into this package.

Exported functions:

source