Message Boards Message Boards

GROUPS:

Solve a system of DAEs with discrete conditions using NDSolve?

Posted 1 year ago
1367 Views
|
4 Replies
|
2 Total Likes
|

I have also asked this question here in SO.

I'm trying to solve a system of DAEs with discrete conditions:

muk = 0.2;
mus = 0.3;
m1 = 1;
m2 = 2;
m3 = 3;
Fn12 = 3;
Fn23 = 2;
minvel = 0.1;
F1[x_] := 2*Sin[5*x];
F2[x_] := 2*Sin[7*x];
Fs12[x_] := (m2*F1[x] - m1*F2[x])/(m1 + m2);
Off[NDSolve::pdord]
s = NDSolve[{m1*x1''[t] == F1[t] - Ff12[t], x1'[0] == 0, x1[0] == 0, 
   m2*x2''[t] == F2[t] + Ff12[t], x2'[0] == 0, x2[0] == 0, 
   Ff12[t] == 
    If[Abs[x1''[t] - x2''[t]] < 0.1 && Abs[Fs12[t]] < mus*Fn12 , 
     Fs12[t], muk*Fn12*Sign[x1''[t] - x2''[t]]]}, {x1, x2, Ff12}, {t, 
   10}]

However when solving I get two weird errors:

NDSolve::tddisc

NDSolve cannot do a discontinuity replacement for event surfaces that depend only on time

NDSolve::nderr

Error test failure at t==...; unable to continue

enter image description here

which searching on google does not offer that much of the results!

I have found some relevant posts and documentations. It seems that I have to use a helper function or something like that using Piecewise and/or WhenEvent functions but I can't get my head around it!

I would appreciate if you could explain why this error happens and how I can modify my code to avoid it?

4 Replies

Foad,

You should use WhenEvent:

s = NDSolve[{m1*x1''[t] == F1[t] - Ff12[t], x1'[0] == 0, x1[0] == 0, 
   m2*x2''[t] == F2[t] + Ff12[t], x2'[0] == 0, x2[0] == 0, 
   Ff12[t] == Fs12[t], 
   WhenEvent[Abs[x1''[t] - x2''[t]] > 0.1 || Abs[Fs12[t]] > mus*Fn12, 
    Ff12[t] -> muk*Fn12*Sign[x1''[t] - x2''[t]]]}, {x1, x2, Ff12}, {t,
    10}]

Note I changed the logic on the event so when the event happens, the expression for Ff12[t] changes.

*** update -- I had a sign backwards in the logic change. -- you should check this to make sure it is what you want.

Regards,

Neil

I tried your code and I get a different error!

s2 = NDSolve[{m1*x1''[t] == F1[t] - Ff12[t], x1'[0] == 0, x1[0] == 0, 
   m2*x2''[t] == F2[t] + Ff12[t], x2'[0] == 0, x2[0] == 0, 
   Ff12[t] == Fs12[t], 
   WhenEvent[Abs[x1''[t] - x2''[t]] > 0.1 || Abs[Fs12[t]] > mus*Fn12, 
    Ff12[t] -> muk*Fn12*Sign[x1''[t] - x2''[t]]]}, {x1, x2, Ff12}, {t,
    10}]

NDSolve: Unable to reinitialize the system at t= ... within specific tolerance

enter image description here

Note that I had a logic issue.

also that error is a warning about accuracy. At the discontinuity it can't keep the requested accuracy (machine precision). Adjust AccuracyGoal and WorkingPrecision to fit your problem with appropriate accuracy. This is not unexpected given the sudden change.

Regards

you can also safely ignore the message or turn it off -- it is just making you aware of the issue.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract