root/doc/html/pmsm_8h-source.html @ 33

Revision 33, 10.7 kB (checked in by smidl, 16 years ago)

Oprava PF a MPF + jejich implementace pro pmsm system

Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3<title>mixpp: work/mixpp/tests/pmsm.h Source File</title>
4<link href="doxygen.css" rel="stylesheet" type="text/css">
5<link href="tabs.css" rel="stylesheet" type="text/css">
6</head><body>
7<!-- Generated by Doxygen 1.5.3 -->
8<div class="tabs">
9  <ul>
10    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
11    <li><a href="annotated.html"><span>Classes</span></a></li>
12    <li class="current"><a href="files.html"><span>Files</span></a></li>
13    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
14  </ul>
15</div>
16<h1>work/mixpp/tests/pmsm.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef PMSM_H</span>
17<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define PMSM_H</span>
18<a name="l00003"></a>00003 <span class="preprocessor"></span>
19<a name="l00004"></a>00004 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rx ( <span class="stringliteral">"1 2 3 4"</span>, <span class="stringliteral">"{ia, ib, om, th}"</span>, ones_i ( 4 ), zeros_i ( 4 ));
20<a name="l00005"></a>00005 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> ru ( <span class="stringliteral">"5 6"</span>, <span class="stringliteral">"{ua, ub}"</span>, ones_i ( 2 ) ,zeros_i ( 2 ));
21<a name="l00006"></a>00006 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> ry ( <span class="stringliteral">"7 8"</span>, <span class="stringliteral">"{oia, oib}"</span>, ones_i ( 2 ) ,zeros_i ( 2 ));
22<a name="l00007"></a>00007
23<a name="l00009"></a><a class="code" href="classIMpmsm.html">00009</a> <span class="keyword">class </span><a class="code" href="classIMpmsm.html" title="State evolution model for a PMSM drive and its derivative with respect to $x$.">IMpmsm</a> : <span class="keyword">public</span> <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables $f(x,u)$.">diffbifn</a> {
24<a name="l00010"></a>00010         <span class="keywordtype">double</span> Rs, Ls, dt, Ypm, kp, p,  J, Mz;
25<a name="l00011"></a>00011
26<a name="l00012"></a>00012 <span class="comment">//TODO hardcoded RVs!!!</span>
27<a name="l00013"></a>00013 <span class="keyword">public</span>:
28<a name="l00014"></a>00014         <a class="code" href="classIMpmsm.html" title="State evolution model for a PMSM drive and its derivative with respect to $x$.">IMpmsm</a>() :<a class="code" href="classdiffbifn.html#0b33e1bfa23be5ed234d172eb4c0e4b5" title="Default constructor (dimy is not set!).">diffbifn</a> ( rx, ru ) {};
29<a name="l00016"></a><a class="code" href="classIMpmsm.html#42818f3426d99fecb7e97be8ffe2e228">00016</a>         <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;}
30<a name="l00017"></a>00017
31<a name="l00018"></a><a class="code" href="classIMpmsm.html#45785869d978dda42828a072ec2caebe">00018</a>         vec <a class="code" href="classIMpmsm.html#45785869d978dda42828a072ec2caebe" title="Evaluates $f(x0,u0)$.">eval</a> ( <span class="keyword">const</span> vec &amp;x0, <span class="keyword">const</span> vec &amp;u0 ) {
32<a name="l00019"></a>00019                 <span class="comment">// last state</span>
33<a name="l00020"></a>00020                 <span class="keywordtype">double</span> iam = x0 ( 0 );
34<a name="l00021"></a>00021                 <span class="keywordtype">double</span> ibm = x0 ( 1 );
35<a name="l00022"></a>00022                 <span class="keywordtype">double</span> omm = x0 ( 2 );
36<a name="l00023"></a>00023                 <span class="keywordtype">double</span> thm = x0 ( 3 );
37<a name="l00024"></a>00024                 <span class="keywordtype">double</span> uam = u0 ( 0 );
38<a name="l00025"></a>00025                 <span class="keywordtype">double</span> ubm = u0 ( 1 );
39<a name="l00026"></a>00026
40<a name="l00027"></a>00027                 vec xk=zeros ( 4 );
41<a name="l00028"></a>00028                 <span class="comment">//ia</span>
42<a name="l00029"></a>00029                 xk ( 0 ) = ( 1.0- Rs/Ls*dt ) * iam + Ypm/Ls*dt*omm * sin ( thm ) + uam*dt/Ls;
43<a name="l00030"></a>00030                 <span class="comment">//ib</span>
44<a name="l00031"></a>00031                 xk ( 1 ) = ( 1.0- Rs/Ls*dt ) * ibm - Ypm/Ls*dt*omm * cos ( thm ) + ubm*dt/Ls;
45<a name="l00032"></a>00032                 <span class="comment">//om</span>
46<a name="l00033"></a>00033                 xk ( 2 ) = omm + kp*p*p * Ypm/J*dt* ( ibm * cos ( thm )-iam * sin ( thm ) ) - p/J*dt*Mz;
47<a name="l00034"></a>00034                 <span class="comment">//th</span>
48<a name="l00035"></a>00035                 xk ( 3 ) = rem(thm + omm*dt,2*pi);
49<a name="l00036"></a>00036                 <span class="keywordflow">return</span> xk;
50<a name="l00037"></a>00037         }
51<a name="l00038"></a>00038
52<a name="l00039"></a><a class="code" href="classIMpmsm.html#b4378b5d3bf64c683e4cf5c5f1cd56f1">00039</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 &amp;x0, <span class="keyword">const</span> vec &amp;u0, mat &amp;A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) {
53<a name="l00040"></a>00040                 <span class="keywordtype">double</span> iam = x0 ( 0 );
54<a name="l00041"></a>00041                 <span class="keywordtype">double</span> ibm = x0 ( 1 );
55<a name="l00042"></a>00042                 <span class="keywordtype">double</span> omm = x0 ( 2 );
56<a name="l00043"></a>00043                 <span class="keywordtype">double</span> thm = x0 ( 3 );
57<a name="l00044"></a>00044                 <span class="comment">// d ia</span>
58<a name="l00045"></a>00045                 A ( 0,0 ) = ( 1.0- Rs/Ls*dt ); A ( 0,1 ) = 0.0;
59<a name="l00046"></a>00046                 A ( 0,2 ) = Ypm/Ls*dt* sin ( thm ); A ( 0,3 ) = Ypm/Ls*dt*omm * ( cos ( thm ) );
60<a name="l00047"></a>00047                 <span class="comment">// d ib</span>
61<a name="l00048"></a>00048                 A ( 1,0 ) = 0.0 ; A ( 1,1 ) = ( 1.0- Rs/Ls*dt );
62<a name="l00049"></a>00049                 A ( 1,2 ) = -Ypm/Ls*dt* cos ( thm ); A ( 1,3 ) = Ypm/Ls*dt*omm * ( sin ( thm ) );
63<a name="l00050"></a>00050                 <span class="comment">// d om</span>
64<a name="l00051"></a>00051                 A ( 2,0 ) = kp*p*p * Ypm/J*dt* ( - sin ( thm ) );
65<a name="l00052"></a>00052                 A ( 2,1 ) = kp*p*p * Ypm/J*dt* ( cos ( thm ) );
66<a name="l00053"></a>00053                 A ( 2,2 ) = 1.0;
67<a name="l00054"></a>00054                 A ( 2,3 ) = kp*p*p * Ypm/J*dt* ( -ibm * sin ( thm )-iam * cos ( thm ) );
68<a name="l00055"></a>00055                 <span class="comment">// d th</span>
69<a name="l00056"></a>00056                 A ( 3,0 ) = 0.0; A ( 3,1 ) = 0.0; A ( 3,2 ) = dt; A ( 3,3 ) = 1.0;
70<a name="l00057"></a>00057         }
71<a name="l00058"></a>00058
72<a name="l00059"></a><a class="code" href="classIMpmsm.html#c3f8dad22ae9855c04a1d593b45c99b5">00059</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 &amp;x0, <span class="keyword">const</span> vec &amp;u0, mat &amp;A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) {it_error ( <span class="stringliteral">"not needed"</span> );};
73<a name="l00060"></a>00060
74<a name="l00061"></a>00061 };
75<a name="l00062"></a>00062
76<a name="l00064"></a><a class="code" href="classOMpmsm.html">00064</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 $f(x,u)$.">diffbifn</a> {
77<a name="l00065"></a>00065 <span class="keyword">public</span>:
78<a name="l00066"></a>00066         <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#0b33e1bfa23be5ed234d172eb4c0e4b5" title="Default constructor (dimy is not set!).">diffbifn</a> ( rx,ru ) {};
79<a name="l00067"></a>00067
80<a name="l00068"></a><a class="code" href="classOMpmsm.html#8e32392c9c635584606287b8c0e8c9da">00068</a>         vec <a class="code" href="classOMpmsm.html#8e32392c9c635584606287b8c0e8c9da" title="Evaluates $f(x0,u0)$.">eval</a> ( <span class="keyword">const</span> vec &amp;x0, <span class="keyword">const</span> vec &amp;u0 ) {
81<a name="l00069"></a>00069                 vec y ( 2 );
82<a name="l00070"></a>00070                 y ( 0 ) = x0 ( 0 );
83<a name="l00071"></a>00071                 y ( 1 ) = x0 ( 1 );
84<a name="l00072"></a>00072                 <span class="keywordflow">return</span> y;
85<a name="l00073"></a>00073         }
86<a name="l00074"></a>00074
87<a name="l00075"></a><a class="code" href="classOMpmsm.html#b75b5fd55b2ac5ed74b5b953af122821">00075</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 &amp;x0, <span class="keyword">const</span> vec &amp;u0, mat &amp;A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) {
88<a name="l00076"></a>00076                 A.clear();
89<a name="l00077"></a>00077                 A ( 0,0 ) = 1.0;
90<a name="l00078"></a>00078                 A ( 1,1 ) = 1.0;
91<a name="l00079"></a>00079         }
92<a name="l00080"></a>00080 };
93<a name="l00081"></a>00081
94<a name="l00082"></a>00082 <span class="preprocessor">#endif //PMSM_H</span>
95</pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Wed Mar 5 15:40:01 2008 for mixpp by&nbsp;
96<a href="http://www.doxygen.org/index.html">
97<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
98</body>
99</html>
Note: See TracBrowser for help on using the browser.