I'm trying to reslove a differential equation with one of the coefficents depending on the dependent variable, it's a simple dynamic system, with one of the coefficients that can assume 2 values: The model I have to solve is a classic mass-spring-damper model, but the spring has two values, the first is when the spring is compressed (k) and the second is when the spring is stretched and depend on a coefficient that represent the level of damage of the system (alp). Here is the code that iI wrote
Model[X_, t_, f1_, f2_, T_, m_, c_, k_, alp_] :=
Module[{L = Log[f2/f1], Mol}, If[X <= 0, Mol = k, Mol = k - alp*k];
Return[m X''[t] + c X'[t] + Mol X[t] ==
Sin[2*Pi*f1*T/L*(Exp[t/T*L] - 1)]]];
fCamp = 563;
T = 8.86;
step = 1/fCamp;
fMin = 2.25;
fMax = 225;
Mas = 1;
Smorz = 2;
Mol = 20000;
Dann = 0.45;
sol =
NDSolve[{Model[x, t, fMin, fMax, T, Mas, Smorz, Mol, Dann],
x[0] == 0, x'[0] == 0}, x, {t, 0, 10},
, MaxStepSize -> step]
But NDSolve gives me this error:
NDSolve::nlnum: The function value {1.28415*10^-9,0.000210658 -1.27571*10^-14 Mol$33139} is not a list of numbers with dimensions {2} at {t,x[t],(x^\[Prime])[t]} = {0.0000149012,1.27571*10^-14,1.28415*10^-9}.
Can someone help me? The purpose of this program is to solve the differential equation:
mx''[t]+cx''[t]+k(x[t])x[t]=F[t]
with k(x[t]):=If(x<=0,k',k'(1-alp))
Given the nature of this differential equation, Non linear behaviour should be showed.
Model[x, t, fMin, fMax, T, Mas, Smorz, Mol, Dann]
to see what ode you are integrating. It's not clear to me what you want, but it is clear to me that the error is in theIf[..]
statement. Specifically,X <= 0
will never be true and never be false, becauseX
is just the symbolx
, which is not a number. Possibly you might makeMol
bePiecewise[{{k, x[t] <= 0}}, k - alp*k]
and get what you want. $\endgroup$