root/applications/pmsm/pmsm_ui.h @ 319

Revision 318, 2.9 kB (checked in by smidl, 15 years ago)

pmsm CRB model

Line 
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
16class 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                } else {
33                        tmp= new IMpmsm;
34                }
35                //Set parameters (recursively)
36                UIcall<IMpmsm*> ( S["params"], &tmp_set , tmp );
37                return tmp;
38        }       
39};
40UIREGISTER ( UIpmsmIM );
41
42//! UI for pmsm observation model
43class UIpmsmOM: public UIbuilder {
44        public:
45                UIpmsmOM():UIbuilder("pmsmOM"){};
46                bdmroot* build ( Setting &S ) const {
47                        return new OMpmsm;
48                }       
49};
50UIREGISTER ( UIpmsmOM );
51
52
53
54//!UI for pmsmDS,
55class UIpmsmDS: public UIbuilder {
56        static void tmp_set ( Setting &S, pmsmDS* DS ) {
57                //pmsmsim_set_parameters (( Rs0,  Ls0, Fmag0, Bf0, p0, kp0,  J0, Uc0, DT0,  dt0);
58                DS->set_parameters ( S["Rs"], S["Ls"], S["Fmag"], S["Bf"], S["p"], S["kp"], \
59                                     S["J"], S["Uc"], S["DT"], 1.0e-6 );
60        };
61public:
62        UIpmsmDS() :UIbuilder ( "pmsmDS" ) {};
63        bdmroot* build ( Setting &S ) const {
64                pmsmDS* tmp = new pmsmDS ( );
65                //Calling function tmp->tmp_set
66                UIcall<pmsmDS*> ( S["params"], &tmp_set , tmp );
67               
68                // Default values of profiles for omega and Mz
69                vec profW=vec("1.0");
70                vec profM=vec("0.0");
71                double tstep=1.0;
72               
73                if ( S.exists ( "tstep" ) ) {tstep=S["tstep"];}
74                if ( S.exists ( "profileW" ) ) {profW=getvec ( S["profileW"] ) ;}
75                if ( S.exists ( "profileM" ) ) {profM=getvec ( S["profileM"] ) ;}
76               
77                tmp->set_profile (tstep , profW, profM);
78               
79                string opts="";
80                if ( S.exists ( "options" ) ) {opts=(const char*)S["options"];}
81                tmp->set_options(opts);
82               
83                return tmp;
84        };
85
86};
87UIREGISTER ( UIpmsmDS );
88
89class UIpmsmCRB: public UIbuilder {
90        public:
91                UIpmsmCRB():UIbuilder("pmsmCRB"){};
92                bdmroot* build ( Setting &S ) const {
93                        diffbifn* IM; UIbuild(S["IM"],IM);
94                        diffbifn* OM; UIbuild(S["OM"],OM);
95               
96                //parameters
97                        pmsmCRB* E; E=new pmsmCRB;
98                        E->set_parameters(IM, OM, diag(getvec(S["dQ"])), diag(getvec(S["dR"])));
99               
100                //statistics
101                        int dim=IM->dimension();
102                        vec mu0;
103                        mat P0;
104                        if (S.exists("mu0")){mu0=getvec(S["mu0"]);}else{mu0=zeros(dim);};
105                        if (S.exists("P0")){mu0=getmat(S["P0"],dim);}else{P0=eye(dim);};
106                        E->set_statistics(mu0,P0);
107               
108                //connect
109                        RV* drv; UIbuild(S["drv"],drv);
110                        E->set_drv(*drv);
111                        RV* rv; UIbuild(S["rv"],rv);
112                        E->set_rv(*rv);
113                        return E;
114                }       
115};
116UIREGISTER ( UIpmsmCRB );
Note: See TracBrowser for help on using the browser.