Utility

To provide some useful utility macros and functions. They can be used to colorize the output strings, query the environments, and parse the input strings, etc.

Source: util.jl

Contents

Index

Macros

ZenCore.@cswitchMacro
@cswitch(constexpr, body)

Provides a C-like switch statement with the falling through behavior. This implementation was borrowed from the following github repository:

  • https://github.com/Gnimuc/CSyntax.jl

Examples

engine = get_d("engine")
@cswitch engine begin
    @case "vasp"
        just_do_it()
        break

    @default
        sorry()
        break
end
source
ZenCore.@time_callMacro
@time_call(ex)

Evaluate a function call (ex), and then print the elapsed time (number of seconds) it took to execute.

This macro is a variation of the standard @elapsed macro.

source
ZenCore.@pcsMacro
@pcs(x...)

Try to print colorful strings. Here x is a combination of strings and colors. Its format likes string1 color1 string2 color2 (repeat). For the supported colors, please check the dict COLORS.

Examples

julia> @pcs "Hello world!" blue
julia> @pcs "Hello " red "world!" green

See also: COLORS, welcome.

source

Global dicts

ZenCore.MODESConstant
MODES

A global dict, which is used to specify the mode for output characters.

source

Functions

ZenCore.requireFunction
require()

Check the version of julia runtime environment. It should be higher than v1.6.x. One of the most important philosophies of the ZenCore package is minimizing the dependence on the third-party libraries as far as possible. Note that the ZenCore package relys on the TOML package to parse the *.toml file. Only in v1.6.0 and higher versions, julia includes the TOML package in its standard library.

source
ZenCore.setup_argsFunction
setup_args(x::Vararg{String})

Setup ARGS manually. This function is used only in REPL environment. We can use this function to update ARGS, so that the query_args() and the other related functions can work correctly.

Examples

julia> setup_args("SrVO3.toml")
1-element Array{String,1}:
 "SrVO3.toml"

See also: query_args.

source
ZenCore.query_inpsFunction
query_inps(engine::String)

Check whether the essential input files exist. This function is designed for the DFT engine only. The input files for the DMFT engine, quantum impurity solver, and Kohn-Sham adaptor will be generated automatically by default. The ZenCore package will take care of them. Do not worry about that.

See also: query_case.

source
ZenCore.query_homeFunction
query_home()

Query the home directory of Zen. Actually, the ZEN_HOME means the directory that the Zen Framework is installed.

See also: query_core.

source
ZenCore.query_coreFunction
query_core()

Query the src/core directory of Zen. Actually, the ZEN_CORE denotes the directory that contains the ZenCore.jl file. Be careful, ZEN_CORE must be included in LOAD_PATH.

See also: query_home.

source
ZenCore.promptFunction
prompt(msg::String)

Print a stylized Zen message to the screen.

source
prompt(msg1::String, msg2::String)

Print a stylized Zen message to the screen.

source
prompt(io::IOStream, msg::String)

Print a stylized Zen message to the given IOStream. This function is used to log the key events during DFT + DMFT iterations.

source
ZenCore.line_to_arrayFunction
line_to_array(io::IOStream)

Convert a line (reading from an IOStream) to a string array.

source
line_to_array(str::AbstractString)

Convert a string (AbstractString) to a string array.

source
ZenCore.colorizeFunction
colorize(c::String, s::String; bg::String = "default", m::String="default")

Return some escape sequences, which will be displayed as colorized texts in the terminal.

source
colorize(c::String, s::String; bg::String = "default", m::String="default")

Return some escape sequences, which will be displayed as colorized texts in the terminal.

source