Utility
Some simple convenience functions for development.
Fortran related
WannierIO.isbinary — Method
isbinary(filename)
Check if the file is in binary format.
WannierIO.isbinary — Method
isbinary(chars)
Check if a sequence of chars is binary.
Lattice
WannierIO.get_lattice — Method
get_lattice(recip_lattice)
Compute lattice from reciprocal lattice.
WannierIO.get_recip_lattice — Method
get_recip_lattice(lattice)
Compute reciprocal lattice from lattice.
Types
WannierIO.FortranBinary — Type
Fortran unformatted IO.
WannierIO.FortranBinaryStream — Type
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")WannierIO.FortranText — Type
Fortran formatted IO.
WannierIO.Mat3 — Type
3 x 3 matrix type.
For lattice and reciprocal lattice.
WannierIO.SymbolVec3 — Type
Pair type associating a Symbol with a Vec3.
Used for win file atoms_frac and kpoint_path.
WannierIO.Vec3 — Type
Length-3 vector type.
For atom positions, kpoints, etc.
WannierIO.Wannier90Text — Type
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.
WannierIO.Wannier90Toml — Type
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.
WannierIO.mat3 — Method
mat3(A)
Convert Vector{Vector} to Mat3. Each vector is a column of the matrix.
WannierIO.vec3 — Method
vec3(A)
Convert Mat3 to Vec3{Vec3}. Each column of the matrix is a vector.
Constants
WannierIO.Bohr — Constant
Bohr radius in Angstrom unit.
This is the default CODATA2006 value in W90 src/constants.F90.
WannierIO.Bohr_QE — Constant
Bohr radius in Angstrom unit.
This is the default (Physical constants, SI (NIST 2018)) value in QE Modules/constants.f90.
Misc
WannierIO.default_header — Method
Default header for writing wannier90 files.
WannierIO.to_toml — Method
to_toml(x)
Convert types for TOML writing.
Examples
using TOML
x = Dict(:a => (; b=1))
TOML.print(to_toml, x)WannierIO.write_toml — Function
Write kwargs into io as a TOML file.
This is more convenient than TOML.print, in that:
- Do some type conversion before writing.
- Keep the order of kwargs, whereas
TOML.printalways requires aDictwhich will change the order of keys.
Examples
write_toml(stdout; b=2, a=1)WannierIO.format_indices — Method
format_indices(indices)
Convert a vector of integers to a string of comma-separated indices or range.
E.g., the exclude_bands tag of win file.
Examples
julia> format_indices([1, 2, 5, 8, 9, 10])
"1-2 5 8-10"WannierIO.parse_bool — Method
parse_bool(s)
Parse a string as bool.
This is capable of parsing Fortran outputs, e.g., .true., .false., true, T.
WannierIO.parse_bool — Method
parse_bool(i)
Parse an integer as bool.
0:false1or-1:true
WannierIO.parse_float — Method
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.
WannierIO.parse_indices — Method
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
julia> parse_indices("1-2 5,8 -10")WannierIO.parse_vector — Method
parse_vector(io, T, n_elements)
Parse a vector of n_elements elements of type T from io.
Arguments
io: input streamT: type of elementsn_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 23Then 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)
endThe number of elements in each line can be different.
WannierIO._isapprox — Method
_isapprox(a, b)
Compare two (same-type) structs.
WannierIO.WannierIO — Module
WannierIO.jl: a package for reading and writing Wannier90 file formats.
WannierIO.jl
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.jlwas isolated and moved into this package.
Exported functions:
get_Uget_Udisread_amnread_bxsfread_chkread_cuberead_eigread_isymread_mmnread_nnkpread_spnread_uHuread_uIuread_unkread_w90_bandread_w90_band_datread_w90_band_kptread_w90_band_labelinforead_w90_hrdatread_w90_rdatread_w90_tbdatread_w90_wsvecread_winread_woutread_xsfwrite_amnwrite_bxsfwrite_chkwrite_cubewrite_eigwrite_mmnwrite_nnkpwrite_spnwrite_uHuwrite_uIuwrite_unkwrite_w90_bandwrite_w90_band_datwrite_w90_band_kptwrite_w90_band_labelinfowrite_w90_hrdatwrite_w90_rdatwrite_w90_tbdatwrite_w90_wsvecwrite_winwrite_xsf