Getting Started#

A Japanese version is here.

Tutorial#

As a tutorial, we describe the procedure for generating model in the case of graphene.

  1. Download graphene_in.py and graphene_ctrl.py from examples directory.

  2. At the same place where the above two files are, run the following:

    $ mp_create -v graphene_in.py
    

    It creates the following files under graphene directory:

    • graphene.pkl : Model information file (binary)

    • graphene.tex, graphene.pdf : Summary of the model information

    • graphene.qtdw : QtDraw file of the model structure

    The .tex/.pdf files are created only when "pdf": {"create": True} (default) and the TeX components listed in Installation (pLaTeX, ptex2pdf and the LaTeX packages) are available:

    • If latex is not found, neither file is written (with -v, a notice is printed).

    • Otherwise the .tex file is written first. If ptex2pdf or a LaTeX package is then found missing, or the compilation fails or does not finish, a warning is printed and the .pdf file, from an earlier run or incomplete, is removed (unless it cannot be removed, e.g., for lack of permission).

    • The .pkl file and the other outputs are written in any case.

    The .qtdw file is created only when "qtdraw": {"create": True} (default) and QtDraw is installed (with -v, a notice is printed if QtDraw is not found).

  3. To analyze the model, e.g., draw dispersion, run the following:

    $ mp_analyze -v graphene_ctrl.py
    

    It creates the following files under graphene directory:

    • info/graphene_matrix.py, info/graphene_hr.dat : Full matrix information for selected SAMBs

    • output/ : Various output for physical quantities

    • samb/ : QtDraw files of SAMBs, <model>_x1.qtdw, <model>_y2.qtdw, <model>_z3.qtdw, …, one file for each atomic (x), cluster (y) or combined (z) SAMB. They are written when samb_figure is True (all the atomic SAMBs, and the cluster and combined SAMBs of the sites and of the bonds with neighbor < max_neighbor of "qtdraw" of the model) or a list of SAMBs (e.g. ["x1", "y2", "z3"]), QtDraw is installed, and the model was created with "qtdraw": {"create": True}. If samb_figure is not False but one of the others is not satisfied, a warning is printed and the directory is not created. At each site or bond center, the harmonics of the atomic SAMB times the cluster weights are summed for each type of the atomic SAMB: the polar parts (Q, T) are drawn as lobes colored by sign (Q: BrBG, T: coolwarm), and the axial parts (G, M) as translucent lobes with arrows of the axial vector \(\hat{r} f\) inside (G: green, M: blue), outward for \(f > 0\). A cluster SAMB is drawn as a combined SAMB with the atomic SAMB \(Q_0\), except an antisymmetric (T, M) bond cluster, drawn as red arrows along the bonds that show the flow given by the imaginary weights, like a bond current. Each arrow is a T (an imaginary hopping); the type of the cluster (T or M) is that of the whole pattern, e.g. circulating flows for M. In a combined SAMB with an antisymmetric bond cluster, the object at a bond center is (atomic part) \(\otimes\) T: the red arrow of the T points along the bond (tail to head) and the lobes carry the sign; when the atomic part is \(Q_0\), the sign and the magnitude go to the arrow, as for a cluster SAMB. With samb_figure_png set to True, PNG files of the same names, <model>_x1.png, …, are also written (rendered off screen). How to read the figures: Figures of the SAMB in the User Guide.

  4. In order to handle graphene.pkl interactively, use the IPython interface. See analyze_model.ipynb for details.

Model input file#

In case of graphene, the model input file is

# graphene_in.py
graphene_in = {
    "model": "graphene",  #  name of model.
    "group": 191,  # No. of space group.
    "cell": {"c": 4},  # set large enough interlayer distance.
    #
    "site": {"C": ("[1/3,2/3,0]", "pz")},  # positions of C site and its orbital.
    "bond": [("C", "C", [1, 2])],  # C-C bonds up to 2nd neighbors.
    #
    "spinful": False,  # spinless.
    #
    "SAMB_select": {  # select combined SAMB.
        "X": [],  # all Q/G/M/T.
    },
}

The other settings are provided as default values, which are given as follows:

