## SFINAE vs Concept

A brief introductory example may be found in Concepts versus SFINAE-based constraints.

#### A Toxic Example

##### Universal Reference is Too Greedy

Universal reference is the terminology in Modern Effect C++, which basically refer to T&& in template functions.

The following code should be short and clear enough.

#include <iostream>

class Person
{ };

class SpecialPerson: public Person
{ };

template<typename T>
void handle(T&& person)
{
std::cout << "Handle person." << std::endl;
}

void handle(int number)
{
std::cout << "Handle number." << std::endl;
}

int main()
{
Person p;
SpecialPerson sp;
int i = 0;
short s = 0;
handle(p);
handle(sp);
handle(i);
handle(s);
}


The behavior is, however, puzzling. It prints

Handle person.
Handle person.
Handle number.
Handle person.


Why did the last line print Handle person.? This is because handle(int) requires a conversion in this case while in handle(T&&) the compiler could infer T = short and provide a perfect match.

We may resort to the C++98 approach and declare handle like the following.

void handle(const Person &);
void handle(int);


However, what if we want to retain perfect forwarding? In such case universal reference is inevitable. The problem may be rephrased as follow: const Person& and Person&& are too restrictive as they matches only lvalue or rvalue reference. T&& is too generic as it matches reference to any type. We need something somewhere between.

##### Detour: How Do C# Handle Such Problem

A simlar problem exists in C#.

using System;

class Person
{ }

class SpecialPerson: Person
{ }

public class Program
{
private static void handle<T>(T person)
{
Console.WriteLine("Handle person.");
}

private static void handle(int number)
{
Console.WriteLine("Handle number.");
}

public static void Main()
{
Person p = new Person();
SpecialPerson sp = new SpecialPerson();
int i = 0;
short s = 0;
handle(p);
handle(sp);
handle(i);
handle(s);
}
}


The above code prints the following.

Handle person.
Handle person.
Handle number.
Handle person.


What surprises us is the last line, where

short s = 0;
handle(s);


prints

Handle person.


Handle number.


Imposing constraints on handle solves the problem.

This code is tested with C#6.0. Compilation may fail with older versions.

using System;

class Person
{ }

class SpecialPerson: Person
{ }

public class Program
{
private static void handle<T>(T person) where T: Person
{
Console.WriteLine("Handle person.");
}

private static void handle(int number)
{
Console.WriteLine("Handle number.");
}

public static void Main()
{
Person p = new Person();
SpecialPerson sp = new SpecialPerson();
int i = 0;
short s = 0;
handle(p);
handle(sp);
handle(i);
handle(s);
}
}


Now the program correctly prints

Handle person.
Handle person.
Handle number.
Handle number.


Question: What is the counterpart of where in C++?

#### Solution: SFINAE vs Concept

##### The SFINAE Solution

SFINAE stands for substitution failure is not an error. In this case, we make use of std::enable_if and implement handle in the following way.

#include <iostream>

class Person
{ };

class SpecialPerson: public Person
{ };

template<typename T,
typename = std::enable_if_t<
std::is_base_of_v<Person, std::decay_t<T>>
>
>
void handle(T&& person)
{
std::cout << "Handle person." << std::endl;
}

void handle(int number)
{
std::cout << "Handle number." << std::endl;
}

int main()
{
Person p;
SpecialPerson sp;
int i = 0;
short s = 0;
handle(p);
handle(sp);
handle(i);
handle(s);
}


It works correctly now and prints

Handle person.
Handle person.
Handle number.
Handle number.

##### The Concept Solution

Concept is introduced in C++20 and enables the following more straightforward implementation closer to where in C#.

#include <iostream>
#include <concepts>

class Person
{ };

class SpecialPerson: public Person
{ };

template<typename T> requires std::derived_from<std::decay_t<T>, Person>
void handle(T&& person)
{
std::cout << "Handle person." << std::endl;
}

void handle(int number)
{
std::cout << "Handle number." << std::endl;
}

int main()
{
Person p;
SpecialPerson sp;
int i = 0;
short s = 0;
handle(p);
handle(sp);
handle(i);
handle(s);
}


It works also correctly now and prints

Handle person.
Handle person.
Handle number.
Handle number.


Expand

2021/12/31 14:37:48

0%
0%
0%
0%

## Green's Functions (I)

Definitions and Diagrams

This post is not aiming at giving a systematic introduction to Green's functions in condensed matter physics. Rather, it is written in a spaghetti pattern that intertwines many related or unrelated materials. For a systematic approach, see my note on quantum field theory.

#### Motivation: Why Do We Need Green's Function

##### The Zero-Temperature Case

