Question: How to make solution of this PDE a function in order to evaluate it?

I got this solution from a PDE. I normally use unapply on the RHS of the solution to make it a function.

But in this, the PDE solution contain some extra stuff at the end. Which  "Where { .....}"

So the only way for me, was to manually copy the initial part of the solution shown on the screen in order to use it later.

I could not find a way to program this part.

Here is an example

restart;

f:=(r,z)->(r-a)*sin(z/H*Pi);
lap:=VectorCalculus:-Laplacian(u(r, z, t), cylindrical[r, theta,z]);
bc:=u(r,0,t)=0,u(r,H,t)=0, u(a,z,t)=0;
ic:=u(r,z,0) = f(r,z);
sol:=pdsolve([diff(u(r,z,t),t) = k*lap,bc,ic],u(r,z,t)) assuming a>0,k>0;

THis gives

Which I verified to be correct.

In case you are not able to get this solution (it needs Maple 2019.1 and Physics 368), here is the lprint

 

lprint(sol)

u(r,z,t) = `casesplit/ans`(Sum(-BesselJ(0,lambda[n]/a*r)*sin(z/H*Pi)*exp(-k*t*(
H^2*lambda[n]^2+Pi^2*a^2)/a^2/H^2)*a/lambda[n]^2*Pi*BesselJ(1,lambda[n])*
StruveH(0,lambda[n])/hypergeom([1/2],[1, 2],-lambda[n]^2),n = 1 .. infinity),{
And(lambda[n] = BesselJZeros(0,n),0 < lambda[n])})

Next to use it (plot., evaluate, etc...) changed the sum go to 15 terms (more than enough) and also replaced a->1,H->3,k->1/100 and  also replaced lambda[n] with BesselJ zeros as follows

sol:=subs({infinity=15,a=1,H=3,k=1/100,lambda[n]=BesselJZeros(0, n)},sol);

Before I use unapply, I had to extract the part of the solution up to where it says "where..." since I do not need the rest any more, since I allready replaced lambda[n] with BesselJZeros calls.

This I did by hand using copy/paste from the screen. Now I am able to finish the task:

solFiltered:=Sum(-BesselJ(0, BesselJZeros(0, n)*r)*sin(z*Pi/3)*
     exp(-t*(9*BesselJZeros(0, n)^2 + Pi^2)/900)*Pi*
     BesselJ(1, BesselJZeros(0, n))*
     StruveH(0, BesselJZeros(0, n))/(BesselJZeros(0, n)^2*
     hypergeom([1/2], [1, 2], -BesselJZeros(0, n)^2)), n = 1 .. 15):

mapleSol:=unapply(solFiltered,r,z,t);

value(mapleSol(.5,2,1));

Which prints -0.4107565091 which is the correct value. It matches my hand solution and also match numerical solution.

What would a better way to do the above than what I did? i.e. to obtain the solFitered above using code only? 

Please Wait...