-1

I guess I am missing something in this code:

integrand = lambda t,x,y: (1/(Tiempo-t))*np.exp(-((x-U*(Tiempo-t))**2+y**2)/(4*a*(Tiempo-t)))

def z_func(x,y,Rate,Conductivity):
    integral, err = integrate.quad(integrand,0,Tiempo,args=(x,y,))
    return ((Rate/(2*math.pi* Conductivity))*integral)

Z = z_func(X, Y, Ql, k)

cs = plt.contour(X, Y, Z,[IncT])

I have an implicit function with an integral, something like f(x,y,t)=A*Integral, where A is constant. It integrates over t. I need to calculate the contour for an specific value of t. But I get several errors such as "Supplied function does not return a valid float", which is the actual error when evaluating the z_func.

What am I doing wrong? Is there another way to solve it?

I should add I'm working with a meshgrid:

     x = arange(-1.0,10.0,0.1)
     y = arange(-1.0,10.0,0.1)

     X,Y = meshgrid(x, y)

Thanks in advance!

Margaral
  • 27
  • 1
  • 10

1 Answers1

0

To avoid this error, z_func must be vectorized:

vz_func = np.vectorize(z_func)
Z = vz_func(X, Y, Ql, k)
Margaral
  • 27
  • 1
  • 10