1
$\begingroup$

i have assigned all the values and the ODE assigned is as this

equa00=0. - Piecewise[{{1.76 + (1/2)*(17.823981400755596 + 3.1865569652622434*Derivative[2][x][t] + 2*(11.76 + 1.2*Derivative[2][x][t])), Derivative[1][x][t] >= 0}, {1.76 + 40*(0.010436534400000001*Derivative[2][x][t] + (1/40)*(11.76 + 1.2*Derivative[2][x][t])), Derivative[1][x][t] < 0}}, 0] + 315.57298205309473*(0.08*Cos[2.7152918354276516*t] - x[t]) - 18.993139260437836*Cos[2.7152918354276516*t]*(0.04347647225924945 + 0.08*Cos[2.7152918354276516*t] - x[t]) +12.880529879718154*Abs[-0.21722334683421213*Sin[2.7152918354276516*t] - Derivative[1][x][t]]*(-0.21722334683421213*Sin[2.7152918354276516*t] - Derivative[1][x][t]) +32.201324699295384*Piecewise[{{0.82175436428797895737596225718394`31.91474201927165, Derivative[1][x][t] >= 0 || Derivative[1][x][t] < 0}}, 0]*(0.04347647225924945 + 0.08*Cos[2.7152918354276516*t] - x[t])*(-0.5898247801232052*Cos[2.7152918354276516*t] - Derivative[2][x][t]) == 1.4*Derivative[2][x][t]


ts = 50;

(*the initial values will affect if it will converge*)
s1 = NDSolve[{equa00, x[0] == 0, x'[0] == 0}, x, {t, 0, ts}, 
  SolveDelayed -> True]

picture2 = Plot[x[t] /. s1, {t, 0, ts}, PlotRange -> All]
picture3 = Plot[x'[t] /. s1, {t, 0, ts}, PlotRange -> All]

but the hints are

NDSolve::ndcf: Repeated convergence test failure at t == 0.`; unable to continue. >>

and when the initial values changes,for example change it to x[0] == 0, x'[0] == 0.1 or x[0] == 0.1, x'[0] == 0,the hints will change,so hwo to deal with it?

and the codes were run in version 7

$\endgroup$
1
1
$\begingroup$

OK, let me turn the fruit of the discussion in chat to an answer. The following solution works in v7:

approx = With[{k = 1000}, 1/Pi ArcTan[k #] + 1/2 &];
s1 = NDSolve[{Simplify`PWToUnitStep@equa00 /. UnitStep -> approx, x[0] == 0, x'[0] == 0},
    x, {t, 0, ts}, SolveDelayed -> True, MaxSteps -> Infinity][[1]]

The idea is not complicated: rewrite the Piecewise function with UnitStep, then replace UnitStep with its continuous approximation approx, so DAE solver of NDSolve (triggered by SolveDelayed -> True) can handle the problem easier.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.