# default model input.
default_model = {
    "model": "unknown",
    "group": "C1",  # PG or SG tag (MPG/MSG are not supported).
    "cell": {},
    "spinful": False,
    # acceptable orbital names (tesseral) in site:
    #   s, p=(px, py, pz), d=(dv, dxy, dxz, dyz, du), f=(fc, fs, fbz, f3, fx, fy, faz).
    #   (Ver.3 renamed f2, f1, f3x, f3y to fc, fs, fx, fy.)
    #   (s,u), (s,d), ...
    #   (1/2,s), (1/2,p), (3/2,p), (3/2,d), (5/2,d), (5/2,f), (7/2,f).
    "site": {},
    "bond": [],
    "SAMB_select": {  # select combined SAMB.
        "X": ["Q", "G"],  # type, "Q/G/M/T", []=all.
        "l": [],  # rank, []=all.
        "Gamma": [],  # "IR"=identity, []=all, "..."/["...","..."]=specified irreps.
        "s": [],  # spin, 0/1, []=all.
    },
    "atomic_select": {  # select atomic SAMB.
        "X": [],  # type, "Q/G/M/T", []=all.
        "l": [],  # rank, []=all.
        "Gamma": [],  # "IR"=identity, []=all, "..."/["...","..."]=specified irreps.
        "s": [],  # spin, 0/1, []=all.
    },
    "site_select": {  # select site-cluster SAMB.
        "l": [],  # rank, []=all.
        "Gamma": [],  # "IR"=identity, []=all, "..."/["...","..."]=specified irreps.
    },
    "bond_select": {  # select bond-cluster SAMB.
        "X": [],  # type, "Q/G/M/T", []=all.
        "l": [],  # rank, []=all.
        "Gamma": [],  # "IR"=identity, []=all, "..."/["...","..."]=specified irreps.
    },
    "toroidal_priority": False,
    "qtdraw": {
        "create": True,  # create QtDraw file ?
        "mode": "standard",  # mode, "standard/detail".
        "view": None,  # [a,b,c], if None, default=[6,5,1].
        #
        "rep_site": True,  # show representative site ?
        "rep_bond": True,  # show representative bond ?
        #
        "max_neighbor": 5,  # max. neighbor to draw.
        "cell_mode": None,  # "off/single/all", if None, single for SG, off for PG.
        "scale": None,  # default or magnification scale.
        "site_radius": 0.07,  # base site radius.
        "bond_width": 0.02,  # base bond width.
    },
    "pdf": {
        "create": True,  # create PDF file ?
        "common_samb": True,  # display common SAMB ?
        "harmonics": True,  # display harmonics ?
        "max_neighbor": 5,  # max. neighbor to write (None: all).
    },
}

You can overwrite whatever you want as in the case of graphene.

Note

MultiPie Ver.3 renamed four f orbitals. The old names are no longer accepted; replace them in your model input files.

Ver.2

Ver.3

Wannier90

f2

fc

fx(x2-3y2)

f1

fs

fy(3x2-y2)

f3x

fx

fxz2

f3y

fy

fyz2

Control file#

In case of graphene, the control file is

# graphene_ctrl.py
graphene_ctrl = {
    "samb": {
        "model": "graphene",
        "parameter": {
            "z2": 1.0,
        },
        "samb_figure": True,
        "k_multipole": True,
    },
    "output": {
        "dispersion": {
            "k_path": "Γ-M-K-Γ",
            "k_point": {"Γ": "[0,0,0]", "K": "[1/3,1/3,0]", "M": "[1/2,0,0]"},
        },
    },
}

The default values of control file are provided as follows:

