Science, Data, Tools

or 'Tips and tricks for a your everyday workflow'

Matteo Guzzo

Prologue

AKA My Research

The cumulant expansion

The struggle has been too long, but we are starting to see the light...

As you might recall...

We are trying to go beyond the GW approximation

and succeed in describing satellites.

The spectral function

It looks like this: \begin{equation} A(\omega) = \mathrm{Im}|G(\omega)| \end{equation}

GW vs Cumulant

Mathematically very different:

\begin{equation} G^{GW} (\omega) = \frac1{ \omega - \epsilon - \Sigma (\omega) } \end{equation}
\begin{equation} G^C(t_1, t_2) = G^0(t_1, t_2) e^{ i \int_{t_1}^{t_2} \int_{t'}^{t_2} dt' dt'' W (t', t'') } \end{equation}

BUT they connect through $\mathrm{Im} W (\omega) = \frac1\pi \mathrm{Im} \Sigma ( \epsilon - \omega )$.

Guzzo et al., Phys. Rev. Lett. 107, 166401, 2011

Implementation

Using a multi-pole representation for $\Sigma^{GW}$:

\begin{equation} \mathrm{Im} W (\omega) = \frac1\pi \mathrm{Im} \Sigma ( \epsilon - \omega ) \end{equation}\begin{equation} W (\tau) = - i \lambda \bigl[ e^{ i \omega_p \tau } \theta ( - \tau ) + e^{ - i \omega_p \tau } \theta ( \tau ) \bigr] \end{equation}

GW vs Cumulant

  • GW:
\begin{equation} A(\omega) = \frac1\pi \frac{\mathrm{Im}\Sigma (\omega)} { [ \omega - \epsilon - \mathrm{Re}\Sigma (\omega) ]^2 + [ \mathrm{Im}\Sigma (\omega) ]^2} \end{equation}
  • Cumulant (plasmon-pole):
\begin{equation} A(\omega) = \frac1\pi \sum_{n=0}^{\infty} \frac{a^n}{n!} \frac{\Gamma}{ (\omega - \epsilon + n \omega_p)^2 + \Gamma^2 } \end{equation}

Problems


\begin{equation} A(\omega) = \frac1\pi \sum_{n=0}^{\infty} \frac{a^n}{n!} \frac{\Gamma}{ (\omega - \epsilon + n \omega_p)^2 + \Gamma^2 } \end{equation}

Alternative: full numerical

With $ t = t_2 - t_1 $:

\begin{equation} G^C (t) = G^0(t) e^{ i \int d\omega \frac{W (\omega)} {\omega^2} \left( e^{i \omega t} -i \omega t - 1 \right) } \end{equation}


Kas et al., Phys. Rev. B 90, 085112, 2014

To be continued... --> https://github.com/teoguso/SF.git

Acknowledgements

Jiangqiang "Sky" Zhou - Ecole Polytechnique, France Matteo Gatti - Ecole Polytechnique, France Andris Gulans - HU Berlin

Let's talk about tools (My actual Outline)

How do you go about your everyday work?

What do you use to:

  • Write and maintain code
  • Review and analyse data
  • Present data and results

My answer

Time to take a breath

(Questions?)

Git

QUESTION: Who knows what Git is?

State of the art for distributed version control

Version control?

Git in a nutshell

Git in a nutshell

  • Very powerful (essential) for collaborative work (e.g. software, articles)

  • Very useful for personal work

Ok, but what should I use it for?

  • Source code
  • Scripts
  • Latex documents

In short:

Any text-based (ASCII) project

Fortran, Python, Latex, Bash, ...

Python + matplotlib


In [ ]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
with plt.xkcd():
    plt.rcParams['figure.figsize'] = (6., 4.)
    x = np.linspace(-5, 5, 50)
    gauss = np.exp(-(x**2) / 2)/np.sqrt(2 * np.pi)
    ax = plt.subplot(111)
    ax.plot(x, gauss, label="Best curve ever")
    cdf = np.array([np.trapz(gauss[:i], x[:i]) for i, _ in enumerate(gauss)])
    plt.plot(x, cdf, label="Bestest curve ever")
    plt.xlim(-3, 3)
    ax.set_xticks([])
    ax.set_yticks([])
    ax.spines['top'].set_visible(False)
    ax.spines['right'].set_visible(False)
    plt.xlabel('most exciting independent variable')
    plt.ylabel("I'm not trolling")
    plt.legend(loc='best')
    plt.annotate("I CAN ALSO\n DO MATH:\n"+
                 "      "+
                 r"$\frac{e^{-\frac{x^2}{2}}}{\sqrt{2\pi}}$", 
        xy=(0.1, 0.4), arrowprops=dict(arrowstyle='->'), xytext=(2, 0.6))
    fname = "./graphics/xkcd1.png"
    plt.savefig(fname, dpi=300)

In [1]:
"""
Simple demo of a scatter plot.
"""
# import numpy as np
# import matplotlib.pyplot as plt


N = 50
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = np.pi * (15 * np.random.rand(N))**2  # 0 to 15 point radiuses

plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.savefig("./graphics/scatter_demo.png", dpi=200)


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-b166694b40ab> in <module>()
      7 
      8 N = 50
----> 9 x = np.random.rand(N)
     10 y = np.random.rand(N)
     11 colors = np.random.rand(N)

NameError: name 'np' is not defined

In [8]:
"""
This shows an example of the "fivethirtyeight" styling, which
tries to replicate the styles from FiveThirtyEight.com.
"""


from matplotlib import pyplot as plt
import numpy as np

x = np.linspace(0, 10)

with plt.style.context('fivethirtyeight'):
    plt.plot(x, np.sin(x) + x + np.random.randn(50))
    plt.plot(x, np.sin(x) + 0.5 * x + np.random.randn(50))
    plt.plot(x, np.sin(x) + 2 * x + np.random.randn(50))
    
plt.savefig("./graphics/fivethirtyeight_demo.png", dpi=200)


Jupyter notebooks

www.jupyter.org

Jupyter what?

  • Interactive scientific computing environment

    • Data analysis and visualization
    • Interactive reports
    • Parallel computing!
  • Originated from the IPython project in 2014
  • Now supports a number of languages (Python, BASH, ...)

Jupyter notebooks

  • Interactive documents that combine

    • Executable code

    • Rich-text elements (Markdown + HTML)

  • They are text-based (Git anyone?)

More cool stuff

LaTex support and syntax highlighting

Write

\begin{equation}
 \Sigma (\omega) = \int \, d\omega' ...
\end{equation}

and get \begin{equation} \Sigma (\omega) = \int \, d\omega' ... \end{equation}

TO DEMO OR NOT TO DEMO?

Also remember to convert to pdf!

Conclusion

  • Git: an essential tool for any workflow
    • tracking of personal work
    • easy collaborative work
  • Jupyter - Great for:

    • Data analysis

    • Reports

    • (Works best with Python)

Resources

Bonus clip

How do you think these slides were made?

See it at https://github.com/teoguso/sol_1116