I'm wishing you a nice day and here is my problem:
I tried to obtain relation between chemical potential and temperature in a semiconductor and I arrived at this equation:
$$ 2 e^{-\Delta/kT} \left( \frac{m_c^* kT}{2 \pi \hbar^2} \right)^{3/2} \alpha = 2 \left( \frac{m_v^* kT}{2 \pi \hbar^2} \right)^{3/2} \frac{1}{\alpha} + \frac{N_D}{1+2e^{-\varepsilon_D/kT} \alpha} $$ where: $$ e^{\mu/kT} \equiv \alpha $$
So basically, Mathematica's task would be to solve this equation with respect to $\alpha$, for a given set of numerical parameters $\Delta, k, m_c^*, m_v^*, \hbar$ and $\varepsilon_D$ find positive real solution and plot a function $\mu = kT \log \alpha$ as a function of $T > 0$. As it seems, the equation is of the third order, so it is solvable in a closed-form. I obtained those solutions:
$$ s = Solve[2 e^{-\Delta/kT} \left( \frac{mc kT}{2 \pi \hbar^2} \right)^{3/2} \alpha == 2 \left( \frac{mv kT}{2 \pi \hbar^2} \right)^{3/2} \frac{1}{\alpha} + \frac{N_D}{1+2e^{-\varepsilon d/kT} \alpha},\alpha] $$ Mathematica code:
eq = 2 E^(-delta/(k T))((mc k T)/(2 Pi hbar^2))^(3/2) alpha == 2 ((mc k T)/(2 Pi hbar^2))^(3/2) (1/alpha) + Nd/(1 + 2 E^(-epsilond/(k T)) alpha);
s = Solve[eq, alpha]
I got three solutions, $\alpha /.s[[1]]$, $\alpha /.s[[2]]$ and $\alpha /.s[[3]]$. I plotted each of them as a function of temperature to see which one is real and positive. It seemed, that $\alpha /.s[[2]]$ is the candidate, so I tried to plot (with some realistic constants):
$$ Plot[Re[(k T Log[\alpha /. s[[2]]])/. \left\{\Delta -> \frac{114}{100}, k -> 1, mc -> \frac{2}{10} \frac{910938291}{100000000} 10^{-31}, mv -> \frac{2}{10} \frac{910938291}{100000000} 10^{-31}, Nd -> 10^{21}, \hbar-> \frac{105457173}{100000000} 10^{-34}, \varepsilon d -> \frac{109}{100} \right\}],{T,0,1/10}] $$ ($T, \Delta, \varepsilon d$ and $\mu$ itself are in electronvolts, so mathematica does not have to deal with too large or too small numbers)
Code:
Plot[Re[(k T Log[alpha /. s[[2]]])/. {delta -> 114/100, k -> 1,
mc -> (2/10)(910938291/100000000) 10^-31,
mv -> (2/10)(910938291/100000000) 10^-31,
Nd -> 10^21, hbar-> 105457173/100000000 10^-34, epsilond ->
109/100}],{T,0,1/10}]
So at first it replaces all constants with their numerical values except the temperature and then it tries to plot that. Even the result has to be real, I had to add Re[] to overcome issue with non-zero imaginary part and the result is quite strange. It looks promising, I think the function does what chemical potential would do, it goes from $\varepsilon d$ at $T = 0$ down to $\Delta/2$ at higher temperatures, but there are strange spikes all over the region for $T < 0.03$. It is very strange, because the solution is obtained analytically via Solve, and the function has no reason to behave like that (those are not a high oscillation spikes, it's rather a numerical artefact).
Then I tried to run ContourPlot on the first equation and I got the same spiky result.
Next thing I tried was to create a list of values of $\mu$ for $0 < T < 0.04$ to see where exactly does the oscillation occur:
$$ Table[Re[(k T Log[\alpha /. s[[2]]])/. \left\{\Delta -> \frac{114}{100}, k -> 1, mc -> \frac{2}{10} \frac{910938291}{100000000} 10^{-31}, mv -> \frac{2}{10} \frac{910938291}{100000000} 10^{-31}, Nd -> 10^{21}, \hbar-> \frac{105457173}{100000000} 10^{-34}, \varepsilon d -> \frac{109}{100}, T -> i \right\}],{i,0.001,0.04,0.001}] $$
Code:
Table[Re[(k T Log[alpha /. s[[2]]])/. {delta -> 114/100, k -> 1,
mc -> (2/10)(910938291/100000000) 10^-31,
mv -> (2/10)(910938291/100000000) 10^-31,
Nd -> 10^21, hbar-> 105457173/100000000 10^-34, epsilond ->
109/100, T -> i }],{i,0.001,0.04,0.001}]
...and I'm left with:
{1.07225, 1.01546, 1.03827, 0.937135, 1.00205, 0.984445, 0.950138, 0.927387, 0.931658, 0.910465, 0.892761, 0.87479, 0.856831, 0.809198, 0.820963, 0.771908, 0.755787, 0.767006, 0.711472, 0.724181, 0.706065, 0.687321, 0.626185, 0.651721, 0.633072, 0.614729, 0.597576, 0.569833, 0.560556, 0.572135, 0.569195, 0.570001, 0.569994, 0.570001, 0.569991, 0.569992, 0.570002, 0.57, 0.57, 0.57}
You can clearly see the oscillations, which is strange, and in fact, creating list with finer step and then ListPlotting this with respect to the same list with $T$ in same range and step results into a similar spiky mess I obtained before. It does not matter how fine I choose the step, always more spikes show up, which in my opinion means, that this is a numerical issue, not a feature of a closed-form solution.
My question is: how should I attack this problem (which is actually solvable in closed-form, but I won't resist a numerical solution)? How can I get a smooth plottable solution for $\mu$ which I can use further both analytically and/or numerically?
Thank you in advance.
{}
button above the edit window. (Inline code is placed between backticks; code blocks are indented four spaces.) The edit window help button?
is also useful for learning how to format your questions and answers. -- The code in your comment is missing the backslashes to the Greek letter names. Please add the code to your question by editing it. $\endgroup$