Changeset 342 for applications
- Timestamp:
- 05/14/09 17:16:45 (16 years ago)
- Location:
- applications/pmsm
- Files:
-
- 5 modified
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/Barcelona/MM.cfg
r338 r342 2 2 3 3 experiment={ 4 ndat = 90000;4 ndat = 60000; 5 5 }; 6 6 … … 9 9 params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";}; 10 10 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]; 13 13 }; 14 14 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"; 15 E1={type="EKF"; 33 16 IM = {type="pmsmIM"; 34 17 params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";}; … … 36 19 }; 37 20 OM = {type="pmsmOM";}; 38 dQ=[ 0.17, 0.17, 0.00004, 1e-8];21 dQ=[1.7, 1.7, 0.004, 1e-5]; 39 22 dR=[0.025, 0.025]; 40 23 dP0=[1., 1., 1., 1.]; … … 44 27 rv = {type="rv"; names=["EKF"]; sizes=[4];}; 45 28 options="logll"; 46 }, 47 // 48 {type="EKF"; 29 }; 30 E2= {type="EKF"; 49 31 IM = {type="pmsmIM"; 50 32 params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";}; … … 52 34 }; 53 35 OM = {type="pmsmOM";}; 54 dQ=[ 0.17, 0.17, 0.004, 1e-5];36 dQ=[1.7, 1.7, 0.004, 1e-5]; 55 37 dR=[0.025, 0.025]; 56 38 dP0=[1., 1., 1., 1.]; … … 60 42 rv = {type="rv"; names=["EKFw"]; sizes=[4];}; 61 43 options="logll"; 62 } 63 64 65 ); 44 }; 45 46 estimator = ( 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 }); 66 55 67 56 logger= { 68 type="dirfilelog";57 ` type="dirfilelog"; 69 58 maxlen = 1; 70 dirname = " exp/Mz";59 dirname = "MM"; 71 60 }; -
applications/pmsm/Barcelona/Mz.cfg
r338 r342 2 2 3 3 experiment={ 4 ndat = 90000;4 ndat = 120000; 5 5 }; 6 6 … … 9 9 params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";}; 10 10 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"; 13 14 }; 14 15 … … 20 21 }; 21 22 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]; 23 29 dR=[0.025, 0.025]; 24 dP0=[ 1., 1., 1., 1., 1e-2];30 dP0=[0., 0., 0., 0., 0.]; 25 31 //connect 26 32 drv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];}; // observed u 27 33 //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u 28 34 rv = {type="rv"; names=["EKFMz"]; sizes=[5];}; 29 options="logll ";35 options="logll,logbounds"; 30 36 }, 31 37 // … … 36 42 }; 37 43 OM = {type="pmsmOM";}; 38 dQ=[0. 17, 0.17, 0.00004, 1e-8];44 dQ=[0.017, 0.017, .1, 1e-6]; 39 45 dR=[0.025, 0.025]; 40 46 dP0=[1., 1., 1., 1.]; … … 43 49 //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u 44 50 rv = {type="rv"; names=["EKF"]; sizes=[4];}; 45 options="logll ";51 options="logll,logbounds"; 46 52 }, 47 53 // … … 52 58 }; 53 59 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]; 55 61 dR=[0.025, 0.025]; 56 62 dP0=[1., 1., 1., 1.]; … … 59 65 //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u 60 66 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"; 62 85 } 63 86 … … 67 90 logger= { 68 91 type="dirfilelog"; 69 maxlen = 1 ;92 maxlen = 100; 70 93 dirname = "exp/Mz"; 71 94 }; -
applications/pmsm/Barcelona/QandR.m
r338 r342 30 30 R11 = (istep+istep)^2/12 31 31 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 35 47 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 48 Qrat=[Fmag/Ls*dt,Fmag/Ls*dt, 1, dt].^2 -
applications/pmsm/pmsmDS.h
r332 r342 35 35 public: 36 36 //! 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 }" );} 38 38 void set_parameters ( double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0 ) { 39 39 pmsmsim_set_parameters ( Rs0, Ls0, Fmag0, Bf0, p0, kp0, J0, Uc0, DT0, dt0 ); … … 41 41 //! parse options: "modelu" => opt_modu=true; 42 42 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];} 46 46 void write ( vec &ut ) {} 47 47 … … 82 82 83 83 //discretization 84 double ustep= 0.6;84 double ustep=1.2; 85 85 KalmanObs [ 0 ] = ustep*itpp::round( KalmanObs [ 0 ]/ ustep) ; 86 86 KalmanObs [ 1 ] = ustep*itpp::round(KalmanObs [ 1 ]/ ustep); … … 177 177 } 178 178 }; 179 180 //! This class behaves like BM but it is evaluating EKF 181 class 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 10 10 #include "stat/loggers_ui.h" 11 11 #include "estim/KF_ui.h" 12 #include "stat/libDS_ui.h" 12 13 13 14 using namespace bdm; -
applications/pmsm/pmsm_ui.h
r332 r342 127 127 }; 128 128 UIREGISTER ( UIpmsmCRB ); 129 130 class 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 }; 160 UIREGISTER ( UIpmsmCRBMz );