Dear Bill, maybe you help me for my last lap !
During each iteration, I need to take the rms value of the current iL2 at that time, for evaluating the power and thus the torque given by the motor. I mean, I cannot wait until the end of all the calculations for taking the general rms value of iL2. I need to do it during each iteration.Please, how can I do that ?
Thank you in advance,
Scabral
iL10 = iL11 = iL20 = iL21 = 0.0;
iL2ef0 = 0.0001; Delta = 0.0001;
J = 0.5;
wr0 = 0.0;
tau = 0.03;
L1 = 5.0/(120.0*Pi); L2 = 5.0/(120.0*Pi); Lm = 20.0/(120*Pi); m = 0;
R1 = 1.5; R2 = 5; s = 1.0;
Vmax = 220.0*Sqrt[2];
w = 120.0 Pi; tmax = 0.01; Phi = 0.0; t1 = 0.0; to = 0.0;
z = Table[to = t1; iL10 = iL11; iL20 = iL21; wr0 = wr1;
iL11 =
iL10 + (Delta *( L2 + Lm)/( L1*L2 + L2*Lm + L1*Lm))*(Vmax *
Sin[w *to + Phi* Pi/180.0] -
R1*iL10 - (Lm/(L2 + Lm))*R2 *iL20 /s);
iL21 =
iL20 + (Delta /( L2 + Lm))*(
Lm*( L2 + Lm)/(
L1 *L2 + L2 *Lm + L1*Lm)*(Vmax *
Sin[w *to + Phi* Pi/180.0] -
R1*iL10 - (Lm/(L2 + Lm))*R2 *iL20 /s) - R2* iL20 / s );
il2sq = z[[All, 2]]^2;
rmsiL2 =
Table[{z[[i, 1]], Sqrt[Mean[Take[il2sq, i]]]}, {i, 1, Length[z]}];
wr1 = wr0 +
Delta*((3*R2*rmsiL2[[1, 1]]^2)/(120.0*Pi*s) - tau*wr0)/J;
s = (120*Pi - wr1)/(120*Pi);
t1 = to + Delta;
{to, iL11, iL21, rmsiL2, wr1}, {to, 0, tmax, Delta}];
how[{ListPlot[z[[All, {1, 3}]], PlotStyle -> Green],
ListPlot[z[[All, {1, 2}]], PlotStyle -> Orange],
ListPlot[rmsiL2, PlotStyle -> Blue]},
PlotRange -> {{0, tmax}, {-50, 50}}]
Show[{ListPlot[z[[All, {1, 3}]], PlotStyle -> Green],
ListPlot[z[[All, {1, 4}]], PlotStyle -> Orange]}]
Messages of errors :
Mean::rectt: Rectangular array expected at position 1 in Mean[{0.,{}}].
Mean::rectt: Rectangular array expected at position 1 in Mean[{0.,{},{}}].
Mean::rectt: Rectangular array expected at position 1 in Mean[{0.,{},{},{}}].
General::stop: Further output of Mean::rectt will be suppressed during this calculation.