dharr

Dr. David Harrington

8270 Reputation

22 Badges

20 years, 359 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

Maple Application Center
I am a retired professor of chemistry at the University of Victoria, BC, Canada. My research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

MaplePrimes Activity


These are replies submitted by dharr

@Math-dashti It seems DEplot isn't set up for this. I'm not sure about fieldplot. Of course you could convert back to cartesian coordinates and use DEplot. odeplot works but is tedious.

restart;

with(plots):

The differential equations in polar coordinates

de1 := diff(r(t),t) = r(t)*(1 - r(t)^2);
de2 := diff(theta(t),t) = 1;

diff(r(t), t) = r(t)*(1-r(t)^2)

diff(theta(t), t) = 1

Phase portrait :-(

DEtools:-DEplot({de1,de2},[r(t),theta(t)], t = 0..5, r = 0..2, theta = 0..2*Pi, coords=polar);

Error, (in DEtools/DEplot) can only plot in cartesian co-ordinates, got invalid option coords = polar

We can do this the hard way via odeplot, one per initial condition

ans1 := dsolve({de1, de2, theta(0)=0, r(0)=1}, {r(t), theta(t)}, numeric): # limit cycle
ans2 := dsolve({de1, de2, theta(0)=0, r(0)=0.01}, {r(t), theta(t)}, numeric): # inside
ans3 := dsolve({de1, de2, theta(0)=0, r(0)=2}, {r(t), theta(t)}, numeric): # outside

p1:=odeplot(ans1, [r(t)*cos(theta(t)), r(t)*sin(theta(t))],t=0..2*Pi, scaling = constrained, labels=[x(t),y(t)]):
p2:=odeplot(ans2, [r(t)*cos(theta(t)), r(t)*sin(theta(t))],t=0..2*Pi, scaling = constrained, labels=[x(t),y(t)]):
p3:=odeplot(ans3, [r(t)*cos(theta(t)), r(t)*sin(theta(t))],t=0..2*Pi, scaling = constrained, labels=[x(t),y(t)]):
display(p1,p2,p3);

NULL

Download polarphase.mw

@Math-dashti The output from PDEtools:-ConservedCurrents({de1,de2}, [u(t),v(t)]); correctly says any function of it will do. I stripped off the arbitrary function and just multiplied by that constant just to agree with @Rouben Rostamian's result. If something is conserved, then any function of it is also conserved.

@Math-dashti FYI, Maple can calculate the conserved quantity from the odes by

PDEtools:-ConservedCurrents({de1,de2}, [u(t),v(t)]);
-(1/2)*op(1, rhs(op(%)));

(The -1/2 just to convert to @Rouben Rostamian's form.)

@Rouben Rostamian  I'm fascinated by symbolic solutions, which was my main interest. Otherwise, I'm not convinced it is that useful. There have been many requests about it on Mapleprimes, so it was more a coding challenge.

@Alfred_F Here's one way. You always have to play around with these things.

restart

puzzle := `assuming`([sum(cos(k*Pi/(2*n+1))^4, k = 1 .. n)], [n::posint])

(1/8)*cos(2*Pi*n/(2*n+1))^2+(1/16)*(4+(-sec(Pi/(2*n+1))*csc(Pi/(2*n+1))+2*cot(Pi/(2*n+1)))*sin(2*Pi*n/(2*n+1)))*cos(2*Pi*n/(2*n+1))+(1/4)*cot(Pi/(2*n+1))*sin(2*Pi*n/(2*n+1))+(3/8)*n-3/8

I often find converting trig things to exp and simplifying can be helpful - here only a little bit

p := `assuming`([simplify(convert(puzzle, exp))], [n::posint])

(3/8)*n-5/16+(1/4)*csc(2*Pi/(2*n+1))*sin(2*Pi*n/(2*n+1))+(1/4)*csc(2*Pi/(2*n+1))*sin(2*Pi*(n+1)/(2*n+1))

Repeat

p2 := `assuming`([simplify(convert(p, exp))], [n::posint])

(3/8)*n-5/16

NULL

Download test.mw

@Rouben Rostamian  If the point is that this is not useful as a numerical method, then I agree. But it does allow one to deduce the correct symbolic solution at x=0, which can then be verified and is well behaved. That presumably is a hint for the solution for general x.

In the post I wasn't enthusiastic about it as a numerical method, and the plot there shows divergence at relatively small x and t values for that example, though not as bad as here. Some of the literature I've seen only gives such comparisons for very short times, before the solution becomes poor.

restart;

Diff(u(x,t),t) = Diff(u(x,t)^3, x, x);
pde := value(%):

Diff(u(x, t), t) = Diff(u(x, t)^3, x, x)

ic := simplify(75^(1/4)*sqrt(sqrt(3)/15 - x^2*sqrt(75)/12));

(1/2)*(-25*x^2+4)^(1/2)

Known exact solution

exact := sqrt(sqrt(3)/15 - (5*x^2)/(4*sqrt(225*t + 3)))/(t + 1/75)^(1/4);

(1/30)*(60*3^(1/2)-1125*x^2/(225*t+3)^(1/2))^(1/2)/(t+1/75)^(1/4)

Calculate many terms

n := 30;
approx := LAD(pde, u(x,t), ic, t, n):

30

Case of x=0

approx0:=eval(approx, x = 0):
[seq(coeff(approx0, t, i), i = 0..n)]:
sol0:=gfun:-guessgf(%,t)[1];

1/(1+75*t)^(1/4)

Agrees with the exact solution at x = 0

simplify(eval(exact, x=0) - sol0);

0

plot(sol0, t = 0..1);

All terms calculated agree with the series solution up to the number of terms calculated.

series(sol0, t, n+1, oterm = false) - approx0;

0

At 30 terms, the approximate solution diverges from the exact at about t = 0.013

plot([approx0, sol0], t=0..0.02, 0..1, color = [red, blue]);

NULL

Download LAD_Barenblatt0.mw

 

@Rouben Rostamian  The discontinuity may pose problems. Apparently "a given initial condition is consistent only with a specific set of boundary conditions"[1]; not sure if that applies here. Anyway, the method gives the same answer as a series expansion of the exact solution in t, so the algorithm appears to work. The hard part is deducing a simple closed form from the series solution, and I didn't make much progress here (I tried not to cheat since I knew the answer.)

LAD_Barenblatt.mw

[1] A. Garcıa-Olivares, Kybernetes, 32 (2003) 548.

@janhardo 

Yes, it can definitely be extended to other types of PDEs. Nonlinear parts that are more complicated than polynomials, such as exp(U*U[x]), might work with the existing code just by removing the polynom check, but I haven't tested it so I'm being careful. Additional time-dependent derivative terms can probably be added to L, and mixed time/spatial terms can probably be dealt with; these just need more code to detect and deal with the initial conditions. ODEs can be dealt with just by treating the highest-order term similarly to the time-dependent term here.

One difficulty is finding reliable test cases in the literature; the literature in this area is full of typos and missing information, for example figures that give values for most but not all of the parameters.

@salim-barzani The value you set for infolevel[LAD] determines how much extra information is printed out durung the calculation. You do not have to set it at all, in which case there is no extra information printed out. Or you can set it to 1, 2, 3 or 4 to include the information described at the top of the worksheet. Setting to 0 gives no information and setting to > 4 is the same as setting to 4. Many Maple commands, e.g., solve, will print information if you set infolevel.
 

In the code I used the userinfo commend to actually print out the information.

@KIRAN SAJJAN You didn't provide a worksheet. Did you change Sb? But if there are remaining errors they probably arise from other errors in the paper, rather than the Maple.

@KIRAN SAJJAN When I look at the worksheet it looks like H = Sb*D(Phi)(0)/(Le*Pr) instead of H(0) = Sb*D(Phi)(0)/(Le*Pr), but it is more than that.

Actually I think the original boundary condition is correct but the sign of Sb is wong. If I set Sb = -1 instead of Sb = 1, then I get correct looking plots. Later in the paper there is a plot where H is either positive or negative at eta = 0 for different signs of Sb.

restart

Parameters as in figures provided.

params := {Cs = .5, Ha = .2, Le = 3, Mc = .2, Nb = .2, Nc = 5, Nr = .2, Nt = .2, Pr = 6, Sb = -1, Ts = .5}

{Cs = .5, Ha = .2, Le = 3, Mc = .2, Nb = .2, Nc = 5, Nr = .2, Nt = .2, Pr = 6, Sb = -1, Ts = .5}

OdeSys := diff(F(eta), eta, eta)-(diff(F(eta), eta))*H(eta)-F(eta)^2+G(eta)^2-Ha*F(eta)+Mc*(Theta(eta)+Nc*Theta(eta)^2-Nr*Phi(eta)), diff(H(eta), eta)+2*F(eta), diff(G(eta), eta, eta)-(diff(G(eta), eta))*H(eta)-2*F(eta)*G(eta)-Ha*G(eta), diff(Theta(eta), eta, eta)-Pr*(H(eta)*(diff(Theta(eta), eta))+F(eta)*Theta(eta))+Pr*Nb*(diff(Theta(eta), eta))*(diff(Phi(eta), eta))+Pr*Nt*(diff(Theta(eta), eta))^2, diff(Phi(eta), eta, eta)-Le*Pr*H(eta)*(diff(Phi(eta), eta))+F(eta)*Phi(eta)+Nt*(diff(Theta(eta), eta, eta))/Nb; Cond := F(0) = 0, G(0) = 1, H(0) = -Sb*(D(Phi))(0)/(Le*Pr), Theta(0) = 1+Ts*(D(Theta))(0), Phi(0) = 1+Cs*(D(Phi))(0), F(10) = 0, G(10) = 0, Theta(10) = 0, Phi(10) = 0

F(0) = 0, G(0) = 1, H(0) = -Sb*(D(Phi))(0)/(Le*Pr), Theta(0) = 1+Ts*(D(Theta))(0), Phi(0) = 1+Cs*(D(Phi))(0), F(10) = 0, G(10) = 0, Theta(10) = 0, Phi(10) = 0

indets(eval([OdeSys], params))

{eta, F(eta), G(eta), H(eta), Phi(eta), Theta(eta), diff(F(eta), eta), diff(G(eta), eta), diff(H(eta), eta), diff(Phi(eta), eta), diff(Theta(eta), eta), diff(diff(F(eta), eta), eta), diff(diff(G(eta), eta), eta), diff(diff(Phi(eta), eta), eta), diff(diff(Theta(eta), eta), eta)}

 

Let's make some approximate solutions that look like the figure. Three look exponential, one looks Gaussian and one looks like linear times exponential.

F__0 := .5*eta*exp(-eta); plot(F__0, eta = 0 .. 8)

.5*eta*exp(-eta)

H__0 := -.8+.75*exp(-.3*eta^2); plot(H__0, eta = 0 .. 8)

-.8+.75*exp(-.3*eta^2)

`Φ__0` := .7*exp(-2*eta); `Θ__0` := `Φ__0`; plot(`Φ__0`, eta = 0 .. 3)

.7*exp(-2*eta)

.7*exp(-2*eta)

G__0 := exp(-eta); plot(G__0, eta = 0 .. 3)

exp(-eta)

ans := dsolve(eval([OdeSys, Cond], params), {F(eta), G(eta), H(eta), Phi(eta), Theta(eta)}, numeric, approxsoln = [F(eta) = F__0, G(eta) = G__0, H(eta) = H__0, Phi(eta) = `Φ__0`, Theta(eta) = `Θ__0`], output = listprocedure)

plots:-odeplot(ans, [[eta, H(eta)], [eta, F(eta)], [eta, G(eta)], [eta, Phi(eta)], [eta, Theta(eta)]], eta = 0 .. 5)

 

Download dsolve2.mw

 

@KIRAN SAJJAN In the pdf, eq 13 is

and in your worksheet you have H(0) = -Sb*D(Phi)(0)/(Le*Pr). Now from the figures D(Phi)(0) is negative, and Sb, Le and Pr are positive, so H(0) will be positive, as it is in your worksheet. But according to the figure, H(0) must be negative. So the paper and your worksheet are wrong. I am suggesting you try removing the negative sign in this boundary condition and see if that works. Of course there may be other errors because of other errors in the paper or your worksheet related to the physics, but as far as I can see Maple is correctly doing what you asked it to do.

@KIRAN SAJJAN Your sahin_base_paper.mw won't run for me - in one of the boundary conditions (the one mentioned in my answer) you have "phis" instead of phi. The plots in that worksheet still have positive H at eta = 0 and you did not change the sign in the boundary condition. lt appears that you didn't read the comment at the end of my worksheet.

@mmcdara Thanks. I used to use approxsoln fairly frequently when I was solving these sorts of Navier-Stokes related systems, and it was always hit-and-miss. I think I was lucky here since the actual solution for H at eta=0 was only a small positive value not too different (relatively) from the negative value in the approxsoln. One can provide a digitized version if as in this case you know the solution, but usually that is not the case. Yes, ability to specify just one of the functions would be a nice feature.

@janhardo I agree that this is part of it. Large output should be suppressed because it takes time to decide it is too large to display.

1 2 3 4 5 6 7 Last Page 3 of 86