00001
00013 #include "pmsmDS.h"
00014 #include <uibuilder.h>
00015
00016 class UIpmsmIM: public UIbuilder {
00017 protected:
00018 static void tmp_set ( Setting &S, IMpmsm* IM ) {
00019
00020 IM->set_parameters ( S["Rs"], S["Ls"], 125e-6, S["Fmag"], S["kp"], S["p"], \
00021 S["J"], 0.0 );
00022 };
00023 public:
00024 UIpmsmIM():UIbuilder("pmsmIM"){};
00025 bdmroot* build ( Setting &S ) const {
00026 IMpmsm* tmp;
00027
00028 if (S.exists("variant")){
00029 string var=S["variant"];
00030 if (var=="Stat"){tmp=new IMpmsmStat;}
00031 if (var=="2o"){tmp=new IMpmsm2o;}
00032 } else {
00033 tmp= new IMpmsm;
00034 }
00035
00036 UIcall<IMpmsm*> ( S["params"], &tmp_set , tmp );
00037 return tmp;
00038 }
00039 };
00040 UIREGISTER ( UIpmsmIM );
00041
00043 class UIpmsmOM: public UIbuilder {
00044 public:
00045 UIpmsmOM():UIbuilder("pmsmOM"){};
00046 bdmroot* build ( Setting &S ) const {
00047 return new OMpmsm;
00048 }
00049 };
00050 UIREGISTER ( UIpmsmOM );
00051
00052
00053
00055 class UIpmsmDS: public UIbuilder {
00056 static void tmp_set ( Setting &S, pmsmDS* DS ) {
00057
00058 DS->set_parameters ( S["Rs"], S["Ls"], S["Fmag"], S["Bf"], S["p"], S["kp"], \
00059 S["J"], S["Uc"], S["DT"], 1.0e-6 );
00060 };
00061 public:
00062 UIpmsmDS() :UIbuilder ( "pmsmDS" ) {};
00063 bdmroot* build ( Setting &S ) const {
00064 pmsmDS* tmp = new pmsmDS ( );
00065
00066 UIcall<pmsmDS*> ( S["params"], &tmp_set , tmp );
00067
00068
00069 vec profW=vec("1.0");
00070 vec profM=vec("0.0");
00071 double tstep=1.0;
00072
00073 if ( S.exists ( "tstep" ) ) {tstep=S["tstep"];}
00074 if ( S.exists ( "profileW" ) ) {profW=getvec ( S["profileW"] ) ;}
00075 if ( S.exists ( "profileM" ) ) {profM=getvec ( S["profileM"] ) ;}
00076
00077 tmp->set_profile (tstep , profW, profM);
00078
00079 string opts="";
00080 if ( S.exists ( "options" ) ) {opts=(const char*)S["options"];}
00081 tmp->set_options(opts);
00082
00083 return tmp;
00084 };
00085
00086 };
00087 UIREGISTER ( UIpmsmDS );
00088
00089 class UIpmsmCRB: public UIbuilder {
00090 public:
00091 UIpmsmCRB():UIbuilder("pmsmCRB"){};
00092 bdmroot* build ( Setting &S ) const {
00093 diffbifn* IM; UIbuild(S["IM"],IM);
00094 diffbifn* OM; UIbuild(S["OM"],OM);
00095
00096
00097 pmsmCRB* E; E=new pmsmCRB;
00098 E->set_parameters(IM, OM, diag(getvec(S["dQ"])), diag(getvec(S["dR"])));
00099
00100
00101 int dim=IM->dimension();
00102 vec mu0;
00103 mat P0;
00104 if (S.exists("mu0")){mu0=getvec(S["mu0"]);}else{mu0=zeros(dim);};
00105 if (S.exists("P0")){mu0=getmat(S["P0"],dim);}else{P0=eye(dim);};
00106 E->set_statistics(mu0,P0);
00107
00108
00109 RV* drv; UIbuild(S["drv"],drv);
00110 E->set_drv(*drv);
00111 RV* rv; UIbuild(S["rv"],rv);
00112 E->set_rv(*rv);
00113 return E;
00114 }
00115 };
00116 UIREGISTER ( UIpmsmCRB );