Changeset 1160
- Timestamp:
- 08/17/10 22:08:08 (14 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/pmsm.h
r666 r1160 26 26 27 27 bool compensate; 28 bool cutoff; 28 29 public: 29 IMpmsm() :diffbifn ( ) {dimy=4; dimx = 4; dimu=2; dimc=6;compensate=true; };30 IMpmsm() :diffbifn ( ) {dimy=4; dimx = 4; dimu=2; dimc=6;compensate=true;cutoff=true;}; 30 31 //! Set mechanical and electrical variables 31 32 virtual 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;} … … 76 77 //th 77 78 xk ( 3 ) = thm + omm*dt; // <0..2pi> 78 if ( xk ( 3 ) >pi ) xk ( 3 )-=2*pi; 79 if ( xk ( 3 ) <-pi ) xk ( 3 ) +=2*pi; 79 if (cutoff) { 80 if ( xk ( 3 ) >pi ) xk ( 3 )-=2*pi; 81 if ( xk ( 3 ) <-pi ) xk ( 3 ) +=2*pi; 82 } 80 83 return xk; 81 84 } … … 113 116 int comp; 114 117 if (UI::get(comp,root,"compensate",UI::optional)){compensate=(comp==1);} 118 int cuto; 119 if (UI::get(cuto,root,"cutoff",UI::optional)){cutoff=(cuto==1);} 115 120 }; 116 121 … … 333 338 UIREGISTER ( OMpmsm ); 334 339 340 //! Observation model for PMSM drive with roundoff-errors 341 class OMpmsmRO: public diffbifn { 342 public: 343 OMpmsmRO() :diffbifn () {dimy=2;dimx=4;dimu=0;}; 344 345 vec eval ( const vec &x0, const vec &u0 ) { 346 vec y ( 2 ); 347 /* y ( 0 ) = x0 ( 0 ); 348 y ( 1 ) = x0 ( 1 );*/ 349 350 double istep=0.085; 351 y[ 0 ] = istep*itpp::round( x0[ 0 ]/ istep) ; 352 y[ 1 ] = istep*itpp::round( x0[ 1 ]/ istep); 353 354 return y; 355 } 356 357 void dfdx_cond ( const vec &x0, const vec &u0, mat &A, bool full=true ) { 358 A.clear(); 359 A ( 0,0 ) = 1.0; 360 A ( 1,1 ) = 1.0; 361 } 362 }; 363 364 UIREGISTER ( OMpmsmRO ); 365 366 335 367 //! Observation model for PMSM drive and its derivative with respect to \f$x\f$ for full vector of observations 336 368 class OMpmsm4: public diffbifn {