Message Boards Message Boards

0
|
4595 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Unexpected solution in a DAE and DiscreteVariables?

Posted 2 years ago

I am solving an DAE problem with NDSolve. It is a physical problem related to friction forces: one mass on the X axis and another on the Y axis, linked by a bar (L=5). There is a part of the equation that must change the sign (the one related to a[t]), and I try to control it by a[t]. I am able to solve this problem as it is a piecewise problem, but I would like to solve it as a whole, so I have tried to use WhenEvent and DiscreteVariables.

deqns= {
  x''[t] == -(1/5) T[t] x[t] + 0.1 a[t] (9.8 + 1/5 T[t] (3 + y[t])), 
  y''[t] == (49 - 2/5 T[t] (3 + y[t]))/5, x[t]^2 + (3 + y[t])^2 == 25,
  WhenEvent[x'[t] == 0, a[t] -> -a[t]],
  x[0] == 4, y[0] == 0, a[0] == 1,
  x'[0] == 0, y'[0] == 0};

sol = NDSolve[
  deqns, {x, y, T, a}, {t, 0, 10},
  DiscreteVariables -> a,
  Method -> {"IndexReduction" -> Automatic}
];

Physical constraints force -4 <= x[t] <= 4, and 0 <= y[t] <=2. My question is about the solution obtained for a[t]. It is defined as "DiscreteVariables", and a[t] should change between -1 and +1 but when I plot it, it is not true. Any suggestion?

Art

POSTED BY: Art Arete
3 Replies
Posted 2 years ago

Cross-posted in Mma.SE.

POSTED BY: xzczd  

Art,

It appears to be related to the DAE and its index reduction. I would contact tech support to see why this doesn't work. I even tried to force a[t] to take on discrete values of -1,1 and it failed:

DiscreteVariables -> {a \[Element] {-1, 1}}

It seems that the DAE solver is taking over and solving for a[t] ignoring its initial condition and WhenEvent. On non DAE problems this works fine. I'm guessing that the index reduction is somehow taking over a[t].

I hope this helps.

Regards,

Neil

POSTED BY: Neil Singer
Posted 2 years ago

Neil, Thank you very much for your interest. I have reported the problem. When I have a response, I will post it.

Best regards.

POSTED BY: Art Arete
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