1 | /*! |
---|
2 | \file |
---|
3 | \brief UserInfo for pmsm related objects |
---|
4 | \author Vaclav Smidl. |
---|
5 | |
---|
6 | ----------------------------------- |
---|
7 | BDM++ - C++ library for Bayesian Decision Making under Uncertainty |
---|
8 | |
---|
9 | Using IT++ for numerical operations |
---|
10 | ----------------------------------- |
---|
11 | */ |
---|
12 | |
---|
13 | #include "pmsmDS.h" |
---|
14 | #include <uibuilder.h> |
---|
15 | |
---|
16 | class UIpmsmIM: public UIbuilder { |
---|
17 | protected: |
---|
18 | static void tmp_set ( Setting &S, IMpmsm* IM ) { |
---|
19 | //set_parameters( Rs0, Ls0, dt0, Ypm0, kp0, p0, J0, Mz0 ) |
---|
20 | IM->set_parameters ( S["Rs"], S["Ls"], 125e-6, S["Fmag"], S["kp"], S["p"], \ |
---|
21 | S["J"], 0.0 ); |
---|
22 | }; |
---|
23 | public: |
---|
24 | UIpmsmIM():UIbuilder("pmsmIM"){}; |
---|
25 | bdmroot* build ( Setting &S ) const { |
---|
26 | IMpmsm* tmp; |
---|
27 | //Switch to variants |
---|
28 | if (S.exists("variant")){ |
---|
29 | string var=S["variant"]; |
---|
30 | if (var=="Stat"){tmp=new IMpmsmStat;} |
---|
31 | if (var=="2o"){tmp=new IMpmsm2o;} |
---|
32 | if (var=="Mz"){tmp=new IMpmsmMz;} |
---|
33 | if (var=="StatMz"){tmp=new IMpmsmStatMz;} |
---|
34 | } else { |
---|
35 | tmp= new IMpmsm; |
---|
36 | } |
---|
37 | //Set parameters (recursively) |
---|
38 | UIcall<IMpmsm*> ( S["params"], &tmp_set , tmp ); |
---|
39 | return tmp; |
---|
40 | } |
---|
41 | }; |
---|
42 | UIREGISTER ( UIpmsmIM ); |
---|
43 | |
---|
44 | //! UI for pmsm observation model |
---|
45 | class UIpmsmOM: public UIbuilder { |
---|
46 | public: |
---|
47 | UIpmsmOM():UIbuilder("pmsmOM"){}; |
---|
48 | bdmroot* build ( Setting &S ) const { |
---|
49 | return new OMpmsm; |
---|
50 | } |
---|
51 | }; |
---|
52 | UIREGISTER ( UIpmsmOM ); |
---|
53 | |
---|
54 | |
---|
55 | class UIpmsmOM4: public UIbuilder { |
---|
56 | public: |
---|
57 | UIpmsmOM4():UIbuilder("pmsmOM4"){}; |
---|
58 | bdmroot* build ( Setting &S ) const { |
---|
59 | return new OMpmsm4; |
---|
60 | } |
---|
61 | }; |
---|
62 | UIREGISTER ( UIpmsmOM4 ); |
---|
63 | |
---|
64 | |
---|
65 | //!UI for pmsmDS, |
---|
66 | class UIpmsmDS: public UIbuilder { |
---|
67 | static void tmp_set ( Setting &S, pmsmDS* DS ) { |
---|
68 | //pmsmsim_set_parameters (( Rs0, Ls0, Fmag0, Bf0, p0, kp0, J0, Uc0, DT0, dt0); |
---|
69 | DS->set_parameters ( S["Rs"], S["Ls"], S["Fmag"], S["Bf"], S["p"], S["kp"], \ |
---|
70 | S["J"], S["Uc"], S["DT"], 1.0e-6 ); |
---|
71 | }; |
---|
72 | public: |
---|
73 | UIpmsmDS() :UIbuilder ( "pmsmDS" ) {}; |
---|
74 | bdmroot* build ( Setting &S ) const { |
---|
75 | pmsmDS* tmp = new pmsmDS ( ); |
---|
76 | //Calling function tmp->tmp_set |
---|
77 | UIcall<pmsmDS*> ( S["params"], &tmp_set , tmp ); |
---|
78 | |
---|
79 | // Default values of profiles for omega and Mz |
---|
80 | vec profW=vec("1.0"); |
---|
81 | vec profM=vec("0.0"); |
---|
82 | double tstep=1.0; |
---|
83 | |
---|
84 | if ( S.exists ( "tstep" ) ) {tstep=S["tstep"];} |
---|
85 | if ( S.exists ( "profileW" ) ) {profW=getvec ( S["profileW"] ) ;} |
---|
86 | if ( S.exists ( "profileM" ) ) {profM=getvec ( S["profileM"] ) ;} |
---|
87 | |
---|
88 | tmp->set_profile (tstep , profW, profM); |
---|
89 | |
---|
90 | string opts=""; |
---|
91 | if ( S.exists ( "options" ) ) {opts=(const char*)S["options"];} |
---|
92 | tmp->set_options(opts); |
---|
93 | |
---|
94 | return tmp; |
---|
95 | }; |
---|
96 | |
---|
97 | }; |
---|
98 | UIREGISTER ( UIpmsmDS ); |
---|
99 | |
---|
100 | class UIpmsmCRB: public UIbuilder { |
---|
101 | public: |
---|
102 | UIpmsmCRB():UIbuilder("pmsmCRB"){}; |
---|
103 | bdmroot* build ( Setting &S ) const { |
---|
104 | diffbifn* IM; UIbuild(S["IM"],IM); |
---|
105 | diffbifn* OM; UIbuild(S["OM"],OM); |
---|
106 | |
---|
107 | //parameters |
---|
108 | pmsmCRB* E; E=new pmsmCRB; |
---|
109 | |
---|
110 | //statistics |
---|
111 | int dim=IM->dimension(); |
---|
112 | vec mu0; |
---|
113 | mat P0; |
---|
114 | if (S.exists("mu0")){mu0=getvec(S["mu0"]);}else{mu0=zeros(dim);}; |
---|
115 | if (S.exists("dP0")){P0=diag(getvec(S["dP0"]));}else{ |
---|
116 | if (S.exists("P0")){mu0=getmat(S["P0"],dim);}else{P0=eye(dim);}; |
---|
117 | } |
---|
118 | E->set_statistics(mu0,P0); |
---|
119 | |
---|
120 | E->set_parameters(IM, OM, diag(getvec(S["dQ"])), diag(getvec(S["dR"]))); |
---|
121 | |
---|
122 | //connect |
---|
123 | RV* drv; UIbuild(S["drv"],drv); |
---|
124 | E->set_drv(*drv); |
---|
125 | RV* rv; UIbuild(S["rv"],rv); |
---|
126 | E->set_rv(*rv); |
---|
127 | return E; |
---|
128 | } |
---|
129 | }; |
---|
130 | UIREGISTER ( UIpmsmCRB ); |
---|
131 | |
---|
132 | class UIpmsmCRBMz: public UIbuilder { |
---|
133 | public: |
---|
134 | UIpmsmCRBMz():UIbuilder("pmsmCRBMz"){}; |
---|
135 | bdmroot* build ( Setting &S ) const { |
---|
136 | diffbifn* IM; UIbuild(S["IM"],IM); |
---|
137 | diffbifn* OM; UIbuild(S["OM"],OM); |
---|
138 | |
---|
139 | //parameters |
---|
140 | pmsmCRBMz* E; E=new pmsmCRBMz; |
---|
141 | |
---|
142 | //statistics |
---|
143 | int dim=IM->dimension(); |
---|
144 | vec mu0; |
---|
145 | mat P0; |
---|
146 | if (S.exists("mu0")){mu0=getvec(S["mu0"]);}else{mu0=zeros(dim);}; |
---|
147 | if (S.exists("dP0")){P0=diag(getvec(S["dP0"]));}else{ |
---|
148 | if (S.exists("P0")){mu0=getmat(S["P0"],dim);}else{P0=eye(dim);}; |
---|
149 | } |
---|
150 | E->set_statistics(mu0,P0); |
---|
151 | |
---|
152 | E->set_parameters(IM, OM, diag(getvec(S["dQ"])), diag(getvec(S["dR"]))); |
---|
153 | |
---|
154 | //connect |
---|
155 | RV* drv; UIbuild(S["drv"],drv); |
---|
156 | E->set_drv(*drv); |
---|
157 | RV* rv; UIbuild(S["rv"],rv); |
---|
158 | E->set_rv(*rv); |
---|
159 | return E; |
---|
160 | } |
---|
161 | }; |
---|
162 | UIREGISTER ( UIpmsmCRBMz ); |
---|