Message Boards Message Boards

0
|
4306 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Inserting conditions on dynamics system

Posted 9 years ago

Hi, guys I have a problem here on how should I add a condition for variable "A" as shown in the image highlighted in red under equation 4 (eq4). The condition I would like to set is that "A" equals "(b/m)p'[t] + (k/m)(p[t]-0.5) when "(p[t] >= l/2)" and "A" equals to zero when "(p[t] < l/2)" .

I've inserted the program file below and hopefully you all can paste it in your nb file and try to check it for me. I truly appreciate your help here a lot.

Thanks again

Best regards, Aaron Aw`

{\[Mu], m, b, k, l, r0, g0} = {3.9877848*10^14, 1, 0.054, 0.0001, 5, 
   7178000, 9.81};

r = Sqrt[(u[t]^2 + (v[t] + r0)^2)];
n = Sqrt[(\[Mu]/r^3)]
n2 = Sqrt[(\[Mu]/r0^3)]
g = (\[Mu]/r^2);
\[Xi] = 2 p[t]/r;
T = (2 \[Pi])/n;


fu = -g (u[t]/r) + 
   g \[Xi]^2 (3/8 (5 Sin[\[Phi][t]]^2 - 2) (u[t]/r) + 
      3/4 Sin[\[Phi][
         t]] (((v[t] + r0)/r) Cos[\[Phi][t]] - (u[t]/
           r) Sin[\[Phi][t]]));
fv = -g ((v[t] + r0)/r) + 
   g \[Xi]^2 (3/8 (5 Sin[\[Phi][t]]^2 - 2) ((v[t] + r0)/r) + 
      3/4 Sin[\[Phi][
         t]] ((u[t]/r) Cos[\[Phi][t]] + ((v[t] + r0)/
           r) Sin[\[Phi][t]]));

BB = -(u[t]/r^2) Derivative[1][v][t] - 
   n2 (u[t]/r) + (Derivative[1][u][t] + n2 ( v[t] + r0)) ((v[t] + r0)/
     r^2); (*thetadot*)
CC = ((v[t] + r0)/r^2) Derivative[1][v][t] - 
   n2 u[t] + (Derivative[1][u][t] + n2 ( v[t] + r0)) (u[t]/r); (*rdot*)


DD = -(u[t]/r^2) fv + ((v[t] + r0)/r^2) fu - (2 BB CC)/r;


A[t] = b/m Derivative[1][p][t] + k/m (p[t] - l/2);

eq1 = (u^\[Prime]\[Prime])[t] + 2 n2 Derivative[1][v][t] - n2^2 u[t] -
    fu;
   eq2 = (v^\[Prime]\[Prime])[t] - 2 n2 Derivative[1][u][t] - 
   n2^2 v[t] - fv - g0;
eq3 = (\[Phi]^\[Prime]\[Prime])[t] + 3 n^2 Sin[ 2 \[Phi][t]]/2 + 
   DD + ((2 Derivative[1][p][t])/p[t]) (BB + Derivative[1][\[Phi]][t]);
eq4 = (p^\[Prime]\[Prime])[t] + A[t] - 
   p[t] (BB + Derivative[1][\[Phi]][t])^2 - 
   g \[Xi] (3 Cos[\[Phi][t]]^2 - 1)/2 + 
   g \[Xi]^3 (15 Cos[\[Phi][t]]^2 - 3)/16;


system1 = 
  NDSolve[{eq1 == 0, eq2 == 0, eq3 == 0, eq4 == 0, 
    u[0] == 0.05*Sin[1.3963], u'[0] == 0, v[0] == 0.05*Cos[1.3963], 
    Derivative[1][v][0] == 0, p[0] == 0.05, 
    Derivative[1][p][0] == 0.001, \[Phi][0] == 1.3963, 
    Derivative[1][\[Phi]][0] == 0}, { u, v, p, \[Phi]}, {t, 0, T}, 
   MaxSteps -> Infinity];


ParametricPlot[ Evaluate[{v[t], u[t]} /. system1], {t, 0, 80000}, 
 ImageSize -> {400, 300}, PlotStyle -> {Blue}, 
 LabelStyle -> Directive[12]]
POSTED BY: Aaron Aw

Hi

when I past your commands into Mathematica I get an error message. But I guess that what you need is WhenEvent.

Cheers, Marco

POSTED BY: Marco Thiel
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