Interfaces

Wannier90

AutoBZ.load_wannier90_dataFunction
load_wannier90_data(seedname::String; bz::AbstractBZ=FBZ(), interp::AbstractWannierInterp=HamiltonianInterp, kwargs...)

Return a tuple (interp, bz) containing the requested Wannier interpolant, interp and the Brillouin zone bz to integrate over. The seedname should point to Wannier90 data to read in. Additional keywords are passed to the interpolant constructor, load_interp, while load_autobz can be referenced for Brillouin zone details. For a list of possible keywords, see subtypes(AbstractBZ) and using TypeTree; tt(AbstractWannierInterp).

source
AutoBZ.load_interpFunction
load_interp(::Type{<:HamiltonianInterp}, seed;
    gauge=Wannier(), soc=nothing,
    compact=:N, precision=Float64, droptol=eps(precision), herm=true)

Load Hamiltonian coefficients from Wannier90 output "seed_hr.dat" into an AbstractHamiltonianInterp that interpolates h with unit period. The gauge keyword can be Wannier or Hamiltonian to set whether the coefficients are interpolated in the orbital basis, i.e. as is, or rotated into the band basis, i.e. the Hamiltonian eigenbasis. Additionally, the soc keyword can specify a SMatrix (from StaticArrays.jl) of twice the size of the coefficients in the seed file that is added to the Hamiltonian in orbital basis. For more details see SOCMatrix.

