I'm solving a vibration problem. After solving two systems of ODEs (one valid in 0-0.1 and the other in 0.1-1) I get the plot of 3 functions, one of them is this, the plot of the variable $y_w$ (Image 1).
I want to see the natural frequencies of this vibration using Fourier transform and I used this code
{
setyw = {};
step = 0.0001;
While[ti < tf, ti = ti + step;
If[ti >= 0.1,
AppendTo[setyw, Evaluate[(yw[ti] /. sfreeNL)[[1, 1]]]],
AppendTo[setyw, Evaluate[(yw[ti] /. sNL)[[$1$]]]]]];
ListLinePlot[Abs[Fourier[setyw]], PlotRange -> Full]}
What I get from 0 to 1 with 0.0001 step is image 2. Which is totally not what I would expect, especially because if I just take a shorter interval, like from 0 to 0.5 I get image 3, which is exactly the same as before, one peak at the beginning and one peak at the end of the interval.
If I add some noise with this code
{
coeff = 1;
mag = 2;
setyw = {};
step = 0.01;
While[ti < tf, ti = ti + step;
If[ti >= 0.1,
AppendTo[setyw,
Evaluate[(yw[ti] /. sfreeNL)[[1, 1]]] +
coeff 10^-mag (RandomReal[] - 1/2)],
AppendTo[setyw,
Evaluate[(yw[ti] /. sNL)[[$1$]]] +
coeff 10^-mag (RandomReal[] - 1/2)]]];
ListLinePlot[Abs[Fourier[setyw]], PlotRange -> Full]}
I get image 4 and 5, which as you can see are symmetric in respect to the half of the interval.
How would you explain this? Is it a problem of code or maths?
Complete code:
Needs["DifferentialEquations`NDSolveProblems`"];
Needs["DifferentialEquations`NDSolveUtilities`"];
Clear["Global`*"];
mw = 40 ;
mv = 20; mp = 12; kw11 = 300000; kw12 = 300000; kw31 = 2000;
cw11 = 300; cw12 = 300; cw31 = 200;
lp = 1.3; lv = 1.4; L = 0.5; A = 0.3; H = 0.45; rp = 0.15; w = 0.01;
rv = 0.16; xG = (L^2 + A^2 + L A)/(3 (L + A));
yG = (H (2 L + A))/(3 (L + A));
lw2 = xG; lw1 = L + A - xG; hw = yG; hv = H - yG; P = 4000;
g = 9.81; M = rp P;
Iv = mv/12 (3 (rv^2 + (rv - w)^2) + lv^2);
Ipx = (mp rp^2)/2;
Ipz = mp/12 (3 rp^2 + lp^2);
Iw = mw (hw + hv)/(12) ((hw + hv)^2 (4 L + A) + 4 L^3 + 6 L^2 A + 4 L A^2 +A^3);
static = Solve[{ywst (kw11 lw1 -
kw12 lw2) + ϑwst (kw11 lw1^2 + kw12 lw2^2 -
kw31) - kw31 ϑvst - (mv +
mp) g hv ϑwst == 0,
ywst (kw11 + kw12) + ϑwst (kw11 lw1 -
kw12 lw2) + (mw + mv + mp) g == 0,
kw31 ϑwst + kw31 ϑvst ==
0}, {ywst, ϑwst, ϑvst}];
sNL = NDSolve[{(mw + mv + mp) yw''[
t] == (mv + mp) hv ϑw''[t] Sin[ϑw[t]] -
mp ξp[t] ϑw''[
t] Cos[ϑv[t]] + (mv + mp) hv (ϑw'[
t])^2 Cos[ϑw[t]] +
mp ξp[t] (ϑv'[t])^2 Sin[ϑv[t]] -
mp ξp'[t] ϑv'[
t] Cos[ϑv[
t]] - (yw[t] + (ywst /. static)[[1]]) (kw11 +
kw12) - (ϑw[t] + (ϑwst /. static)[[
1]]) (lw1 kw11 - lw2 kw12) +
yw'[t] (cw11 + cw12) + ϑw'[
t] (cw11 lw1 - cw12 lw2) - (mw + mv + mp) g,
(Iw + Ipz + Iv + (mp + mv) hv^2) ϑw''[
t] == -(Ipz +
mp hv ξp[
t] (Sin[ϑv[t]] Cos[ϑw[t]] -
Sin[ϑw[t]] Cos[ϑv[
t]])) ϑv''[t] + (mv + mp) hv yw''[
t] Sin[ϑw[t]] +
mp hv ξp''[
t] (Cos[ϑv[t]] Cos[ϑw[t]] +
Sin[ϑw[t]] Sin[ϑv[t]]) -
2 mp hv ξp'[
t] (ϑw'[
t] Sin[ϑw[t]] Cos[ϑv[
t]] - ϑv'[
t] Sin[ϑw[t]] Cos[ϑv[t]]) -
mp hv ξp[
t] (ϑv'[
t])^2 (Cos[ϑv[t]] Cos[ϑw[t]] -
Sin[ϑw[t]] Sin[ϑv[t]]) - (yw[
t] + (ywst /. static)[[1]]) (kw11 lw1 -
kw12 lw2) - (ϑw[
t] + (ϑwst /. static)[[1]]) (lw1^2 kw11 +
lw2^2 kw12 + kw31) +
kw31 (ϑv[t] + (ϑvst /. static)[[1]]) -
yw'[t] (-cw11 lw1 + cw12 lw2) + ϑw'[
t] (cw11 lw1^2 + cw12 lw2^2 + cw31) -
cw31 ϑv'[
t] + (mv +
mp) g hv Sin[ϑw[
t] + (ϑwst /. static)[[1]]],
(Iv + Ipz + mp (ξp[t])^2) ϑv''[
t] == -mp ξp[t] yw''[
t] Cos[ϑv[t]] - (Iv + Ipz +
mp hv ξp[
t] (Cos[ϑw[t]] Sin[ϑv[t]] -
Sin[ϑw[t]] Cos[ϑv[
t]])) ϑw''[t] -
2 mp ξp[t] ξp'[t] ϑv'[t] -
mp hv ξp[
t] (ϑw'[
t])^2 (Cos[ϑv[t]] Cos[ϑw[t]] +
Sin[ϑw[t]] Sin[ϑv[t]]) -
kw31 (ϑv[t] + (ϑvst /. static)[[
1]] - (ϑwst /. static)[[1]] - ϑw[
t]) + cw31 (ϑv'[t] - ϑw'[t]) -
mp g ξp[
t] Cos[ϑv[t] + (ϑvst /. static)[[
1]]],
mp ξp''[t] ==
mp hv ϑv''[
t] (Cos[ϑv[t]] Cos[ϑw[t]] +
Sin[ϑw[t]] Sin[ϑv[t]]) -
mp yw''[t] Sin[ϑw[t]] -
mp hv (ϑw'[
t])^2 (Sin[ϑw[t]] Cos[ϑv[t]] -
Sin[ϑv[t]] Cos[ϑw[t]]) -
mp ξp[t] (ϑv'[t])^2 -
mp g Sin[ϑv[t] + (ϑvst /. static)[[
1]]] + P, yw[0] == (ywst /. static)[[1]],
yw'[0] ==
0, ϑw[0] == (ϑwst /. static)[[
1]], ϑw'[0] == 0, ϑv[0] ==
0.1, ϑv'[0] == 0, ξp[0] == 0, ξp'[0] ==
0}, {yw, ϑw, ϑv, ξp}, {t, 0, 0.1},
Method -> {"EquationSimplification" -> "Residual"}, MaxSteps -> Infinity];
yw1 = Evaluate[yw[0.1] /. sNL];
[CurlyTheta]w1 = Evaluate[ϑw[0.1] /. sNL];
[CurlyTheta]v1 = Evaluate[ϑv[0.1] /. sNL];
dyw1 = Evaluate[yw'[0.1] /. sNL];
dϑw1 = Evaluate[ϑw'[0.1] /. sNL];
dϑv1 = Evaluate[ϑv'[0.1] /. sNL];
sfreeNL =
NDSolve[{(mw + mv) yw''[t] + (mw + mv) (lw1 - lw2) ϑw''[
t] - (mw + mv) g + (kw11 + kw12) yw[
t] + (lw1 kw11 - lw2 kw12) ϑw[
t] + (cw11 + cw12) yw'[
t] + (lw1 cw11 - lw2 cw12) ϑw'[t] == 0,
(mw + mv) (lw1 - lw2) yw''[
t] + ((mw + mv) (lw1 - lw2)^2 + Iw + Iv +
mv hv^2) ϑw''[
t] - (mw + mv) g (lw1 - lw2) + (kw11 lw1 - kw12 lw2) yw[
t] + (kw11 lw1^2 + kw12 lw2^2) ϑw[t] -
kw31 (ϑv[t] - ϑw[t]) + (cw11 lw1 -
cw12 lw2) yw'[
t] + (cw11 lw1^2 + cw12 lw2^2 + cw31) ϑw'[t] -
cw31 ϑv'[t] == 0,
Iv ϑv''[t] +
kw31 (ϑv[t] - ϑw[t]) +
cw31 (ϑv'[t] - ϑw'[t]) == 0,
yw[0.1] == yw1,
yw'[0.1] ==
dyw1, ϑw[0.1] == ϑw1, ϑw'[
0.1] == dϑw1, ϑv[
0.1] == ϑv1, ϑv'[0.1] ==
dϑv1}, {yw, ϑw, ϑv}, {t, 0.1,
1}, Method -> {"ExplicitRungeKutta"}, MaxSteps -> Infinity];
p1 = Plot[Evaluate[yw[x] /. sNL], {x, 0, 0.1}, PlotRange -> All,
AxesLabel -> {t, Subscript[y, w]},
LabelStyle -> Directive[Red, Medium], PlotStyle -> Thick];
p2 = Plot[Evaluate[ϑw[x] /. sNL], {x, 0, 0.1},
PlotRange -> All, AxesLabel -> {t, Subscript[ϑ, w]},
LabelStyle -> Directive[Red, Medium], PlotStyle -> Thick];
p3 = Plot[Evaluate[ϑv[x] /. sNL], {x, 0, 0.1},
PlotRange -> All, AxesLabel -> {t, Subscript[ϑ, v]},
LabelStyle -> Directive[Red, Medium], PlotStyle -> Thick];
p4 = Plot[Evaluate[ξp[x] /. sNL], {x, 0, 0.1}, PlotRange -> All,
AxesLabel -> {t, Subscript[ξ, p]},
LabelStyle -> Directive[Red, Medium], PlotStyle -> Thick];
p12 = Plot[Evaluate[yw[x] /. sfreeNL], {x, 0.1, 1}, PlotRange -> All,
AxesLabel -> {t, Subscript[y, w]},
LabelStyle -> Directive[Red, Medium], PlotStyle -> Thick];
p22 = Plot[Evaluate[ϑw[x] /. sfreeNL], {x, 0.1, 1},
PlotRange -> All, AxesLabel -> {t, Subscript[ϑ, w]},
LabelStyle -> Directive[Red, Medium], PlotStyle -> Thick];
p32 = Plot[Evaluate[ϑv[x] /. sfreeNL], {x, 0.1, 1},
PlotRange -> All, AxesLabel -> {t, Subscript[ϑ, v]},
LabelStyle -> Directive[Red, Medium], PlotStyle -> Thick];
Show[p1, p12]
Show[p2, p22]
Show[p3, p32]
ti = Input["starting time? (minimo 0)"];
tf = Input["final time? (max 1)"];
setyw = {};
step = Input["which step?"];
While[ti < tf, ti = ti + step;
If[ti >= 0.1,
AppendTo[setyw, Evaluate[(yw[ti] /. sfreeNL)[[1, 1]]]],
AppendTo[setyw, Evaluate[(yw[ti] /. sNL)[[1]]]]]];
ListLinePlot[Abs[Fourier[setyw]], PlotRange -> Full]
Here is a link to the file:
https://drive.google.com/file/d/0B-w5qQPBHkwLZEFyYTU4blZTN3M/view?usp=sharing




{}button to format it. I think posting the code here without input dialogues is handier. – Feyre Aug 14 '16 at 12:15Periodogram. You may just be confused about the location of the zero frequency (it's at the left), and if you data is real-valued, then you would expect the symmetry of the Fourier components at positive and negative frequencies (in magnitude). The right half of the output ofFouriercorresponds to the negative frequencies. – Jens Aug 14 '16 at 17:09