Venkat Subramanian

386 Reputation

13 Badges

15 years, 242 days

MaplePrimes Activity


These are replies submitted by

@Axel Vogt 

 

I think sol2 is for the original ODE and needs the IC. I am using 0.153...as used by the OP.

@Axel Vogt 

Bogo, also for this specific problem, I am not sure if the constants and ICs should be looked at. Both Y(x) and YFD(x) are very close (almost same).

@bogo 

Bogo, you are welcome. Thanks for the acknowledgement. You can call sol1(300) instead of sol1(100) to get sol2 for longer times. Also, for some reason, in Maple 14 classic worksheet it won't plot from 1 to 49 in the same graph, but the code wil plot if you split and plot. You can save those plots separately and display together.

See code below.

 

restart:

Digits:=15;

Digits := 15

(1)

de := diff(Y(x), x)+10^5*(Y(x)^2-YFD(x)^2)/x^2 = 0;

de := diff(Y(x), x)+100000*(Y(x)^2-YFD(x)^2)/x^2 = 0

(2)

YFD:=proc (x)  local xi,g; g:=2;
if not type(evalf(x),'numeric') then
      'procname'(x)
   else Re(evalf((1/2)*g*(int((xi^2-x^2)^(1/2)*xi/(exp(xi)+1), xi = x .. infinity))/Pi^2));
end if;
end proc;

YFD := proc (x) local xi, g; g := 2; if not type(evalf(x), 'numeric') then ('procname')(x) else Re(evalf((1/2)*((g/Pi^2)*(int((xi^2-x^2)^(1/2)*xi/(exp(xi)+1), xi = x .. infinity))))) end if end proc

(3)

 

 

IC:=Y(1)=YFD(1);

IC := Y(1) = .153496865945853

(4)

#infolevel[all]:=10;

sol:=dsolve({de,IC},type=numeric,known='YFD',method=lsode):

sol(1);

[x = 1., Y(x) = .153496865945853]

(5)

 Solution will be evaluated at a later stage

#sol(1.00001);

#sol(1.0001);

 

 

 The itnegral equation is converted to a differential equation and solved in parametric and compiled form with respect to x and xi = 100 is taken to be infinity (not changing much beyond x = 45).

eq2:=diff(y(xi),xi)=(xi^2-1.*x^2)^(1/2)*xi/(exp(xi)+1.)/Pi^2;

eq2 := diff(y(xi), xi) = (xi^2-1.*x^2)^(1/2)*xi/((exp(xi)+1.)*Pi^2)

(6)

sol1:=dsolve({eq2,y(x)=0},type=numeric,'parameters'=[x],compile=true,abserr=1e-15,relerr=1e-14):

Warning, relerr increased from .1e-13 to 5.00001e-013

 

sol1('parameters'=[1]);

[x = 1.]

(7)

sol1(1);sol1(2);

[xi = 1., y(xi) = 0.]

[xi = 2., y(xi) = 0.286491817180358e-1]

(8)

sol1(45.00000000000);

[xi = 45.00000000000, y(xi) = .153496865945855]

(9)

sol1(100);

[xi = 100., y(xi) = .153496865945855]

(10)

y11:=subs(sol1(100),y(xi));

y11 := .153496865945855

(11)

y11-subs(sol1(2),y(xi));

.124847684227819

(12)

YFD(2);

0.995300744084111e-1

(13)

 

 

YFD2:=proc (x)  
global sol1,y;
local xi,z1,g; g:=2;
if not type(evalf(x),'numeric') then
      'procname'(x)
   else
   sol1('parameters'=[x]);
z1:=sol1(300);
rhs(z1[2]);#subs(sol1(100),y(xi)):   

end if;
end proc;

YFD2 := proc (x) local xi, z1, g; global sol1, y; g := 2; if not type(evalf(x), 'numeric') then ('procname')(x) else sol1('parameters' = [x]); z1 := sol1(300); rhs(z1[2]) end if end proc

(14)

YFD(1);YFD2(1);

.153496865945853

.153496865945855

(15)

 

 

 One can note that the dsolve solution for the integral is much faster than the integral calucation and provides the same value.

de2:=diff(Y(x), x)+10^5*(Y(x)^2-YFD2(x)^2)/x^2 = 0;;

de2 := diff(Y(x), x)+100000*(Y(x)^2-YFD2(x)^2)/x^2 = 0

(16)

sol2:=dsolve({de2,IC},type=numeric,known='YFD2',method=lsode,abserr=1e-4,maxfun=0):

sol2(1);

[x = 1., Y(x) = .153496865945853]

(17)

 Next time taken is compared for the original dsolve with integral for the procedure and the new dsolve.

t11:=time():sol(1.00001);time()-t11;

[x = 1.00001, Y(x) = .153496759729280]

2.247

(18)

t11:=time():sol2(1.00001);time()-t11;

[x = 1.00001, Y(x) = .153496712677963]

0.

(19)

t11:=time():sol(1.0001);time()-t11;

[x = 1.0001, Y(x) = .153493467077101]

18.283

(20)

t11:=time():sol2(1.0001);time()-t11;

[x = 1.0001, Y(x) = .153485985046870]

0.