In condensed matter physics, it's a common task for us to evaluate the expectation value of a certain operator (for the ground state) \begin{align*} \langle \mathscr{J}(\vb{x}) \rangle &= \frac{\bra{\Omega} \mathscr{J}(\vb{x}) \ket{\Omega}}{\bra{\Omega}\ket{\Omega}} \\ &= \pm i \lim_{t\rightarrow t^+} \lim_{\vb{x}' \rightarrow \vb{x}} \sum_{\alpha\beta} J_{\beta\alpha}(\vb{x}) G_{\alpha\beta}(\vb{x}t, \vb{x}'t') \\ &= \pm i \lim_{t\rightarrow t^+} \lim_{\vb{x}' \rightarrow \vb{x}} \tr[J(\vb{x}) G(\vb{x}t,\vb{x}'t')]. \end{align*} for $\mathscr{J}(\vb{x}) = \sum_{\alpha\beta} \psi_\beta^\dagger(\vb{x})J_{\beta\alpha}(x) \psi_\alpha(\vb{x})$ where we have defined the Green's function $iG_{\alpha\beta}(\vb{x}t;\vb{x'}t') = \frac{\bra{\Omega} T[\psi_\alpha(\vb{x}t) \psi^\dagger_\beta(\vb{x}'t')]\ket{\Omega}}{\bra{\Omega}\ket{\Omega}}.$

A few remarks are in order here:

• The field operators are complete in principle: all the observables could be constructed from field operators.
• If the Hamiltonian is time-independent, the Green's function depends only on $$(t-t')$$. After taking the limit $$t\rightarrow t'$$ it doesn't matter at which $$t$$ we evaluate the Green's function.
• The limit $$\vb{x}'\rightarrow \vb{x}$$ should act before $$J_{\alpha\beta}(\vb{x})$$ since $$J$$ may contain gradient.
• The number density is given by $n_{\alpha\beta}(\vb{x}) = \pm i \tr G(\vb{x}t; \vb{x}t^+).$
• The spin density is given by $\langle \vb*{\sigma}(\vb{x}) \rangle = \pm i \tr[\vb*{\sigma} G(\vb{xt;\vb{x}t^+})].$

Surprisingly, we don't need the four-point function in order to evaluated the interaction term. After some calculation we find for $V(\vb{x},\vb{x}')_{\alpha\alpha',\beta\beta'} = V(\vb{x}',\vb{x})_{\beta\beta',\alpha\alpha'}.$ that $\langle H \rangle = \pm \frac{1}{2}i \int \dd{^3 x} \lim_{t'\rightarrow t^+}\lim_{\vb{x}' \rightarrow \vb{x}} \qty[i\hbar \pdv{}{t} - \frac{\hbar^2 \grad^2}{2m}] \tr G(\vb{x}t; \vb{x'}t').$

Useful, right? Now the question becomes how do we evaluate Green's functions. Before we open the Pandora's box of Feynman diagrams, let's see how do we handle the case of finite-temperature.

##### The Finite-Temperature Case

At non-zero temperature, we have the similar result \begin{align*} \langle J \rangle &= \Tr(\rho_G J) \\ &= \mp \sum_{\alpha\beta} \int \dd{^3 x} \lim_{\vb{x}'\rightarrow\vb{x}} \lim_{\tau'\rightarrow\tau^+} J_{\beta\alpha}(x) \mathscr{G}_{\alpha\beta}(\vb{x}\tau; \vb{x}'\tau') \\ &= \mp \int \dd{^3 x} \lim_{\vb{x}' \rightarrow \vb{x}} \lim_{\tau'\rightarrow \tau^+} \tr[J(x)\mathscr{G}(\vb{x}\tau; \vb{x}'\tau')], \end{align*} where we have defined the Matsubara Green's function $\mathscr{G}_{\alpha\beta}(\vb{x}\tau;\vb{x}'\tau') = -\Tr[\rho_G T_\tau[\psi_{\alpha}(\vb{x}\tau) \psi^\dagger_{\beta}(\vb{x}'\tau')]],$ the modified Heisenberg picture (i.e. $$\tau = it$$) \begin{align*} \psi_{\alpha}(\vb{x}\tau) &= e^{K\tau/\hbar} \psi_\alpha(\vb{x}) e^{-K\tau/\hbar}, \\ \psi_{\alpha}^\dagger(\vb{x}\tau) &= e^{K\tau/\hbar} \psi_\alpha^\dagger(\vb{x}) e^{-K\tau/\hbar}, \end{align*} and the statistical properties \begin{align*} K &= H - \mu N, \\ Z_G &= e^{-\beta\Omega} = \Tr e^{-\beta K}, \\ \rho_G &= Z^{-1}_G e^{-\beta K} = e^{\beta(\Omega - K)}. \end{align*}

#### Example: Degenerate Electron Gas

