When I copy-n-paste the code if runs (thankfully) and produces the error message:
1231:~/mypy$ python3 stack53381357.py
Traceback (most recent call last):
File "stack53381357.py", line 105, in <module>
Z = Ek(X, Y)
File "stack53381357.py", line 67, in Ek
while s < 3.05 and t < 1e-7 :
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Note that the full message does tell us where the problem is - in the Ek
function at line 67. That is relevant information.
That confirms my comment - Ek
is called with array arguments, and that propagates through the loop, changing s
to an array.
When I add a print to the end of the Ek
loop:
print(type(s), s.shape)
I get, before the error:
<class 'numpy.ndarray'> (100, 100)
So, yes, s
has changed from a scalar to a numpy
array, the same shape as the X
and Y
arrays you passed to Ek
.
Your 3 functions appear to have been written for scalar inputs. I'm not going to try to figure out how they should work with the meshgrid
inputs. You could iterate over the pa
and Ea
elements. Or you could modify the functions so they do behave when given array values. At the very least the
while (s<3.05) and (t<1e-7):
has to be written to be meaningful when s
is an array. There may be other problems with array inputs.