Hello. After running the attached code by substituting random values into model, I get quite a few errors, namely Part::partw:, Set::partw:, Rule::argr:,NDSolveValue::ndode: . I would greatly appreciate any help!
M = 23.58/1000;
l = 0.9;
Ms = (2*2.02)/1000 Sqrt[l^2 - 0.4^2];
NN = 10;
dl = Sqrt[l^2 - 0.4^2]/NN;
g = 9.81;
e = 0.9229372872377224;
m[n_] := If[n == NN, M, Ms/(NN - 1)];
r[n_, t_] :=
Sum[UnitVector[3, 1]*dl Sin[\[Theta][i, t]] -
UnitVector[3, 3]*dl Cos[\[Theta][i, t]], {i, n}];
rdot[n_, t_] := D[r[n, t], t];
tt[t_] := 1/2 Sum[m[n]*Total[rdot[n, t]^2], {n, NN}];
vv[t_] := g*Sum[m[n]*r[n, t][[3]], {n, NN}];
ll[t_] := tt[t] - vv[t];
rr[t_] :=
1/2 kvc*Sum[(D[\[Theta][n, t], t] - D[\[Theta][n - 1, t], t])^2, {n,
2, NN}];
airdamp[t_] := 1/2 cd*Total[rdot[NN, t]^2];
eqLag[k_] :=
D[D[ll[t], D[\[Theta][k, t], t]], t] -
D[ll[t], \[Theta][k, t]] == -D[rr[t], D[\[Theta][k, t], t]];
lastpend :=
D[D[ll[t], D[\[Theta][NN, t], t]], t] -
D[ll[t], \[Theta][NN, t]] == -D[airdamp[t],
D[\[Theta][NN, t], t]] - D[rr[t], D[\[Theta][NN, t], t]];
eqs = Join[Table[eqLag[k], {k, NN - 1}], {lastpend} ];
initialData =
Flatten[Table[{\[Theta][k, 0] == ArcTan[0.423/-0.723],
Derivative[0, 1][\[Theta]][k, 0] == 0}, {k, NN}]];
model[cd_?NumberQ, kvc_?NumberQ] :=
Module[{\[Theta], t},
NDSolveValue[Flatten@{eqs, initialData},
Table[\[Theta][k, t], {k, NN}], {t, 0, 75.272},
Method -> {"EquationSimplification" -> "Residual"},
StartingStepSize -> 10^-6, MaxStepFraction -> 1/100000,
MaxStepSize -> 10^-6, MaxSteps -> Infinity]]
model[1, 1]