# default control.
default_control = {
    "mode": "samb",  # samb (SAMB-based only), wannier (wannier-based only), symcw (SAMB and wannier based).
    "grid": (50, 50, 50),  # k-grid size (b1, b2, b3).
    "samb": {
        "model": None,  # model name for .pkl (optional in wannier mode).
        "select": {  # SAMB select condition, where S=site name, R=orbital rank, N=neighbor bond.
            # "site": [("A", [1, 2])],  # S or (S, [R]) in list.
            # "bond": [[0, 1, 2]],  # S1;S2, N, [N], (S1;S2, N), (S1;S2, [N]), (S1;S2, R1;R2), (S1;S2, R1;R2, N) or (S1;S2, R1;R2, [N]) in list.
            # "X": [],  # SAMB type Q/G/T/M in list. empty []=all.
            # "l": [],  # SAMB rank, 0, 1, ..., 11 in list. empty []=all.
            # "Gamma": ["A1g"],  # SAMB irreps. in list. "IR"=identity irrep., empty []=all.
            # "s": [],  # SAMB internal rank, 0,1 in list. empty []=all
        },
        "parameter": {  # SAMB with finite weight (float, or str of sympy const., e.g., "sqrt(2)"), or filename of z_j dict (.py file relative to model_name/info/).
            # "z1": 1.0,
        },
        "samb_figure": False,  # save SAMB QtDraw files ? True (all x, and y, z of sites and bonds with neighbor < qtdraw/max_neighbor of the model) or list of SAMB, e.g. ["x1", "y2", "z3"].
        "samb_figure_png": False,  # save also PNG files of the SAMB figures ?
        "k_multipole": False,  # compute momentum multipole ?
        "NG_sum_rule": False,  # Nambu-Goldstone sum rule ?
    },
    "wannier": {  # Closest Wannier (CW) or SymWannier setting.
        "dir": "wannier",  # directory for wannier input, i.e., "./seedname/wannier".
        "seedname": None,  # read +(.win, .nnkp, _hr.dat, _wsvec.dat if exists, ...).
        "ket_wannier": [],  # correspondence between Wannier and MultiPie basis, [MultiPie ket name, "orbital@site(sublattice)"] in Wannier order. If empty, automatically determined.
    },
    "output": {  # physical quantity setting.
        "dir": "output",  #  output directory.
        "fourier": {"tb_gauge": True},  # TB gauge ?
        "dos": False,  # DOS: False (none), "auto" (partial DOS for each site cluster and orbital, spin summed), or [[ket name]] (sum of partial DOS of the kets in each list). total DOS is always included.
        "dos_e_num": 1000,  # number of energy points of DOS (range includes all eigenvalues).
        "dos_width": None,  # Gaussian broadening of DOS. if None, 1% of the band width.
        "dos_method": "gaussian",  # DOS method, "gaussian" or "tetrahedron" (optimized tetrahedron method by libtetrabz).
        "dos_spin": False,  # resolve spin, u/d, of spinful basis in "auto" DOS ?
        "n_electron": None,  # number of occupied states per primitive cell (one per band) to determine fermi energy. if None, 0 (samb mode) or that of seedname.win.
        "save_k_path": False,  # save Ek, Uk along k path in .npz ?
        "save_k_full": False,  # save Ek, Uk on full k grid in .npz ?
        "callback_k_path": None,  # file (.py, relative to topdir) defining callback_k_path(Ek, Uk, info), called with eigen system along k path.
        "callback_k_full": None,  # file (.py, relative to topdir) defining callback_k_full(Ek, Uk, info), called with eigen system on full k grid.
        "callback_info": [],  # quantities added to info of callback_k_full as info[keyword], [k,n] on full k grid. local quantity, "Sx/Sy/Sz/Lx/Ly/Lz/Qu/Qv/Qyz/Qxz/Qxy", or SAMB, "zj".
        "dispersion": {  # dispersion info.
            "power": None,  # positive power p: Ek^p is used in the dispersion and DOS, with fermi energy = 0 (n_electron cannot be used). -|Ek|^p if Ek^p is not a real number (negative Ek with non-integer p). if None, power=1.
            "k_path": "",  # symmetry line, separated by "-". disconnected points by "|". if empty str, default values are used for k_path and k_point.
            "k_point": {"Γ": "[0,0,0]"},  # k-point (fractional, primitive cell of model, or of seedname.win without model).
            "local": [],  # local quantity, "Sx/Sy/Sz/Lx/Ly/Lz/Qu/Qv/Qyz/Qxz/Qxy".
            "weight": False,  # orbital weight (fat band): False (none), "auto" (each site cluster and orbital, spin summed), or [[ket name]].
            "z": [],  # SAMB, [zj], expectation value <u_kn|Z_j(k)|u_kn> of each band along k path.
        },
        "z_expectation": [],  # SAMB, [zj] or "all" (all selected SAMBs), expectation value summed over occupied states (T=0) per primitive cell.
    },
}

