       # NDSolve works one day, gives error the next!

• To: mathgroup@smc.vnet.net
• Subject: [mg10347] NDSolve works one day, gives error the next!
• From: "Christopher R. Carlen" <crobc@epix.net>
• Date: Thu, 8 Jan 1998 23:41:06 -0500
• Organization: epix Internet Services

```I have the following job for NDSolve:

------------------------------------------------ Vd[i_]:= 60 i /; i>= 0
&& i<= 0.01
Vd[i_]:= .01 i + .6 /; i > 0.01
Vd[i_]:=10^4 i /; i < 0

(* That defined a piecewise linear function *)

A = 14.14;
f = 60;
Rl = 100;
L=0.001;      (* Define some parameters *)

V[t_]=A Sin[ 2 Pi f t ]      (* Another function *)

eqns={
V[t] - L (q2''[t] - q3''[t]) - Vd[ q2'[t] ] + Vd[ q3'[t] ]==0, V[t] - L
(q2''[t] - q3''[t])- Vd[ q2'[t] ] -
Rl (q2'[t] + q3'[t]) - Vd[ q2'[t] ]==0, q2==0, q3==0, q2'==0,
q3'==0}

(* Well, those are my equations to solve, so do it: *)

ans=NDSolve[ eqns, {q2[t], q3[t]}, {t, 0, 2/60}, MaxSteps->2500]

(* Now I do some processing to the output *)

i6[t_]= D[ q2[t]/.ans[], t ] + D[ q3[t]/.ans[], t ]

(* Then plot i6[t] *)
------------------------------------------------------

I had solved this, just as you see it, many times with complete success.
I have plots of the output.  They look like the absolute value of a Sin
function.  The equations represent the Kirchhoff's analysis of a
full-wave-bridge rectifier, and the output should be the absolute value
of a sine wave.  The piecewise linear function is the diode model,
giving the voltage across the diode as a func. of current.

*** THE PROBLEM ***

I tried running this sequence of calculations again after being away
from it a few days, and I get an error message from NDSolve:

NDSolve::ntdv : Cannot find explicit formula for derivatives.

After many hours trying to figure this out, being certain that nothing
had changed since the last time I saw it work fine, I started trying to
solve all sorts of similar systems of equations until I noticed some
patterns.

Finally, I discovered that the following perterbation of my equations

eqns={
V[t] -L( .999999 q2''[t]-1.000001 q3''[t])- Vd[ q2'[t] ] + Vd[ q3'[t]
]==0,
V[t] -L( 1.000001 q2''[t]-0.999999 q3''[t])- Vd[ q2'[t] ] -
Rl (q2'[t] + q3'[t]) - Vd[ q2'[t] ]==0, q2==0, q3==0,
q2'==0, q3'==0}

So I would postulate that some sort of low level error in the numerical
arithmetic sometimes does and sometimes doesn't create this
perterbation for me, leading to inconsistent behavior from day to day.
The coefficients that I have inserted may be taken closer toward unity
and I still get a solution even at 1 (+or-) 10^-8 .

At 1 (+or-) 10^-10 I get the following error:

NDSolve::"ndcf":
"Repeated convergence test failure at t == 3.92985788203463748`*^-7;
\
unable to continue.

I don't mind so much having to perturb in order to get the solution.
But I don't understand why this is so.  I also know that it has worked
without having to do this at all before.  If someone can explain this
situation, I will tell everyone I meet that they are the greatest
genius in the world.  (Small reward, I know, but I just mean I'd be
very thankful.)

Thanks...

_______________________
Christopher R. Carlen