|
| 1 | +# |
| 2 | +# DCore -- Integrated DMFT software for correlated electrons |
| 3 | +# Copyright (C) 2017 The University of Tokyo |
| 4 | +# |
| 5 | +# This program is free software: you can redistribute it and/or modify |
| 6 | +# it under the terms of the GNU General Public License as published by |
| 7 | +# the Free Software Foundation, either version 3 of the License, or |
| 8 | +# (at your option) any later version. |
| 9 | +# |
| 10 | +# This program is distributed in the hope that it will be useful, |
| 11 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +# GNU General Public License for more details. |
| 14 | +# |
| 15 | +# You should have received a copy of the GNU General Public License |
| 16 | +# along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 17 | +# |
| 18 | + |
| 19 | +import numpy |
| 20 | + |
| 21 | +from dcore._dispatcher import MeshImFreq, GfReFreq, GfImFreq |
| 22 | +from dcore.program_options import create_parser, parse_parameters |
| 23 | + |
| 24 | + |
| 25 | +def _set_n_pade(omega_cutoff, beta, n_min, n_max): |
| 26 | + """ |
| 27 | + Return (int)n_pade: the number of Matsubara frequencies below the cutoff frequency. |
| 28 | + n_pade is bounded between n_min and n_max |
| 29 | + """ |
| 30 | + n_pade = int((beta * omega_cutoff + numpy.pi) / (2.0 * numpy.pi)) |
| 31 | + print("n_pade = {} (evaluated from omega_pade)".format(n_pade)) |
| 32 | + n_pade = max(n_pade, n_min) |
| 33 | + n_pade = min(n_pade, n_max) |
| 34 | + print("n_pade = {}".format(n_pade)) |
| 35 | + return n_pade |
| 36 | + |
| 37 | + |
| 38 | +def anacont(sigma_iw_npz, beta, mesh_w, params_pade): |
| 39 | + iw_max = params_pade["iomega_max"] |
| 40 | + n_min = params_pade["n_min"] |
| 41 | + n_max = params_pade["n_max"] |
| 42 | + eta = params_pade["eta"] |
| 43 | + n_pade = _set_n_pade(iw_max, beta, n_min=n_min, n_max=n_max) |
| 44 | + |
| 45 | + data_w = {} |
| 46 | + num_data = numpy.sum([key.startswith("data") for key in sigma_iw_npz.keys()]) |
| 47 | + for idata in range(num_data): |
| 48 | + key = f"data{idata}" |
| 49 | + data = sigma_iw_npz[key] |
| 50 | + mesh_iw = MeshImFreq(beta, "Fermion", data.shape[0] // 2) |
| 51 | + sigma_iw = GfImFreq(data=data, beta=beta, mesh=mesh_iw) |
| 52 | + sigma_w = GfReFreq(mesh=mesh_w, target_shape=data.shape[1:]) |
| 53 | + sigma_w.set_from_pade(sigma_iw, n_points=n_pade, freq_offset=eta) |
| 54 | + data_w[key] = sigma_w.data |
| 55 | + return data_w |
| 56 | + |
| 57 | + |
| 58 | +def parameters_from_ini(inifile): |
| 59 | + parser = create_parser(["post.anacont.pade"]) |
| 60 | + parser.read(inifile) |
| 61 | + params = parser.as_dict() |
| 62 | + return params["post.anacont.pade"] |
0 commit comments