Changeset 232 for pmsm/pmsm.h

Show
Ignore:
Timestamp:
01/15/09 10:53:57 (15 years ago)
Author:
smidl
Message:

test 2 order Taylor

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pmsm/pmsm.h

    r224 r232  
    1212RV ru ( "{ua ub }"); 
    1313RV ry ( "{oia oib }"); 
     14RV rU = concat(ru, RV("{dua dub }")); 
    1415 
    1516// class uipmsm : public uibase{ 
    1617//      double Rs, Ls, dt, Ypm, kp, p,  J, Mz; 
    1718// }; 
     19 
     20vec x2o_dbg(4); 
    1821 
    1922//! State evolution model for a PMSM drive and its derivative with respect to \f$x\f$ 
     
    7477}; 
    7578 
     79//! State evolution model for a PMSM drive and its derivative with respect to \f$x\f$ 
     80class IMpmsm2o : public diffbifn { 
     81        protected: 
     82                double Rs, Ls, dt, Ypm, kp, p,  J, Mz; 
     83 
     84        public: 
     85                IMpmsm2o() :diffbifn (rx.count(), rx, rU ) {}; 
     86        //! Set mechanical and electrical variables 
     87                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;} 
     88 
     89                vec eval ( const vec &x0, const vec &u0 ) { 
     90                // last state 
     91                        double iam = x0 ( 0 ); 
     92                        double ibm = x0 ( 1 ); 
     93                        double omm = x0 ( 2 ); 
     94                        double thm = x0 ( 3 ); 
     95                        double uam = u0 ( 0 ); 
     96                        double ubm = u0 ( 1 ); 
     97                        double dua = u0 ( 2 )/dt; 
     98                        double dub = u0 ( 3 )/dt; 
     99 
     100                        double cth = cos(thm); 
     101                        double sth = sin(thm); 
     102                        double d2t = dt*dt/2; 
     103                         
     104                        double dia = (- Rs/Ls*iam +  Ypm/Ls*omm * sth + uam/Ls); 
     105                        double dib = (- Rs/Ls*ibm -  Ypm/Ls*omm * cth + ubm/Ls); 
     106                        double dom = kp*p*p * Ypm/J *( ibm * cth-iam * sth ) - p/J*Mz; 
     107                        double dth = omm; 
     108                         
     109                        double d2ia = (- Rs/Ls*dia +  Ypm/Ls*(dom * sth + omm*cth) + dua/Ls); 
     110                        double d2ib = (- Rs/Ls*dib -  Ypm/Ls*(dom * cth - omm*sth) + dub/Ls); 
     111                        double d2om = kp*p*p * Ypm/J *( dib * cth-ibm*sth - (dia * sth + iam *cth)); 
     112                        double d2th = dom; 
     113                         
     114                        vec xk=zeros ( 4 ); 
     115                        xk ( 0 ) =  iam + dt*dia;// +d2t*d2ia; 
     116                        xk ( 1 ) = ibm + dt*dib;// +d2t*d2ib; 
     117                        xk ( 2 ) = omm +dt*dom;// +d2t*d2om; 
     118                        xk ( 3 ) = thm + dt*dth;// +d2t*d2th; // <0..2pi> 
     119                         
     120                        x2o_dbg(0)=d2t*d2ia; 
     121                        x2o_dbg(1)=d2t*d2ib; 
     122                        x2o_dbg(2)=d2t*d2om; 
     123                        x2o_dbg(3)=d2t*d2th; 
     124                         
     125                        if ( xk ( 3 ) >pi ) xk ( 3 )-=2*pi; 
     126                        if ( xk ( 3 ) <-pi ) xk ( 3 ) +=2*pi; 
     127                        return xk; 
     128                } 
     129 
     130                void dfdx_cond ( const vec &x0, const vec &u0, mat &A, bool full=true ) { 
     131                        double iam = x0 ( 0 ); 
     132                        double ibm = x0 ( 1 ); 
     133                        double omm = x0 ( 2 ); 
     134                        double thm = x0 ( 3 ); 
     135                // d ia 
     136                        A ( 0,0 ) = ( 1.0- Rs/Ls*dt ); A ( 0,1 ) = 0.0; 
     137                        A ( 0,2 ) = Ypm/Ls*dt* sin ( thm ); A ( 0,3 ) = Ypm/Ls*dt*omm * ( cos ( thm ) ); 
     138                // d ib 
     139                        A ( 1,0 ) = 0.0 ; A ( 1,1 ) = ( 1.0- Rs/Ls*dt ); 
     140                        A ( 1,2 ) = -Ypm/Ls*dt* cos ( thm ); A ( 1,3 ) = Ypm/Ls*dt*omm * ( sin ( thm ) ); 
     141                // d om 
     142                        A ( 2,0 ) = kp*p*p * Ypm/J*dt* ( - sin ( thm ) ); 
     143                        A ( 2,1 ) = kp*p*p * Ypm/J*dt* ( cos ( thm ) ); 
     144                        A ( 2,2 ) = 1.0; 
     145                        A ( 2,3 ) = kp*p*p * Ypm/J*dt* ( -ibm * sin ( thm )-iam * cos ( thm ) ); 
     146                // d th 
     147                        A ( 3,0 ) = 0.0; A ( 3,1 ) = 0.0; A ( 3,2 ) = dt; A ( 3,3 ) = 1.0; 
     148                } 
     149 
     150                void dfdu_cond ( const vec &x0, const vec &u0, mat &A, bool full=true ) {it_error ( "not needed" );}; 
     151 
     152}; 
     153 
    76154//! State evolution model for a PMSM drive and its derivative with respect to \f$x\f$, equation for \f$\omega\f$ is omitted.$ 
    77155class IMpmsmStat : public IMpmsm {