Venkat Subramanian

256 Reputation

10 Badges

9 years, 230 days

MaplePrimes Activity


These are answers submitted by

If you know the specific integral you want to calculate beforehand, then add an additional variable z(t) defined as

dz/dt = y^2 with z(0)=0. z(1) gives the integral. The advantage is that the integral you get is of the same order of accuracy as u. You can use arbitrary number of Digits (Digits = 20 or 30).

Unfortunately this approach can be used only if the resulting system is an ODE. If your resulting system is a DAE, Maple cannot solve it (DAE BVP)

restart:

eq:=-1.2*diff(y(t),t$2)+0.2*y(t)=2;

eq := -1.2*(diff(y(t), `$`(t, 2)))+.2*y(t) = 2

(1)

bcs:=y(0)=1,y(1)=0;

bcs := y(0) = 1, y(1) = 0

(2)

eq2:=diff(z(t),t)=y(t)^2;

eq2 := diff(z(t), t) = y(t)^2

(3)

sol:=dsolve({eq,eq2,bcs,z(0)=0},type=numeric,abserr=1e-8,maxmesh=100):

with(plots):

odeplot(sol,[[t,y(t)],[t,z(t)]],0..1,thickness=3,axes=boxed);

 

sol(1);

[t = 1., y(t) = 0., diff(y(t), t) = -1.79470197426050, z(t) = .482858946230082]

(4)

 

 

Download IntegralMapleprimes.mws

hope this helps.

restart:

eq1:=diff(V(t)*C(t),t)=G-K*C(t);

eq1 := (diff(V(t), t))*C(t)+V(t)*(diff(C(t), t)) = G-K*C(t)

(1)

eq2:=diff(V(t),t)=alpha-beta;

eq2 := diff(V(t), t) = alpha-beta

(2)

dsolve({eq1,eq2});

[{V(t) = (alpha-beta)*t+_C2}, {C(t) = (Int(G*exp((alpha-beta+K)*(Int(1/V(t), t)))/V(t), t)+_C1)*exp(Int(-(alpha-beta+K)/V(t), t))}]

(3)

V(t):=c1+(alpha-beta)*t;

V(t) := c1+(alpha-beta)*t

(4)

eq1;

(alpha-beta)*C(t)+(c1+(alpha-beta)*t)*(diff(C(t), t)) = G-K*C(t)

(5)

dsolve({eq1,C(0)=c2});

C(t) = ((c1+t*alpha-t*beta)^(1+K/(alpha-beta))*G/(alpha-beta+K)-(-c2*alpha+c2*beta-c2*K+c1^(-(alpha-beta+K)/(alpha-beta))*c1^((alpha-beta+K)/(alpha-beta))*G)/(c1^(-(alpha-beta+K)/(alpha-beta))*(alpha-beta+K)))*(c1+(alpha-beta)*t)^(-alpha/(alpha-beta)+beta/(alpha-beta)-K/(alpha-beta))

(6)

 


Download solvesequentially.mws

Add u as an additional variable defined by dh/dt = u

Then enter to Maple in DAE form. My guess is that you are lucky because this approach works for this case as the addition of u enables Maple to convert this system to explicit dy/dt = f form.  But in general Maple cannot solve nonlinear DAEs or ODEs if it cannot convert them to explicit ODE form dy/dt = f. In fact, this is a serious flaw. The assumption made here is that all ODEs and DAEs can be converted to dy/dt = f(y) form. This is not true for many nonlinear or implicit ODEs until you add addtional variables. Maple avoids using Newton Raphson or any nonlinear solvers in its ODE solver.

Code attached. It is best to post some range for parameters or the physics of the problem. I can't guess the values of the parameters. You have to find u(0) for every set of parameters. For the parameters I chose, there is a singularity at 3.22 or so.

 

 

 

 

restart:

ODE1:=A*u(t)^2+B*u(t)*(h(t)+C)+E*h(t)=F*cos(u(t));

ODE1 := A*u(t)^2+B*u(t)*(h(t)+C)+E*h(t) = F*cos(u(t))

(1)

eqic:=A*u1^2+B*u1*C=F*cos(u1);

eqic := A*u1^2+B*C*u1 = F*cos(u1)

(2)

 For the simulation shown u has an initial condition of Pi/2. When parameters change, change ic accordingly.

ODE2:=diff(h(t),t)=u(t):

sol:=dsolve({ODE1,ODE2,h(0)=0,u(0)=Pi/2},type=numeric,parameters=[A,B,C,E,F],stiff=true,maxfun=0):

sol('parameters'=[0,0,1,1,1]):

with(plots):

odeplot(sol,[t,h(t)],0..3);

 

odeplot(sol,[t,u(t)],0..1);

 

 

 

 

Download convertimplicitODEtoDAE.mws

I would suggest to post the original problem first so that we can make sure there was no mistake in the formulation when converted to adjoint formulation as a BVP.

If the code is posted as a mws for the BVP, I can try to solve and post it back. One can sometimes trick the BVPsolver in Maple to solve when the Newton iteration fails. Read help files on continuation.

 

1 2 Page 2 of 2