With average density $$\langle n \rangle = N/V$$ fixed, the expectation value of interation energy is given by $\langle V \rangle = \frac{1}{2} \int \dd{^3 x} \int \dd{^3 x'} V(\vb{x} - \vb{x}')[\langle \tilde{n}(\vb{x}) \tilde{n}(\vb{x}') \rangle + \langle n(\vb{x})\rangle \langle n(\vb{x}) \rangle - \delta(\vb{x} - \vb{x}')\langle n(\vb{x}) \rangle].$ where we have defined $$\tilde{n}(\vb{x}) = n(\vb{x}) - \langle n(\vb{x})\rangle$$. The last two terms are essentially constants and may therefore be discarded. Now our goal becomes evaluating the polarization propagator (or the four-point function) $iD(x, x') = \frac{\bra{\Omega} T[\tilde{n}_H(x') \tilde{n}_H(x)] \ket{\Omega}}{\bra{\Omega} \ket{\Omega}}.$ Its non-interacting counterpart is defined by $iD^0(x',x) = \bra{0} T[\tilde{n}_I(x')\tilde{n}_I(x)] \ket{0}.$ Now the expectation value $$\langle V \rangle$$ could be divided into the non-interacting contribution and the interating contribution \begin{align*} \langle V \rangle &= \frac{1}{2} \int \dd{^3 x} \dd{^3 x'} V(\vb{x} - \vb{x}')[iD^0(\vb{x}'t, \vb{x}t) + n^2 - \delta(\vb{x} - \vb{x}')n] + \frac{1}{2}\int \dd{^3 x} \dd{^3 x'} V(\vb{x} - \vb{x}')[iD(\vb{x}'t, \vb{x}t) - iD^0(\vb{x}'t, \vb{x}t)] \\ &= \bra{\Phi_0} V \ket{\Phi_0} + \frac{1}{2}\int \dd{^3 x} \dd{^3 x'} V(\vb{x} - \vb{x}')[iD(\vb{x}'t, \vb{x}t) - iD^0(\vb{x}'t, \vb{x}t)]. \end{align*}

Expand

2021/12/23 21:57:01

0%
0%
0%
0%

## Category Theory

#### Definition and Examples

• A category $$C$$ consists of the following.
• A class $$\operatorname{ob} C$$ of objects.
• For each ordered pair of objects $$(A,B)$$, a set of $$\mathrm{hom}_{C}(A,B)$$ whose elements are called morphisms with domain $$A$$ and codomain $$B$$.
• For each ordered triple of objects $$(A,B,C)$$, a map $$(f,g)\mapsto gf$$ of the product set $$\mathrm{hom}(A,B) \times \mathrm{hom}(B,C)$$ into $$\mathrm{hom}(A,C)$$.
• The objects and morphisms satisfy the following conditions:
• If $$(A,B) \neq (C,D)$$, then $$\mathrm{hom}(A,B)$$ and $$\mathrm{hom}(C,D)$$ are disjoint.
• If $$f\in\mathrm{hom}(A,B)$$, $$g\in\mathrm{hom}(B,C)$$ and $$h\in\mathrm{hom}(B,C)$$, then $$(hg)f = h(gf)$$.
• For every object $$A$$ we have an element $$\mathbb{1}_A\in \mathrm{hom}(A,A)$$ such that $$f\mathbb{1}_A = f$$ for every $$f\in \mathrm{hom}(A,B)$$ and $$\mathbb{1}_A g = g$$ for every $$g\in \mathrm{hom}(B,A)$$.
• A category $$D$$ is called a subcategory of $$C$$ if
• $$\operatorname{ob} C$$ is a subclass of $$\operatorname{ob}D$$ and
• for any $$A,B\in \operatorname{ob} D$$, $$\mathrm{hom}_D(A,B) \subset \mathrm{hom}_C(A,B)$$.
• $$\mathbb{1}_A$$ is defined in the same way as in $$D$$.
• A subcategory $$D$$ is called full if for every $$A,B\in D$$ $\mathrm{hom}_D(A,B) = \mathrm{hom}_C(A,B).$

Monoids are identified with categories whose object classes are single-element sets.

• A category $$C$$ is called small if $$\operatorname{ob} C$$ is a set.
• An element $$f\in \mathrm{hom}(A,B)$$ is called an isomorphism if there exists a $$g\in \mathrm{hom}(B,A)$$ such that $$fg = \mathbb{1}_B$$ and $$gf = \mathbb{1}_A$$.
• $$g$$ is uniquely defined by $$f$$ and is denoted $$f^{-1}$$.
• $$(f^{-1})^{-1} = f$$.
• If $$f$$ and $$h$$ are isomorphisms, and $$fh$$ is defined, then $$fh$$ is also an isomorphism.

Groups are identifies with categories whose object classes are single-element sets and all morphisms are isomorphisms. A groupoid is a small category in which morphisms are isomorphisms.