In a typical use, you first create the SAMBs for all irreps, and then choose the necessary SAMBs, such as the symmetry-breaking terms in addition to the identity irreps., by specifying samb/select and/or samb/parameter in the control file.

Post-processing tools#

The density of states, the Fermi energy from the filling, the orbital weight (fat band), the output of the eigenvalues and eigenvectors, callbacks for custom calculations, local operators, and the expectation values of SAMBs are set in output of the control file. See Post-processing tools for details and an example.

Format of input files#

Model input files and control files are Python files that contain dictionaries, e.g., graphene_in = {...}.

  • They are not executed as Python code. Each dictionary is read with ast.literal_eval, so only literals (strings, numbers, lists, tuples, dictionaries, True/False/None) are allowed. Arithmetic such as 2*2, variables and import cannot be used.

  • Fractions and symbolic values are given as strings, e.g., "[1/3,2/3,0]". Strings representing mathematical expressions are parsed by SymPy.

  • With mp_create (or create_model), every dictionary in a model input file, name = {...}, is treated as a separate model, and with mp_analyze (or analyze_model), every dictionary in a control file is treated as a separate control. MaterialModel.analyze(filename) and ModelAnalyzer.analyze(filename) expect one dictionary per file.

  • Unknown keys, e.g., a typo such as "spinfull", are errors: ValueError: unknown key(s) in model 'x': 'spinfull' (did you mean 'spinful'?). The accepted keys are those in the default model and the default control above, and also

    • cell: a, b, c, alpha, beta, gamma,

    • SAMB_select, atomic_select, site_select, bond_select: X, l, Gamma, s,

    • samb/select: site, bond, X, l, Gamma, s.

    The keys of the following dictionaries are not checked against the defaults, but have their own rules:

    • site names in site: non-empty strings without ;, and without _ for sites used in bond (; and _ are used in the names of site and bond clusters). Letters and digits, e.g., "Fe1", are recommended for all sites, since the names also appear in the PDF (LaTeX) and in file names. LaTeX special characters, e.g., # or %, in the model and site names are escaped in the PDF.

    • SAMB names in samb/parameter: names of the generated SAMBs, e.g., "z1". samb/parameter may also be the name of a Python file containing one dictionary of the same form, given relative to model_name/info/, with the extension, e.g., "my_z.py" for model_name/info/my_z.py (not "info/my_z.py", "my_z" or an absolute path). When the parameters are not empty, mp_analyze writes them to model_name/info/model_name_z.py, which is overwritten at each run; copy it to another name to edit it.

    • k-point labels in output/dispersion/k_point: labels used in k_path, without -, | and spaces, which separate the points in k_path.

  • wannier/read_KS has been removed: "read_KS": True is an error, and "read_KS": False in an old control file is ignored with a warning (remove it from the control file).

Note

Strings representing mathematical expressions in input files are parsed by SymPy’s parse_expr, which uses eval internally, and the model file model_name.pkl is stored with Python’s pickle. Use input files and .pkl files only from trusted sources.

Command-line tools#

  • mp_create, mp_analyze and mp_convert exit with status 1 when an error occurs, and with status 2 for a usage error, e.g., no input file or an unknown option. The error is printed in one message with the input file and, when applicable, the model and the site concerned; with -v, the full traceback is printed instead.

  • When several input files are given, all of them are read before any model is created or analyzed.

  • mp_create -i and mp_analyze -i print the default model and control, which can be used as a template of an input file.

  • python -m multipie.scripts.mp_create, python -m multipie.scripts.mp_analyze and python -m multipie.scripts.mp_convert work in the same way.

  • mp_convert converts a model (.pkl) of Ver.2 into Ver.3, or renumbers a model of Ver.3 before 3.2.0, and the weights of its controls (see Changes from Ver.2).

  • Messages such as the elapsed time and warnings are written to stdout through the multipie logger. create_model and analyze_model (and so mp_create and mp_analyze) set it up unless it already has a handler; the logging configuration of the application, e.g., the root logger in Jupyter, is not changed. To collect the messages elsewhere, add a handler to the multipie logger before calling them.

