Closed pablosanjose closed 6 months ago
I suspect the solution of moving parent into solver is not optimal. The reason is that some solvers, such as AppliedSchurGreenSolver
, gets called several times when computing a GreenSolution
or when doing call!(::SelfEnergy, ω; params...)
of the corresponding Green functions.
Rather, we could leave parent::AbstractHamiltonian
as a field of GreenFunction
and change minimal_callsafe_copy(::AppliedGreenSolver)
to minimal_callsafe_copy(::AppliedGreenSolver, parentham)
, to restore aliases. minimal_callsafe_copy(::SelfEnergySolver)
should also be modified to restore any internal aliases the solver has.
How does
call!(g::GreenFunction, ω; params...)
work?g
encloses aparent::AbstractHamiltonian
and asolver::AppliedGreenSolver
. Here,solver
was obtained withsolver = apply(s::AbstractGreenSolver, parent, contacts)
, so it is a closure overparent
. Hence, to callsolver
on someω
andparams
, we docall!(parent; params...)
that appliesparams...
and then we dosolver(ω, Σblocks, corbs)
to obtain aGreenSlicer
.There is a crucial flaw in this design: it relies on the closure being preserved. If we do
minimcal_callsafe_copy(g)
this makes a copy ofparent
and a copy ofsolver
. The closure relation is now broken, andcall!
gives wrong results silently.MWE:
One possible solution is to move
parent
intosolver
, and change api so that the GreenSlicer is obtained withsolver(ω, Σblocks, corbs; params...)