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
ZenCore.COLORSZenCore.MODESZenCore.colorizeZenCore.erfZenCore.goodbyeZenCore.is_ploZenCore.is_qeZenCore.is_vaspZenCore.is_wannierZenCore.line_to_arrayZenCore.line_to_cmplxZenCore.overviewZenCore.promptZenCore.query_argsZenCore.query_caseZenCore.query_coreZenCore.query_dftZenCore.query_dmftZenCore.query_homeZenCore.query_inpsZenCore.query_solverZenCore.query_stopZenCore.query_testZenCore.requireZenCore.setup_argsZenCore.sorryZenCore.str_to_structZenCore.subscriptZenCore.welcomeZenCore.@cswitchZenCore.@pcsZenCore.@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
endZenCore.@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 global dict COLORS.
Examples
julia> @pcs "Hello world!" blue
julia> @pcs "Hello " red "world!" greenGlobal dicts
ZenCore.COLORS — ConstantCOLORSA global dict, which is used to specify the system colors.
ZenCore.MODES — ConstantMODESA 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(::NULLEngine)
query_inps(::VASPEngine)
query_inps(::QEEngine)
query_inps(::WANNIEREngine)Check whether the essential input files exist. It acts as a dispatcher. 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_test — 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(ae::AbstractEngine)Query the home directory of the chosen DFT backend. It supports vasp, quantum espresso, and wannier90 by now.
See also: query_dmft, query_solver.
ZenCore.query_dmft — FunctionZenCore.query_solver — Functionquery_solver(as::AbstractSolver)Query the home directories of various quantum impurity solvers. Now it supports CTHYB₁, CTHYB₂, HIA, and NORG.
See also: query_dft, query_dmft.
ZenCore.is_vasp — FunctionZenCore.is_qe — FunctionZenCore.is_plo — FunctionZenCore.is_wannier — FunctionZenCore.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.str_to_struct — Functionstr_to_struct(str::AbstractString, postfix::AbstractString)Convert a string (str) to an instance of struct. Here postfix could be Engine, Solver, Adaptor, Mode, and Mixer.
Examples
julia> str_to_struct("vasp", "Engine")
ZenCore.VASPEngine()
julia> str_to_struct("hia", "Solver")
ZenCore.HIASolver()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.