Interact Exercise 6

Imports

Put the standard imports for Matplotlib, Numpy and the IPython widgets in the following cell.


In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np

In [2]:
from IPython.display import Image
from IPython.html.widgets import interact, interactive, fixed


:0: FutureWarning: IPython widgets are experimental and may change in the future.

Exploring the Fermi distribution

In quantum statistics, the Fermi-Dirac distribution is related to the probability that a particle will be in a quantum state with energy $\epsilon$. The equation for the distribution $F(\epsilon)$ is:


In [3]:
Image('fermidist.png')


Out[3]:

In this equation:

  • $\epsilon$ is the single particle energy.
  • $\mu$ is the chemical potential, which is related to the total number of particles.
  • $k$ is the Boltzmann constant.
  • $T$ is the temperature in Kelvin.

In the cell below, typeset this equation using LaTeX:

\begin{equation*} F(\epsilon) = -\frac{1}{e^{\frac{\epsilon-\mu}{kT}} + 1} \end{equation*}

Define a function fermidist(energy, mu, kT) that computes the distribution function for a given value of energy, chemical potential mu and temperature kT. Note here, kT is a single variable with units of energy. Make sure your function works with an array and don't use any for or while loops in your code.


In [51]:
def fermidist(energy, mu, kT):
    """Compute the Fermi distribution at energy, mu and kT."""
    F = (-1) / ((np.exp((energy - mu) / (kT))) + 1)
    return F

In [52]:
assert np.allclose(fermidist(0.5, 1.0, 10.0), 0.51249739648421033)
assert np.allclose(fermidist(np.linspace(0.0,1.0,10), 1.0, 10.0),
    np.array([ 0.52497919,  0.5222076 ,  0.51943465,  0.5166605 ,  0.51388532,
               0.51110928,  0.50833256,  0.50555533,  0.50277775,  0.5       ]))


---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-52-6de4cc798fa3> in <module>()
----> 1 assert np.allclose(fermidist(0.5, 1.0, 10.0), 0.51249739648421033)
      2 assert np.allclose(fermidist(np.linspace(0.0,1.0,10), 1.0, 10.0),
      3     np.array([ 0.52497919,  0.5222076 ,  0.51943465,  0.5166605 ,  0.51388532,
      4                0.51110928,  0.50833256,  0.50555533,  0.50277775,  0.5       ]))

AssertionError: 

Write a function plot_fermidist(mu, kT) that plots the Fermi distribution $F(\epsilon)$ as a function of $\epsilon$ as a line plot for the parameters mu and kT.

  • Use enegies over the range $[0,10.0]$ and a suitable number of points.
  • Choose an appropriate x and y limit for your visualization.
  • Label your x and y axis and the overall visualization.
  • Customize your plot in 3 other ways to make it effective and beautiful.

In [53]:
def plot_fermidist(mu, kT):
    energy = np.linspace(0, 10, 100)
    plt.figure(figsize=(15,5))
    plt.plot(energy, fermidist(energy, mu, kT))
    plt.grid(True)
    plt.xlabel('Particle Energy')
    plt.ylabel('Fermi-Dirac Distribution')
    plt.xticks([0, 2, 4, 6, 8, 10], ['0', '2$\epsilon$', '4$\epsilon$', '6$\epsilon$', '8$\epsilon$', '10$\epsilon$'])
    plt.ylim(-1,1)

In [54]:
plot_fermidist(4.0, 1.0)



In [55]:
assert True # leave this for grading the plot_fermidist function

Use interact with plot_fermidist to explore the distribution:

  • For mu use a floating point slider over the range $[0.0,5.0]$.
  • for kT use a floating point slider over the range $[0.1,10.0]$.

In [56]:
interact(plot_fermidist, mu = (0.0, 5.0, 0.5), kT = (0.1, 10.0, 0.1))


Provide complete sentence answers to the following questions in the cell below:

  • What happens when the temperature $kT$ is low?
  • What happens when the temperature $kT$ is high?
  • What is the effect of changing the chemical potential $\mu$?
  • The number of particles in the system are related to the area under this curve. How does the chemical potential affect the number of particles.

Use LaTeX to typeset any mathematical symbols in your answer.

1) When kT is very low, the lefthand side of the graph is extremely flat and close to the bottom, while the righthand side of the graph is extremely flat and close to the top of the graph. They are joined by an extremely steep increase of the graph that occurs over a very small interval of energy. The smaller $\mu$ is, the farther left this steep increase is. The larger $\mu$ is, the farther to the right of the graph this steep increase is.

2) When $kT$ is high, the graph becomes nearly linear.

3) Changing $\mu$ when $kT$ is low changes where the sudden steep increase is. Changing $\mu$ when $kT$ is high makes the graph move up and down slightly, but does not have any consistent change on the graph.

4) Again, the impact of $\mu$ really depends how high or low $kT$ is. If $kT$ is high, changing $\mu$ doesn't seem to have a consistent change on the number of particles. However if $kT$ is very low, increasing $\mu$ clearly decreases the number of particles, while increasing $\mu$ clearly increases the number of particles.