Just as has been mentioned in comments already (by @Hristo Iliev and @Pavel Annosov), quad
returns a tuple of stuff. If you're assuming the integration has no problems, as you seem to be doing in Mathematica (which is not that good of an idea though), out of this tuple you only need the first element, which is supposed to be the integration result.
But this will only give you a single number, not a function of T
. To get the latter, you'll need to define the corresponding function yourself, just like you did in Mathematica with your \Delta[T_]:=...
Here are a few bits to get you started:
def f(E, T):
"""To be integrated over T."""
temp = np.sqrt(E * E + T * T)
return np.tanh(1477.92 * temp) / temp
def gap(T):
"""Integration result: \Delta(T)"""
return quad(f, 0, 1, args=(T, ))[0] #NB: [0] select the 1st element of a tuple
Notice that you need to use the args=(T,)
syntax to send the T
parameter to the function being integrated: quad
integrates over the first argument of the function, and it needs other arguments to be able to evaluate f(E, T)
.
Now you can feed this gap(T)
to fsolve
, which also expects a function (a callable
, to be more precise).
On a slightly more general level, you should not be using numerical values of the Boltzmann constant, hbar and the like (even Mathematica complains!). What you should do instead, you should write your formulas in the dimensionless form: measure temperature in energy units (hence k_B = 1) etc, do appropriate substitutions in the integrals, so that you deal with dimensionless functions of dimensionless arguments --- and then make a computer handle those.