How to make a database file - SpM-lab/irbasis GitHub Wiki

In this page, the procedure to update the database is explained.

  1. Compute the solution of the basis functions, and make a reference data by using irlib.

It is convenient to use a sample script generate.py in irlib to compute basis functions and generate a reference data.

For example, the following script will make basis_f-mp-Lambda10000.0.txt.

from __future__ import print_function

import numpy
import irlib

# Compute basis functions very accurately

max_dim = 1000

# Cut off for singular values
cutoff = 1e-12

# Relative accuracy for basis functions
r_tol = 1e-8

verbose = True

# Initial value of bits (will be increased automatically if necessary)
prec = 64

# Number of piecewise polynomials for each section
n_local_poly = 8

# Degree of Gauss-Legendre quadrature used in evaluating kernel matrix elements (recommended n_gl_node > 2 * n_local_poly)
n_gl_node = 24

## Construct basis
statis = 'F'
for Lambda in [10000.0]:
    print("Computing basis functions... It may take some time")
    if statis == 'F':
        b = irlib.compute_basis(irlib.FERMIONIC, Lambda, max_dim, cutoff, "mp", r_tol, prec, n_local_poly, n_gl_node, verbose)
        irlib.savetxt("basis_f-mp-Lambda"+str(Lambda)+".txt", b)
    else:
        b = irlib.compute_basis(irlib.BOSONIC, Lambda, max_dim, cutoff, "mp", r_tol, prec, n_local_poly, n_gl_node, verbose)
        irlib.savetxt("basis_b-mp-Lambda"+str(Lambda)+".txt", b)
    print("Done!")

You can easily obtain new data by changing parameters

max_dim
cutoff
r_tol
prec
n_local_poly
n_gl_node

and Lambda.

  1. Update database

After making a reference data, you can store the data in hdf5 file by using make_h5.py in the database folder. The optional arguments of make_h5.py are

  -h, --help            show this help message and exit
  -o OUTPUTFILE, --output OUTPUTFILE
                        Path to output hdf5 file. (default: irbasis.h5)
  -i INPUTFILE, --input INPUTFILE
                        Path to input file. (mandatory)
  -l LAMBDA, --lambda LAMBDA
                        Value of lambda. (mandatory)
  -p PREFIX, --prefix PREFIX
                        Data will be stored in this HF5 group. (mandatory)

For example, you can update/create irbasis.h5 by using the following command.

$ python make_h5.py -i basis_f-mp-Lambda10000.0.txt -p basis_f-mp-Lambda10000.0 -l 10000.0

The reference data for u_{nl} can be generated by running make_unl_safe.py and is saved into a HDF file (unl_safe_ref.h5).

In practice, we use a shell script like this.

export SCRIPT=~/git/irbasis/database/make_h5.py
export SCRIPT2=~/git/irbasis/database/make_unl_safe.py

rm -f irbasis.h5

for Lambda in 10.0 100.0 1000.0 10000.0 100000.0 1000000.0 10000000.0 ; do
    python ${SCRIPT}  -i basis_f-mp-Lambda${Lambda}.txt    -p basis_f-mp-Lambda${Lambda} -l ${Lambda}
    python ${SCRIPT}  -i basis_b-mp-Lambda${Lambda}.txt    -p basis_b-mp-Lambda${Lambda} -l ${Lambda}
    python ${SCRIPT2} -i basis_f-mp-Lambda${Lambda}.txt -l ${Lambda}
    python ${SCRIPT2} -i basis_b-mp-Lambda${Lambda}.txt -l ${Lambda}
done