I'm trying to plot the cross section with respect to the photon energy $h\nu$ but for $\gamma = 1.0, 1.2, 2.0 $ in the same axes

$\sigma = \left[\left(\frac{\xi_{eff}}{\xi_{0}}\right)^2 \frac{n_r}{\varepsilon}\right]\frac{4\pi}{3}\alpha_{fs}h\nu|\frac{1}{2}\frac{R}{2^\beta \Gamma(\beta + 1)}\int_{0}^\infty \left(\gamma\rho\right)^{2\beta}e^{-\frac{1}{2}\gamma^2\rho^2}\gamma^2\rho^2d\rho|^{2} \frac{\hbar\Gamma_f}{\left(\lambda_{01} - \lambda_{00} - h\nu\right)^2 + \left(\hbar\Gamma_f\right)^2} $


$ \lambda_{00} = 2\gamma^2\left(\beta + 1\right) - \frac{\gamma^4}{4} $

e $ \lambda_{01} = 2\gamma^2\left(\beta + 3\right) - \frac{\gamma^4}{4} $

are the energies of the final and ground states, and $ \beta =\sqrt{ \left(m - \Phi\right)^2) - \frac{\gamma^4}{4} } $

Here' s my attempt to solve this problem in Python:

from scipy.integrate import quad
import numpy as np
from scipy.special import gamma
from scipy.constants import  pi, alpha
import matplotlib.pyplot as plt

epsilon = 13.1 #dielectric constant of the material
gamma_C = 0.5 # donor impurity linewidth 
nr = 3.2 #refractive index of semiconductor
m = 0 # magnetic number
flux = 0  # Phi in eqn 8 magnetic flux
R = 5  #radius of the qunatum ring in nm
r = np.linspace(0, 6 * R)
rho = r / R
m_0 = 0.0067*0.511 # electron effective mass
h = 4.13e-15 # Planck constant in eV
hbar =  6.58e-16 # reduced Planck constant in eV
#Photon energy
h_ni = np.linspace(0, 100/h) #in eV

#Function that calculates the integrand
def func(rho, gama):
    beta = np.sqrt((m - flux)**2 + gama**4/4)
    return ((gama * rho)**2*beta * np.exp(-1/2*(gama * rho)**2) 
         * (gama * rho)**2/2   ) 

def cross_section(h_ni, gama):
    #function that calculates the photoionisation cross sectio
    beta = np.sqrt((m - flux)**2 + gama**4/4)
    Ei = gama**2*(1+beta)-gama**4/2
    Ef = gama**2*(3+beta)-gama**4/2

    return ((nr/epsilon) * 4*pi/3 * alpha * h_ni * 
          R ** 2 / (2**beta * gamma(beta + 1)) * 
          abs(quad(func, 0, np.infty))**2  *
            hbar*gamma_C/(((Ef-Ei-h_ni))**2 + ( hbar*gamma_C)**2))



for gama in [1.0, 1.5, 2.0]:
    plt.plot(h_ni, cross_section(h_ni, gama))

But I got the following error

   TypeError: func() missing 1 required positional argument: 'gama'

How can I solve this? Any help is welcome.

  • 1
    $\begingroup$ I would suggest that you non-dimensionalize your equation since right now you have too much parameters and it is a bit cumbersome to work with. $\endgroup$ – nicoguaro Apr 6 at 1:20
  • $\begingroup$ Revision 7 of the question got an answer (which seemed to help). Continuing editing and debugging the code on Computational Science SE (as well as on StackOverflow) should not happen. Moreover, revision 7 that got the answer is certainly off-topic, as it is about the syntaxis of the particular functionality in Python. $\endgroup$ – Anton Menshov Apr 6 at 23:15
  • $\begingroup$ So, I did a rollback and closed this question. If while solving this problem you get the question that is more aligned with the computational science aspect, feel free to ask a new question. $\endgroup$ – Anton Menshov Apr 6 at 23:17
  • $\begingroup$ Actually, I solved the syntaxis problem, but found several other problems in the computational aspects. I'll ask another question $\endgroup$ – Daniel Lima Apr 7 at 20:49

Your function func(rho, gamma) takes two arguments while you pass only one (I think none). That is what your error tells you.

Recheck where you use func(rho, gamma) and make sure you pass two arguments.

| cite | improve this answer | |
  • $\begingroup$ Edited the question and removed argument gamma. Now I have a plot but it seem pretty weird. $\endgroup$ – Daniel Lima Apr 6 at 21:44
  • $\begingroup$ @DanielLima don't know why the question is closed. However, you can ask in the comment if there is any problem. $\endgroup$ – reboot Apr 7 at 10:48
  • $\begingroup$ Maybe you should ask this question on StackOverflow. As your problem seems to related to programming error rather than your logic. $\endgroup$ – reboot Apr 7 at 10:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.