On 4/27/12 7:18 PM, Debashish Saha wrote:

You will want to ask numpy questions on the numpy mailing list.

  http://www.scipy.org/Mailing_Lists

When you do, I recommend stating a clear question in addition to the code and the traceback (although those are very much appreciated). But just to get you on your way, remove the np.vectorize() line (you don't need it) and double-check the order of arguments that you are passing to delta_l(K,l).

from __future__ import division
from numpy import*
import numpy as np
import matplotlib.pyplot as plt
from scipy.special import jv
from scipy.special import yn


h_cross=1
m=1
E=np.linspace(0.1,10,100)

V0=-100
R=2
K=(2*E)**0.5
K_P=(2*(E-V0))**0.5




'''r=np.linspace(-10,10,1000)
def V(r):
     if r>0 and r<R:
         return V0
     return 0
V=np.vectorize(V)
ax.set_ylim(-200,10)
plt.plot(r,V(r))'''


def sph_jv(l,r):
     return (pi/(2*r))**0.5*jv(l+0.5,r)



def sph_yn(l,r):
     return (pi/(2*r))**0.5*yn(l+0.5,r)




def delta_l(K,l):
     return 
arctan(((K_P*R)**2*sph_jv(l,K*R)-(2*l+3)*(K*R)*sph_jv(l+1,K*R))/((K_P*R)**2*sph_yn(l,K*R)-(2*l+3)*(K*R)*sph_yn(l+1,K*R)))
l=6
delta_l=np.vectorize(delta_l)
plt.plot(K,delta_l(l,K))

plt.show()





ValueError                                Traceback (most recent call last)
C:\Python27\lib\site-packages\IPython\utils\py3compat.pyc in
execfile(fname, glob, loc)
     166             else:
     167                 filename = fname
-->  168             exec compile(scripttext, filename, 'exec') in glob, loc
     169     else:
     170         def execfile(fname, *where):

C:\Users\Neeraj\Desktop\14.py in<module>()
      45 l=6
      46 delta_l=np.vectorize(delta_l)
--->  47 plt.plot(K,delta_l(l,K))
      48
      49 display(gcf())

C:\Python27\lib\site-packages\numpy\lib\function_base.pyc in
__call__(self, *args)
    1880         if self.nout == 1:
    1881             _res = array(self.ufunc(*newargs),copy=False,
->  1882                          subok=True,dtype=self.otypes[0])
    1883         else:
    1884             _res = tuple([array(x,copy=False,subok=True,dtype=c) \

ValueError: setting an array element with a sequence.


--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to