1
$\begingroup$

I am trying to solve a series of nonlinear differential equation with complex condition as described by block diagram below. The left figure describes general concepts and the right figure describes the equations used in each state. Here, I want to be able to plot displacement of $x1$.

If possible, it would be great if you can make every equation inside a NDSolve function since later, I want to determine the connection between Amplitude $A$ and displacement $x1$ after 100th period.

EDIT 1

Here's my trial code with When Event Method:

T = 10;k = 1;m1 = 1;m2 = 1;A = 1;Fs = 2;Fk0 = 1;\[Epsilon] = 10^-5;

sol = First@NDSolve[{
 x0[t] == A Sin[2 Pi t],
 x2''[t] == -k/m2 x2[t] - m1/m2 (x0''[t] + x1''[t]), x2'[0] == 0, 
 x2[0] == 0,
 Y[t] == go[t]*(x1''[t] + k/m1 x2[t] + x0''[t] + Fk0/m1 Sign[x1'[t]]) + 
   (1 - go[t])*x1'[t],
 Y[t] == 0, go[0] == 0, x1[0] == 0,
 WhenEvent[go[t] == 0 && Abs[-k m2 - m1 x0''[t]] > Fs, go[t] -> 1],
 WhenEvent[go[t] == 1 && x1'[t] < \[Epsilon], go[t] -> 0]},
{x0, x1, x2, Y}, {t, 0, T}, DiscreteVariables -> go, 
MaxSteps -> Infinity, SolveDelayed -> True];

Plot[{x0[t], x1[t] /. sol // Evaluate}, {t, 0, T}, Frame -> True]

It returns error code as below.

Which is actually a bit predictable because I tried to work around the algorithm using these 2 equations.

Y[t] == go[t]*(x1''[t] + k/m1 x2[t] + x0''[t] + Fk0/m1 Sign[x1'[t]]) +
  (1 -go[t])*x1'[t],
Y[t] == 0

I have no other idea on how to change the equation from

x1'[t]=0

to

x1''[t] = -k/m1 x2[t] - x0''[t] - Fk0/m1 Sign[x1'[t]]

EDIT 2
I got another code below inspired by Mathematica's stick slip Tutorial Here, I assumed $x{2}[t]=0$, to make it simpler.

Clear All;
T = 10;
A = 1;
Fk0 = 10;
m1 = 1;
x0[t_] = A Sin[2 Pi t];
Fk[t_] = -Fk0  Sign[x1'[t]];
Fs = 100;
e = 10^-5;
sol =
 NDSolve[{x1''[t] == If [stuck[t] == 1, 0, - x0''[t] + Fk[t]/m1], 
 x1[0] == 0, x1'[0] == 0,
 WhenEvent[Abs[x1'[t]] < e, 
  stuck[t] -> Boole[Abs[-m1 x0''[t]] < Fs]],
 WhenEvent[ -m1 x0''[t] < Fs, stuck[t] -> 0], stuck[0] == 0},
  {x1}, {t, 0, T}, DiscreteVariables -> stuck[t], 
 SolveDelayed -> True];
Plot[{x0''[t], x1[t] /. sol // Evaluate}, {t, 0, T}, Frame -> True]

But it returns error below:

$\endgroup$
  • 3
    $\begingroup$ The purpose of this site isn't solving your problems, but helping you to do that. Please post something nearer to Mathematica code and tell us about your problems with your implementation $\endgroup$ – Dr. belisarius Jan 29 '14 at 11:48
  • $\begingroup$ Also, just in case you haven't done it yet, take a look at WhenEvent[] $\endgroup$ – Dr. belisarius Jan 29 '14 at 14:53
  • $\begingroup$ Hi, just to let you guys know, I already have some code, but I still have not used When Event method. I will upload the code soon. $\endgroup$ – Dadan Ari Wibowo Jan 30 '14 at 6:46
  • $\begingroup$ Take a look here at the Static Friction model reference.wolfram.com/mathematica/ref/WhenEvent.html $\endgroup$ – Dr. belisarius Feb 3 '14 at 19:58
  • 1
    $\begingroup$ Just come to mention that Clear All; doesn't make any sense……What you need is Clear["`*"] $\endgroup$ – xzczd Feb 5 '14 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.