Utility
Some simple convenience functions for development.
Fortran related
WannierIO.isbinary
— Methodisbinary(filename)
Check if the file is in binary format.
WannierIO.isbinary
— Methodisbinary(chars)
Check if a sequence of chars is binary.
Lattice
WannierIO.get_lattice
— Methodget_lattice(recip_lattice)
Compute lattice from reciprocal lattice.
WannierIO.get_recip_lattice
— Methodget_recip_lattice(lattice)
Compute reciprocal lattice from lattice.
Types
WannierIO.FortranBinary
— TypeFortran unformatted IO.
WannierIO.FortranBinaryStream
— TypeFortran 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
— TypeFortran formatted IO.
WannierIO.Mat3
— Type3 x 3 matrix type.
For lattice and recip_lattice.
WannierIO.Mat3
— MethodVector{Vector}
-> Mat3
WannierIO.SymbolVec3
— TypePair type associating a Symbol
with a Vec3
.
For win file atoms_frac
and kpoint_path
.
WannierIO.Vec3
— TypeLength-3 vector type.
For atom posistions, kpoints, etc.
WannierIO.Vec3
— MethodMat3
-> Vec3{Vec3}
WannierIO.Wannier90Text
— TypePlain 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
— TypeTOML 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.
Constants
WannierIO.Bohr
— ConstantBohr radius in Angstrom unit.
This is the default CODATA2006 value in W90 src/constants.F90
.
WannierIO.Bohr_QE
— ConstantBohr radius in Angstrom unit.
This is the default (Physical constants, SI (NIST 2018)) value in QE Modules/constants.f90
.
Misc
WannierIO.default_header
— MethodDefault header for writing wannier90 files.
WannierIO.write_toml
— Methodwrite_toml(io; kwargs...)
Write kwargs
into io
as a TOML file.
Do some type conversion before writing.
WannierIO.parse_bool
— Methodparse_bool(s)
Parse a string as bool
.
This is capable of parsing Fortran outputs, e.g., .true.
, .false.
, true
, T
.
WannierIO.parse_bool
— Methodparse_bool(i)
Parse an integer as bool
.
0
:false
1
or-1
:true
WannierIO.parse_float
— Methodparse_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
— Methodparse_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
WannierIO.parse_vector
— Methodparse_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 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.
WannierIO._isapprox
— Method_isapprox(a, b)
Compare two (same-type) structs.
WannierIO.WannierIO
— ModuleWannierIO.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.jl
was isolated and moved into this package.
Exported functions:
get_U
get_Udis
read_amn
read_bxsf
read_chk
read_cube
read_eig
read_mmn
read_nnkp
read_spn
read_uHu
read_unk
read_w90_band
read_w90_band_dat
read_w90_band_kpt
read_w90_band_labelinfo
read_w90_hrdat
read_w90_rdat
read_w90_tbdat
read_w90_wsvec
read_win
read_wout
read_xsf
write_amn
write_bxsf
write_chk
write_cube
write_eig
write_mmn
write_nnkp
write_spn
write_uHu
write_unk
write_w90_band
write_w90_band_dat
write_w90_band_kpt
write_w90_band_labelinfo
write_w90_hrdat
write_w90_tbdat
write_w90_wsvec
write_win
write_xsf