Real-material application: SrVO3

In this example we perform an analytic continuation for an impurity \(G(\tau)\) calculated from DFT+DMFT for the t2g subspace of paramagnetic SrVO3. All three t2g orbitals are degenerate, thus we have to perform the continuation only for one orbital. The DFT+DMFT solution itself can be obtained with the TRIQS/dft_tools package and we like to refer the interested user to the corresponding user guide page on SrVO3. However, for this example we directly provide the \(G(\tau)\) at \(\beta = 37.5~1/eV\) as a downloadable file. For simplicity we use a constant error of \(10^{-3}\) for all \(\tau\) points.

Running TauMaxEnt

 1
 2from triqs_maxent import *
 3import numpy as np
 4
 5# initialize TauMaxEnt, set G_tau from file, set omega and alpha mesh
 6# set the probability; then add Bryan and Classic analyzers are added by the program
 7# LineFit and Chi2Curvature analyzers are set set by default
 8tm = TauMaxEnt(probability='normal')
 9tm.set_G_tau_file(filename='srvo3_G_tau.dat', tau_col=0, G_col=1, err_col=2)
10tm.omega = HyperbolicOmegaMesh(omega_min=-10, omega_max=10, n_points=400)
11tm.alpha_mesh = LogAlphaMesh(alpha_min=1e-4, alpha_max=100, n_points=50)
12# run MaxEnt
13res = tm.run()
14
15# run the same calculation with preblur
16# Here we guess the preblur parameter b, but it is better to determine
17# b with a chi2(b) linefit or curvature analysis!
18# set preblur parameter b, PreblurA_of_H and PreblurKernel
19b = 0.1
20tm.A_of_H = PreblurA_of_H(b=b, omega=tm.omega)
21K_orig = tm.K
22tm.K = PreblurKernel(K=K_orig, b=b)
23# run Maxent with preblur
24res_pb = tm.run()

Analyzing the result

In the following we plot \(\chi^2(\alpha)\) and the corresponding curvature as well as the result of the linefit. The LineFitAnalyzer uses as optimal \(\alpha\) value the intersection of the two fitted lines. The Chi2CurvatureAnalyzer uses the \(\alpha\) at the maximum curvature of \(\chi^2(\alpha)\). Further we enabled in this example the calculation of the probability for each \(\alpha\). Then, the ClassicAnalyzer takes the \(\alpha\) at the maximum of the probability and the BryanAnalyzer averages over all spectral functions weighted by the corresponding probabilities.

Usually the results of the LineFitAnalyzer and the Chi2CurvatureAnalyzer are similar. Also, as the probability is often sharply peaked at an \(\alpha\) value the ClassicAnalyzer and BryanAnalyzer give similar spectral functions.

 1# analysis of the output (here we only look at the normal run without preblur)
 2import matplotlib.pyplot as plt
 3plt.rcParams['figure.figsize'] = (8, 8)
 4plt.rcParams.update({'font.size': 16})
 5
 6fig1 = plt.figure()
 7# chi2(alpha)
 8plt.subplot(2, 2, 1)
 9res.plot_chi2()
10# curvature(alpha)
11plt.subplot(2, 2, 2)
12res.analyzer_results['Chi2CurvatureAnalyzer'].plot_curvature()
13# linefit of chi2(alpha)
14plt.subplot(2, 2, 3)
15res.analyzer_results['LineFitAnalyzer'].plot_linefit()
16plt.ylim(1e1, 1e4)
17# probablity(alpha)
18plt.subplot(2, 2, 4)
19res.plot_probability()
20plt.tight_layout()
21fig1.savefig('srvo3_analysis.png')
22
23# spectral function A
24matplotlib.rcParams['figure.figsize'] = (8, 6)
25fig2 = plt.figure()
26plt.plot(res.omega, res.get_A_out('LineFitAnalyzer'),
27         '-', lw=3, label='LineFit')
28plt.plot(res.omega, res.get_A_out('Chi2CurvatureAnalyzer'),
29         '--', lw=3, label='Chi2Curvature')
30plt.plot(res.omega, res.get_A_out('BryanAnalyzer'),
31         '-', lw=3, label='Bryan')
32plt.plot(res.omega, res.get_A_out('ClassicAnalyzer'),
33         '--', lw=3, label='Classic')
34plt.plot(res_pb.omega, res_pb.get_A_out('LineFitAnalyzer'),
35         'k-', lw=3, label='Preblur LineFit')
36plt.legend()
37plt.xlim(-6, 6)
38plt.ylim(0, 1)
39plt.ylabel('A')
40plt.xlabel(r'$\omega$')
41plt.tight_layout()
42fig2.savefig('srvo3_A.png')
43
44# print the optimal alpha-values
45print(('Curvature: ', res.analyzer_results[
46      'Chi2CurvatureAnalyzer']['alpha_index']))
47print(('LineFit: ', res.analyzer_results['LineFitAnalyzer']['alpha_index']))
48print(('Classic: ', res.analyzer_results['ClassicAnalyzer']['alpha_index']))
49print(('Preblur LineFit: ', res_pb.analyzer_results[
50      'LineFitAnalyzer']['alpha_index']))
../_images/srvo3_analysis.png ../_images/srvo3_A.png

Note that the LineFitAnalyzer and the Chi2CurvatureAnalyzer are less sensitive to the given error, and thus work also well when the real error is not known. On the other hand, the analyzers based on the probability depend on the given error. As an exercise try to set the error to a different value, e.g.:

tm.error(1e-4)

and compare the result spectral functions of the different analyzers. You might need to adjust also the \(\alpha\)-grid. If the error is, e.g., scaled by a factor of 10, the \(\alpha\) range should be changed by a factor of 100.

Visualization in notebook

Above we have used the plot_* method, which is implemented for many objects, to visualize the output. However, the data can be also visualized with the interactive Jupyter widget JupyterPlotMaxEnt:

from triqs_maxent.plot.jupyter_plot_maxent import JupyterPlotMaxEnt
JupyterPlotMaxEnt(res)

For further ways to visualize your results have a look at the Visualization page.

Saving the data to a h5-file

The data of the MaxEnt run (MaxEntResult) can be stored as MaxEntResultData object to a h5-file with:

from h5 import *
with HDFArchive('srvo3_maxent.h5','w') as ar:
    ar['maxent_result'] = res.data
    ar['maxent_result_pb'] = res_pb.data