• The dual category $$C^{\mathrm{op}}$$ of $$C$$ is defined by
• $$\operatorname{ob} C^{\mathrm{op}} = \operatorname{ob} C$$.
• $$\mathrm{hom}_{C^{\mathrm{op}}}(A,B) = \mathrm{hom}_{C}(B,A)$$.
• Composition $$gf$$ in $$C^{\mathrm{op}}$$ is defined by $$fg$$ in $$C$$.
• $$\mathbb{1}_A$$ as in $$C$$.
• The product category $$C\times D$$ is defined by
• $$\operatorname{ob} C\times D = \operatorname{ob}C \times \operatorname{ob} D$$.
• $$\mathrm{hom}_{C\times D}((A,A'),(B,B')) = \mathrm{hom}_{C}(A,B)\times \mathrm{hom}_{C}(A',B')$$.
• Composition defined component-wise.
• $$\mathbb{1}_{(A,A')}$$ defined component-wise.

Expand

2021/12/21 14:03:46

0%
0%
0%
0%

## LnOPnCh₂ Series

#### Structure

• LnO layer + PnCh₂ layer.
• Usually P4 symmetry.

#### Previous Work

##### LaOBiS₂
• Thermoelectric $$\ce{LaO_{1-x}F_{x}BiS2}{}$$ (Omachi2014).
• Thermoelectric $$\ce{LaOBiS_{2-x}Se_x}{}$$ (Mizuguchi2014)(Nishida2015).
• $$\kappa \sim 1 \mathrm{W}\cdot \mathrm{m}^{-1} \cdot \mathrm{K}^{-1}$$.
• $$zT\sim 0.36$$ at 370°C.
##### LnOSbSe₂
• Thermoelectric $$\ce{LaO_{1-x}F_xSbSe2}{}$$ and $$\ce{CeO_{1-x}F_xSbSe2}{}$$ (Goto2018).
• $$\ce{NdOSbS2}$$ is likely an insulator.

#### Calculation

• $$\ce{LnOAsSe2}{}$$, with predicted $$zT\sim 2$$ (Ochi2017), synthesis failed due to the stable phase $$\ce{Ln4O4Se3}{}$$ (Goto2018).
• $$\ce{NdOSbS2}$$, already synthesized (Tanryverdiev1996), large PF (Ochi2017).
• Designing principles: (Ochi2017)
• Small SOC;
• Small Bi-Bi and large Bi-S hopping amplitudes;
• Small on-site energy difference between the Bi-$$p_{x,y}{}$$ orbitals and S-$$p_{x,y}{}$$ orbitals.
• $$\Rightarrow$$ replacing Bi with lighter elements and S with heavier elements (putting them closer in the periodic table);
• Band structures of $$\ce{LnO_{1-x}F_x BiS2}{}$$ calculated (Morice2016).
• The change of rare earth does not affect the Fermi surface.
• Conduction electrons are confined to the BiS₂ planes.

#### Proposal

##### (Ce,Pr)OBiS₂
• Also replacing S with Se.
• Thermoelectric properties should be similar to that of LaOBiS₂.
##### NdOSbS₂
• Try to make it a semiconductor.
##### LnOAsSe₂
• Try to synthesize.

#### Miscellany

Expand

2021/11/10 21:17:47

0%
0%
0%
0%

## Quantum Transport

### Linear Response

#### Formulations

##### Kubo Formula
• System undergoes a perturbation $\hat{H}' = \hat{V}(t) \Theta(t-t_0).$
• Up to the first order, $\langle \hat{A}(t) \rangle = \langle \hat{A} \rangle_0 - i \int_{t_0}^t \dd{t'} \langle [ \hat{A}(t), \hat{V}(t') ] \rangle_0.$
##### Green-Kubo Relations
• Transport coefficient is given by $\gamma = \int_0^\infty \langle \dot{A}(0) \dot{A}(t) \rangle \dd{t}.$

### Mesoscopic Transport

#### Landauer Formula

• Ideal conductors (two terminals) $I = 2e \int_{\mu_2}^{\mu_1} v_k \dv{k}{\epsilon_k} \frac{\dd{\epsilon_k}}{2\pi} = \frac{2e}{h}(\mu_1 - \mu_2)$ and therefore $G = \frac{I}{V} = \frac{2e^2}{h}.$
• Inserting a mesoscopic conducting device with transmission coefficient $$T$$, we find the Büttiker formula $G = \frac{2e^2}{h}T.$ The conductivity of the device itself is given by the Landauer formula $G = \frac{2e^2}{h}\frac{T}{1-T}.$
• Büttiker formula $I_p = \sum_q G_{pq}(V_q - V_p).$

Expand

2021/10/29 17:35:29

0%
0%
0%
0%
0%
0%