The first problem is due to the use of the max function, you need to explicitly use Numpy’s version, i.e. np.max, for that to work. The built-in max does not know about arrays.
The second problem, given your initial conditions, I am guessing you have xc running from -0.8 to 0.2 which means that you are taking the square-root of a negative number. Numpy (and python more generally) hands back a NaN and also prints the warning you mentioned.
Kyle
> On Apr 16, 2015, at 3:06 PM, Gustavo Quintero <
gustavoqu...@gmail.com> wrote:
>
> Hello,
>
> I'm trying to modify the initial condition in advencion_1d.py, as follow:
>
> #Initial data
> def G(x,beta):
> return np.exp((beta)*(x)**2)
>
> def F(x,y,z):
> return np.sqrt(max(1.0 - (y**2)*(x - z)**2,0.0))
>
> def H(x):
> return 1.0 - abs(10.0*(x - 0.1))
>
> xc = state.grid.x.centers
> beta = 334.477773; a = 0.5; z = -0.7; al = 10.0; d = 0.005
> state.q[0,:] = np.zeros(xc.shape[0])
> state.q[0,:] = ((-0.8 <= xc)*(xc <= -0.6)*(H(xc)))+((-0.4 <= xc)*(xc <= -0.2)*(1.0))+((0.0 <= xc)*(xc <= 0.2)*(max(xc,0.0))).
>
> This throws me the following result:
>
> "ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()"
>
> Similarly, I want to extract the square root of xc, as follow:
>
> state.q[0,:] = np.zeros(xc.shape[0])
> state.q[0,:] = ((-0.8 <= xc)*(xc <= -0.6)*(xc))+((-0.4 <= xc)*(xc <= -0.2)*(max(xc,0.0)))+((0.0 <= xc)*(xc <= 0.2)*(H(xc))) + ((0.4 <= xc)*(xc <= 0.6)*(np.sqrt(xc))),
>
> but I get the same error above and also this error:
>
> <error.png>
>
> Note: with other functions I have not problem, for instance: xc**2, np.sin(xc), etc.
>
> I would really appreciate any help.
>
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups "claw-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
claw-users+...@googlegroups.com.
> To post to this group, send email to
claw-...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/claw-users.
> For more options, visit
https://groups.google.com/d/optout.