(21)

with(plots):

odeplot(sol2,[x,Y(x)],1..7);

 

odeplot(sol2,[x,Y(x)],7..11);

 

odeplot(sol2,[x,Y(x)],11..15);

 

odeplot(sol2,[x,Y(x)],15..19);

 

odeplot(sol2,[x,Y(x)],19..49);

 

 Note that in sol2, compile=true can't be used as it is not able to recognize YDF2. If that can be enabled this code will run even faster.

 

Download knownfunctiondsolve3.mws

@bogo 

You are welcome.

I think it is just the syntax to enable dsolve/numeric codes to read. Not sure, perhpas Allan Wittkopf or other Maplesoft developers can explain the need for the same.

I have posted a more efficient approach. See below.

@Preben Alsholm 

Preben, that is perfect. The parameters epsilon(=mu), tinit (initialization time), the constant q inside the tanh function are tunable parameters. My experience suggests that, 

epsilon = 1e-4 is good for abserr =1 e-6,

tinit = 0.1 is a good start for total time of integration of 1. Typically, we don't need more than tinit = 200 if we have to integrate till t = 10,000 for the original DAE system.

 

initstep = 0.1 or 0.01 is a good number (greater than epsilon).

q= 1000 is good, but for very long integrations, q = 100 may be sufficient.

@Markiyan Hirnyk 

you wrote "You wrote "if you take a linear system of DAEs. The mu approach will theoretically go to the expected steady state irrespective of the value of mu. (When only algebraic equations are solved). For example take Az=b as the algebraic equation". Can you kindly explain that in detail?"

@Markiyan Hirnyk 

 

not, the modified equations. When I find time, I will post codes for non-autonomous systems that work. If there are specific equations you want me to solve, let me know.

 

@Markiyan Hirnyk 

 

df/dt=f(u,z)

0=g(u,z)

 

rhs of ODEs for non-autonomous system will have f(u,z,t)

 

@Markiyan Hirnyk 

 

Sorry for the terminology confusion. Epsilon is used in the pdf file and mu was used in the Maple file.

@Preben Alsholm 

 

As of now the model written does not have an explicit t dependence in it. Of course one can add a dummy variable dTdt = 1 and convert non-autonomous system to autonomous system. My interests are in large scale systems. So adding one more equation is not bad.

The theory of Rosenbrock methods is well developed, but the implementation in many sovlers do not address this (non-autonomous systems) always.

The proposed approach can handle non-autonomous systems directly by freezing explicit 't' dependent functions in g by multiplying by tanh function. In addition, the explicit time dependent functions in the right hand side (r.h.s.) of f also needs to be taken care of.

We have done this in at least 2-3 different appraoches and are currently trying to find and document the best possible approach by trying different test cases. If you have oscillatory forcing functions, then including partial derivative of that with t may be important.

 

@Preben Alsholm 

 

Most of the statements about dsolve are based on standard dsolve approaches inbuilt into Maple. This implicit ODE was given as an example as one can use the proposed approach wihtout using fsolve and including compile=true.

For complicated implicit ODEs, fsolve approach may not work (Because of the insistence on strict tolerance of 1e-15).

 

Also, please note that first 3 examples can be solved with standard Maple dsolve/numeric command if we use fsolve to find consistent IC for algebraic variable before calling dsolve/numeric. For smaller and linear systems, Maple can extend the Algebraic equations to arrive at the explicit form dz/dt = rhs. However, for nonlinear and large scale DAEs, Maple wastes time and RAM unsuccessfully.

 

@ 

 

Acer, is there a reason why we need to enter 0 for zero entries? Is it possible to avoid entering zeros for sparse matrices?

Also, the output  for Solve(3,VV) returns a matrix with 1 column. Is it possible to return a vector?

Thanks

 

@Markiyan Hirnyk 

 

if you take a linear system of DAEs. The mu approach will theoretically go to the expected steady state irrespective of the value of mu. (When only algebraic equations are solved). For example take Az=b as the algebraic equation.

 

 

@Markiyan Hirnyk 

Markiyan, I modified the text to remove the word bifurcation. The theory of bifurcation for DAEs is more difficult than for ODEs.

I wondered where I saw the word bifurcation. I found the reference. http://link.springer.com/article/10.1007%2FBF01398915

Please check page 555. The authors claim, 

In the first step a simple DAE like (4.1) is analyzed.
(4.1) y'=z, y(0)= 1
y^2 + z^2-1, z(0)=0
Under the index-1 assumption a unique solution exists for t < Pi/2:
(4.2) y (t) = sin (t), z (t) = cos (t)
At t=Pi/2 the index-1 assumption is violated and
(4.3) y(t)= 1, z(t)=0
or bifurcations from (4.3) to (4.2) are admissible solutions.

@Markiyan Hirnyk 

Markiyan,

When I use Maple to solve this I get (Without specifying ICs)

[{y(t) = 1}, {z(t) = 0}], [{y(t) = -1}, {z(t) = 0}], [{y(t) = -sin(-t+_C1), y(t) = sin(-t+_C1)}, {z(t) = diff(y(t),t)}] 

 

 

 

First 10 11 12 13 14 15 16 Page 12 of 17