Parallel computation#

The atomic multipole matrices, create_atomic_multipole_matrix in multipie.util.util_atomic_multipole, and the atomic SAMBs, Group.create_atomic_samb_L, are computed in parallel with joblib. These are used to generate the database. In mp_create (MaterialModel.analyze), the orthogonalization of the atomic and combined SAMBs is also done in parallel for a large model, e.g., a spinful model with d orbitals; a small model is processed serially, since starting the processes would take longer than the computation. The output does not depend on the number of processes. The number of processes is given by the environment variable MULTIPIE_N_JOBS:

  • not set or empty: all cores (-1, default),

  • 1: serial,

  • n > 1: n processes, n < 0: number of cores + 1 + n processes (at least 1), as in joblib,

  • 0 or a non-integer value is an error.

$ MULTIPIE_N_JOBS=4 python my_script.py   # a script calling the functions above

In PowerShell on Windows, use $env:MULTIPIE_N_JOBS = "4" before running the script; the setting remains for the session until it is removed by Remove-Item env:MULTIPIE_N_JOBS.

Output files#

The description of the output files is as follows (with model_name prefixed):

  • model_name : all files are created under model_name.

    • .pdf : model info. in PDF.

    • .pkl : model data (binary).

    • .qtdw : model structure in QtDraw.

    • .tex : model info. source.

    • samb/

      • _atomic_samb.qtdw : atomic SAMBs.

      • _A-B-…_def.qtdw : definition of the site clusters (all sites in one file).

      • _A-B-…qtdw : site-cluster SAMBs (all sites in one file).

      • _A;B_nnn_m_def.qtdw : definition of A;B (nnn-neighbor, m) bond cluster (nnn: neighbor, 3 digits, e.g., 001).

      • _A;B_nnn_m.qtdw : A;B (nnn-neighbor, m) bond-cluster SAMBs.

    • info/

      • _hr.dat : H[R] matrix data.

      • _info_output.py : info. of output.

      • _info_samb.py : info. of model and SAMBs.

      • _info_wannier.py : info. of wannier.

      • _info.py : global info.

      • _k.py : SAMBs in momentum rep.

      • _matrix.py : SAMB matrix data.

      • _var.py : relation between zj and atomic parameters at bond 1 (see below).

      • _z.py : zj parameters.

    • output/

      • _dispersion.eps : dispersion in EPS.

      • _dispersion.pdf : dispersion in PDF.

      • _dispersion.txt : dispersion data.

      • _dos.eps : DOS in EPS.

      • _dos.pdf : DOS in PDF.

      • _dos.txt : DOS data (when output/dos is not False).

      • _eigen_k_path.npz, _eigen_k_full.npz : eigenvalues and eigenvectors (when output/save_k_path or output/save_k_full is True).

      • _weight.pdf : dispersion colored by the orbital weight.

      • _weight.txt : dispersion with the orbital weight (when output/dispersion/weight is not False).

      • plot_dos.gnu, plot_weight.gnu : command scripts to plot DOS and orbital weight by gnuplot.

      • plot_band.gnu : command script to plot by gnuplot.

The _var.py file gives, for each bond cluster, the head and tail sites of its bond 1 and each \(z_j\) of the identity irrep in terms of the matrix elements of bond 1 (from 3.2.0), e.g., for graphene:

graphene_var = {
    "C;C_001_1": {"bond": ("C(2)", "C(1)"), "z2": "sqrt(6)*g_{pz,pz}"},
    "C;C_002_1": {"bond": ("C(1)", "C(1)"), "z3": "2*sqrt(3)*g_{pz,pz}"},
}
  • "bond": (head site, tail site) of bond 1, as atom(sublattice).

  • g_{a,b} and h_{a,b}: the matrix element of bond 1 between the head orbital a and the tail orbital b is \(H_{a,b} = g_{a,b} + i h_{a,b}\).

  • The orbitals are written as they are for a spinless model (e.g., pz), as pxu and pxd for (px,u) and (px,d) (spinful, lgs), and with the letter of the rank for the jml basis, e.g., p(3/2,1/2) for (3/2,1/2) of p, so that p and d with the same \((j, m)\) are distinguished.