86 | | <a name="l00072"></a>00072 <span class="keyword">class </span>IMpmsmStat : <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 $x$.">IMpmsm</a> { |
87 | | <a name="l00073"></a>00073 IMpmsmStat() :<a class="code" href="classIMpmsm.html" title="State evolution model for a PMSM drive and its derivative with respect to $x$.">IMpmsm</a>() {}; |
88 | | <a name="l00075"></a>00075 <span class="keywordtype">void</span> <a class="code" href="classIMpmsm.html#42818f3426d99fecb7e97be8ffe2e228" 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;} |
89 | | <a name="l00076"></a>00076 |
90 | | <a name="l00077"></a>00077 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 ) { |
91 | | <a name="l00078"></a>00078 <span class="comment">// last state</span> |
92 | | <a name="l00079"></a>00079 <span class="keywordtype">double</span> iam = x0 ( 0 ); |
93 | | <a name="l00080"></a>00080 <span class="keywordtype">double</span> ibm = x0 ( 1 ); |
94 | | <a name="l00081"></a>00081 <span class="keywordtype">double</span> omm = x0 ( 2 ); |
95 | | <a name="l00082"></a>00082 <span class="keywordtype">double</span> thm = x0 ( 3 ); |
96 | | <a name="l00083"></a>00083 <span class="keywordtype">double</span> uam = u0 ( 0 ); |
97 | | <a name="l00084"></a>00084 <span class="keywordtype">double</span> ubm = u0 ( 1 ); |
98 | | <a name="l00085"></a>00085 |
99 | | <a name="l00086"></a>00086 vec xk=zeros ( 4 ); |
100 | | <a name="l00087"></a>00087 <span class="comment">//ia</span> |
101 | | <a name="l00088"></a>00088 xk ( 0 ) = ( 1.0- Rs/Ls*dt ) * iam + Ypm/Ls*dt*omm * sin ( thm ) + uam*dt/Ls; |
102 | | <a name="l00089"></a>00089 <span class="comment">//ib</span> |
103 | | <a name="l00090"></a>00090 xk ( 1 ) = ( 1.0- Rs/Ls*dt ) * ibm - Ypm/Ls*dt*omm * cos ( thm ) + ubm*dt/Ls; |
104 | | <a name="l00091"></a>00091 <span class="comment">//om</span> |
105 | | <a name="l00092"></a>00092 xk ( 2 ) = omm;<span class="comment">// + kp*p*p * Ypm/J*dt* ( ibm * cos ( thm )-iam * sin ( thm ) ) - p/J*dt*Mz;</span> |
106 | | <a name="l00093"></a>00093 <span class="comment">//th</span> |
107 | | <a name="l00094"></a>00094 xk ( 3 ) = rem(thm + omm*dt,2*pi); <span class="comment">// <0..2pi></span> |
108 | | <a name="l00095"></a>00095 <span class="keywordflow">return</span> xk; |
109 | | <a name="l00096"></a>00096 } |
110 | | <a name="l00097"></a>00097 |
111 | | <a name="l00098"></a>00098 <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> ) { |
112 | | <a name="l00099"></a>00099 <span class="comment">// double iam = x0 ( 0 );</span> |
113 | | <a name="l00100"></a>00100 <span class="comment">// double ibm = x0 ( 1 );</span> |
114 | | <a name="l00101"></a>00101 <span class="keywordtype">double</span> omm = x0 ( 2 ); |
115 | | <a name="l00102"></a>00102 <span class="keywordtype">double</span> thm = x0 ( 3 ); |
116 | | <a name="l00103"></a>00103 <span class="comment">// d ia</span> |
117 | | <a name="l00104"></a>00104 A ( 0,0 ) = ( 1.0- Rs/Ls*dt ); A ( 0,1 ) = 0.0; |
118 | | <a name="l00105"></a>00105 A ( 0,2 ) = Ypm/Ls*dt* sin ( thm ); A ( 0,3 ) = Ypm/Ls*dt*omm * ( cos ( thm ) ); |
119 | | <a name="l00106"></a>00106 <span class="comment">// d ib</span> |
120 | | <a name="l00107"></a>00107 A ( 1,0 ) = 0.0 ; A ( 1,1 ) = ( 1.0- Rs/Ls*dt ); |
121 | | <a name="l00108"></a>00108 A ( 1,2 ) = -Ypm/Ls*dt* cos ( thm ); A ( 1,3 ) = Ypm/Ls*dt*omm * ( sin ( thm ) ); |
122 | | <a name="l00109"></a>00109 <span class="comment">// d om</span> |
123 | | <a name="l00110"></a>00110 A ( 2,0 ) = 0.0;<span class="comment">//kp*p*p * Ypm/J*dt* ( - sin ( thm ) );</span> |
124 | | <a name="l00111"></a>00111 A ( 2,1 ) = 0.0;<span class="comment">//kp*p*p * Ypm/J*dt* ( cos ( thm ) );</span> |
125 | | <a name="l00112"></a>00112 A ( 2,2 ) = 1.0; |
126 | | <a name="l00113"></a>00113 A ( 2,3 ) = 0.0;<span class="comment">//kp*p*p * Ypm/J*dt* ( -ibm * sin ( thm )-iam * cos ( thm ) );</span> |
127 | | <a name="l00114"></a>00114 <span class="comment">// d th</span> |
128 | | <a name="l00115"></a>00115 A ( 3,0 ) = 0.0; A ( 3,1 ) = 0.0; A ( 3,2 ) = dt; A ( 3,3 ) = 1.0; |
129 | | <a name="l00116"></a>00116 } |
130 | | <a name="l00117"></a>00117 |
131 | | <a name="l00118"></a>00118 <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> );}; |
132 | | <a name="l00119"></a>00119 |
133 | | <a name="l00120"></a>00120 }; |
134 | | <a name="l00121"></a>00121 |
135 | | <a name="l00123"></a><a class="code" href="classOMpmsm.html">00123</a> <span class="keyword">class </span><a class="code" href="classOMpmsm.html" title="Observation model for PMSM drive and its derivative with respect to $x$.">OMpmsm</a>: <span class="keyword">public</span> <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a> { |
136 | | <a name="l00124"></a>00124 <span class="keyword">public</span>: |
137 | | <a name="l00125"></a>00125 <a class="code" href="classOMpmsm.html" title="Observation model for PMSM drive and its derivative with respect to $x$.">OMpmsm</a>() :<a class="code" href="classdiffbifn.html#797772c0d5aab8ddccec19dfe4bb2d77" title="Default constructor (dimy is not set!).">diffbifn</a> (2, rx,ru ) {}; |
138 | | <a name="l00126"></a>00126 |
139 | | <a name="l00127"></a><a class="code" href="classOMpmsm.html#8e32392c9c635584606287b8c0e8c9da">00127</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 ) { |
140 | | <a name="l00128"></a>00128 vec y ( 2 ); |
141 | | <a name="l00129"></a>00129 y ( 0 ) = x0 ( 0 ); |
142 | | <a name="l00130"></a>00130 y ( 1 ) = x0 ( 1 ); |
143 | | <a name="l00131"></a>00131 <span class="keywordflow">return</span> y; |
144 | | <a name="l00132"></a>00132 } |
145 | | <a name="l00133"></a>00133 |
146 | | <a name="l00134"></a><a class="code" href="classOMpmsm.html#b75b5fd55b2ac5ed74b5b953af122821">00134</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> ) { |
147 | | <a name="l00135"></a>00135 A.clear(); |
148 | | <a name="l00136"></a>00136 A ( 0,0 ) = 1.0; |
149 | | <a name="l00137"></a>00137 A ( 1,1 ) = 1.0; |
150 | | <a name="l00138"></a>00138 } |
151 | | <a name="l00139"></a>00139 }; |
152 | | <a name="l00140"></a>00140 |
153 | | <a name="l00141"></a>00141 <span class="preprocessor">#endif //PMSM_H</span> |
| 86 | <a name="l00073"></a><a class="code" href="classIMpmsmStat.html">00073</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> { |
| 87 | <a name="l00074"></a>00074 <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>() {}; |
| 88 | <a name="l00076"></a>00076 <span class="keywordtype">void</span> set_parameters ( <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;} |
| 89 | <a name="l00077"></a>00077 |
| 90 | <a name="l00078"></a>00078 vec eval ( <span class="keyword">const</span> vec &x0, <span class="keyword">const</span> vec &u0 ) { |
| 91 | <a name="l00079"></a>00079 <span class="comment">// last state</span> |
| 92 | <a name="l00080"></a>00080 <span class="keywordtype">double</span> iam = x0 ( 0 ); |
| 93 | <a name="l00081"></a>00081 <span class="keywordtype">double</span> ibm = x0 ( 1 ); |
| 94 | <a name="l00082"></a>00082 <span class="keywordtype">double</span> omm = x0 ( 2 ); |
| 95 | <a name="l00083"></a>00083 <span class="keywordtype">double</span> thm = x0 ( 3 ); |
| 96 | <a name="l00084"></a>00084 <span class="keywordtype">double</span> uam = u0 ( 0 ); |
| 97 | <a name="l00085"></a>00085 <span class="keywordtype">double</span> ubm = u0 ( 1 ); |
| 98 | <a name="l00086"></a>00086 |
| 99 | <a name="l00087"></a>00087 vec xk=zeros ( 4 ); |
| 100 | <a name="l00088"></a>00088 <span class="comment">//ia</span> |
| 101 | <a name="l00089"></a>00089 xk ( 0 ) = ( 1.0- Rs/Ls*dt ) * iam + Ypm/Ls*dt*omm * sin ( thm ) + uam*dt/Ls; |
| 102 | <a name="l00090"></a>00090 <span class="comment">//ib</span> |
| 103 | <a name="l00091"></a>00091 xk ( 1 ) = ( 1.0- Rs/Ls*dt ) * ibm - Ypm/Ls*dt*omm * cos ( thm ) + ubm*dt/Ls; |
| 104 | <a name="l00092"></a>00092 <span class="comment">//om</span> |
| 105 | <a name="l00093"></a>00093 xk ( 2 ) = omm;<span class="comment">// + kp*p*p * Ypm/J*dt* ( ibm * cos ( thm )-iam * sin ( thm ) ) - p/J*dt*Mz;</span> |
| 106 | <a name="l00094"></a>00094 <span class="comment">//th</span> |
| 107 | <a name="l00095"></a>00095 xk ( 3 ) = rem(thm + omm*dt,2*pi); <span class="comment">// <0..2pi></span> |
| 108 | <a name="l00096"></a>00096 <span class="keywordflow">return</span> xk; |
| 109 | <a name="l00097"></a>00097 } |
| 110 | <a name="l00098"></a>00098 |
| 111 | <a name="l00099"></a>00099 <span class="keywordtype">void</span> dfdx_cond ( <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> ) { |
| 112 | <a name="l00100"></a>00100 <span class="comment">// double iam = x0 ( 0 );</span> |
| 113 | <a name="l00101"></a>00101 <span class="comment">// double ibm = x0 ( 1 );</span> |
| 114 | <a name="l00102"></a>00102 <span class="keywordtype">double</span> omm = x0 ( 2 ); |
| 115 | <a name="l00103"></a>00103 <span class="keywordtype">double</span> thm = x0 ( 3 ); |
| 116 | <a name="l00104"></a>00104 <span class="comment">// d ia</span> |
| 117 | <a name="l00105"></a>00105 A ( 0,0 ) = ( 1.0- Rs/Ls*dt ); A ( 0,1 ) = 0.0; |
| 118 | <a name="l00106"></a>00106 A ( 0,2 ) = Ypm/Ls*dt* sin ( thm ); A ( 0,3 ) = Ypm/Ls*dt*omm * ( cos ( thm ) ); |
| 119 | <a name="l00107"></a>00107 <span class="comment">// d ib</span> |
| 120 | <a name="l00108"></a>00108 A ( 1,0 ) = 0.0 ; A ( 1,1 ) = ( 1.0- Rs/Ls*dt ); |
| 121 | <a name="l00109"></a>00109 A ( 1,2 ) = -Ypm/Ls*dt* cos ( thm ); A ( 1,3 ) = Ypm/Ls*dt*omm * ( sin ( thm ) ); |
| 122 | <a name="l00110"></a>00110 <span class="comment">// d om</span> |
| 123 | <a name="l00111"></a>00111 A ( 2,0 ) = 0.0;<span class="comment">//kp*p*p * Ypm/J*dt* ( - sin ( thm ) );</span> |
| 124 | <a name="l00112"></a>00112 A ( 2,1 ) = 0.0;<span class="comment">//kp*p*p * Ypm/J*dt* ( cos ( thm ) );</span> |
| 125 | <a name="l00113"></a>00113 A ( 2,2 ) = 1.0; |
| 126 | <a name="l00114"></a>00114 A ( 2,3 ) = 0.0;<span class="comment">//kp*p*p * Ypm/J*dt* ( -ibm * sin ( thm )-iam * cos ( thm ) );</span> |
| 127 | <a name="l00115"></a>00115 <span class="comment">// d th</span> |
| 128 | <a name="l00116"></a>00116 A ( 3,0 ) = 0.0; A ( 3,1 ) = 0.0; A ( 3,2 ) = dt; A ( 3,3 ) = 1.0; |
| 129 | <a name="l00117"></a>00117 } |
| 130 | <a name="l00118"></a>00118 |
| 131 | <a name="l00119"></a>00119 <span class="keywordtype">void</span> dfdu_cond ( <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> );}; |
| 132 | <a name="l00120"></a>00120 |
| 133 | <a name="l00121"></a>00121 }; |
| 134 | <a name="l00122"></a>00122 |
| 135 | <a name="l00124"></a><a class="code" href="classOMpmsm.html">00124</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="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a> { |
| 136 | <a name="l00125"></a>00125 <span class="keyword">public</span>: |
| 137 | <a name="l00126"></a>00126 <a class="code" href="classOMpmsm.html" title="Observation model for PMSM drive and its derivative with respect to .">OMpmsm</a>() :<a class="code" href="classdiffbifn.html#797772c0d5aab8ddccec19dfe4bb2d77" title="Default constructor (dimy is not set!).">diffbifn</a> (2, rx,ru ) {}; |
| 138 | <a name="l00127"></a>00127 |
| 139 | <a name="l00128"></a><a class="code" href="classOMpmsm.html#8e32392c9c635584606287b8c0e8c9da">00128</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 ) { |
| 140 | <a name="l00129"></a>00129 vec y ( 2 ); |
| 141 | <a name="l00130"></a>00130 y ( 0 ) = x0 ( 0 ); |
| 142 | <a name="l00131"></a>00131 y ( 1 ) = x0 ( 1 ); |
| 143 | <a name="l00132"></a>00132 <span class="keywordflow">return</span> y; |
| 144 | <a name="l00133"></a>00133 } |
| 145 | <a name="l00134"></a>00134 |
| 146 | <a name="l00135"></a><a class="code" href="classOMpmsm.html#b75b5fd55b2ac5ed74b5b953af122821">00135</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> ) { |
| 147 | <a name="l00136"></a>00136 A.clear(); |
| 148 | <a name="l00137"></a>00137 A ( 0,0 ) = 1.0; |
| 149 | <a name="l00138"></a>00138 A ( 1,1 ) = 1.0; |
| 150 | <a name="l00139"></a>00139 } |
| 151 | <a name="l00140"></a>00140 }; |
| 152 | <a name="l00141"></a>00141 |
| 153 | <a name="l00142"></a>00142 <span class="preprocessor">#endif //PMSM_H</span> |