Utilities

Index

Documentation

QuantumEspressoIO.cart2fracFunction

Convert Cartesian to fractional coordinates based on lattice vectors.

Arguments

  • lattice: Each element is a lattice vector.
    • For lattice vectors, the unit is usually in angstrom.
    • For reciprocal lattice vectors, the unit is usually in 1/angstrom.
  • vec: a vector or a list of vectors in Cartesian coordinates.

Examples

lattice = [[0.0, 1.0, 2.0], [3.0, 0.0, 4.0], [5.0, 6.0, 0.0]];
positions = [[2.1, 1.9, 1.0], [21.0, 19.0, 10.0]];
frac2cart(lattice, cart2frac(lattice, positions[1])) ≈ positions[1]
# output
true
frac2cart(lattice, cart2frac(lattice, positions)) ≈ positions
# output
true
source
QuantumEspressoIO.frac2cartFunction

Convert fractional to Cartesian coordinates based on lattice vectors.

Arguments

  • lattice: Each element is a lattice vector.
    • For lattice vectors, the unit is usually in angstrom.
    • For reciprocal lattice vectors, the unit is usually in 1/angstrom.
  • vec: a vector or a list of vectors in fractional coordinates.

Examples

lattice = [[0.0, 1.0, 2.0], [3.0, 0.0, 4.0], [5.0, 6.0, 0.0]];
positions = [[0.1, 0.2, 0.3], [1.0, 2.0, 3.0]];
frac2cart(lattice, positions[1])
# output
3-element Vector{Float64}:
 2.1
 1.9
 1.0
frac2cart(lattice, positions)
# output
2-element Vector{Vector{Float64}}:
 [2.1, 1.9, 1.0]
 [21.0, 19.0, 10.0]
source
QuantumEspressoIO.get_latticeFunction

Compute real-space lattice vectors from reciprocal-space lattice vectors.

Arguments

  • recip_lattice: Can be a vector of reciprocal lattice vectors, or a Mat3 matrix.

Examples

recip_lattice = [[0.0, 1.0, 2.0], [3.0, 0.0, 4.0], [5.0, 6.0, 0.0]];
get_lattice(recip_lattice)
# output
3-element Vector{Vector{Float64}}:
 [-2.6927937030769655, 2.243994752564138, 2.019595277307724]
 [1.3463968515384828, -1.121997376282069, 0.5609986881410345]
 [0.4487989505128276, 0.6731984257692414, -0.3365992128846207]
recip_lattice = mat3(recip_lattice);
get_lattice(recip_lattice)
# output
3×3 StaticArraysCore.SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 -2.69279   1.3464     0.448799
  2.24399  -1.122      0.673198
  2.0196    0.560999  -0.336599
get_recip_lattice(get_lattice(recip_lattice)) ≈ recip_lattice
# output
true
source
QuantumEspressoIO.get_recip_latticeFunction

Compute reciprocal-space lattice vectors from real-space lattice vectors.

Arguments

  • lattice: Can be a vector of lattice vectors, or a Mat3 matrix.

Examples

lattice = [[0.0, 1.0, 2.0], [3.0, 0.0, 4.0], [5.0, 6.0, 0.0]];
get_recip_lattice(lattice)
# output
3-element Vector{Vector{Float64}}:
 [-2.6927937030769655, 2.243994752564138, 2.019595277307724]
 [1.3463968515384828, -1.121997376282069, 0.5609986881410345]
 [0.4487989505128276, 0.6731984257692414, -0.3365992128846207]
lattice = mat3(lattice);
get_recip_lattice(lattice)
# output
3×3 StaticArraysCore.SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 -2.69279   1.3464     0.448799
  2.24399  -1.122      0.673198
  2.0196    0.560999  -0.336599
source
QuantumEspressoIO.format_fortranMethod

Convert a Julia value to a string representation of Fortran value.

Examples

julia> format_fortran("hello")
"'hello'"
julia> format_fortran(1.0)
"1.0"
julia> format_fortran(true)
".true."
source
QuantumEspressoIO.parse_boolMethod
parse_bool(s)

Parse a string as bool.

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

Examples

julia> parse_bool(".true.")
true
julia> parse_bool("false")
false
julia> parse_bool("T")
true
julia> parse_bool("F")
false
julia> parse_bool("1")
true
julia> parse_bool("0")
false
source
QuantumEspressoIO.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.

Examples

julia> parse_float("1.0D-10")
1.0e-10
julia> parse_float("1***")
NaN
source
QuantumEspressoIO.parse_valueMethod
parse_value(value)

Parse a Fortran value.

Examples

julia> parse_value("'hello'")
"hello"
julia> parse_value(".true.")
true
julia> parse_value("1.0D-10")
1.0e-10
julia> parse_value("1")
1
source
QuantumEspressoIO.remove_commentMethod
remove_comment(line)

Remove comment and strip empty spaces.

Examples

julia> remove_comment("  ! This is a comment")
""
julia> remove_comment("  input")
"input"
julia> remove_comment("  name1 = value1  ! comment 2")
"name1 = value1"
julia> remove_comment("  name2 = value2  # comment 3")
"name2 = value2"
source
QuantumEspressoIO.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
QuantumEspressoIO.mat3Method
mat3(A)

Convert Vector{Vector} to Mat3. Each vector is a column of the matrix.

Note

This is not defined as a constructor of Mat3 to avoid type piracy.

source
QuantumEspressoIO.vec3Method
vec3(A)

Convert Mat3 to Vec3{Vec3}. Each column of the matrix is a vector.

Note

This is not defined as a constructor of vec3 to avoid type piracy.

source
QuantumEspressoIO.Bohr_QEConstant

Bohr radius in Angstrom unit.

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

source