There are also several keywords to control the memory usage of the array: compact which may indicate the coefficient matrices are Hermitian, precision which sets the floating-point precision of the array, and droptol which skips coefficients under the given relative tolerance. Possible values of compact are:

  • :N: do not store the coefficients in compact form
  • :L: store the lower triangle of the coefficients
  • :U: store the upper triangle of the coefficients
  • :S: store the lower triangle of the symmetrized coefficients, (c+c')/2

Additionally, the herm keyword specifies whether to check if the coefficients give a Hermitian matrix-valued Fourier series and if so it returns a special Hermitian series evaluator with optimizations for faster evaluation in AutoBZ workflows. To get a more user-friendly series for experimental usage, use herm=false.

source
load_interp(::Type{<:BerryConnectionInterp}, seed;
    coord=Lattice(), soc=nothing,
    precision=Float64, compact=:N, droptol=eps(precision))

Load position operator coefficients from Wannier90 output "seed_r.dat" into a BerryConnectionInterp that interpolates (A1, A2, A3). Specify coord as Lattice or Cartesian to have the position operator interpolated in those coordinates.

source
load_interp(::Type{<:GradientVelocityInterp}, seed, A;
    gauge=Wannier(), vcomp=Whole(), coord=Lattice(), soc=nothing,
    precision=Float64, compact=:N, droptol=eps(precision), herm=true)

Load coefficients for a Hamiltonian and its derivatives from Wannier90 output "seed_hr.dat" into a GradientVelocityInterp that interpolates (h, v). Specify vcomp as Whole, Intra, or Inter to use certain transitions. Note these velocities are not gauge-covariant. Additionally, the herm keyword specifies whether to check if the coefficients give a Hermitian matrix-valued Fourier series and if so it returns a special Hermitian series evaluator with optimizations for faster evaluation in AutoBZ workflows. To get a more user-friendly series for experimental usage, use herm=false.

source
load_interp(::Type{<:CovariantVelocityInterp}, seed, A;
    gauge=Wannier(), vcomp=whole(), coord=Lattice(), soc=nothing,
    precision=Float64, compact=:N, droptol=eps(precision), herm=true)

Load coefficients for a Hamiltonian and its derivatives from Wannier90 output "seed_hr.dat" and "seed_r.dat" into a CovariantVelocityInterp that interpolates (h, v). Specify vcomp as Whole, Intra, or Inter to use certain transitions. These velocities are gauge-covariant. Additionally, the herm keyword specifies whether to check if the coefficients give a Hermitian matrix-valued Fourier series and if so it returns a special Hermitian series evaluator with optimizations for faster evaluation in AutoBZ workflows. To get a more user-friendly series for experimental usage, use herm=false.

source
load_interp(::Type{<:MassVelocityInterp}, seed, A;
    gauge=Wannier(), vcomp=Whole(), coord=Lattice(), soc=nothing,
    precision=Float64, compact=:N, droptol=eps(precision), herm=true)

Load coefficients for a Hamiltonian and its derivatives from Wannier90 output "seed_hr.dat" into a MassVelocityInterp that interpolates (h, v, μ). Specify vcomp as Whole, Intra, or Inter to use certain transitions. Note these operators are not gauge-covariant. Additionally, the herm keyword specifies whether to check if the coefficients give a Hermitian matrix-valued Fourier series and if so it returns a special Hermitian series evaluator with optimizations for faster evaluation in AutoBZ workflows. To get a more user-friendly series for experimental usage, use herm=false.

source

PythTB

AutoBZ.load_pythtb_dataFunction
load_pythtb_data(m, [species]; bz=FBZ(), interp=HamiltonianInterp, kws...)

Returns (interp, bz) from a PythTB model m for use with AutoBZ.jl solvers. Only supports spinless, fully-periodic systems. Supplying a list of atomic species is helpful when chosing a bz of AutoBZCore.IBZ, since PythTB loses some information by combining the atomic and orbital indices into a multi-index. By default, species assigns a different element to orbitals at different positions. To call PythTB from Julia see e.g. PyCall.jl.

source

Python

Julia code, including AutoBZ.jl, can be called from Python using the package PyJulia

Setup

TL;DR

$ julia -e 'import Pkg; Pkg.add("PyCall")'
$ python3 -m pip install julia

If you want to, you can install PyJulia in a Python venv, but on the Julia side PyCall.jl must be installed in the default environment

Demo

The Python snippet below shows how from the demos folder of the AutoBZ repository you can run one of the demo scripts:

from julia.api import Julia
jl = Julia(compiled_modules=False)

# julia environment setup in working directory 'demos'
jl.eval("""
import Pkg
Pkg.activate(".")
Pkg.instantiate()
""")

# capture output of script
out = jl.eval('include("dos_test.jl")')

The first two lines are adapted for loading PyJulia on Debian systems.

MATLAB

Julia code, including AutoBZ.jl, can be called from MATLAB using the package MATDaemon.jl.

Setup

  1. Download the

jlcall.m script, which will install the Julia server when first called.

  1. Install Julia and give MATLAB the path the Julia binary by running setenv('PATH',['path-to-julia/bin:',getenv('PATH')]);
  2. Test that jlcall works by running jlcall('sort', {rand(2,5)}, struct('dims', int64(2)))
  3. Create setup.jl with the lines import Pkg; Pkg.activate("."); Pkg.develop(path=expanduser("path-to-AutoBZ.jl"));
  4. Start a julia server within MATLAB with the appropriate modules: jlcall('', 'project', 'path-to-myproject', 'setup', 'path-to-setup.jl', 'modules', {'LinearAlgebra','AutoBZ'}, 'threads', 'auto', 'restart', true);
  5. Now AutoBZ can be used via jlcall

Demo

Suppose we would like to run the function get_dos defined in this script.jl

import Pkg; Pkg.activate("."); Pkg.develop(path=expanduser("path-to-AutoBZ.jl"))
using AutoBZ

function get_dos(seedname, self_energy_path, ωs, rtol, atol)
    H, FBZ = load_wannier90_data(seedname)
    Σ = load_self_energy(self_energy_path)
    integrand = DOSSolver(Σ, H, FBZ, IAI(); ω=first(ωs))
    solver = IntegralSolver(integrand, FBZ, abstol=atol, reltol=rtol)
    return map(ωs) do ω
        update_gloc!(solver; ω)
        solve!(solver).value
    end
end

The MATLAB snippet below shows how to setup the Julia server to run a demo script.

jlcall('', ...
    'project', '/path/to/MyProject', % use Julia environment with AutoBZ
    'setup', '/path/to/setup.jl', % path to script shown above
    'modules', {'AutoBZ'}, % import AutoBZ and other modules
    'threads', 'auto', % use the default number of Julia threads
    'restart', true % start a fresh Julia server environment
)

and the snippet below shows how to call get_dos from MATLAB

jlcall('get_dos', '.../svo', '.../svo_self_energy.txt', {0.5})