89 | | <a name="l00031"></a><a class="code" href="classIMpmsm.html#45785869d978dda42828a072ec2caebe">00031</a> vec <a class="code" href="classIMpmsm.html#45785869d978dda42828a072ec2caebe" title="Evaluates .">eval</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0 ) { |
90 | | <a name="l00032"></a>00032 <span class="comment">// last state</span> |
91 | | <a name="l00033"></a>00033 <span class="keyword">const</span> <span class="keywordtype">double</span> &iam = x0 ( 0 ); |
92 | | <a name="l00034"></a>00034 <span class="keyword">const</span> <span class="keywordtype">double</span> &ibm = x0 ( 1 ); |
93 | | <a name="l00035"></a>00035 <span class="keyword">const</span> <span class="keywordtype">double</span> &omm = x0 ( 2 ); |
94 | | <a name="l00036"></a>00036 <span class="keyword">const</span> <span class="keywordtype">double</span> &thm = x0 ( 3 ); |
95 | | <a name="l00037"></a>00037 <span class="keyword">const</span> <span class="keywordtype">double</span> &uam = u0 ( 0 ); |
96 | | <a name="l00038"></a>00038 <span class="keyword">const</span> <span class="keywordtype">double</span> &ubm = u0 ( 1 ); |
97 | | <a name="l00039"></a>00039 |
98 | | <a name="l00040"></a>00040 vec xk( 4 ); |
99 | | <a name="l00041"></a>00041 <span class="comment">//ia</span> |
100 | | <a name="l00042"></a>00042 xk ( 0 ) = ( 1.0- Rs/Ls*dt ) * iam + Ypm/Ls*dt*omm * sin ( thm ) + uam*dt/Ls; |
101 | | <a name="l00043"></a>00043 <span class="comment">//ib</span> |
102 | | <a name="l00044"></a>00044 xk ( 1 ) = ( 1.0- Rs/Ls*dt ) * ibm - Ypm/Ls*dt*omm * cos ( thm ) + ubm*dt/Ls; |
103 | | <a name="l00045"></a>00045 <span class="comment">//om</span> |
104 | | <a name="l00046"></a>00046 xk ( 2 ) = omm + kp*p*p * Ypm/J*dt* ( ibm * cos ( thm )-iam * sin ( thm ) ) - p/J*dt*Mz; |
105 | | <a name="l00047"></a>00047 <span class="comment">//th</span> |
106 | | <a name="l00048"></a>00048 xk ( 3 ) = thm + omm*dt; <span class="comment">// <0..2pi></span> |
107 | | <a name="l00049"></a>00049 <span class="keywordflow">if</span> ( xk ( 3 ) >pi ) xk ( 3 )-=2*pi; |
108 | | <a name="l00050"></a>00050 <span class="keywordflow">if</span> ( xk ( 3 ) <-pi ) xk ( 3 ) +=2*pi; |
109 | | <a name="l00051"></a>00051 <span class="keywordflow">return</span> xk; |
110 | | <a name="l00052"></a>00052 } |
111 | | <a name="l00053"></a>00053 |
112 | | <a name="l00054"></a><a class="code" href="classIMpmsm.html#b4378b5d3bf64c683e4cf5c5f1cd56f1">00054</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsm.html#b4378b5d3bf64c683e4cf5c5f1cd56f1" title="Evaluates and writes result into A .">dfdx_cond</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0, mat &A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) { |
113 | | <a name="l00055"></a>00055 <span class="keyword">const</span> <span class="keywordtype">double</span> &iam = x0 ( 0 ); |
114 | | <a name="l00056"></a>00056 <span class="keyword">const</span> <span class="keywordtype">double</span> &ibm = x0 ( 1 ); |
115 | | <a name="l00057"></a>00057 <span class="keyword">const</span> <span class="keywordtype">double</span> &omm = x0 ( 2 ); |
116 | | <a name="l00058"></a>00058 <span class="keyword">const</span> <span class="keywordtype">double</span> &thm = x0 ( 3 ); |
117 | | <a name="l00059"></a>00059 <span class="comment">// d ia</span> |
118 | | <a name="l00060"></a>00060 A ( 0,0 ) = ( 1.0- Rs/Ls*dt ); A ( 0,1 ) = 0.0; |
119 | | <a name="l00061"></a>00061 A ( 0,2 ) = Ypm/Ls*dt* sin ( thm ); A ( 0,3 ) = Ypm/Ls*dt*omm * ( cos ( thm ) ); |
120 | | <a name="l00062"></a>00062 <span class="comment">// d ib</span> |
121 | | <a name="l00063"></a>00063 A ( 1,0 ) = 0.0 ; A ( 1,1 ) = ( 1.0- Rs/Ls*dt ); |
122 | | <a name="l00064"></a>00064 A ( 1,2 ) = -Ypm/Ls*dt* cos ( thm ); A ( 1,3 ) = Ypm/Ls*dt*omm * ( sin ( thm ) ); |
123 | | <a name="l00065"></a>00065 <span class="comment">// d om</span> |
124 | | <a name="l00066"></a>00066 A ( 2,0 ) = kp*p*p * Ypm/J*dt* ( - sin ( thm ) ); |
125 | | <a name="l00067"></a>00067 A ( 2,1 ) = kp*p*p * Ypm/J*dt* ( cos ( thm ) ); |
126 | | <a name="l00068"></a>00068 A ( 2,2 ) = 1.0; |
127 | | <a name="l00069"></a>00069 A ( 2,3 ) = kp*p*p * Ypm/J*dt* ( -ibm * sin ( thm )-iam * cos ( thm ) ); |
128 | | <a name="l00070"></a>00070 <span class="comment">// d th</span> |
129 | | <a name="l00071"></a>00071 A ( 3,0 ) = 0.0; A ( 3,1 ) = 0.0; A ( 3,2 ) = dt; A ( 3,3 ) = 1.0; |
130 | | <a name="l00072"></a>00072 } |
131 | | <a name="l00073"></a>00073 |
132 | | <a name="l00074"></a><a class="code" href="classIMpmsm.html#c3f8dad22ae9855c04a1d593b45c99b5">00074</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsm.html#c3f8dad22ae9855c04a1d593b45c99b5" title="Evaluates and writes result into A .">dfdu_cond</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0, mat &A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) {it_error ( <span class="stringliteral">"not needed"</span> );}; |
133 | | <a name="l00075"></a>00075 |
134 | | <a name="l00076"></a>00076 }; |
135 | | <a name="l00077"></a>00077 |
136 | | <a name="l00079"></a><a class="code" href="classIMpmsm2o.html">00079</a> <span class="keyword">class </span><a class="code" href="classIMpmsm2o.html" title="State evolution model for a PMSM drive and its derivative with respect to .">IMpmsm2o</a> : <span class="keyword">public</span> <a class="code" href="classIMpmsm.html" title="State evolution model for a PMSM drive and its derivative with respect to .">IMpmsm</a> { |
137 | | <a name="l00080"></a>00080 <span class="keyword">protected</span>: |
138 | | <a name="l00081"></a>00081 <span class="comment">// double Rs, Ls, dt, Ypm, kp, p, J, Mz;</span> |
139 | | <a name="l00083"></a><a class="code" href="classIMpmsm2o.html#5b668744a1e5189f324897a62b9c3ea6">00083</a> <span class="comment"></span> <span class="keywordtype">double</span> <a class="code" href="classIMpmsm2o.html#5b668744a1e5189f324897a62b9c3ea6" title="store first derivatives for the use in second derivatives">dia</a>, dib, dom, dth; |
140 | | <a name="l00085"></a><a class="code" href="classIMpmsm2o.html#74954dedce055db9ee50d53790e8341c">00085</a> <span class="keywordtype">double</span> <a class="code" href="classIMpmsm2o.html#74954dedce055db9ee50d53790e8341c" title="d2t = dt^2/2, cth = cos(th), sth=sin(th)">d2t</a>, cth, sth; |
141 | | <a name="l00086"></a>00086 <span class="keywordtype">double</span> iam, ibm, omm, thm, uam, ubm; |
142 | | <a name="l00087"></a>00087 <span class="keyword">public</span>: |
143 | | <a name="l00088"></a>00088 <a class="code" href="classIMpmsm2o.html" title="State evolution model for a PMSM drive and its derivative with respect to .">IMpmsm2o</a>() :<a class="code" href="classIMpmsm.html" title="State evolution model for a PMSM drive and its derivative with respect to .">IMpmsm</a> () {}; |
144 | | <a name="l00090"></a><a class="code" href="classIMpmsm2o.html#abdefc0467678a05abf12f5c77eaf49d">00090</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsm2o.html#abdefc0467678a05abf12f5c77eaf49d" title="Set mechanical and electrical variables.">set_parameters</a> ( <span class="keywordtype">double</span> Rs0, <span class="keywordtype">double</span> Ls0, <span class="keywordtype">double</span> dt0, <span class="keywordtype">double</span> Ypm0, <span class="keywordtype">double</span> kp0, <span class="keywordtype">double</span> p0, <span class="keywordtype">double</span> J0, <span class="keywordtype">double</span> Mz0 ) {Rs=Rs0; Ls=Ls0; dt=dt0; Ypm=Ypm0; kp=kp0; p=p0; J=J0; Mz=Mz0; <a class="code" href="classIMpmsm2o.html#74954dedce055db9ee50d53790e8341c" title="d2t = dt^2/2, cth = cos(th), sth=sin(th)">d2t</a>=dt*dt/2;} |
145 | | <a name="l00091"></a>00091 |
146 | | <a name="l00092"></a><a class="code" href="classIMpmsm2o.html#86e04b5118e567ea7a2540059f553f41">00092</a> vec <a class="code" href="classIMpmsm2o.html#86e04b5118e567ea7a2540059f553f41" title="Evaluates .">eval</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0 ) { |
147 | | <a name="l00093"></a>00093 <span class="comment">// last state</span> |
148 | | <a name="l00094"></a>00094 iam = x0 ( 0 ); |
149 | | <a name="l00095"></a>00095 ibm = x0 ( 1 ); |
150 | | <a name="l00096"></a>00096 omm = x0 ( 2 ); |
151 | | <a name="l00097"></a>00097 thm = x0 ( 3 ); |
152 | | <a name="l00098"></a>00098 uam = u0 ( 0 ); |
153 | | <a name="l00099"></a>00099 ubm = u0 ( 1 ); |
154 | | <a name="l00100"></a>00100 |
155 | | <a name="l00101"></a>00101 cth = cos(thm); |
156 | | <a name="l00102"></a>00102 sth = sin(thm); |
157 | | <a name="l00103"></a>00103 |
158 | | <a name="l00104"></a>00104 <a class="code" href="classIMpmsm2o.html#5b668744a1e5189f324897a62b9c3ea6" title="store first derivatives for the use in second derivatives">dia</a> = (- Rs/Ls*iam + Ypm/Ls*omm * sth + uam/Ls); |
159 | | <a name="l00105"></a>00105 dib = (- Rs/Ls*ibm - Ypm/Ls*omm * cth + ubm/Ls); |
160 | | <a name="l00106"></a>00106 dom = kp*p*p * Ypm/J *( ibm * cth-iam * sth ) - p/J*Mz; |
161 | | <a name="l00107"></a>00107 dth = omm; |
162 | | <a name="l00108"></a>00108 |
163 | | <a name="l00109"></a>00109 vec xk=zeros ( 4 ); |
164 | | <a name="l00110"></a>00110 xk ( 0 ) = iam + dt*<a class="code" href="classIMpmsm2o.html#5b668744a1e5189f324897a62b9c3ea6" title="store first derivatives for the use in second derivatives">dia</a>;<span class="comment">// +d2t*d2ia;</span> |
165 | | <a name="l00111"></a>00111 xk ( 1 ) = ibm + dt*dib;<span class="comment">// +d2t*d2ib;</span> |
166 | | <a name="l00112"></a>00112 xk ( 2 ) = omm +dt*dom;<span class="comment">// +d2t*d2om;</span> |
167 | | <a name="l00113"></a>00113 xk ( 3 ) = thm + dt*dth;<span class="comment">// +d2t*dom; // <0..2pi></span> |
168 | | <a name="l00114"></a>00114 |
169 | | <a name="l00115"></a>00115 <span class="keywordflow">if</span> ( xk ( 3 ) >pi ) xk ( 3 )-=2*pi; |
170 | | <a name="l00116"></a>00116 <span class="keywordflow">if</span> ( xk ( 3 ) <-pi ) xk ( 3 ) +=2*pi; |
171 | | <a name="l00117"></a>00117 <span class="keywordflow">return</span> xk; |
172 | | <a name="l00118"></a>00118 } |
173 | | <a name="l00119"></a>00119 |
174 | | <a name="l00121"></a><a class="code" href="classIMpmsm2o.html#cf66e75d9e532b0a1c2135b34ac57c89">00121</a> vec <a class="code" href="classIMpmsm2o.html#cf66e75d9e532b0a1c2135b34ac57c89" title="eval 2nd order Taylor expansion, MUST be used only as a follow up AFTER eval()!!">eval2o</a>(<span class="keyword">const</span> vec &du){ |
175 | | <a name="l00122"></a>00122 <span class="keywordtype">double</span> dua = du ( 0 )/dt; |
176 | | <a name="l00123"></a>00123 <span class="keywordtype">double</span> dub = du ( 1 )/dt; |
| 89 | <a name="l00031"></a>00031 <span class="keywordtype">void</span> modelpwm(<span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec u0, <span class="keywordtype">double</span> &ua, <span class="keywordtype">double</span> &ub){ |
| 90 | <a name="l00032"></a>00032 <span class="comment">/* ua=u0[0];</span> |
| 91 | <a name="l00033"></a>00033 <span class="comment"> ub=u0[1];</span> |
| 92 | <a name="l00034"></a>00034 <span class="comment"> return;*/</span> |
| 93 | <a name="l00035"></a>00035 <span class="keywordtype">double</span> sq3=<a class="code" href="group__miscfunc.html#g20af7c97287e8275db8c2b0f650310ac" title="Square root of the elements.">sqrt</a> ( 3.0 ); |
| 94 | <a name="l00036"></a>00036 <span class="keywordtype">double</span> i1=x0(0); |
| 95 | <a name="l00037"></a>00037 <span class="keywordtype">double</span> i2=0.5* ( -i1+sq3*x0[1] ); |
| 96 | <a name="l00038"></a>00038 <span class="keywordtype">double</span> i3=0.5* ( -i1-sq3*x0[1] ); |
| 97 | <a name="l00039"></a>00039 <span class="keywordtype">double</span> u1=u0(0); |
| 98 | <a name="l00040"></a>00040 <span class="keywordtype">double</span> u2=0.5* ( -u1+sq3*u0(1) ); |
| 99 | <a name="l00041"></a>00041 <span class="keywordtype">double</span> u3=0.5* ( -u1-sq3*u0(1) ); |
| 100 | <a name="l00042"></a>00042 |
| 101 | <a name="l00043"></a>00043 <span class="keywordtype">double</span> du1=1.4* ( double ( i1>0.3 ) - double ( i1<-0.3 ) ) +0.2*i1; |
| 102 | <a name="l00044"></a>00044 <span class="keywordtype">double</span> du2=1.4* ( double ( i2>0.3 ) - double ( i2<-0.3 ) ) +0.2*i2; |
| 103 | <a name="l00045"></a>00045 <span class="keywordtype">double</span> du3=1.4* ( double ( i3>0.3 ) - double ( i3<-0.3 ) ) +0.2*i3; |
| 104 | <a name="l00046"></a>00046 ua = ( 2.0* ( u1-du1 )- ( u2-du2 )- ( u3-du3 ) ) /3.0; |
| 105 | <a name="l00047"></a>00047 ub = ( ( u2-du2 )- ( u3-du3 ) ) /sq3; |
| 106 | <a name="l00048"></a>00048 } |
| 107 | <a name="l00049"></a>00049 |
| 108 | <a name="l00050"></a><a class="code" href="classIMpmsm.html#45785869d978dda42828a072ec2caebe">00050</a> vec <a class="code" href="classIMpmsm.html#45785869d978dda42828a072ec2caebe" title="Evaluates .">eval</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0 ) { |
| 109 | <a name="l00051"></a>00051 <span class="comment">// last state</span> |
| 110 | <a name="l00052"></a>00052 <span class="keyword">const</span> <span class="keywordtype">double</span> &iam = x0 ( 0 ); |
| 111 | <a name="l00053"></a>00053 <span class="keyword">const</span> <span class="keywordtype">double</span> &ibm = x0 ( 1 ); |
| 112 | <a name="l00054"></a>00054 <span class="keyword">const</span> <span class="keywordtype">double</span> &omm = x0 ( 2 ); |
| 113 | <a name="l00055"></a>00055 <span class="keyword">const</span> <span class="keywordtype">double</span> &thm = x0 ( 3 ); |
| 114 | <a name="l00056"></a>00056 <span class="keywordtype">double</span> uam; |
| 115 | <a name="l00057"></a>00057 <span class="keywordtype">double</span> ubm; |
| 116 | <a name="l00058"></a>00058 |
| 117 | <a name="l00059"></a>00059 modelpwm(x0,u0,uam,ubm); |
| 118 | <a name="l00060"></a>00060 |
| 119 | <a name="l00061"></a>00061 vec xk( 4 ); |
| 120 | <a name="l00062"></a>00062 <span class="comment">//ia</span> |
| 121 | <a name="l00063"></a>00063 xk ( 0 ) = ( 1.0- Rs/Ls*dt ) * iam + Ypm/Ls*dt*omm * <a class="code" href="group__trifunc.html#g680fb273328ac7897cf28f6f980fe458" title="Sine function.">sin</a> ( thm ) + uam*dt/Ls; |
| 122 | <a name="l00064"></a>00064 <span class="comment">//ib</span> |
| 123 | <a name="l00065"></a>00065 xk ( 1 ) = ( 1.0- Rs/Ls*dt ) * ibm - Ypm/Ls*dt*omm * <a class="code" href="group__trifunc.html#g098a0025955a83d70458225324c21acf" title="Cosine function.">cos</a> ( thm ) + ubm*dt/Ls; |
| 124 | <a name="l00066"></a>00066 <span class="comment">//om</span> |
| 125 | <a name="l00067"></a>00067 xk ( 2 ) = omm + kp*p*p * Ypm/J*dt* ( ibm * <a class="code" href="group__trifunc.html#g098a0025955a83d70458225324c21acf" title="Cosine function.">cos</a> ( thm )-iam * <a class="code" href="group__trifunc.html#g680fb273328ac7897cf28f6f980fe458" title="Sine function.">sin</a> ( thm ) ) - p/J*dt*Mz; |
| 126 | <a name="l00068"></a>00068 <span class="comment">//th</span> |
| 127 | <a name="l00069"></a>00069 xk ( 3 ) = thm + omm*dt; <span class="comment">// <0..2pi></span> |
| 128 | <a name="l00070"></a>00070 <span class="keywordflow">if</span> ( xk ( 3 ) >pi ) xk ( 3 )-=2*pi; |
| 129 | <a name="l00071"></a>00071 <span class="keywordflow">if</span> ( xk ( 3 ) <-pi ) xk ( 3 ) +=2*pi; |
| 130 | <a name="l00072"></a>00072 <span class="keywordflow">return</span> xk; |
| 131 | <a name="l00073"></a>00073 } |
| 132 | <a name="l00074"></a>00074 |
| 133 | <a name="l00075"></a><a class="code" href="classIMpmsm.html#b4378b5d3bf64c683e4cf5c5f1cd56f1">00075</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsm.html#b4378b5d3bf64c683e4cf5c5f1cd56f1" title="Evaluates and writes result into A .">dfdx_cond</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0, mat &A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) { |
| 134 | <a name="l00076"></a>00076 <span class="keyword">const</span> <span class="keywordtype">double</span> &iam = x0 ( 0 ); |
| 135 | <a name="l00077"></a>00077 <span class="keyword">const</span> <span class="keywordtype">double</span> &ibm = x0 ( 1 ); |
| 136 | <a name="l00078"></a>00078 <span class="keyword">const</span> <span class="keywordtype">double</span> &omm = x0 ( 2 ); |
| 137 | <a name="l00079"></a>00079 <span class="keyword">const</span> <span class="keywordtype">double</span> &thm = x0 ( 3 ); |
| 138 | <a name="l00080"></a>00080 <span class="comment">// d ia</span> |
| 139 | <a name="l00081"></a>00081 A ( 0,0 ) = ( 1.0- Rs/Ls*dt ); A ( 0,1 ) = 0.0; |
| 140 | <a name="l00082"></a>00082 A ( 0,2 ) = Ypm/Ls*dt* <a class="code" href="group__trifunc.html#g680fb273328ac7897cf28f6f980fe458" title="Sine function.">sin</a> ( thm ); A ( 0,3 ) = Ypm/Ls*dt*omm * ( <a class="code" href="group__trifunc.html#g098a0025955a83d70458225324c21acf" title="Cosine function.">cos</a> ( thm ) ); |
| 141 | <a name="l00083"></a>00083 <span class="comment">// d ib</span> |
| 142 | <a name="l00084"></a>00084 A ( 1,0 ) = 0.0 ; A ( 1,1 ) = ( 1.0- Rs/Ls*dt ); |
| 143 | <a name="l00085"></a>00085 A ( 1,2 ) = -Ypm/Ls*dt* <a class="code" href="group__trifunc.html#g098a0025955a83d70458225324c21acf" title="Cosine function.">cos</a> ( thm ); A ( 1,3 ) = Ypm/Ls*dt*omm * ( <a class="code" href="group__trifunc.html#g680fb273328ac7897cf28f6f980fe458" title="Sine function.">sin</a> ( thm ) ); |
| 144 | <a name="l00086"></a>00086 <span class="comment">// d om</span> |
| 145 | <a name="l00087"></a>00087 A ( 2,0 ) = kp*p*p * Ypm/J*dt* ( - <a class="code" href="group__trifunc.html#g680fb273328ac7897cf28f6f980fe458" title="Sine function.">sin</a> ( thm ) ); |
| 146 | <a name="l00088"></a>00088 A ( 2,1 ) = kp*p*p * Ypm/J*dt* ( <a class="code" href="group__trifunc.html#g098a0025955a83d70458225324c21acf" title="Cosine function.">cos</a> ( thm ) ); |
| 147 | <a name="l00089"></a>00089 A ( 2,2 ) = 1.0; |
| 148 | <a name="l00090"></a>00090 A ( 2,3 ) = kp*p*p * Ypm/J*dt* ( -ibm * <a class="code" href="group__trifunc.html#g680fb273328ac7897cf28f6f980fe458" title="Sine function.">sin</a> ( thm )-iam * <a class="code" href="group__trifunc.html#g098a0025955a83d70458225324c21acf" title="Cosine function.">cos</a> ( thm ) ); |
| 149 | <a name="l00091"></a>00091 <span class="comment">// d th</span> |
| 150 | <a name="l00092"></a>00092 A ( 3,0 ) = 0.0; A ( 3,1 ) = 0.0; A ( 3,2 ) = dt; A ( 3,3 ) = 1.0; |
| 151 | <a name="l00093"></a>00093 } |
| 152 | <a name="l00094"></a>00094 |
| 153 | <a name="l00095"></a><a class="code" href="classIMpmsm.html#c3f8dad22ae9855c04a1d593b45c99b5">00095</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsm.html#c3f8dad22ae9855c04a1d593b45c99b5" title="Evaluates and writes result into A .">dfdu_cond</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0, mat &A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) {<a class="code" href="group__errorhandlingfunc.html#g22d38e98332f9edff88cc501463eedce" title="Abort unconditionally.">it_error</a> ( <span class="stringliteral">"not needed"</span> );}; |
| 154 | <a name="l00096"></a>00096 }; |
| 155 | <a name="l00097"></a>00097 |
| 156 | <a name="l00098"></a>00098 |
| 157 | <a name="l00100"></a><a class="code" href="classIMpmsm2o.html">00100</a> <span class="keyword">class </span><a class="code" href="classIMpmsm2o.html" title="State evolution model for a PMSM drive and its derivative with respect to .">IMpmsm2o</a> : <span class="keyword">public</span> <a class="code" href="classIMpmsm.html" title="State evolution model for a PMSM drive and its derivative with respect to .">IMpmsm</a> { |
| 158 | <a name="l00101"></a>00101 <span class="keyword">protected</span>: |
| 159 | <a name="l00102"></a>00102 <span class="comment">// double Rs, Ls, dt, Ypm, kp, p, J, Mz;</span> |
| 160 | <a name="l00104"></a><a class="code" href="classIMpmsm2o.html#5b668744a1e5189f324897a62b9c3ea6">00104</a> <span class="comment"></span> <span class="keywordtype">double</span> <a class="code" href="classIMpmsm2o.html#5b668744a1e5189f324897a62b9c3ea6" title="store first derivatives for the use in second derivatives">dia</a>, dib, dom, dth; |
| 161 | <a name="l00106"></a><a class="code" href="classIMpmsm2o.html#74954dedce055db9ee50d53790e8341c">00106</a> <span class="keywordtype">double</span> <a class="code" href="classIMpmsm2o.html#74954dedce055db9ee50d53790e8341c" title="d2t = dt^2/2, cth = cos(th), sth=sin(th)">d2t</a>, cth, sth; |
| 162 | <a name="l00107"></a>00107 <span class="keywordtype">double</span> iam, ibm, omm, thm, uam, ubm; |
| 163 | <a name="l00108"></a>00108 <span class="keyword">public</span>: |
| 164 | <a name="l00109"></a>00109 <a class="code" href="classIMpmsm2o.html" title="State evolution model for a PMSM drive and its derivative with respect to .">IMpmsm2o</a>() :<a class="code" href="classIMpmsm.html" title="State evolution model for a PMSM drive and its derivative with respect to .">IMpmsm</a> () {}; |
| 165 | <a name="l00111"></a><a class="code" href="classIMpmsm2o.html#abdefc0467678a05abf12f5c77eaf49d">00111</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsm2o.html#abdefc0467678a05abf12f5c77eaf49d" title="Set mechanical and electrical variables.">set_parameters</a> ( <span class="keywordtype">double</span> Rs0, <span class="keywordtype">double</span> Ls0, <span class="keywordtype">double</span> dt0, <span class="keywordtype">double</span> Ypm0, <span class="keywordtype">double</span> kp0, <span class="keywordtype">double</span> p0, <span class="keywordtype">double</span> J0, <span class="keywordtype">double</span> Mz0 ) {Rs=Rs0; Ls=Ls0; dt=dt0; Ypm=Ypm0; kp=kp0; p=p0; J=J0; Mz=Mz0; <a class="code" href="classIMpmsm2o.html#74954dedce055db9ee50d53790e8341c" title="d2t = dt^2/2, cth = cos(th), sth=sin(th)">d2t</a>=dt*dt/2;} |
| 166 | <a name="l00112"></a>00112 |
| 167 | <a name="l00113"></a><a class="code" href="classIMpmsm2o.html#86e04b5118e567ea7a2540059f553f41">00113</a> vec <a class="code" href="classIMpmsm2o.html#86e04b5118e567ea7a2540059f553f41" title="Evaluates .">eval</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0 ) { |
| 168 | <a name="l00114"></a>00114 <span class="comment">// last state</span> |
| 169 | <a name="l00115"></a>00115 iam = x0 ( 0 ); |
| 170 | <a name="l00116"></a>00116 ibm = x0 ( 1 ); |
| 171 | <a name="l00117"></a>00117 omm = x0 ( 2 ); |
| 172 | <a name="l00118"></a>00118 thm = x0 ( 3 ); |
| 173 | <a name="l00119"></a>00119 uam = u0 ( 0 ); |
| 174 | <a name="l00120"></a>00120 ubm = u0 ( 1 ); |
| 175 | <a name="l00121"></a>00121 |
| 176 | <a name="l00122"></a>00122 cth = <a class="code" href="group__trifunc.html#g098a0025955a83d70458225324c21acf" title="Cosine function.">cos</a>(thm); |
| 177 | <a name="l00123"></a>00123 sth = <a class="code" href="group__trifunc.html#g680fb273328ac7897cf28f6f980fe458" title="Sine function.">sin</a>(thm); |
178 | | <a name="l00125"></a>00125 vec xth2o(4); |
179 | | <a name="l00126"></a>00126 xth2o(0) = (- Rs/Ls*<a class="code" href="classIMpmsm2o.html#5b668744a1e5189f324897a62b9c3ea6" title="store first derivatives for the use in second derivatives">dia</a> + Ypm/Ls*(dom * sth + omm*cth) + dua/Ls); |
180 | | <a name="l00127"></a>00127 xth2o(1) = (- Rs/Ls*dib - Ypm/Ls*(dom * cth - omm*sth) + dub/Ls); |
181 | | <a name="l00128"></a>00128 xth2o(2) = kp*p*p * Ypm/J *( dib * cth-ibm*sth - (<a class="code" href="classIMpmsm2o.html#5b668744a1e5189f324897a62b9c3ea6" title="store first derivatives for the use in second derivatives">dia</a> * sth + iam *cth)); |
182 | | <a name="l00129"></a>00129 xth2o(3) = dom; |
183 | | <a name="l00130"></a>00130 <span class="keywordflow">return</span> xth2o; |
184 | | <a name="l00131"></a>00131 } |
185 | | <a name="l00132"></a><a class="code" href="classIMpmsm2o.html#0a3e125df1e53821e08accbd4960d713">00132</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsm2o.html#0a3e125df1e53821e08accbd4960d713" title="Evaluates and writes result into A .">dfdx_cond</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0, mat &A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) { |
186 | | <a name="l00133"></a>00133 iam = x0 ( 0 ); |
187 | | <a name="l00134"></a>00134 ibm = x0 ( 1 ); |
188 | | <a name="l00135"></a>00135 omm = x0 ( 2 ); |
189 | | <a name="l00136"></a>00136 thm = x0 ( 3 ); |
190 | | <a name="l00137"></a>00137 <span class="comment">// d ia</span> |
191 | | <a name="l00138"></a>00138 A ( 0,0 ) = ( 1.0- Rs/Ls*dt ); A ( 0,1 ) = 0.0; |
192 | | <a name="l00139"></a>00139 A ( 0,2 ) = Ypm/Ls*dt* sin ( thm ); A ( 0,3 ) = Ypm/Ls*dt*omm * ( cos ( thm ) ); |
193 | | <a name="l00140"></a>00140 <span class="comment">// d ib</span> |
194 | | <a name="l00141"></a>00141 A ( 1,0 ) = 0.0 ; A ( 1,1 ) = ( 1.0- Rs/Ls*dt ); |
195 | | <a name="l00142"></a>00142 A ( 1,2 ) = -Ypm/Ls*dt* cos ( thm ); A ( 1,3 ) = Ypm/Ls*dt*omm * ( sin ( thm ) ); |
196 | | <a name="l00143"></a>00143 <span class="comment">// d om</span> |
197 | | <a name="l00144"></a>00144 A ( 2,0 ) = kp*p*p * Ypm/J*dt* ( - sin ( thm ) ); |
198 | | <a name="l00145"></a>00145 A ( 2,1 ) = kp*p*p * Ypm/J*dt* ( cos ( thm ) ); |
199 | | <a name="l00146"></a>00146 A ( 2,2 ) = 1.0; |
200 | | <a name="l00147"></a>00147 A ( 2,3 ) = kp*p*p * Ypm/J*dt* ( -ibm * sin ( thm )-iam * cos ( thm ) ); |
201 | | <a name="l00148"></a>00148 <span class="comment">// d th</span> |
202 | | <a name="l00149"></a>00149 A ( 3,0 ) = 0.0; A ( 3,1 ) = 0.0; A ( 3,2 ) = dt; A ( 3,3 ) = 1.0; |
203 | | <a name="l00150"></a>00150 <span class="comment">// FOR d2t*dom!!!!!!!!!</span> |
204 | | <a name="l00151"></a>00151 <span class="comment">/* A ( 3,0 ) = dt* kp*p*p * Ypm/J*dt* ( - sin ( thm ) );</span> |
205 | | <a name="l00152"></a>00152 <span class="comment"> A ( 3,1 ) = dt* kp*p*p * Ypm/J*dt* ( cos ( thm ) );</span> |
206 | | <a name="l00153"></a>00153 <span class="comment"> A ( 3,2 ) = dt;</span> |
207 | | <a name="l00154"></a>00154 <span class="comment"> A ( 3,3 ) = 1.0 + dt* kp*p*p * Ypm/J*dt* ( -ibm * sin ( thm )-iam * cos ( thm ) );*/</span> |
208 | | <a name="l00155"></a>00155 } |
209 | | <a name="l00156"></a>00156 |
210 | | <a name="l00157"></a><a class="code" href="classIMpmsm2o.html#27f9d89bce832056f747d985df77a726">00157</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsm2o.html#27f9d89bce832056f747d985df77a726" title="Evaluates and writes result into A .">dfdu_cond</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0, mat &A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) {it_error ( <span class="stringliteral">"not needed"</span> );}; |
211 | | <a name="l00158"></a>00158 |
212 | | <a name="l00159"></a>00159 }; |
213 | | <a name="l00160"></a>00160 |
214 | | <a name="l00162"></a><a class="code" href="classIMpmsmStat.html">00162</a> <span class="keyword">class </span><a class="code" href="classIMpmsmStat.html" title="State evolution model for a PMSM drive and its derivative with respect to , equation...">IMpmsmStat</a> : <span class="keyword">public</span> <a class="code" href="classIMpmsm.html" title="State evolution model for a PMSM drive and its derivative with respect to .">IMpmsm</a> { |
215 | | <a name="l00163"></a>00163 <span class="keyword">public</span>: |
216 | | <a name="l00164"></a>00164 <a class="code" href="classIMpmsmStat.html" title="State evolution model for a PMSM drive and its derivative with respect to , equation...">IMpmsmStat</a>() :<a class="code" href="classIMpmsm.html" title="State evolution model for a PMSM drive and its derivative with respect to .">IMpmsm</a>() {}; |
217 | | <a name="l00166"></a><a class="code" href="classIMpmsmStat.html#6379210623a2d353d42bfc87ccbd4384">00166</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsmStat.html#6379210623a2d353d42bfc87ccbd4384" title="Set mechanical and electrical variables.">set_parameters</a> ( <span class="keywordtype">double</span> Rs0, <span class="keywordtype">double</span> Ls0, <span class="keywordtype">double</span> dt0, <span class="keywordtype">double</span> Ypm0, <span class="keywordtype">double</span> kp0, <span class="keywordtype">double</span> p0, <span class="keywordtype">double</span> J0, <span class="keywordtype">double</span> Mz0 ) {Rs=Rs0; Ls=Ls0; dt=dt0; Ypm=Ypm0; kp=kp0; p=p0; J=J0; Mz=Mz0;} |
218 | | <a name="l00167"></a>00167 |
219 | | <a name="l00168"></a><a class="code" href="classIMpmsmStat.html#5ed3582c2c0edb0753387a82598f8d21">00168</a> vec <a class="code" href="classIMpmsmStat.html#5ed3582c2c0edb0753387a82598f8d21" title="Evaluates .">eval</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0 ) { |
220 | | <a name="l00169"></a>00169 <span class="comment">// last state</span> |
221 | | <a name="l00170"></a>00170 <span class="keywordtype">double</span> iam = x0 ( 0 ); |
222 | | <a name="l00171"></a>00171 <span class="keywordtype">double</span> ibm = x0 ( 1 ); |
223 | | <a name="l00172"></a>00172 <span class="keywordtype">double</span> omm = x0 ( 2 ); |
224 | | <a name="l00173"></a>00173 <span class="keywordtype">double</span> thm = x0 ( 3 ); |
225 | | <a name="l00174"></a>00174 <span class="keywordtype">double</span> uam = u0 ( 0 ); |
226 | | <a name="l00175"></a>00175 <span class="keywordtype">double</span> ubm = u0 ( 1 ); |
227 | | <a name="l00176"></a>00176 |
228 | | <a name="l00177"></a>00177 vec xk=zeros ( 4 ); |
229 | | <a name="l00178"></a>00178 <span class="comment">//ia</span> |
230 | | <a name="l00179"></a>00179 xk ( 0 ) = ( 1.0- Rs/Ls*dt ) * iam + Ypm/Ls*dt*omm * sin ( thm ) + uam*dt/Ls; |
231 | | <a name="l00180"></a>00180 <span class="comment">//ib</span> |
232 | | <a name="l00181"></a>00181 xk ( 1 ) = ( 1.0- Rs/Ls*dt ) * ibm - Ypm/Ls*dt*omm * cos ( thm ) + ubm*dt/Ls; |
233 | | <a name="l00182"></a>00182 <span class="comment">//om</span> |
234 | | <a name="l00183"></a>00183 xk ( 2 ) = omm;<span class="comment">// + kp*p*p * Ypm/J*dt* ( ibm * cos ( thm )-iam * sin ( thm ) ) - p/J*dt*Mz;</span> |
235 | | <a name="l00184"></a>00184 <span class="comment">//th</span> |
236 | | <a name="l00185"></a>00185 xk ( 3 ) = rem(thm + omm*dt,2*pi); <span class="comment">// <0..2pi></span> |
237 | | <a name="l00186"></a>00186 <span class="keywordflow">return</span> xk; |
238 | | <a name="l00187"></a>00187 } |
239 | | <a name="l00188"></a>00188 |
240 | | <a name="l00189"></a><a class="code" href="classIMpmsmStat.html#29a9c09fd328e89748d9be0801e84831">00189</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsmStat.html#29a9c09fd328e89748d9be0801e84831" title="Evaluates and writes result into A .">dfdx_cond</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0, mat &A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) { |
241 | | <a name="l00190"></a>00190 <span class="comment">// double iam = x0 ( 0 );</span> |
242 | | <a name="l00191"></a>00191 <span class="comment">// double ibm = x0 ( 1 );</span> |
243 | | <a name="l00192"></a>00192 <span class="keywordtype">double</span> omm = x0 ( 2 ); |
244 | | <a name="l00193"></a>00193 <span class="keywordtype">double</span> thm = x0 ( 3 ); |
245 | | <a name="l00194"></a>00194 <span class="comment">// d ia</span> |
246 | | <a name="l00195"></a>00195 A ( 0,0 ) = ( 1.0- Rs/Ls*dt ); A ( 0,1 ) = 0.0; |
247 | | <a name="l00196"></a>00196 A ( 0,2 ) = Ypm/Ls*dt* sin ( thm ); A ( 0,3 ) = Ypm/Ls*dt*omm * ( cos ( thm ) ); |
248 | | <a name="l00197"></a>00197 <span class="comment">// d ib</span> |
249 | | <a name="l00198"></a>00198 A ( 1,0 ) = 0.0 ; A ( 1,1 ) = ( 1.0- Rs/Ls*dt ); |
250 | | <a name="l00199"></a>00199 A ( 1,2 ) = -Ypm/Ls*dt* cos ( thm ); A ( 1,3 ) = Ypm/Ls*dt*omm * ( sin ( thm ) ); |
251 | | <a name="l00200"></a>00200 <span class="comment">// d om</span> |
252 | | <a name="l00201"></a>00201 A ( 2,0 ) = 0.0;<span class="comment">//kp*p*p * Ypm/J*dt* ( - sin ( thm ) );</span> |
253 | | <a name="l00202"></a>00202 A ( 2,1 ) = 0.0;<span class="comment">//kp*p*p * Ypm/J*dt* ( cos ( thm ) );</span> |
254 | | <a name="l00203"></a>00203 A ( 2,2 ) = 1.0; |
255 | | <a name="l00204"></a>00204 A ( 2,3 ) = 0.0;<span class="comment">//kp*p*p * Ypm/J*dt* ( -ibm * sin ( thm )-iam * cos ( thm ) );</span> |
256 | | <a name="l00205"></a>00205 <span class="comment">// d th</span> |
257 | | <a name="l00206"></a>00206 A ( 3,0 ) = 0.0; A ( 3,1 ) = 0.0; A ( 3,2 ) = dt; A ( 3,3 ) = 1.0; |
258 | | <a name="l00207"></a>00207 } |
259 | | <a name="l00208"></a>00208 |
260 | | <a name="l00209"></a><a class="code" href="classIMpmsmStat.html#ff740ee20100ae2a2d03a2538638f8e8">00209</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsmStat.html#ff740ee20100ae2a2d03a2538638f8e8" title="Evaluates and writes result into A .">dfdu_cond</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0, mat &A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) {it_error ( <span class="stringliteral">"not needed"</span> );}; |
261 | | <a name="l00210"></a>00210 |
262 | | <a name="l00211"></a>00211 }; |
263 | | <a name="l00212"></a>00212 |
264 | | <a name="l00214"></a><a class="code" href="classOMpmsm.html">00214</a> <span class="keyword">class </span><a class="code" href="classOMpmsm.html" title="Observation model for PMSM drive and its derivative with respect to .">OMpmsm</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a> { |
265 | | <a name="l00215"></a>00215 <span class="keyword">public</span>: |
266 | | <a name="l00216"></a>00216 <a class="code" href="classOMpmsm.html" title="Observation model for PMSM drive and its derivative with respect to .">OMpmsm</a>() :<a class="code" href="classbdm_1_1diffbifn.html#92ff29d748e445b440453a38d0b09681" title="Default constructor (dimy is not set!).">diffbifn</a> () {<a class="code" href="classbdm_1_1fnc.html#52156cb4a52a62d51fc7455985797a62" title="Length of the output vector.">dimy</a>=2;<a class="code" href="classbdm_1_1diffbifn.html#a193aa2c4a500139c0c4b669691e588e" title="cache for rvx.count()">dimx</a>=4;<a class="code" href="classbdm_1_1diffbifn.html#30c45617eec89adeb4ebaa763d093fb0" title="cache for rvu.count()">dimu</a>=2;}; |
267 | | <a name="l00217"></a>00217 |
268 | | <a name="l00218"></a><a class="code" href="classOMpmsm.html#8e32392c9c635584606287b8c0e8c9da">00218</a> vec <a class="code" href="classOMpmsm.html#8e32392c9c635584606287b8c0e8c9da" title="Evaluates .">eval</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0 ) { |
269 | | <a name="l00219"></a>00219 vec y ( 2 ); |
270 | | <a name="l00220"></a>00220 y ( 0 ) = x0 ( 0 ); |
271 | | <a name="l00221"></a>00221 y ( 1 ) = x0 ( 1 ); |
272 | | <a name="l00222"></a>00222 <span class="keywordflow">return</span> y; |
273 | | <a name="l00223"></a>00223 } |
274 | | <a name="l00224"></a>00224 |
275 | | <a name="l00225"></a><a class="code" href="classOMpmsm.html#b75b5fd55b2ac5ed74b5b953af122821">00225</a> <span class="keywordtype">void</span> <a class="code" href="classOMpmsm.html#b75b5fd55b2ac5ed74b5b953af122821" title="Evaluates and writes result into A .">dfdx_cond</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0, mat &A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) { |
276 | | <a name="l00226"></a>00226 A.clear(); |
277 | | <a name="l00227"></a>00227 A ( 0,0 ) = 1.0; |
278 | | <a name="l00228"></a>00228 A ( 1,1 ) = 1.0; |
279 | | <a name="l00229"></a>00229 } |
280 | | <a name="l00230"></a>00230 }; |
| 179 | <a name="l00125"></a>00125 <a class="code" href="classIMpmsm2o.html#5b668744a1e5189f324897a62b9c3ea6" title="store first derivatives for the use in second derivatives">dia</a> = (- Rs/Ls*iam + Ypm/Ls*omm * sth + uam/Ls); |
| 180 | <a name="l00126"></a>00126 dib = (- Rs/Ls*ibm - Ypm/Ls*omm * cth + ubm/Ls); |
| 181 | <a name="l00127"></a>00127 dom = kp*p*p * Ypm/J *( ibm * cth-iam * sth ) - p/J*Mz; |
| 182 | <a name="l00128"></a>00128 dth = omm; |
| 183 | <a name="l00129"></a>00129 |
| 184 | <a name="l00130"></a>00130 vec xk=<a class="code" href="group__specmat.html#g10723ecada06221cbe64fe2736a59de1" title="A Double (rows,cols)-matrix of zeros.">zeros</a> ( 4 ); |
| 185 | <a name="l00131"></a>00131 xk ( 0 ) = iam + dt*<a class="code" href="classIMpmsm2o.html#5b668744a1e5189f324897a62b9c3ea6" title="store first derivatives for the use in second derivatives">dia</a>;<span class="comment">// +d2t*d2ia;</span> |
| 186 | <a name="l00132"></a>00132 xk ( 1 ) = ibm + dt*dib;<span class="comment">// +d2t*d2ib;</span> |
| 187 | <a name="l00133"></a>00133 xk ( 2 ) = omm +dt*dom;<span class="comment">// +d2t*d2om;</span> |
| 188 | <a name="l00134"></a>00134 xk ( 3 ) = thm + dt*dth;<span class="comment">// +d2t*dom; // <0..2pi></span> |
| 189 | <a name="l00135"></a>00135 |
| 190 | <a name="l00136"></a>00136 <span class="keywordflow">if</span> ( xk ( 3 ) >pi ) xk ( 3 )-=2*pi; |
| 191 | <a name="l00137"></a>00137 <span class="keywordflow">if</span> ( xk ( 3 ) <-pi ) xk ( 3 ) +=2*pi; |
| 192 | <a name="l00138"></a>00138 <span class="keywordflow">return</span> xk; |
| 193 | <a name="l00139"></a>00139 } |
| 194 | <a name="l00140"></a>00140 |
| 195 | <a name="l00142"></a><a class="code" href="classIMpmsm2o.html#cf66e75d9e532b0a1c2135b34ac57c89">00142</a> vec <a class="code" href="classIMpmsm2o.html#cf66e75d9e532b0a1c2135b34ac57c89" title="eval 2nd order Taylor expansion, MUST be used only as a follow up AFTER eval()!!">eval2o</a>(<span class="keyword">const</span> vec &du){ |
| 196 | <a name="l00143"></a>00143 <span class="keywordtype">double</span> dua = du ( 0 )/dt; |
| 197 | <a name="l00144"></a>00144 <span class="keywordtype">double</span> dub = du ( 1 )/dt; |
| 198 | <a name="l00145"></a>00145 |
| 199 | <a name="l00146"></a>00146 vec xth2o(4); |
| 200 | <a name="l00147"></a>00147 xth2o(0) = (- Rs/Ls*<a class="code" href="classIMpmsm2o.html#5b668744a1e5189f324897a62b9c3ea6" title="store first derivatives for the use in second derivatives">dia</a> + Ypm/Ls*(dom * sth + omm*cth) + dua/Ls); |
| 201 | <a name="l00148"></a>00148 xth2o(1) = (- Rs/Ls*dib - Ypm/Ls*(dom * cth - omm*sth) + dub/Ls); |
| 202 | <a name="l00149"></a>00149 xth2o(2) = kp*p*p * Ypm/J *( dib * cth-ibm*sth - (<a class="code" href="classIMpmsm2o.html#5b668744a1e5189f324897a62b9c3ea6" title="store first derivatives for the use in second derivatives">dia</a> * sth + iam *cth)); |
| 203 | <a name="l00150"></a>00150 xth2o(3) = dom; |
| 204 | <a name="l00151"></a>00151 <span class="comment">// multiply by dt^2/2</span> |
| 205 | <a name="l00152"></a>00152 xth2o*=<a class="code" href="classIMpmsm2o.html#74954dedce055db9ee50d53790e8341c" title="d2t = dt^2/2, cth = cos(th), sth=sin(th)">d2t</a>/2; |
| 206 | <a name="l00153"></a>00153 <span class="keywordflow">return</span> xth2o; |
| 207 | <a name="l00154"></a>00154 } |
| 208 | <a name="l00155"></a><a class="code" href="classIMpmsm2o.html#0a3e125df1e53821e08accbd4960d713">00155</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsm2o.html#0a3e125df1e53821e08accbd4960d713" title="Evaluates and writes result into A .">dfdx_cond</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0, mat &A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) { |
| 209 | <a name="l00156"></a>00156 iam = x0 ( 0 ); |
| 210 | <a name="l00157"></a>00157 ibm = x0 ( 1 ); |
| 211 | <a name="l00158"></a>00158 omm = x0 ( 2 ); |
| 212 | <a name="l00159"></a>00159 thm = x0 ( 3 ); |
| 213 | <a name="l00160"></a>00160 <span class="comment">// d ia</span> |
| 214 | <a name="l00161"></a>00161 A ( 0,0 ) = ( 1.0- Rs/Ls*dt ); A ( 0,1 ) = 0.0; |
| 215 | <a name="l00162"></a>00162 A ( 0,2 ) = Ypm/Ls*dt* <a class="code" href="group__trifunc.html#g680fb273328ac7897cf28f6f980fe458" title="Sine function.">sin</a> ( thm ); A ( 0,3 ) = Ypm/Ls*dt*omm * ( <a class="code" href="group__trifunc.html#g098a0025955a83d70458225324c21acf" title="Cosine function.">cos</a> ( thm ) ); |
| 216 | <a name="l00163"></a>00163 <span class="comment">// d ib</span> |
| 217 | <a name="l00164"></a>00164 A ( 1,0 ) = 0.0 ; A ( 1,1 ) = ( 1.0- Rs/Ls*dt ); |
| 218 | <a name="l00165"></a>00165 A ( 1,2 ) = -Ypm/Ls*dt* <a class="code" href="group__trifunc.html#g098a0025955a83d70458225324c21acf" title="Cosine function.">cos</a> ( thm ); A ( 1,3 ) = Ypm/Ls*dt*omm * ( <a class="code" href="group__trifunc.html#g680fb273328ac7897cf28f6f980fe458" title="Sine function.">sin</a> ( thm ) ); |
| 219 | <a name="l00166"></a>00166 <span class="comment">// d om</span> |
| 220 | <a name="l00167"></a>00167 A ( 2,0 ) = kp*p*p * Ypm/J*dt* ( - <a class="code" href="group__trifunc.html#g680fb273328ac7897cf28f6f980fe458" title="Sine function.">sin</a> ( thm ) ); |
| 221 | <a name="l00168"></a>00168 A ( 2,1 ) = kp*p*p * Ypm/J*dt* ( <a class="code" href="group__trifunc.html#g098a0025955a83d70458225324c21acf" title="Cosine function.">cos</a> ( thm ) ); |
| 222 | <a name="l00169"></a>00169 A ( 2,2 ) = 1.0; |
| 223 | <a name="l00170"></a>00170 A ( 2,3 ) = kp*p*p * Ypm/J*dt* ( -ibm * <a class="code" href="group__trifunc.html#g680fb273328ac7897cf28f6f980fe458" title="Sine function.">sin</a> ( thm )-iam * <a class="code" href="group__trifunc.html#g098a0025955a83d70458225324c21acf" title="Cosine function.">cos</a> ( thm ) ); |
| 224 | <a name="l00171"></a>00171 <span class="comment">// d th</span> |
| 225 | <a name="l00172"></a>00172 A ( 3,0 ) = 0.0; A ( 3,1 ) = 0.0; A ( 3,2 ) = dt; A ( 3,3 ) = 1.0; |
| 226 | <a name="l00173"></a>00173 <span class="comment">// FOR d2t*dom!!!!!!!!!</span> |
| 227 | <a name="l00174"></a>00174 <span class="comment">/* A ( 3,0 ) = dt* kp*p*p * Ypm/J*dt* ( - sin ( thm ) );</span> |
| 228 | <a name="l00175"></a>00175 <span class="comment"> A ( 3,1 ) = dt* kp*p*p * Ypm/J*dt* ( cos ( thm ) );</span> |
| 229 | <a name="l00176"></a>00176 <span class="comment"> A ( 3,2 ) = dt;</span> |
| 230 | <a name="l00177"></a>00177 <span class="comment"> A ( 3,3 ) = 1.0 + dt* kp*p*p * Ypm/J*dt* ( -ibm * sin ( thm )-iam * cos ( thm ) );*/</span> |
| 231 | <a name="l00178"></a>00178 } |
| 232 | <a name="l00179"></a>00179 |
| 233 | <a name="l00180"></a><a class="code" href="classIMpmsm2o.html#27f9d89bce832056f747d985df77a726">00180</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsm2o.html#27f9d89bce832056f747d985df77a726" title="Evaluates and writes result into A .">dfdu_cond</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0, mat &A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) {<a class="code" href="group__errorhandlingfunc.html#g22d38e98332f9edff88cc501463eedce" title="Abort unconditionally.">it_error</a> ( <span class="stringliteral">"not needed"</span> );}; |
| 234 | <a name="l00181"></a>00181 |
| 235 | <a name="l00182"></a>00182 }; |
| 236 | <a name="l00183"></a>00183 |
| 237 | <a name="l00185"></a><a class="code" href="classIMpmsmStat.html">00185</a> <span class="keyword">class </span><a class="code" href="classIMpmsmStat.html" title="State evolution model for a PMSM drive and its derivative with respect to , equation...">IMpmsmStat</a> : <span class="keyword">public</span> <a class="code" href="classIMpmsm.html" title="State evolution model for a PMSM drive and its derivative with respect to .">IMpmsm</a> { |
| 238 | <a name="l00186"></a>00186 <span class="keyword">public</span>: |
| 239 | <a name="l00187"></a>00187 <a class="code" href="classIMpmsmStat.html" title="State evolution model for a PMSM drive and its derivative with respect to , equation...">IMpmsmStat</a>() :<a class="code" href="classIMpmsm.html" title="State evolution model for a PMSM drive and its derivative with respect to .">IMpmsm</a>() {}; |
| 240 | <a name="l00189"></a><a class="code" href="classIMpmsmStat.html#6379210623a2d353d42bfc87ccbd4384">00189</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsmStat.html#6379210623a2d353d42bfc87ccbd4384" title="Set mechanical and electrical variables.">set_parameters</a> ( <span class="keywordtype">double</span> Rs0, <span class="keywordtype">double</span> Ls0, <span class="keywordtype">double</span> dt0, <span class="keywordtype">double</span> Ypm0, <span class="keywordtype">double</span> kp0, <span class="keywordtype">double</span> p0, <span class="keywordtype">double</span> J0, <span class="keywordtype">double</span> Mz0 ) {Rs=Rs0; Ls=Ls0; dt=dt0; Ypm=Ypm0; kp=kp0; p=p0; J=J0; Mz=Mz0;} |
| 241 | <a name="l00190"></a>00190 |
| 242 | <a name="l00191"></a><a class="code" href="classIMpmsmStat.html#5ed3582c2c0edb0753387a82598f8d21">00191</a> vec <a class="code" href="classIMpmsmStat.html#5ed3582c2c0edb0753387a82598f8d21" title="Evaluates .">eval</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0 ) { |
| 243 | <a name="l00192"></a>00192 <span class="comment">// last state</span> |
| 244 | <a name="l00193"></a>00193 <span class="keywordtype">double</span> iam = x0 ( 0 ); |
| 245 | <a name="l00194"></a>00194 <span class="keywordtype">double</span> ibm = x0 ( 1 ); |
| 246 | <a name="l00195"></a>00195 <span class="keywordtype">double</span> omm = x0 ( 2 ); |
| 247 | <a name="l00196"></a>00196 <span class="keywordtype">double</span> thm = x0 ( 3 ); |
| 248 | <a name="l00197"></a>00197 <span class="keywordtype">double</span> uam = u0 ( 0 ); |
| 249 | <a name="l00198"></a>00198 <span class="keywordtype">double</span> ubm = u0 ( 1 ); |
| 250 | <a name="l00199"></a>00199 |
| 251 | <a name="l00200"></a>00200 vec xk=<a class="code" href="group__specmat.html#g10723ecada06221cbe64fe2736a59de1" title="A Double (rows,cols)-matrix of zeros.">zeros</a> ( 4 ); |
| 252 | <a name="l00201"></a>00201 <span class="comment">//ia</span> |
| 253 | <a name="l00202"></a>00202 xk ( 0 ) = ( 1.0- Rs/Ls*dt ) * iam + Ypm/Ls*dt*omm * <a class="code" href="group__trifunc.html#g680fb273328ac7897cf28f6f980fe458" title="Sine function.">sin</a> ( thm ) + uam*dt/Ls; |
| 254 | <a name="l00203"></a>00203 <span class="comment">//ib</span> |
| 255 | <a name="l00204"></a>00204 xk ( 1 ) = ( 1.0- Rs/Ls*dt ) * ibm - Ypm/Ls*dt*omm * <a class="code" href="group__trifunc.html#g098a0025955a83d70458225324c21acf" title="Cosine function.">cos</a> ( thm ) + ubm*dt/Ls; |
| 256 | <a name="l00205"></a>00205 <span class="comment">//om</span> |
| 257 | <a name="l00206"></a>00206 xk ( 2 ) = omm - p/J*dt*Mz;<span class="comment">// + kp*p*p * Ypm/J*dt* ( ibm * cos ( thm )-iam * sin ( thm ) );</span> |
| 258 | <a name="l00207"></a>00207 <span class="comment">//th</span> |
| 259 | <a name="l00208"></a>00208 xk ( 3 ) = <a class="code" href="group__miscfunc.html#g2c726012179bce791250afed60d508aa" title="Elementwise reminder of the division x/y for double and mat.">rem</a>(thm + omm*dt,2*pi); <span class="comment">// <0..2pi></span> |
| 260 | <a name="l00209"></a>00209 <span class="keywordflow">return</span> xk; |
| 261 | <a name="l00210"></a>00210 } |
| 262 | <a name="l00211"></a>00211 |
| 263 | <a name="l00212"></a><a class="code" href="classIMpmsmStat.html#29a9c09fd328e89748d9be0801e84831">00212</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsmStat.html#29a9c09fd328e89748d9be0801e84831" title="Evaluates and writes result into A .">dfdx_cond</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0, mat &A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) { |
| 264 | <a name="l00213"></a>00213 <span class="comment">// double iam = x0 ( 0 );</span> |
| 265 | <a name="l00214"></a>00214 <span class="comment">// double ibm = x0 ( 1 );</span> |
| 266 | <a name="l00215"></a>00215 <span class="keywordtype">double</span> omm = x0 ( 2 ); |
| 267 | <a name="l00216"></a>00216 <span class="keywordtype">double</span> thm = x0 ( 3 ); |
| 268 | <a name="l00217"></a>00217 <span class="comment">// d ia</span> |
| 269 | <a name="l00218"></a>00218 A ( 0,0 ) = ( 1.0- Rs/Ls*dt ); A ( 0,1 ) = 0.0; |
| 270 | <a name="l00219"></a>00219 A ( 0,2 ) = Ypm/Ls*dt* <a class="code" href="group__trifunc.html#g680fb273328ac7897cf28f6f980fe458" title="Sine function.">sin</a> ( thm ); A ( 0,3 ) = Ypm/Ls*dt*omm * ( <a class="code" href="group__trifunc.html#g098a0025955a83d70458225324c21acf" title="Cosine function.">cos</a> ( thm ) ); |
| 271 | <a name="l00220"></a>00220 <span class="comment">// d ib</span> |
| 272 | <a name="l00221"></a>00221 A ( 1,0 ) = 0.0 ; A ( 1,1 ) = ( 1.0- Rs/Ls*dt ); |
| 273 | <a name="l00222"></a>00222 A ( 1,2 ) = -Ypm/Ls*dt* <a class="code" href="group__trifunc.html#g098a0025955a83d70458225324c21acf" title="Cosine function.">cos</a> ( thm ); A ( 1,3 ) = Ypm/Ls*dt*omm * ( <a class="code" href="group__trifunc.html#g680fb273328ac7897cf28f6f980fe458" title="Sine function.">sin</a> ( thm ) ); |
| 274 | <a name="l00223"></a>00223 <span class="comment">// d om</span> |
| 275 | <a name="l00224"></a>00224 A ( 2,0 ) = 0.0;<span class="comment">//kp*p*p * Ypm/J*dt* ( - sin ( thm ) );</span> |
| 276 | <a name="l00225"></a>00225 A ( 2,1 ) = 0.0;<span class="comment">//kp*p*p * Ypm/J*dt* ( cos ( thm ) );</span> |
| 277 | <a name="l00226"></a>00226 A ( 2,2 ) = 1.0; |
| 278 | <a name="l00227"></a>00227 A ( 2,3 ) = 0.0;<span class="comment">//kp*p*p * Ypm/J*dt* ( -ibm * sin ( thm )-iam * cos ( thm ) );</span> |
| 279 | <a name="l00228"></a>00228 <span class="comment">// d th</span> |
| 280 | <a name="l00229"></a>00229 A ( 3,0 ) = 0.0; A ( 3,1 ) = 0.0; A ( 3,2 ) = dt; A ( 3,3 ) = 1.0; |
| 281 | <a name="l00230"></a>00230 } |
282 | | <a name="l00233"></a>00233 <span class="preprocessor">#endif //PMSM_H</span> |
| 283 | <a name="l00232"></a><a class="code" href="classIMpmsmStat.html#ff740ee20100ae2a2d03a2538638f8e8">00232</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsmStat.html#ff740ee20100ae2a2d03a2538638f8e8" title="Evaluates and writes result into A .">dfdu_cond</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0, mat &A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) {<a class="code" href="group__errorhandlingfunc.html#g22d38e98332f9edff88cc501463eedce" title="Abort unconditionally.">it_error</a> ( <span class="stringliteral">"not needed"</span> );}; |
| 284 | <a name="l00233"></a>00233 |
| 285 | <a name="l00234"></a>00234 }; |
| 286 | <a name="l00235"></a>00235 |
| 287 | <a name="l00237"></a><a class="code" href="classIMpmsmMz.html">00237</a> <span class="keyword">class </span><a class="code" href="classIMpmsmMz.html" title="State for PMSM with unknown Mz.">IMpmsmMz</a>: <span class="keyword">public</span> <a class="code" href="classIMpmsm.html" title="State evolution model for a PMSM drive and its derivative with respect to .">IMpmsm</a>{ |
| 288 | <a name="l00238"></a>00238 <span class="keyword">public</span>: |
| 289 | <a name="l00239"></a>00239 <a class="code" href="classIMpmsmMz.html" title="State for PMSM with unknown Mz.">IMpmsmMz</a>() {<a class="code" href="classbdm_1_1fnc.html#52156cb4a52a62d51fc7455985797a62" title="Length of the output vector.">dimy</a>=5; <a class="code" href="classbdm_1_1diffbifn.html#a193aa2c4a500139c0c4b669691e588e" title="cache for rvx.count()">dimx</a> = 5; <a class="code" href="classbdm_1_1diffbifn.html#30c45617eec89adeb4ebaa763d093fb0" title="cache for rvu.count()">dimu</a>=2;}; |
| 290 | <a name="l00241"></a><a class="code" href="classIMpmsmMz.html#c9a6825b8683ad125e3bf7edec2df7e7">00241</a> vec <a class="code" href="classIMpmsmMz.html#c9a6825b8683ad125e3bf7edec2df7e7" title="extend eval by Mz">eval</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0 ) { |
| 291 | <a name="l00242"></a>00242 vec x(4); |
| 292 | <a name="l00243"></a>00243 Mz = x0(4); <span class="comment">//last of the state is Mz</span> |
| 293 | <a name="l00244"></a>00244 |
| 294 | <a name="l00245"></a>00245 <span class="comment">//teh first 4 states are same as before (given that Mz is set)</span> |
| 295 | <a name="l00246"></a>00246 x=<a class="code" href="classIMpmsmMz.html#c9a6825b8683ad125e3bf7edec2df7e7" title="extend eval by Mz">IMpmsm::eval</a>(x0,u0); <span class="comment">// including model of drops!</span> |
| 296 | <a name="l00247"></a>00247 <span class="keywordflow">return</span> concat(x,Mz); |
| 297 | <a name="l00248"></a>00248 } |
| 298 | <a name="l00249"></a><a class="code" href="classIMpmsmMz.html#925804179c2874acdb9943bdc27c567a">00249</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsmMz.html#925804179c2874acdb9943bdc27c567a" title="Evaluates and writes result into A .">dfdx_cond</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0, mat &A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) { |
| 299 | <a name="l00250"></a>00250 <span class="comment">//call initial</span> |
| 300 | <a name="l00251"></a>00251 <span class="keywordflow">if</span> (full) A.clear(); |
| 301 | <a name="l00252"></a>00252 <a class="code" href="classIMpmsmMz.html#925804179c2874acdb9943bdc27c567a" title="Evaluates and writes result into A .">IMpmsm::dfdx_cond</a>(x0,u0,A,full); |
| 302 | <a name="l00253"></a>00253 A(2,4)=- p/J*dt; |
| 303 | <a name="l00254"></a>00254 A(4,4)=1.0; |
| 304 | <a name="l00255"></a>00255 } |
| 305 | <a name="l00256"></a>00256 }; |
| 306 | <a name="l00257"></a>00257 |
| 307 | <a name="l00259"></a><a class="code" href="classIMpmsmStatMz.html">00259</a> <span class="keyword">class </span><a class="code" href="classIMpmsmStatMz.html" title="State for PMSM with unknown Mz.">IMpmsmStatMz</a>: <span class="keyword">public</span> <a class="code" href="classIMpmsmStat.html" title="State evolution model for a PMSM drive and its derivative with respect to , equation...">IMpmsmStat</a>{ |
| 308 | <a name="l00260"></a>00260 <span class="keyword">public</span>: |
| 309 | <a name="l00261"></a>00261 <a class="code" href="classIMpmsmStatMz.html" title="State for PMSM with unknown Mz.">IMpmsmStatMz</a>() {<a class="code" href="classbdm_1_1fnc.html#52156cb4a52a62d51fc7455985797a62" title="Length of the output vector.">dimy</a>=5; <a class="code" href="classbdm_1_1diffbifn.html#a193aa2c4a500139c0c4b669691e588e" title="cache for rvx.count()">dimx</a> = 5; <a class="code" href="classbdm_1_1diffbifn.html#30c45617eec89adeb4ebaa763d093fb0" title="cache for rvu.count()">dimu</a>=2;}; |
| 310 | <a name="l00263"></a><a class="code" href="classIMpmsmStatMz.html#757c6be06a948c840a57e4d32f30214e">00263</a> vec <a class="code" href="classIMpmsmStatMz.html#757c6be06a948c840a57e4d32f30214e" title="extend eval by Mz">eval</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0 ) { |
| 311 | <a name="l00264"></a>00264 vec x(4); |
| 312 | <a name="l00265"></a>00265 Mz = x0(4); <span class="comment">//last of the state is Mz</span> |
| 313 | <a name="l00266"></a>00266 |
| 314 | <a name="l00267"></a>00267 <span class="comment">//teh first 4 states are same as before (given that Mz is set)</span> |
| 315 | <a name="l00268"></a>00268 x=<a class="code" href="classIMpmsmStatMz.html#757c6be06a948c840a57e4d32f30214e" title="extend eval by Mz">IMpmsmStat::eval</a>(x0,u0); <span class="comment">// including model of drops!</span> |
| 316 | <a name="l00269"></a>00269 <span class="keywordflow">return</span> concat(x,Mz); |
| 317 | <a name="l00270"></a>00270 } |
| 318 | <a name="l00271"></a><a class="code" href="classIMpmsmStatMz.html#957571e0a81177d399cc2539aafad8da">00271</a> <span class="keywordtype">void</span> <a class="code" href="classIMpmsmStatMz.html#957571e0a81177d399cc2539aafad8da" title="Evaluates and writes result into A .">dfdx_cond</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0, mat &A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) { |
| 319 | <a name="l00272"></a>00272 <span class="comment">//call initial</span> |
| 320 | <a name="l00273"></a>00273 <span class="keywordflow">if</span> (full) A.clear(); |
| 321 | <a name="l00274"></a>00274 <a class="code" href="classIMpmsmStatMz.html#957571e0a81177d399cc2539aafad8da" title="Evaluates and writes result into A .">IMpmsmStat::dfdx_cond</a>(x0,u0,A,full); |
| 322 | <a name="l00275"></a>00275 A(2,4)=- p/J*dt; |
| 323 | <a name="l00276"></a>00276 A(4,4)=1.0; |
| 324 | <a name="l00277"></a>00277 } |
| 325 | <a name="l00278"></a>00278 }; |
| 326 | <a name="l00279"></a>00279 |
| 327 | <a name="l00280"></a>00280 |
| 328 | <a name="l00282"></a><a class="code" href="classOMpmsm.html">00282</a> <span class="keyword">class </span><a class="code" href="classOMpmsm.html" title="Observation model for PMSM drive and its derivative with respect to .">OMpmsm</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a> { |
| 329 | <a name="l00283"></a>00283 <span class="keyword">public</span>: |
| 330 | <a name="l00284"></a>00284 <a class="code" href="classOMpmsm.html" title="Observation model for PMSM drive and its derivative with respect to .">OMpmsm</a>() :<a class="code" href="classbdm_1_1diffbifn.html#92ff29d748e445b440453a38d0b09681" title="Default constructor (dimy is not set!).">diffbifn</a> () {<a class="code" href="classbdm_1_1fnc.html#52156cb4a52a62d51fc7455985797a62" title="Length of the output vector.">dimy</a>=2;<a class="code" href="classbdm_1_1diffbifn.html#a193aa2c4a500139c0c4b669691e588e" title="cache for rvx.count()">dimx</a>=4;<a class="code" href="classbdm_1_1diffbifn.html#30c45617eec89adeb4ebaa763d093fb0" title="cache for rvu.count()">dimu</a>=2;}; |
| 331 | <a name="l00285"></a>00285 |
| 332 | <a name="l00286"></a><a class="code" href="classOMpmsm.html#8e32392c9c635584606287b8c0e8c9da">00286</a> vec <a class="code" href="classOMpmsm.html#8e32392c9c635584606287b8c0e8c9da" title="Evaluates .">eval</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0 ) { |
| 333 | <a name="l00287"></a>00287 vec y ( 2 ); |
| 334 | <a name="l00288"></a>00288 y ( 0 ) = x0 ( 0 ); |
| 335 | <a name="l00289"></a>00289 y ( 1 ) = x0 ( 1 ); |
| 336 | <a name="l00290"></a>00290 <span class="keywordflow">return</span> y; |
| 337 | <a name="l00291"></a>00291 } |
| 338 | <a name="l00292"></a>00292 |
| 339 | <a name="l00293"></a><a class="code" href="classOMpmsm.html#b75b5fd55b2ac5ed74b5b953af122821">00293</a> <span class="keywordtype">void</span> <a class="code" href="classOMpmsm.html#b75b5fd55b2ac5ed74b5b953af122821" title="Evaluates and writes result into A .">dfdx_cond</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0, mat &A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) { |
| 340 | <a name="l00294"></a>00294 A.clear(); |
| 341 | <a name="l00295"></a>00295 A ( 0,0 ) = 1.0; |
| 342 | <a name="l00296"></a>00296 A ( 1,1 ) = 1.0; |
| 343 | <a name="l00297"></a>00297 } |
| 344 | <a name="l00298"></a>00298 }; |
| 345 | <a name="l00299"></a>00299 |
| 346 | <a name="l00301"></a><a class="code" href="classOMpmsm4.html">00301</a> <span class="keyword">class </span><a class="code" href="classOMpmsm4.html" title="Observation model for PMSM drive and its derivative with respect to for full vector...">OMpmsm4</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a> { |
| 347 | <a name="l00302"></a>00302 <span class="keyword">public</span>: |
| 348 | <a name="l00303"></a>00303 <a class="code" href="classOMpmsm4.html" title="Observation model for PMSM drive and its derivative with respect to for full vector...">OMpmsm4</a>() :<a class="code" href="classbdm_1_1diffbifn.html#92ff29d748e445b440453a38d0b09681" title="Default constructor (dimy is not set!).">diffbifn</a> () {<a class="code" href="classbdm_1_1fnc.html#52156cb4a52a62d51fc7455985797a62" title="Length of the output vector.">dimy</a>=4;<a class="code" href="classbdm_1_1diffbifn.html#a193aa2c4a500139c0c4b669691e588e" title="cache for rvx.count()">dimx</a>=4;<a class="code" href="classbdm_1_1diffbifn.html#30c45617eec89adeb4ebaa763d093fb0" title="cache for rvu.count()">dimu</a>=2;}; |
| 349 | <a name="l00304"></a>00304 |
| 350 | <a name="l00305"></a><a class="code" href="classOMpmsm4.html#77f43dbd2aa19f65f8e2b7be551b81a4">00305</a> vec <a class="code" href="classOMpmsm4.html#77f43dbd2aa19f65f8e2b7be551b81a4" title="Evaluates .">eval</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0 ) { |
| 351 | <a name="l00306"></a>00306 vec y ( 4 ); |
| 352 | <a name="l00307"></a>00307 y = x0 ; |
| 353 | <a name="l00308"></a>00308 <span class="keywordflow">return</span> y; |
| 354 | <a name="l00309"></a>00309 } |
| 355 | <a name="l00310"></a>00310 |
| 356 | <a name="l00311"></a><a class="code" href="classOMpmsm4.html#1318b00e606d0a82df354c49494026dd">00311</a> <span class="keywordtype">void</span> <a class="code" href="classOMpmsm4.html#1318b00e606d0a82df354c49494026dd" title="Evaluates and writes result into A .">dfdx_cond</a> ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0, mat &A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) { |
| 357 | <a name="l00312"></a>00312 <span class="keywordflow">if</span> (full) A=<a class="code" href="group__specmat.html#gbfc73e72a56769280cd9fda812367196" title="A non-copying version of the eye function.">eye</a>(4); |
| 358 | <a name="l00313"></a>00313 } |
| 359 | <a name="l00314"></a>00314 }; |
| 360 | <a name="l00315"></a>00315 |
| 361 | <a name="l00317"></a>00317 <span class="preprocessor">#endif //PMSM_H</span> |