Changeset 342

Show
Ignore:
Timestamp:
05/14/09 17:16:45 (15 years ago)
Author:
smidl
Message:

Barcelona

Files:
8 modified
1 copied

Legend:

Unmodified
Added
Removed
  • applications/pmsm/Barcelona/MM.cfg

    r338 r342  
    22 
    33experiment={ 
    4         ndat = 90000; 
     4        ndat = 60000; 
    55}; 
    66 
     
    99        params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";}; 
    1010        tstep = 1.0; // steps for profile in [s] 
    11         profileW = [1, 5, 10, 10, 3, 0, -3, -10, -10, 3, 0]; 
    12         profileM = [0, 10, 0, 0, 10, 0, 10, 0, 10, 0]; 
     11        profileW = [1, 5, 10, 10, 10, 3, 0, 0]; 
     12        profileM = [0, 0, 10, 0, 10, 0, 10, 0]; 
    1313}; 
    1414 
    15 estimator = ( 
    16          {type="EKF"; 
    17          IM = {type="pmsmIM"; 
    18                 params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";}; 
    19                 variant = "Mz"; 
    20          }; 
    21          OM = {type="pmsmOM";}; 
    22          dQ=[0.17, 0.17, 0.004, 1e-6, 1e-1]; 
    23          dR=[0.025, 0.025]; 
    24          dP0=[1., 1., 1., 1., 1e-2]; 
    25          //connect 
    26          drv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];};  // observed u 
    27          //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u 
    28          rv = {type="rv"; names=["EKFMz"]; sizes=[5];}; 
    29          options="logll"; 
    30          }, 
    31                                  // 
    32          {type="EKF"; 
     15E1={type="EKF"; 
    3316         IM = {type="pmsmIM"; 
    3417                params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";}; 
     
    3619         }; 
    3720         OM = {type="pmsmOM";}; 
    38          dQ=[0.17, 0.17, 0.00004, 1e-8]; 
     21         dQ=[1.7, 1.7, 0.004, 1e-5]; 
    3922         dR=[0.025, 0.025]; 
    4023         dP0=[1., 1., 1., 1.]; 
     
    4427         rv = {type="rv"; names=["EKF"]; sizes=[4];}; 
    4528         options="logll"; 
    46          }, 
    47                                                                  // 
    48          {type="EKF"; 
     29         }; 
     30E2= {type="EKF"; 
    4931         IM = {type="pmsmIM"; 
    5032                params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";}; 
     
    5234         }; 
    5335         OM = {type="pmsmOM";}; 
    54          dQ=[0.17, 0.17, 0.004, 1e-5]; 
     36         dQ=[1.7, 1.7, 0.004, 1e-5]; 
    5537         dR=[0.025, 0.025]; 
    5638         dP0=[1., 1., 1., 1.]; 
     
    6042         rv = {type="rv"; names=["EKFw"]; sizes=[4];}; 
    6143         options="logll"; 
    62          } 
    63  
    64  
    65 ); 
     44         }; 
     45          
     46estimator = ( 
     47        {type="internal";path="E1";}, 
     48        {type="internal";path="E2";}, 
     49        {type="MultiModel"; 
     50         models=( 
     51                {type="internal";path="E1";}, 
     52                {type="internal";path="E2";}); 
     53                options="logll"; 
     54        }); 
    6655         
    6756logger= { 
    68         type="dirfilelog"; 
     57`       type="dirfilelog"; 
    6958        maxlen = 1; 
    70         dirname = "exp/Mz"; 
     59        dirname = "MM"; 
    7160}; 
  • applications/pmsm/Barcelona/Mz.cfg

    r338 r342  
    22 
    33experiment={ 
    4         ndat = 90000; 
     4        ndat = 120000; 
    55}; 
    66 
     
    99        params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";}; 
    1010        tstep = 1.0; // steps for profile in [s] 
    11         profileW = [1, 5, 10, 10, 3, 0, -3, -10, -10, 3, 0]; 
    12         profileM = [0, 10, 0, 0, 10, 0, 10, 0, 10, 0]; 
     11        profileW = [0, 1, 5, 10, 10, 3, 0, 0, -3, -3, -10, -10, -4, 0, 0]; 
     12        profileM = [0, 10, 0, 0, 10, 0, 0, 0, 0, 0, 10, 0, 0]; 
     13        options = "modelu"; 
    1314}; 
    1415 
     
    2021         }; 
    2122         OM = {type="pmsmOM";}; 
    22          dQ=[0.17, 0.17, 0.004, 1e-6, 1e-1]; 
     23/*       dQ :  
     24        { 
     25        elements = [ 0.001738643873, 0.001738643873, 1.00000004, 1.562501e-08, 1 ]; 
     26        cols = 4; 
     27        };*/ 
     28        dQ=[0.0017, 0.0017, 0.00000004, 1e-14, 1e-1]; 
    2329         dR=[0.025, 0.025]; 
    24          dP0=[1., 1., 1., 1., 1e-2]; 
     30         dP0=[0., 0., 0., 0., 0.]; 
    2531         //connect 
    2632         drv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];};  // observed u 
    2733         //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u 
    2834         rv = {type="rv"; names=["EKFMz"]; sizes=[5];}; 
    29          options="logll"; 
     35         options="logll,logbounds"; 
    3036         }, 
    3137                                 // 
     
    3642         }; 
    3743         OM = {type="pmsmOM";}; 
    38          dQ=[0.17, 0.17, 0.00004, 1e-8]; 
     44         dQ=[0.017, 0.017, .1, 1e-6]; 
    3945         dR=[0.025, 0.025]; 
    4046         dP0=[1., 1., 1., 1.]; 
     
    4349         //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u 
    4450         rv = {type="rv"; names=["EKF"]; sizes=[4];}; 
    45          options="logll"; 
     51         options="logll,logbounds"; 
    4652         }, 
    4753                                                                 // 
     
    5258         }; 
    5359         OM = {type="pmsmOM";}; 
    54          dQ=[0.17, 0.17, 0.004, 1e-5]; 
     60         dQ=[0.017, 0.017, .1, 1e-6];//[0.017, 0.017, 100., 1e-4]; 
    5561         dR=[0.025, 0.025]; 
    5662         dP0=[1., 1., 1., 1.]; 
     
    5965         //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u 
    6066         rv = {type="rv"; names=["EKFw"]; sizes=[4];}; 
    61          options="logll"; 
     67         options="logll,logbounds"; 
     68         }, 
     69 
     70         {type="pmsmCRBMz"; 
     71         IM = {type="pmsmIM"; 
     72                params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";}; 
     73                variant = "Mz"; 
     74         }; 
     75         OM = {type="pmsmOM";}; 
     76        dQ=[0.0017, 0.0017, 0.00000004, 1e-14, 1e-1]; 
     77//       dQ=[0.017, 0.017, .1, 1e-6];//[0.017, 0.017, 100., 1e-4]; 
     78         dR=[0.025, 0.025]; 
     79         dP0=[0., 0., 0., 0., 0.]; 
     80         //connect 
     81         drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];};  // observed u 
     82         //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u 
     83         rv = {type="rv"; names=["CRB"]; sizes=[5];}; 
     84         options="logll,logbounds"; 
    6285         } 
    6386 
     
    6790logger= { 
    6891        type="dirfilelog"; 
    69         maxlen = 1; 
     92        maxlen = 100; 
    7093        dirname = "exp/Mz"; 
    7194}; 
  • applications/pmsm/Barcelona/QandR.m

    r338 r342  
    3030R11 = (istep+istep)^2/12 
    3131 
    32 %diffs 
    33 Tl=10; 
    34 th=[0 pi/2 pi]; 
     32% %diffs 
     33 Tl=10; 
     34% th=[0 pi/2 pi]; 
     35% dom = p/J*Tl*dt 
     36% dia = Fmag/Ls*dt*dom*sin(th) 
     37% dib = -Fmag/Ls*dt*dom*cos(th) 
     38% dth = dom*dt 
     39%  
     40% % from om=0; 
     41% dom2= dom + kp*p*p * Fmag/J*dt* ( dib .* cos ( th +dth)- dia .* sin ( th +dth) ) + dom 
     42% dia = Fmag/Ls*dt*dom2.*sin(th+dth) 
     43% dib = -Fmag/Ls*dt*dom2.*cos(th+dth) 
     44% dth = dom2*dt 
     45%  
     46 
    3547dom = p/J*Tl*dt 
    36 dia = Fmag/Ls*dt*dom*sin(th) 
    37 dib = -Fmag/Ls*dt*dom*cos(th) 
    38 dth = dom*dt 
    39  
    40 % from om=0; 
    41 dom2= dom + kp*p*p * Fmag/J*dt* ( dib .* cos ( th +dth)- dia .* sin ( th +dth) ) + dom 
    42 dia = Fmag/Ls*dt*dom2.*sin(th+dth) 
    43 dib = -Fmag/Ls*dt*dom2.*cos(th+dth) 
    44 dth = dom2*dt 
     48Qrat=[Fmag/Ls*dt,Fmag/Ls*dt, 1, dt].^2 
  • applications/pmsm/pmsmDS.h

    r332 r342  
    3535public: 
    3636        //! Constructor with fixed sampling period 
    37         pmsmDS ()   {Dt=125; Drv=RV ( "{o_ua o_ub o_ia o_ib t_ua t_ub o_om o_th }" );} 
     37        pmsmDS ()   {Dt=125; Drv=RV ( "{o_ua o_ub o_ia o_ib t_ua t_ub o_om o_th Mz }" );} 
    3838        void set_parameters ( double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0 ) { 
    3939                pmsmsim_set_parameters ( Rs0, Ls0, Fmag0, Bf0, p0, kp0, J0, Uc0, DT0, dt0 ); 
     
    4141        //! parse options: "modelu" => opt_modu=true; 
    4242        void set_options ( string &opt ) { 
    43                 opt_modu = ( opt.find ( "modelu" ) ==string::npos ); 
    44         } 
    45         void getdata ( vec &dt ) {dt.set_subvector(0,vec ( KalmanObs,6 ));dt(6)=x[2];dt(7)=x[3];} 
     43                opt_modu = ( opt.find ( "modelu" ) !=string::npos ); 
     44        } 
     45        void getdata ( vec &dt ) {dt.set_subvector(0,vec ( KalmanObs,6 ));dt(6)=x[2];dt(7)=x[3];dt(8)=x[8];} 
    4646        void write ( vec &ut ) {} 
    4747 
     
    8282                 
    8383                //discretization 
    84                 double ustep=0.6; 
     84                double ustep=1.2; 
    8585                KalmanObs [ 0 ] = ustep*itpp::round( KalmanObs [ 0 ]/ ustep) ; 
    8686                KalmanObs [ 1 ] = ustep*itpp::round(KalmanObs [ 1 ]/ ustep); 
     
    177177        } 
    178178}; 
     179 
     180//! This class behaves like BM but it is evaluating EKF 
     181class pmsmCRBMz : public EKFfull{ 
     182        protected: 
     183                int L_CRB; 
     184        public: 
     185        //! constructor 
     186                pmsmCRBMz():EKFfull(){} 
     187 
     188                void bayes(const vec &dt){ 
     189//assume we know state exactly: 
     190                        vec true_state(5); 
     191                        true_state.set_subvector(0,vec(x,4)); // read from pmsm 
     192                        true_state(4)=x[8]; 
     193                         
     194                        E.set_mu(true_state); 
     195                        mu = true_state; 
     196                        //hack for ut 
     197                        EKFfull::bayes(dt); 
     198                } 
     199         
     200                void log_add(logger &L, const string &name="" ){ 
     201                        L_CRB=L.add(concat(rx,RV("Mz",1,0)),"crb"); 
     202                } 
     203                void logit(logger &L){ 
     204                        L.logit(L_CRB,diag(_R())); 
     205                } 
     206}; 
  • applications/pmsm/pmsm_estim.cpp

    r318 r342  
    1010#include "stat/loggers_ui.h" 
    1111#include "estim/KF_ui.h" 
     12#include "stat/libDS_ui.h" 
    1213 
    1314using namespace bdm; 
  • applications/pmsm/pmsm_ui.h

    r332 r342  
    127127}; 
    128128UIREGISTER ( UIpmsmCRB ); 
     129 
     130class UIpmsmCRBMz: public UIbuilder { 
     131        public: 
     132                UIpmsmCRBMz():UIbuilder("pmsmCRBMz"){}; 
     133                bdmroot* build ( Setting &S ) const { 
     134                        diffbifn* IM; UIbuild(S["IM"],IM); 
     135                        diffbifn* OM; UIbuild(S["OM"],OM); 
     136                 
     137                //parameters 
     138                        pmsmCRBMz* E; E=new pmsmCRBMz; 
     139                 
     140                //statistics 
     141                        int dim=IM->dimension(); 
     142                        vec mu0; 
     143                        mat P0; 
     144                        if (S.exists("mu0")){mu0=getvec(S["mu0"]);}else{mu0=zeros(dim);}; 
     145                        if (S.exists("dP0")){P0=diag(getvec(S["dP0"]));}else{ 
     146                                if (S.exists("P0")){mu0=getmat(S["P0"],dim);}else{P0=eye(dim);}; 
     147                        } 
     148                        E->set_statistics(mu0,P0); 
     149                 
     150                        E->set_parameters(IM, OM, diag(getvec(S["dQ"])), diag(getvec(S["dR"]))); 
     151 
     152                //connect 
     153                        RV* drv; UIbuild(S["drv"],drv); 
     154                        E->set_drv(*drv); 
     155                        RV* rv; UIbuild(S["rv"],rv); 
     156                        E->set_rv(*rv); 
     157                        return E; 
     158                }        
     159}; 
     160UIREGISTER ( UIpmsmCRBMz ); 
  • bdm/stat/libBM.h

    r340 r342  
    629629        //!access function 
    630630        const RV& _urv() const {return Urv;} 
     631        //! set random rvariables 
     632        virtual void set_drv (const  RV &drv, const RV &urv) { Drv=drv;Urv=urv;} 
    631633}; 
    632634 
  • bdm/stat/libDS.h

    r313 r342  
    6868        //! returns number of data in the file; 
    6969        int ndat(){return Data.cols();} 
     70        //! no sense to log this type 
     71        void log_add ( logger &L ) {}; 
     72        //! no sense to log this type 
     73        void logit ( logger &L ) {}; 
    7074}; 
    7175 
     
    7680 
    7781*/ 
    78 class ItppFileDS: public FileDS { 
    79  
    80 public: 
    81         ItppFileDS ( const string &fname, const string &varname ) :FileDS() { 
     82class ITppFileDS: public FileDS { 
     83 
     84public: 
     85        ITppFileDS ( const string &fname, const string &varname ) :FileDS() { 
    8286                it_file it ( fname ); 
    8387                it << Name ( varname );  
     
    8589                time = 0; 
    8690                //rowid and delays are ignored 
    87         } 
     91        }; 
    8892}; 
    8993 
  • bdm/stat/libDS_ui.h

    r280 r342  
    122122}; 
    123123UIREGISTER ( UIstateDS ); 
     124 
     125/*! \brief UI for reading data from files 
     126 
     127\code 
     128\endcode 
     129*/ 
     130 
     131class UIITppFileDS : public UIbuilder { 
     132        public: 
     133                UIITppFileDS() :UIbuilder ( "ITppFileDS" ) {}; 
     134                bdmroot* build ( Setting &S ) const { 
     135                        RV* rvtmp; 
     136                        UIbuild(S["rv"], rvtmp); 
     137                        ITppFileDS *DS=new ITppFileDS(S["filename"],S["varname"]); 
     138                        DS->set_drv(*rvtmp,RV()); 
     139                        return DS; 
     140                } 
     141}; 
     142UIREGISTER ( UIITppFileDS ); 
     143 
    124144#endif // DS_UI_H