Show
Ignore:
Timestamp:
03/14/11 09:32:42 (13 years ago)
Author:
smidl
Message:

new modle of pmsm

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/pmsm/pmsm.h

    r1292 r1295  
    125125UIREGISTER ( IMpmsm ); 
    126126 
     127//! Evolution model of \f$ \omega, \vartheta\f$ for a PMSM drive and its derivative with respect to \f$x\f$ 
     128class IMpmsmOT : public diffbifn { 
     129protected: 
     130        double Rs, Ls, dt, Ypm, kp, p,  J, Mz; 
     131         
     132        bool compensate; 
     133        bool cutoff; 
     134public: 
     135        IMpmsmOT() :diffbifn ( ) {dimy=2; dimx = 2; dimu=4; dimc=6;compensate=true;cutoff=true;}; 
     136        //! Set mechanical and electrical variables 
     137        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;} 
     138         
     139        void modelpwm(const vec &x0, const vec u0, double &ua, double &ub){ 
     140                /*              ua=u0[0]; 
     141                 *              ub=u0[1]; 
     142                 *              return;*/ 
     143                double sq3=sqrt ( 3.0 ); 
     144                double i1=x0(0); 
     145                double i2=0.5* ( -i1+sq3*x0[1] ); 
     146                double i3=0.5* ( -i1-sq3*x0[1] ); 
     147                double u1=u0(0); 
     148                double u2=0.5* ( -u1+sq3*u0(1) ); 
     149                double u3=0.5* ( -u1-sq3*u0(1) ); 
     150                 
     151                double du1=1.4* ( double ( i1>0.3 ) - double ( i1<-0.3 ) ) +0.2*i1; 
     152                double du2=1.4* ( double ( i2>0.3 ) - double ( i2<-0.3 ) ) +0.2*i2; 
     153                double du3=1.4* ( double ( i3>0.3 ) - double ( i3<-0.3 ) ) +0.2*i3; 
     154                ua = ( 2.0* ( u1-du1 )- ( u2-du2 )- ( u3-du3 ) ) /3.0; 
     155                ub = ( ( u2-du2 )- ( u3-du3 ) ) /sq3; 
     156        } 
     157         
     158        vec eval ( const vec &x0, const vec &u0 ) { 
     159                // last state 
     160                const double &omm = x0 ( 0 ); 
     161                const double &thm = x0 ( 1 ); 
     162                double uam; 
     163                double ubm; 
     164                 
     165                if (compensate){ 
     166                        modelpwm(x0,u0,uam,ubm); 
     167                } else { 
     168                        uam = u0(0); 
     169                        ubm = u0(1); 
     170                } 
     171                 
     172                const double &iam = u0 ( 2 ); 
     173                const double &ibm = u0 ( 3 ); 
     174                 
     175                vec xk( 2 ); 
     176                //ia 
     177                //om 
     178                xk ( 0 ) = omm + kp*p*p * Ypm/J*dt* ( ibm * cos ( thm )-iam * sin ( thm ) ) - p/J*dt*Mz; 
     179                //th 
     180                xk ( 1 ) = thm + omm*dt; // <0..2pi> 
     181                if (cutoff) { 
     182                        if ( xk ( 1 ) >pi ) xk ( 1 )-=2*pi; 
     183                        if ( xk ( 1 ) <-pi ) xk ( 1 ) +=2*pi; 
     184                } 
     185                return xk; 
     186        } 
     187         
     188        void dfdx_cond ( const vec &x0, const vec &u0, mat &A, bool full=true ) { 
     189                const double &omm = x0 ( 0 ); 
     190                const double &thm = x0 ( 1 ); 
     191 
     192                const double &iam = u0 ( 2 ); 
     193                const double &ibm = u0 ( 3 ); 
     194                 
     195                // d ia 
     196                // d om 
     197                A ( 0,0 ) = 1.0; 
     198                A ( 0,1 ) = kp*p*p * Ypm/J*dt* ( -ibm * sin ( thm )-iam * cos ( thm ) ); 
     199                // d th 
     200                A ( 1,0 ) = dt;  
     201                A ( 1,1 ) = 1.0; 
     202        } 
     203         
     204        void dfdu_cond ( const vec &x0, const vec &u0, mat &A, bool full=true ) {it_error ( "not needed" );}; 
     205         
     206        void from_setting( const Setting &root ) 
     207        {        
     208                 
     209                const SettingResolver& params_b=root["params"]; 
     210                const Setting& params=params_b.result; 
     211                 
     212                set_parameters ( params["Rs"], params["Ls"], 125e-6, params["Fmag"], \ 
     213                params["kp"], params["p"], params["J"], 0.0); 
     214                int comp=0; 
     215                if (UI::get(comp,root,"compensate",UI::optional)){compensate=(comp==1);} 
     216                int cuto=0; 
     217                if (UI::get(cuto,root,"cutoff",UI::optional)){cutoff=(cuto==1);} 
     218        }; 
     219         
     220        // TODO dodelat void to_setting( Setting &root ) const; 
     221}; 
     222 
     223UIREGISTER ( IMpmsmOT ); 
     224 
    127225 
    128226//! State evolution model for a PMSM drive and its derivative with respect to \f$x\f$ 
     
    233331                if (UI::get(comp,root,"compensate",UI::optional)){compensate=(comp==1);} 
    234332                int cuto=0; 
    235                 if (UI::get(cuto,root,"cutoff",UI::optional)){cutoff=(cuto==1);} 
     333                if (UI::get(cuto,root,"cutoff",UI::optional)){ 
     334                        cutoff=(cuto==1); 
     335                } 
    236336        }; 
    237337         
     
    240340 
    241341UIREGISTER ( IMpmsmDQ ); 
    242  
    243  
    244  
    245  
    246  
    247342 
    248343 
     
    544639UIREGISTER ( OMpmsmDQ ); 
    545640 
     641//! Observation model for PMSM drive in reduced form coordinates 
     642class OMpmsmOT: public diffbifn { 
     643public: 
     644        double Rs, Ls, dt, Ypm, kp, p,  J, Mz; 
     645         
     646        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;} 
     647         
     648        OMpmsmOT() :diffbifn () {dimy=2;dimx=2;dimu=4;}; 
     649         
     650        vec eval ( const vec &x0, const vec &u0 ) { 
     651                vec y ( 2 ); 
     652                const double &omm = x0(0); 
     653                const double &thm = x0(1); 
     654                 
     655                const double &uam = u0 ( 0 ); 
     656                const double &ubm = u0 ( 1 ); 
     657                const double &iam = u0 ( 2 ); 
     658                const double &ibm = u0 ( 3 ); 
     659                 
     660                y ( 0 ) = ( 1.0- Rs/Ls*dt ) * iam + Ypm/Ls*dt*omm * sin ( thm ) + uam*dt/Ls; 
     661                //ib 
     662                y ( 1 ) = ( 1.0- Rs/Ls*dt ) * ibm - Ypm/Ls*dt*omm * cos ( thm ) + ubm*dt/Ls; 
     663                 
     664                return y; 
     665        } 
     666         
     667        void dfdx_cond ( const vec &x0, const vec &u0, mat &A, bool full=true ) { 
     668                const double &omm = x0(0); 
     669                const double &thm = x0(1); 
     670                                 
     671                A ( 0,0 ) = Ypm/Ls*dt* sin ( thm );  
     672                A ( 0,1 ) = Ypm/Ls*dt*omm * ( cos ( thm ) ); 
     673                // d ib 
     674                A ( 1,0 ) = -Ypm/Ls*dt* cos ( thm );  
     675                A ( 1,1 ) = Ypm/Ls*dt*omm * ( sin ( thm ) ); 
     676                 
     677                 
     678        } 
     679 
     680void from_setting( const Setting &root ) 
     681{        
     682         
     683        const SettingResolver& params_b=root["params"]; 
     684        const Setting& params=params_b.result; 
     685         
     686        set_parameters ( params["Rs"], params["Ls"], 125e-6, params["Fmag"], \ 
     687        params["kp"], params["p"], params["J"], 0.0); 
     688}; 
     689 
     690}; 
     691 
     692UIREGISTER ( OMpmsmOT ); 
     693 
    546694 
    547695/*!@}*/