Mercurial > hg > ltpda
comparison m-toolbox/m/mdcs/mdc1/models/ltpda_mdc1_C.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % LTPDA_MDC1_C returns a frequency-domain model of the controllers for MDC1. | |
2 % | |
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
4 % | |
5 % DESCRIPTION: LTPDA_MDC1_C returns a frequency-domain model of the controllers | |
6 % for MDC1. | |
7 % | |
8 % CALL: b = ltpda_mdc1_C(pl) | |
9 % | |
10 % PARAMETERS: | |
11 % | |
12 % 'Controller' - Choose controller [default: 'DF'] | |
13 % 'DF' - Drag-free controller (including delay) | |
14 % 'SUS' - Suspension controller (including delay) | |
15 % 'f' - a vector of frequencies [default: 1] | |
16 % or | |
17 % 'f1' - start frequency [default: 1e-6] | |
18 % 'f2' - stop frequency [default: 5] | |
19 % 'nf' - number of frequency points [default: 1000] | |
20 % 'scale' - frequency spacing, 'lin' or 'log' [default: 'log'] | |
21 % | |
22 % VERSION: $Id: ltpda_mdc1_C.m,v 1.3 2008/08/08 13:35:23 anneke Exp $ | |
23 % | |
24 % The following call returns a parameter list object that contains the | |
25 % default parameter values: | |
26 % | |
27 % >> pl = ltpda_mdc1_C(ao, 'Params') | |
28 % | |
29 % The following call returns a string that contains the routine CVS version: | |
30 % | |
31 % >> version = ltpda_mdc1_C(ao,'Version') | |
32 % | |
33 % The following call returns a string that contains the routine category: | |
34 % | |
35 % >> category = ltpda_mdc1_C(ao,'Category') | |
36 % | |
37 % HISTORY: 11-04-08 M Hewitson | |
38 % Creation | |
39 % | |
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
41 function varargout = ltpda_mdc1_C(varargin) | |
42 %%% Check if this is a call for parameters | |
43 if utils.helper.isinfocall(varargin{:}) | |
44 varargout{1} = getInfo(varargin{3}); | |
45 return | |
46 end | |
47 | |
48 %%% Collect input variable names | |
49 in_names = cell(size(varargin)); | |
50 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
51 | |
52 pli = utils.helper.collect_objects(varargin(:), 'plist', in_names); | |
53 | |
54 %%% Decide on a deep copy or a modify | |
55 %%% REMARK: If you create a new AO (call the constructor) then | |
56 %%% it is not necessay to copy the input-AOs !!!!!!!!!!!!!!!!!!!!!!!!! | |
57 | |
58 | |
59 %%% Combine plists | |
60 pl = combine(pli, getDefaultPlist('Range')); | |
61 | |
62 | |
63 %% Extract parameters from plist | |
64 | |
65 f = find(pl, 'f'); | |
66 if isempty(f) | |
67 f1 = find(pl, 'f1'); | |
68 f2 = find(pl, 'f2'); | |
69 nf = find(pl, 'nf'); | |
70 scale = find(pl, 'scale'); | |
71 | |
72 switch scale | |
73 case 'lin' | |
74 f = linspace(f1, f2, nf); | |
75 case 'log' | |
76 f = logspace(log10(f1), log10(f2), nf); | |
77 end | |
78 end | |
79 | |
80 cont = find(pl, 'Controller'); | |
81 | |
82 %% Compute response for frequencies f | |
83 | |
84 switch upper(cont) | |
85 case 'DF' | |
86 a = getDFcontroller(f); | |
87 case 'SUS' | |
88 a = getSUScontroller(f); | |
89 otherwise | |
90 error('### Unknown controller requested.'); | |
91 end | |
92 | |
93 varargout{1} = a; | |
94 end | |
95 %-------------------------------------------------------------------------- | |
96 % Get DF controller for each frequency | |
97 function o = getSUScontroller(f) | |
98 | |
99 % Compute desired response | |
100 T = 0.1; | |
101 z = exp(1i*2*pi*f*T); | |
102 zi = 1./z; | |
103 | |
104 f1 = -2.4365e-4./(1-exp(-1.0772e-2).*zi); | |
105 f2 = complex(1.2115e-4, 3.0511e-5)./(1-exp(complex(-5.5589e-3,-6.4448e-3)).*zi); | |
106 f3 = complex(1.2115e-4, -3.0511e-5)./(1-exp(complex(-5.5589e-3, 6.4448e-3)).*zi); | |
107 f4 = 1.0741e-6./(1 - 1.*zi); | |
108 | |
109 % Controller delay | |
110 s = 1i*2*pi*f; | |
111 dt = 305/1000; | |
112 D = (exp(-s.*(T+dt)) .* (-1+exp(s.*T)) )./(s.*T); | |
113 | |
114 H = 0.1.*( f1 + f2 + f3 + f4).*D; | |
115 | |
116 % Create fsdata object | |
117 fsd = fsdata(f, H); | |
118 | |
119 % Create an AO | |
120 o = ao(fsd); | |
121 o.setXunits('Hz'); | |
122 o.setYunits('N/V'); | |
123 o.setName('C_{sus}'); | |
124 end | |
125 %-------------------------------------------------------------------------- | |
126 % Get DF controller for each frequency | |
127 function o = getDFcontroller(f) | |
128 | |
129 % Transform from f to z | |
130 T = 0.1; | |
131 z = exp(1i*2*pi*f*T); | |
132 zi = 1./z; | |
133 | |
134 % Compute individual terms in the frequency series | |
135 f1 = -1.61./(1-exp(-0.30943).*zi); | |
136 f2 = complex(0.86807, 0.12606)./(1-exp(complex(-9.753e-2,-1.6175e-1)).*zi); | |
137 f3 = complex(0.86807, -0.12606)./(1-exp(complex(-9.753e-2,1.6175e-1)).*zi); | |
138 f4 = -complex(6.4699,70.435)./(1-exp(complex(-5.5289e-5,-4.8946e-6)).*zi); | |
139 f5 = -complex(6.4699,-70.435)./(1-exp(complex(-5.5289e-5,4.8946e-6)).*zi); | |
140 f6 = 12.946./(1 - 1.*zi); | |
141 | |
142 % Controller delay | |
143 s = 1i*2*pi*f; | |
144 dt = 315/1000; | |
145 D = (exp(-s.*(T+dt)) .* (-1+exp(s.*T)) )./(s.*T); | |
146 | |
147 % Combine all terms into a single response | |
148 H = 0.1.*( f1 + f2 + f3 + f4 + f5 + f6 ) .* D; | |
149 | |
150 % Build a frequency-series data object | |
151 fsd = fsdata(f, H); | |
152 | |
153 % build the AO and set its name | |
154 o = ao(fsd); | |
155 % Set X-units, Y-units and name to something meaningful | |
156 o.setXunits('Hz'); | |
157 o.setYunits('N/V'); | |
158 o.setName('C_{df}'); | |
159 end | |
160 | |
161 %-------------------------------------------------------------------------- | |
162 function plo = getDefaultPlist(varargin) | |
163 % List of available parameter sets | |
164 sets = {'List', 'Range'}; | |
165 | |
166 if nargin == 0 | |
167 plo = sets; | |
168 return | |
169 end | |
170 | |
171 set = varargin{1}; | |
172 | |
173 switch set | |
174 case 'List' | |
175 plo = plist('Controller', 'DF', 'f', [1]); | |
176 case 'Range' | |
177 plo = plist('Controller', 'DF', ... | |
178 'f1', 1e-6,... | |
179 'f2', 5,... | |
180 'nf', 1000,... | |
181 'scale', 'log'); | |
182 otherwise | |
183 plo = plist(); | |
184 end | |
185 end | |
186 %-------------------------------------------------------------------------- | |
187 function ii = getInfo(varargin) | |
188 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
189 sets = {}; | |
190 pl = []; | |
191 else | |
192 sets = {'Default'}; | |
193 pl = getDefaultPlist; | |
194 end | |
195 % Build info object | |
196 ii = minfo(mfilename, 'CLASS', '', 'CATEGORY', '$Id: ltpda_mdc1_C.m,v 1.3 2008/08/08 13:35:23 anneke Exp $', sets, pl); | |
197 end | |
198 | |
199 | |
200 |