Skip to main content

caroli_green/
decimation.rs

1//! Surface Green's function by decimation (Lopez Sancho, Lopez Sancho & Rubio, J. Phys. F 15,
2//! 851 (1985)).
3//!
4//! Needs a finite imaginary part of the energy and loses accuracy when the energy is close to an
5//! eigenvalue of the cell Hamiltonian (with `η = 1e-12`, `T` of a clean chain is wrong by 0.5 at
6//! `E = 1e-9`). Kept as an independent cross-check of [`crate::modes`].
7
8use crate::{GreenError, inverse, mul, resolvent_matrix};
9use caroli_model::{CMat, c64};
10
11/// Surface Green's function of a semi-infinite lead at complex energy `z`. `h00` is the cell
12/// Hamiltonian and `away` the coupling `⟨n| H |n+1⟩` from a cell to the next one further away
13/// from the surface.
14pub fn surface_green(h00: &CMat, away: &CMat, z: c64) -> Result<CMat, GreenError> {
15    const MAX_STEPS: usize = 200;
16    const TOL: f64 = 1e-14;
17    let mut alpha = away.clone();
18    let mut beta = away.adjoint().to_owned();
19    let mut eps_s = h00.clone();
20    let mut eps = h00.clone();
21    for _ in 0..MAX_STEPS {
22        let g = inverse(&resolvent_matrix(z, &eps));
23        let ag = mul(&alpha, &g);
24        let bg = mul(&beta, &g);
25        let agb = mul(&ag, &beta);
26        eps_s += &agb;
27        eps += &agb + mul(&bg, &alpha);
28        alpha = mul(&ag, &alpha);
29        beta = mul(&bg, &beta);
30        let scale = 1.0 + eps.norm_max();
31        if alpha.norm_max() < TOL * scale && beta.norm_max() < TOL * scale {
32            return Ok(inverse(&resolvent_matrix(z, &eps_s)));
33        }
34    }
35    Err(GreenError::NoConvergence(MAX_STEPS))
36}