Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.5K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Help using WhenEvent with NDSolve to avoid complex solutions

Anonymous User
Anonymous User
Posted 10 years ago

Hello there, I would appreciate your help with me on this. I am modeling a second order differential equation ( mass and spring ). The spring is nonlinear (k x[t]^1.5). NDSolve solves the system but when encounters complex solutions it stoppes which makes sense to me. I want to make a constraint or a condition by using WhenEvent function inside the NDSolve to set x[t] to zero everytime the solution becomes complex or to just take the positive real part of it and continue solving for the specified period of time of 10 seconds. I've trying with no success. Please see the code in this message and I am also attaching the file for you. I would highly appreciate your help. Thank you

values = {m1 -> 1, m2 -> 2, m3 -> 3, E1 -> 210, E2 -> 210, 
   E3 -> 210, \[Nu]1 -> 1/3, \[Nu]2 ->  1/3, \[Nu]3 ->  1/3, 
   R1 -> 349/10000, R2 -> 349/10000, R3 -> 349/10000};
IC = {x1[0] == 0, x1'[0] == 1};
k1 = (1 - \[Nu]1^2)/(\[Pi] E1) /. values;
k2 = (1 - \[Nu]2^2)/(\[Pi] E2) /. values;
K12 = 4/(3 \[Pi] (k1 + k2)) Sqrt[(R1 R2)/(R1 + R2)] /. values;
\[Delta]12 = x1[t] + R1 /. values;
F12 = K12 \[Delta]12^1.5;
EQ1 = m1 x1''[t] +  K12 (x1[t])^(3/2) == 0 /. values;
eqn = NDSolve[{EQ1, IC} /. values, {x1[t],x1'[t]
}, {t, 0, 10}, Method -> "StiffnessSwitching"]
Plot[Evaluate[x1[t] /. eqn], {t, 0, 10}, GridLines -> Automatic, 
 PlotRange -> All]
Plot[Evaluate[x1'[t] /. eqn], {t, 0, 10}, GridLines -> Automatic, 
 PlotRange -> All]
Attachments:
POSTED BY: Anonymous User
4 Replies
Anonymous User
Anonymous User
Posted 10 years ago

Now I understand it well. Thank you so much for the help David :) Regards, Khalid

POSTED BY: Anonymous User
Posted 10 years ago
POSTED BY: David Keith
Anonymous User
Anonymous User
Posted 10 years ago

Dear David, thank you for your help. I understand your explanation of the problem. It made it a lot easier for me to understand what the NDSolve does when it encounters negative solutions, which results in complex solutions. Would you please tell me what are you telling NDSolve to do by your suggestion ( Sign[x1[t]] Abs[x1[t]]^(3/2) ). I want to understand what does it do when it encounters negative solutuions. Thank you again for your help David Regards, Khalid

POSTED BY: Anonymous User
Posted 10 years ago
POSTED BY: David Keith
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard