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
ZenCore.COLORS
ZenCore.MODES
ZenCore.colorize
ZenCore.erf
ZenCore.goodbye
ZenCore.line_to_array
ZenCore.line_to_cmplx
ZenCore.overview
ZenCore.prompt
ZenCore.query_args
ZenCore.query_case
ZenCore.query_core
ZenCore.query_dft
ZenCore.query_dmft
ZenCore.query_home
ZenCore.query_inps
ZenCore.query_solver
ZenCore.query_stop
ZenCore.require
ZenCore.setup_args
ZenCore.sorry
ZenCore.subscript
ZenCore.welcome
ZenCore.@cswitch
ZenCore.@pcs
ZenCore.@time_call
Macros
ZenCore.@cswitch
— Macro@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
ZenCore.@time_call
— Macro@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.
ZenCore.@pcs
— Macro@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
Global dicts
ZenCore.COLORS
— ConstantCOLORS
A global dict, which is used to specify the system colors.
ZenCore.MODES
— ConstantMODES
A global dict, which is used to specify the mode for output characters.
Functions
ZenCore.require
— Functionrequire()
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.
ZenCore.setup_args
— Functionsetup_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
.
ZenCore.query_args
— FunctionZenCore.query_case
— FunctionZenCore.query_inps
— Functionquery_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
.
ZenCore.query_stop
— FunctionZenCore.query_home
— Functionquery_home()
Query the home directory of Zen
. Actually, the ZEN_HOME
means the directory that the Zen
Framework is installed.
See also: query_core
.
ZenCore.query_core
— Functionquery_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
.
ZenCore.query_dft
— Functionquery_dft(engine::String)
Query the home directory of the chosen DFT engine.
See also: query_dmft
, query_solver
.
ZenCore.query_dmft
— FunctionZenCore.query_solver
— Functionquery_solver(engine::String)
Query the home directories of various quantum impurity solvers.
See also: query_dft
, query_dmft
.
ZenCore.welcome
— Functionwelcome()
Print out the welcome messages to the screen.
ZenCore.overview
— Functionoverview()
Print out the overview of Zen to the screen.
ZenCore.goodbye
— Functiongoodbye()
Print the goodbye messages to the screen.
ZenCore.sorry
— Functionsorry()
Print an error message to the screen.
ZenCore.prompt
— Functionprompt(msg::String)
Print a stylized Zen message to the screen.
prompt(msg1::String, msg2::String)
Print a stylized Zen message to the screen.
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.
ZenCore.line_to_array
— Functionline_to_array(io::IOStream)
Convert a line (reading from an IOStream) to a string array.
line_to_array(str::AbstractString)
Convert a string (AbstractString) to a string array.
ZenCore.line_to_cmplx
— Functionline_to_cmplx(io::IOStream)
Convert a line (reading from an IOStream) to a cmplx number. It is used to parse the LOCPROJ
file only.
See also: vaspio_projs
.
ZenCore.erf
— FunctionZenCore.subscript
— Functionsubscript(num::I64)
Convert a number (it must be in [0,9]) to subscript.
ZenCore.colorize
— Functioncolorize(c::String, s::String; bg::String = "default", m::String="default")
Return some escape sequences, which will be displayed as colorized texts in the terminal.
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.