Put the standard imports for Matplotlib, Numpy and the IPython widgets in the following cell.
In [29]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import math as m
In [30]:
from IPython.display import Image
from IPython.html.widgets import interact, interactive, fixed
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 [31]:
Image('fermidist.png')
Out[31]:
In [32]:
%% html
<equation>
F($epsilon$)=$1/(e^(($epsilon$ -$mu$)/kT)-1)
</equation>
In this equation:
In the cell below, typeset this equation using LaTeX:
YOUR ANSWER HERE
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 [84]:
def fermidist(energy, mu, kT):
"""Compute the Fermi distribution at energy, mu and kT."""
# YOUR CODE HERE
a = np.array(energy - mu)
b = np.array(a/kT)
c = np.array(m.exp(b))
d = np.array(c+1)
f = np.array(1/d)
return f
In [85]:
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 ]))
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
.
In [67]:
def plot_fermidist(mu, kT):
# YOUR CODE HERE
a = np.array(mu)
b = np.array(kT)
plt.scatter(a, b)
plt.ylabel('Temperature')
plt.xlabel('Chemical Potential')
In [68]:
plot_fermidist(4.0, 1.0)
In [50]:
assert True # leave this for grading the plot_fermidist function
Use interact
with plot_fermidist
to explore the distribution:
mu
use a floating point slider over the range $[0.0,5.0]$.kT
use a floating point slider over the range $[0.1,10.0]$.
In [69]:
# YOUR CODE HERE
w = interactive(plot_fermidist, mu =(0.0,5.0,0.1), kT=(0.1,10.0,0.1));
In [70]:
w
Provide complete sentence answers to the following questions in the cell below:
Use LaTeX to typeset any mathematical symbols in your answer.
YOUR ANSWER HERE
In [ ]:
When kT is low then energy is high and when kT is high then energy is low.
Lowering the chemical potential would result in a higher energy and raising the chemical potental would result in a lower energy.
A smaller area would result in less particls