Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Allowing imtime_bubble_chi0_wk to take 2 inputs. #46

Open
andrewkhardy opened this issue Aug 7, 2024 · 7 comments
Open

Comments

@andrewkhardy
Copy link

andrewkhardy commented Aug 7, 2024

I would be happy to implement this but would need some advice on how to proceed with a PR.

Summary

Modify the function imtime_bubble_chi0_wk(G_wk, nw) so that it can take two Green's functions as inputs. The interface would be something like imtime_bubble_chi0_wk(G_a_wk,G_b_wk, nw) or imtime_bubble_chi0_wk(G_wk,"up","down", nw) where you provide names for the GFBlock object.

Motivation

Often times in GW calculations (or self-consistent loops generally), or for more generalized susceptibilities, one would like to be able to compute the generalized bubble / susceptibility

$\Pi(k,\tau)=\sum_{p}\sum_\sigma G_{A\sigma}(k + p,\tau)G_{B \sigma}( p,-\tau).$
(or spin-mixing terms).

Implementation

Currently, I believe this is only implemented in the C++ code. The function we would need to modify is chi_Dtr_t chi0_tr_from_grt_PH(g_Dtr_cvt g_tr) in chi_imtime.cpp I believe to allow for two inputs.

@andrewkhardy
Copy link
Author

This should be implemented by the following PR whenever people have some free-time to look at it.

Andrew

@HugoStrand
Copy link
Member

Dear Andrew,

Thank you for the feature request and the pull request #47.

Before giving feedback on the details of your pull request I would like to ask for your help to understand better what you want to accomplish on a high level. (So that there is no other/better way of mapping this to the TPRF notation/nomenclature).

In contrast to most TRIQS solvers TPRF (currently) takes an approach assuming that there are no symmetries in the single particle indices. I.e. for cases where you might get a block Greens function (BlockGF) with separate spin "up" and "down" blocks from your impurity solver, in TPRF we have so far repacked the single particle Green's function so that all single particle indices (both spin and orbital) are contained in the single particle Green's function matrix-valued structure.

To be concrete. For a spin-ful single band system, we would currently map the block greens function to a matrix valued Green's function along the lines

# G_w : from impurity solver BlockGF with up/down block structure
g_w = Gf(mesh=G_w.mesh, target_shape=[2,2])
g_w[0, 0] << G_w['up']
g_w[1, 1] << G_w['down']

this way the Green's function has the spin structure $g_{\sigma,\sigma'}$ in the target space (see target_shape above). Here is a similar example for the three band Sr2RuO4 tutorial (https://github.com/TRIQS/tprf/blob/3.3.x/doc/user_guide/dmft_susceptibility_dbse/common.py#L251)

When computing the bubble susceptibility using this Green's function we get the four index result $\chi^{(0)}_{\sigma_1, \sigma_2, \sigma_3, \sigma_4}$ where the "up", "down" case in your example above can be obtained by indexing the four spin indices.

I know that this is not the most memory optimal way of doing things if you have a problem with, e.g. spin symmetry. Perhaps it is time to consider generalise the TPRF routines to also accept block Green's functions. I am interested in hearing your view on this.

In your application is there some case that can not be covered by mapping the BlockGF to a matrix valued Green's function?

I look forward to hear back from you and working with you on the PR.

Cheers, Hugo

@andrewkhardy
Copy link
Author

andrewkhardy commented Aug 12, 2024

Hi Hugo,

Thanks so much. Since posting that, I have figured out the matrix structure. In my example, where I wanted to compute

$\sum_{k,\omega} V_kG(k,\omega) G(k+Q, \omega + \Omega)$

embedding $V_k G(k,\omega)$ inside a g_k_w[1,1] object does in fact accomplish what I was hoping to implement. This probably makes my PR pointless.

That said, there's a lot of contracted indices here computed that I do not need. I would eventually like to place this bubble inside a self-consistent loop and perform hundreds of iterations to converge my Dyson equations. I am hoping to do this for two fermion flavours, two spins, and with the form factor $V_k$. That would be infeasible currently. I could make several 2x2 matrix Green's functions for each step, but perhaps there is a more memory efficient manner? Perhaps if you were able to add indices explicitly as input? For example, I do not need any diagonal elements of my (at worst-case) 8x8 Green's function susceptibility.

If I'm misunderstanding or not making things clear let me know and I'll try to elaborate.

@HugoStrand
Copy link
Member

Dear Andrew,

I am sorry for the silence. The product you want to compute is a convolution in frequency and momentum, so in order to do it computationally efficient you would like to do the product in real space and imaginary time

$$\sum_{k,\nu} V_{k} G(k, \nu) G(k + q, \nu + \omega) \rightarrow V_r G(r, \tau) G(-r, -\tau)$$

This should give you $N log N$ scaling with respect to momentum and frequency.

You can compute the bubble part using,
https://triqs.github.io/tprf/latest/cpp2rst_generated/triqs_tprf/chi0_tr_from_grt_PH.html#triqs-tprf-chi0-tr-from-grt-ph

and the Green's function transform from momentum and frequency space can be done using

    g_wr = fourier_wk_to_wr(g_wk)
    g_tr = fourier_wr_to_tr(g_wr)

If you add the $V_r$ multiplication to the $GG$ bubble calculator steps, see
https://github.com/TRIQS/tprf/blob/3.3.x/python/triqs_tprf/lattice_utils.py#L191
it should give you the desired result.

Best, Hugo

@andrewkhardy
Copy link
Author

andrewkhardy commented Oct 3, 2024

Dear Hugo,

Thank you for your response. The logic you discussed I believe is exactly the logic used in imtime_bubble_chi0_wk. This makes sense to me. Currently however, the only way I see to add the $V_r$ multiplication however is embedding in the matrix as discussed above, so I still believe the PR which would allow a specific bubble $G_A * G_B$ would be useful as it saves time by not having to construct this new Frankenstein'd GF block. Adding a function that allows chi0_tr_from_grt_PH to take two inputs was exactly what the PR hopefully accomplishes.

@HugoStrand
Copy link
Member

Dear Andrew,

I disagree, you can make the $V(r)$ product with the bubble, i.e.

g_wr = fourier_wk_to_wr(g_wk)
g_tr = fourier_wr_to_tr(g_wr)
gg_tr = chi0_tr_from_grt_PH(g_tr)
ggV_tr = gg_tr.copy()
ggV_tr.data[:] = gg_tr.data[:] * V_r.data[:][None, :, ...]
ggV_wr = chi_wr_from_chi_tr(ggV_tr, nw=nw)
ggV_wk = chi_wk_from_chi_wr(ggV_wr)

This does the multiplication of V after taking the product with two Green's functions.

Do you think this would be a solution for you?

Best, Hugo

@andrewkhardy
Copy link
Author

andrewkhardy commented Oct 3, 2024

Dear Hugo, ah! Now I understand, thank you very much for writing that out more explicitly for me. Yes this will work. I do have use cases where I want different G's that come from genuinely different lattices, but I'll wait on the PR request for that more general case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants