00001 #ifndef PMSM_H
00002 #define PMSM_H
00003
00004 RV rx ( "1 2 3 4", "{ia, ib, om, th}", ones_i ( 4 ), zeros_i ( 4 ));
00005 RV ru ( "5 6", "{ua, ub}", ones_i ( 2 ) ,zeros_i ( 2 ));
00006 RV ry ( "7 8", "{oia, oib}", ones_i ( 2 ) ,zeros_i ( 2 ));
00007
00009 class IMpmsm : public diffbifn {
00010 double Rs, Ls, dt, Ypm, kp, p, J, Mz;
00011
00012
00013 public:
00014 IMpmsm() :diffbifn ( rx, ru ) {};
00016 void set_parameters ( double Rs0, double Ls0, double dt0, double Ypm0, double kp0, double p0, double J0, double Mz0 ) {Rs=Rs0; Ls=Ls0; dt=dt0; Ypm=Ypm0; kp=kp0; p=p0; J=J0; Mz=Mz0;}
00017
00018 vec eval ( const vec &x0, const vec &u0 ) {
00019
00020 double iam = x0 ( 0 );
00021 double ibm = x0 ( 1 );
00022 double omm = x0 ( 2 );
00023 double thm = x0 ( 3 );
00024 double uam = u0 ( 0 );
00025 double ubm = u0 ( 1 );
00026
00027 vec xk=zeros ( 4 );
00028
00029 xk ( 0 ) = ( 1.0- Rs/Ls*dt ) * iam + Ypm/Ls*dt*omm * sin ( thm ) + uam*dt/Ls;
00030
00031 xk ( 1 ) = ( 1.0- Rs/Ls*dt ) * ibm - Ypm/Ls*dt*omm * cos ( thm ) + ubm*dt/Ls;
00032
00033 xk ( 2 ) = omm + kp*p*p * Ypm/J*dt* ( ibm * cos ( thm )-iam * sin ( thm ) ) - p/J*dt*Mz;
00034
00035 xk ( 3 ) = rem(thm + omm*dt,2*pi);
00036 return xk;
00037 }
00038
00039 void dfdx_cond ( const vec &x0, const vec &u0, mat &A, bool full=true ) {
00040 double iam = x0 ( 0 );
00041 double ibm = x0 ( 1 );
00042 double omm = x0 ( 2 );
00043 double thm = x0 ( 3 );
00044
00045 A ( 0,0 ) = ( 1.0- Rs/Ls*dt ); A ( 0,1 ) = 0.0;
00046 A ( 0,2 ) = Ypm/Ls*dt* sin ( thm ); A ( 0,3 ) = Ypm/Ls*dt*omm * ( cos ( thm ) );
00047
00048 A ( 1,0 ) = 0.0 ; A ( 1,1 ) = ( 1.0- Rs/Ls*dt );
00049 A ( 1,2 ) = -Ypm/Ls*dt* cos ( thm ); A ( 1,3 ) = Ypm/Ls*dt*omm * ( sin ( thm ) );
00050
00051 A ( 2,0 ) = kp*p*p * Ypm/J*dt* ( - sin ( thm ) );
00052 A ( 2,1 ) = kp*p*p * Ypm/J*dt* ( cos ( thm ) );
00053 A ( 2,2 ) = 1.0;
00054 A ( 2,3 ) = kp*p*p * Ypm/J*dt* ( -ibm * sin ( thm )-iam * cos ( thm ) );
00055
00056 A ( 3,0 ) = 0.0; A ( 3,1 ) = 0.0; A ( 3,2 ) = dt; A ( 3,3 ) = 1.0;
00057 }
00058
00059 void dfdu_cond ( const vec &x0, const vec &u0, mat &A, bool full=true ) {it_error ( "not needed" );};
00060
00061 };
00062
00064 class OMpmsm: public diffbifn {
00065 public:
00066 OMpmsm() :diffbifn ( rx,ru ) {};
00067
00068 vec eval ( const vec &x0, const vec &u0 ) {
00069 vec y ( 2 );
00070 y ( 0 ) = x0 ( 0 );
00071 y ( 1 ) = x0 ( 1 );
00072 return y;
00073 }
00074
00075 void dfdx_cond ( const vec &x0, const vec &u0, mat &A, bool full=true ) {
00076 A.clear();
00077 A ( 0,0 ) = 1.0;
00078 A ( 1,1 ) = 1.0;
00079 }
00080 };
00081
00082 #endif //PMSM_H