I'm trying to draw a plot of the Fermi-Dirac distribution,
for which I'd like to show a few lines of varied temperate (T). My code works for this, except for zero temperature, it results in a Dimension too large
error from pgfplots. Is there a way to resolve this while keeping the real value of the Boltzman constant, k_B
, in electron volts?
MWE:
\documentclass[tikz,border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=$\frac{mv^2}{2k_BT}$ (eV),
ylabel=$f(n)$,
legend entries={0 K,100 K,1000 K,10000 K},
x tick style={color=black},
y tick style={color=black},
xtick pos=left,
ytick pos=left,
xmin=-3,
xmax=3,
ymin=-0.1,
ymax=1.1
]
\addplot[samples=50,black] {(1/((exp((x)/(80.617e-5))+1))};
\addplot[samples=50,blue,dashed] {(1/((exp((x)/(8.617e-3))+1))};
\addplot[samples=50,red,dashed] {(1/((exp((x)/(8.617e-2))+1))};
\addplot[samples=50,green,dashed] {(1/((exp((x)/(8.617e-1))+1))};
\end{axis}
\end{tikzpicture}
\end{document}
This code compiles but 80.617e-5
should be 8.617e-5
which breaks the code. I've tried varying/removing xmin
, xmax
with no success. I also read in a few answers something to do with fpu
but this didn't seem to work for me or is no longer required? restrict x to domain
did not seem to help, though I could be using it wrong.