Utils

Exported functions

ElemCo.Utils.amdmklFunction
amdmkl(reset::Bool=false)

Create a modified libmkl_rt.so and libmkl_core.so to make MKL work fast on "Zen" AMD machines (e.g., Ryzen series). Solution is based on this forum post.

This function is only needed on AMD machines. In order to execute it, call amdmkl() in a separate Julia session (not in the same session where you want to run calculations). For example, your workflow could look like this:

> julia -e 'using ElemCo; ElemCo.amdmkl()'
> julia input.jl

where input.jl is your script that uses ElemCo.jl. The changes can be reverted by calling amdmkl(true).

source
ElemCo.Utils.argmaxNMethod
argmaxN(vals, N; by::Function=identity)

Return the indices of the N largest elements in vals.

The order of equal elements is preserved. The keyword argument by can be used to specify a function to compare the elements, i.e., the function is applied to the elements before comparison.

Example

julia> argmaxN([1,2,3,4,5,6,7,8,9,10], 3)
3-element Vector{Int64}:
 10
  9
  8
julia> argmaxN([1,2,3,4,5,-6,-7,-8,-9,-10], 3; by=abs)
3-element Vector{Int64}:
 10
  9
  8
julia> argmaxN([1.0, 1.10, 1.112, -1.113, 1.09], 3; by=x->round(abs(x),digits=2))
3-element Vector{Int64}:
 3
 4
 2
source
ElemCo.Utils.kwarg_provided_in_macroMethod
kwarg_provided_in_macro(kwargs, key::Symbol)

Check whether key is in kwargs.

This is used in macros to check whether a keyword argument is passed. The keyword argument in question key is passed as a symbol, e.g. :thr. kwargs is the keyword argument list passed to the macro.

source
ElemCo.Utils.mainnameMethod
mainname(file::String)

Return the main name of a file, i.e. the part before the last dot and the extension.

Examples:

julia> mainname("~/test.xyz")
("test", "xyz")

julia> mainname("test")
("test", "")
source
ElemCo.Utils.print_infoFunction
print_info(info::AbstractString, additional_info::AbstractString="")

Print info between two lines.

If additional not empty: additional info after main.

source
ElemCo.Utils.print_memoryMethod
print_memory(EC::AbstractECInfo, mem1, info::AbstractString, verb::Int)

Print memory usage with message info if verbosity verb is smaller than PrintOptions.memory.

Note that memory is also used by other processes and the operating system, so the memory usage reported here is merely an estimate.

source
ElemCo.Utils.print_timeMethod
print_time(EC::AbstractECInfo, t1, info::AbstractString, verb::Int)

Print time with message info if verbosity verb is smaller than PrintOptions.time.

source
ElemCo.Utils.subspace_in_spaceMethod
subspace_in_space(subspace, space)

Return the positions of subspace in space (with respect to space)

subspace and space are lists of indices with respect to the full space (e.g., 1:norb).

Examples

julia> get_subspace_of_space([1,3,5], [1,3,4,5])
3-element Array{Int64,1}:
  1
  2 
  4
source
ElemCo.Utils.subspace_in_spaceMethod
subspace_in_space(subspace::UnitRange{Int}, space::UnitRange{Int})

Return the positions of subspace in space (with respect to space)

subspace and space are ranges of indices with respect to the full space (e.g., 1:norb).

Examples

julia> get_subspace_of_space(4:6, 2:7)
3:5
source
ElemCo.Utils.substrFunction
substr(string::AbstractString, start::Int, len::Int=-1)

Return substring of string starting at start spanning len characters (including unicode). If len is not given, the substring spans to the end of string.

Example:

julia> substr("λabδcd", 2, 3)
"abδ"
source
ElemCo.Utils.substrMethod
substr(string::AbstractString, range::UnitRange{Int})

Return substring of string defined by range (including unicode).

Example:

julia> substr("λabδcd", 2:4)
"abδ"
source
ElemCo.Utils.warnFunction
warn(msg::AbstractString, err=false)

Print a warning message. If err is true, the message is printed as an error message.

The message is printed with a scull emoji.

Example

julia> warn("This is a warning message.")
source
ElemCo.Utils.OutDictType
OutDict

An ordered descriptive dictionary that maps keys of type String to values of type Float64.

source
ElemCo.Utils.@istoplevelMacro
@istoplevel

Macro to check if the current scope is the top level scope.

(from https://discourse.julialang.org/t/is-there-a-way-to-determine-whether-code-is-toplevel)

source

Internal functions