Questions regarding the use of nested forloop hasFor-loops have been posted for a few times on StackExchange. However, I think that the solutions to those questions are not really applicable to what I am trying to do here. I am trying to use a nested for loopFor-loops in NDSolve, which somehow does not work.
One of the methodmethods included in the solution to other similar problems include things like putting If in whichWhich, and that. That does not seem to work for me.
TheMy code is attached below:
ClearAll["Global`*"] z[t_] := y[t] - l Cos[\[CurlyPhi][t]];Cos[φ[t]]; n[t_] := k Abs[z[t]]^(3/2) - c z'[t]; R = 0.0238; k = 141000000; c = 20; g = 9.81; \[Mu]kμk = 0.1804; i = 8.92958*10^-6; m = 0.035; l = R Sqrt[2 (1 + Sin[(1/2) \[Pi]π - 2*0.41])]; a = NDSolve[{m y''[t] == {m y''[t] == n[t] - m g, \[CurlyPhi]''[ t]φ''[t] == (n[t]*l*Sin[\[CurlyPhi][t]]n[t]*l*Sin[φ[t]] + m x''[t]*l*Cos[\[CurlyPhi][t]]x''[t]*l*Cos[φ[t]])/i, x''[t] == If[(x[t] - l*\[CurlyPhi][t]l*φ[t] == 0) // Evaluate, l (\[CurlyPhi]''[ l t](φ''[t] Cos[\[CurlyPhi][t]]Cos[φ[t]] - \[CurlyPhi]'[t]^2 Sin[\[CurlyPhi][ φ'[t]^2 t]]Sin[φ[t]]) // Evaluate, If[x[t] - l*\[CurlyPhi][t]l*φ[t] > 0, -\[Mu]k*n[t]μk*n[t]/m // Evaluate, -\[Mu]k*n[t]μk*n[t]/m // Evaluate]], y[0] == l*Cos[0.41], y'[0] == -2.22, \[CurlyPhi][0] φ[0] == 0.41, \[CurlyPhi]'[0]φ'[0] == -50, x[0] == 0, x'[0] == 0, WhenEvent[z[t] == 0 // Evaluate, "StopIntegration"; Print[y'[t]]; Print[\[CurlyPhi]'[t]]] "StopIntegration"; Print[y'[t]]; Print[φ'[t]]]}, {y'[t], y[t], x[t], x'[t], \[CurlyPhi][t]φ[t], \[CurlyPhi]'[t]φ'[t], z[t], n[t], \[CurlyPhi]''[t]φ''[t]}, {t, 0, 0.2}, Method -> {"EquationSimplification" -> "Residual", "DiscontinuityProcessing" -> False}, AccuracyGoal -> Automatic, WorkingPrecision -> MachinePrecision, MaxSteps -> 100000000, PrecisionGoal -> Automatic] x''[t] == If[(x[t] - l*\[CurlyPhi][t]l*φ[t] == 0) // Evaluate, l (\[CurlyPhi]''[ l t](φ''[t] Cos[\[CurlyPhi][t]]Cos[φ[t]] - \[CurlyPhi]'[t]^2 Sin[\[CurlyPhi][ φ'[t]^2 t]]Sin[φ[t]]) // Evaluate, If[x[t] - l*\[CurlyPhi][t]l*φ[t] > 0, -\[Mu]k*n[t]μk*n[t]/m // Evaluate, -\[Mu]k*n[t]μk*n[t]/m // Evaluate]], It would be great if anyone can help. Thanks in advance.
Edit
Edit: I am trying to simulate a bounce of an object through these equationsthis equation. I have the equation describing the motion along the y axis, x axis and rotation respectively. However, for the motion along the x axis-axis, it would be piecewise as during the collision, there may be both static friction and kinetic friction (so. I have to take both into account of both) And under. Under kinetic friction, it will be either in the positive or negative direction depending on the relative motion between contact point and ground. (thatsThat's why there is aare nested if, the main ifIf expressions. The outer If is to differentiate between static and kinetic friction, while the nested ifinner If is to differentiate between positive and negative kinetic friction ).