Get iterative solution of simultaneous differential equations?

Posted 1 year ago
1686 Views
|
8 Replies
|
3 Total Likes
|
 Dears, I try to implement a program for evaluating the behavior of the stator and rotor currents of a three-phase induction motor , through the Eule´rs method.The rotor is locked and thus s=1. Nonetheless, I have not succeeded in plotting them, simultaneously as well the rms value of the stator currentt. Would someone help me, please ? iL10 = iL11 = iL20 = iL21 = 0.0; iL2ef0 = iL2ef1 = 0.0; Delta = 0.0001; L1 = 5.0/(120.0*Pi); L2 = 5.0/(120.0*Pi); Lm = 20.0/(120*Pi); R1 = 1.5; R2 = 5; s = 1.0; Vmax = 220.0*Sqrt[2]; w = 120.0 Pi; tmax = 0.05; Phi = 0.0; t1 = 0.0; to = 0.0; ListPlot[Table[to = t1; iL10 = iL11; iL20 = iL21; iL2ef0 = iL2ef1; 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 ); iL2ef1 = Sqrt[ ( (iL2ef0^2)/(t1/Delta + 1) + (iL21^2) + (iL20^2))/(t1/ Delta + 2) ]; t1 = to + Delta; {t1, iL21}, {t1, 0, tmax, Delta}; {t1, iL11}, {t1, 0, tmax, Delta} ]] 
8 Replies
Sort By:
Posted 1 year ago
 The way you are writing the last few arguments to Table Table[ ... t1 = to + Delta; {t1, iL21}, {t1, 0, tmax, Delta}; {t1, iL11}, {t1, 0, tmax, Delta}] do not match the documentation for Table. Table[expr, {i, imin, imax, di}] Perhaps try this instead z = Table[... t1 = to + Delta; {t1, iL21, iL11}, {t1, 0, tmax, Delta}]; which produces a row of three items t1,iL21,iL11 for each t1 and then ListPlot uses the desired columns. ListPlot[{z[[All, {1, 2}]], z[[All, {1, 3}]]}] Then Sqrt[Mean[z[[All, 2]]^2]] and Sqrt[Mean[z[[All, 3]]^2]] will calculate the square root of the mean of the squares of iL21 and iL11Please check this carefully, perhaps on smaller examples, until you are certain that you trust that this is precisely correct.
Posted 1 year ago
 Dear Bill. Thank you very much and again, for your holy help.I really got confused with the resulting graphics from my proposition. One of them was correct, while the other not. You are right with the need in respecting the structure. But I thought a message of error should appear to my proposition... I suppose your suggestion creates a table of numbers that is somehow stored anywhere and I wonder if this can be a problem if the number of iterations goes too far. Gonna try it. Your proposition for the RMS gives a general result. But what if I want to evaluate the accumulated RMS value at each iteration? This is what I need. thank you so much !!!!!
Posted 1 year ago
 In fact, I would expect to have the graphics like this. Please, note that the blue line is the Rms value of iL2, the green sinusoidal.
Posted 1 year ago
 . il2sq = z[[All, 2]]^2; rmsiL2 = Table[{z[[i, 1]], Sqrt[Mean[Take[il2sq, i]]]}, {i, 1, Length[z]}]; Show[{ListPlot[z[[All, {1, 3}]], PlotStyle -> Green], ListPlot[z[[All, {1, 2}]], PlotStyle -> Orange], ListPlot[rmsiL2, PlotStyle -> Blue]}] 
Posted 1 year ago
 Bravissimo ! You are great ! Please, allow me mentioning that Mathematica language is not so intuitive as the programming languages used to be, some decades ago. Of course, this is to facilitate new and bigger achievements that are constantly demanded .
Posted 1 year ago
 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. 
 . ... rms = 0; z = Table[ ... rms = Sqrt[(rms^2*(t1/Delta) + iL21^2)/(t1/Delta + 1)]; {t1, iL21, iL11, rms}, {t1, 0, tmax, Delta}]; Show[{ListPlot[z[[All, {1, 3}]], PlotStyle -> Green], ListPlot[z[[All, {1, 2}]], PlotStyle -> Orange], ListPlot[z[[All, {1, 4}]], PlotStyle -> Blue]}] This attempts to do an "online" calculation or RMS, where each subsequent value depends only on the previous value. Please test all this very carefully until you are certain that I have made no mistakes. And study this until you can understand how and why I did what I did. That may help you when you need to make further changes.I am very concerned about the line t1 = to + Delta; that you have inside your Table when you also have {t1, 0, tmax, Delta} controlling the construction of your Table. This is not the way this is usually done. I would remove that t1 = to + Delta; unless you understand something about this that I do not see.You commented about how the Mathematica language is different from other languages that you have seen. The Mathematica language is much more different than you imagine it to be. Even when it looks somewhat like other languages, even when you have learned more about it and think you might understand it, it will still be much more different than you imagine it to be.