1 | function ismodelselfconsistent(md),
|
---|
2 | %ISMODELSELFCONSISTENT - check that model forms a closed form solvable problem.
|
---|
3 | %
|
---|
4 | % Usage:
|
---|
5 | % ismodelselfconsistent(md),
|
---|
6 |
|
---|
7 | %tolerance we use in litmus checks for the consistency of the model
|
---|
8 | tolerance=10^-12;
|
---|
9 |
|
---|
10 | %check usage
|
---|
11 | if nargin~=1,
|
---|
12 | help ismodelselfconsistent
|
---|
13 | error('ismodelselfconsistent error message: wrong usage');
|
---|
14 | end
|
---|
15 |
|
---|
16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TRANSIENT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
17 |
|
---|
18 | %check analysis
|
---|
19 | if md.analysis_type==TransientAnalysisEnum,
|
---|
20 | if md.dt<=0,
|
---|
21 | error('model not consistent: field dt must be positive for a transient run')
|
---|
22 | end
|
---|
23 |
|
---|
24 | %recursive call to ismodelselfconsistent
|
---|
25 | if strcmpi(md.type,'2d'),
|
---|
26 | analysis=[DiagnosticAnalysisEnum PrognosticAnalysisEnum];
|
---|
27 | else
|
---|
28 | analysis=[DiagnosticAnalysisEnum PrognosticAnalysisEnum ThermalAnalysisEnum];
|
---|
29 | end
|
---|
30 |
|
---|
31 | for i=1:length(analysis),
|
---|
32 | md.analysis_type=analysis(i);
|
---|
33 | ismodelselfconsistent(md);
|
---|
34 | end
|
---|
35 | end
|
---|
36 |
|
---|
37 |
|
---|
38 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% COMMON CHECKS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
39 |
|
---|
40 | %COUNTER
|
---|
41 | if md.counter<3,
|
---|
42 | error(['model ' md.name ' is not correctly configured. You forgot one step in the following sequence (mesh, geography, parameterize,setelementstype)!']);
|
---|
43 | end
|
---|
44 |
|
---|
45 | %NAME
|
---|
46 | if isempty(md.name),
|
---|
47 | error(['model is not correctly configured: missing name!']);
|
---|
48 | end
|
---|
49 |
|
---|
50 | %ELEMENTSTYPE
|
---|
51 | if size(md.elements_type,1)~=md.numberofelements | size(md.elements_type,2)~=2,
|
---|
52 | error(['model not consistent: types of elements have not been set properly, run setelementstype first'])
|
---|
53 | end
|
---|
54 | if any(ones(md.numberofelements,1)-((md.elements_type(:,1)==HutterFormulationEnum) + (md.elements_type(:,1)==MacAyealFormulationEnum) + (md.elements_type(:,1)==PattynFormulationEnum)))
|
---|
55 | error(['model not consistent: types of elements have not been set properly, run setelementstype first'])
|
---|
56 | end
|
---|
57 | if any(ones(md.numberofelements,1)-((md.elements_type(:,2)==StokesFormulationEnum) + (md.elements_type(:,2)==NoneFormulationEnum)))
|
---|
58 | error(['model not consistent: types of elements have not been set properly, run setelementstype first'])
|
---|
59 | end
|
---|
60 | if strcmpi(md.type,'2d'),
|
---|
61 | if (ismember(PattynFormulationEnum,md.elements_type(:,1)) | ismember(StokesFormulationEnum,md.elements_type(:,2))),
|
---|
62 | error(['model not consistent: for a 2d model, only MacAyeal''s and Hutter''s elements are allowed']);
|
---|
63 | end
|
---|
64 | end
|
---|
65 | if (md.ismacayealpattyn==0 && md.ishutter==0 && md.isstokes==0),
|
---|
66 | error(['model not consistent: no elements type set for this model. at least one of ismacayealpattyn, ishutter and isstokes need to be =1']);
|
---|
67 | end
|
---|
68 | if (md.analysis_type==DiagnosticAnalysisEnum & any(ismember(MacAyealFormulationEnum,md.elements_type(:,1)) & ismember(PattynFormulationEnum,md.elements_type(:,1))))
|
---|
69 | error(['model not consistent: coupling MacAyeal/Pattyn not implemented yet']);
|
---|
70 | end
|
---|
71 | if (md.isstokes & md.analysis_type==TransientAnalysisEnum());
|
---|
72 | error(['model not consistent: Stokes transient not implemented yet']);
|
---|
73 | end
|
---|
74 |
|
---|
75 | %ICEFRONT
|
---|
76 | if strcmpi(md.type,'2d'),
|
---|
77 | fields={'pressureload'};
|
---|
78 | checksize(md,fields,[NaN 4]);
|
---|
79 | elseif strcmpi(md.type,'3d'),
|
---|
80 | fields={'pressureload'};
|
---|
81 | checksize(md,fields,[NaN 6]);
|
---|
82 | end
|
---|
83 |
|
---|
84 | %NO NAN
|
---|
85 | fields={'numberofelements','numberofgrids','x','y','z','drag','drag_type','p','q',...
|
---|
86 | 'rho_ice','rho_water','B','elementoniceshelf','surface','thickness','bed','g','lowmem','sparsity','nsteps','maxiter',...
|
---|
87 | 'tolx','np','eps_res','exclusive','n','gridonbed','gridonsurface','elementonbed','elementonsurface','deltaH','DeltaH','timeacc','timedec'};
|
---|
88 | checknan(md,fields);
|
---|
89 |
|
---|
90 | %FIELDS >= 0
|
---|
91 | fields={'numberofelements','numberofgrids','elements','drag','drag_type','p','q',...
|
---|
92 | 'rho_ice','rho_water','B','elementoniceshelf','thickness','g','eps_res','eps_rel','eps_abs','nsteps','maxiter','tolx','exclusive',...
|
---|
93 | 'sparsity','lowmem','n','gridonbed','gridonsurface','elementonbed','elementonsurface','deltaH','DeltaH','timeacc','timedec'};
|
---|
94 | checkgreater(md,fields,0);
|
---|
95 |
|
---|
96 | %FIELDS > 0
|
---|
97 | fields={'numberofelements','numberofgrids','elements','drag_type','p',...
|
---|
98 | 'rho_ice','rho_water','B','thickness','g','eps_res','eps_rel','eps_abs','maxiter','tolx',...
|
---|
99 | 'sparsity','deltaH','DeltaH','timeacc','timedec'};
|
---|
100 | checkgreaterstrict(md,fields,0);
|
---|
101 |
|
---|
102 | %SIZE NUMBEROFELEMENTS
|
---|
103 | fields={'p','q','elementoniceshelf','n','elementonbed'};
|
---|
104 | checksize(md,fields,[md.numberofelements 1]);
|
---|
105 |
|
---|
106 | %SIZE NUMBEROFELEMENTS
|
---|
107 | fields={'elements'};
|
---|
108 | checklength(md,fields,md.numberofelements);
|
---|
109 |
|
---|
110 | %SIZE NUMBEROFGRIDS
|
---|
111 | fields={'x','y','z','B','drag','melting','accumulation','surface','thickness','bed','gridonbed','gridonsurface'};
|
---|
112 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
113 |
|
---|
114 | %SIZE 6
|
---|
115 | fields={'spcvelocity'};
|
---|
116 | checksize(md,fields,[md.numberofgrids 6]);
|
---|
117 |
|
---|
118 | %THICKNESS = SURFACE - BED
|
---|
119 | if any((md.thickness-md.surface+md.bed)>tolerance),
|
---|
120 | error(['model not consistent: model ' md.name ' violates the equality thickness=surface-bed!']);
|
---|
121 | end
|
---|
122 |
|
---|
123 | %RIFTS
|
---|
124 | if md.numrifts,
|
---|
125 | if ~strcmpi(md.type,'2d'),
|
---|
126 | error(['model not consistent: models with rifts are only supported in 2d for now!']);
|
---|
127 | end
|
---|
128 | if ~isstruct(md.rifts),
|
---|
129 | error(['model not consistent: md.rifts should be a structure!']);
|
---|
130 | end
|
---|
131 | if ~isempty(find(md.segmentmarkers>=2)),
|
---|
132 | %We have segments with rift markers, but no rift structure!
|
---|
133 | error(['model not consistent: model ' md.name ' should be processed for rifts (run meshprocessrifts)!']);
|
---|
134 | end
|
---|
135 | %Check that rifts are filled with proper material
|
---|
136 | checkvalues(md,{'rifts.fill'},[WaterEnum() AirEnum() IceEnum() MelangeEnum()]);
|
---|
137 | else
|
---|
138 | if ~isnans(md.rifts),
|
---|
139 | error(['model not consistent: md.rifts shoud be NaN since md.numrifts is 0!']);
|
---|
140 | end
|
---|
141 | end
|
---|
142 |
|
---|
143 | %ARTIFICIAL DIFFUSIVITY
|
---|
144 | if ~ismember(md.artificial_diffusivity,[0 1]),
|
---|
145 | error('model not consistent: artificial_diffusivity should be a scalar (1 or 0)');
|
---|
146 | end
|
---|
147 |
|
---|
148 | %PARAMETEROUTPUT
|
---|
149 | if md.numoutput~=length(md.parameteroutput),
|
---|
150 | error('model not consistent: numoutput should be the same size as parameteroutput');
|
---|
151 | end
|
---|
152 |
|
---|
153 | %CONNECTIVITY
|
---|
154 | if strcmpi(md.type,'2d'),
|
---|
155 | if md.connectivity<9,
|
---|
156 | error('model not consistent: connectivity should be at least 9 for 2d models');
|
---|
157 | end
|
---|
158 | end
|
---|
159 | if strcmpi(md.type,'3d'),
|
---|
160 | if md.connectivity<24,
|
---|
161 | error('model not consistent: connectivity should be at least 24 for 3d models');
|
---|
162 | end
|
---|
163 | end
|
---|
164 |
|
---|
165 | %LOWMEM = 0 or 1
|
---|
166 | if ((md.lowmem ~= 1) & (md.lowmem~=0)),
|
---|
167 | error(['model not consistent: model ' md.name ' lowmem field should be 0 or 1']);
|
---|
168 | end
|
---|
169 |
|
---|
170 | %PARALLEL
|
---|
171 | if ~strcmpi(md.cluster,'none'),
|
---|
172 |
|
---|
173 | %NAN VALUES
|
---|
174 | fields={'time','np'};
|
---|
175 | checknan(md,fields);
|
---|
176 |
|
---|
177 | %FIELD > 0
|
---|
178 | fields={'time','np'};
|
---|
179 | checkgreaterstrict(md,fields,0);
|
---|
180 |
|
---|
181 | end
|
---|
182 |
|
---|
183 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SOLUTION CHECKS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
184 |
|
---|
185 | %QMU
|
---|
186 | if md.qmu_analysis,
|
---|
187 | if md.qmu_params.evaluation_concurrency~=1,
|
---|
188 | error(['model not consistent: concurrency should be set to 1 when running dakota in library mode']);
|
---|
189 | end
|
---|
190 | if ~isempty(md.part),
|
---|
191 | if numel(md.part)~=md.numberofgrids,
|
---|
192 | error(['model not consistent: user supplied partition for qmu analysis should have size md.numberofgrids x 1 ']);
|
---|
193 | end
|
---|
194 | if find(md.part)>=md.numberofgrids,
|
---|
195 | error(['model not consistent: user supplied partition should be indexed from 0 (c-convention)']);
|
---|
196 | end
|
---|
197 | if min(md.part)~=0,
|
---|
198 | error(['model not consistent: partition vector not indexed from 0 on']);
|
---|
199 | end
|
---|
200 | if max(md.part)>=md.numberofgrids,
|
---|
201 | error(['model not consistent: partition vector cannot have maximum index larger than number of grids']);
|
---|
202 | end
|
---|
203 | if ~isempty(find(md.part<0)),
|
---|
204 | error(['model not consistent: partition vector cannot have values less than 0']);
|
---|
205 | end
|
---|
206 | if ~isempty(find(md.part>=md.npart)),
|
---|
207 | error(['model not consistent: partition vector cannot have values more than md.npart-1']);
|
---|
208 | end
|
---|
209 |
|
---|
210 | end
|
---|
211 | if md.eps_rel>1.1*10^-5,
|
---|
212 | error(['model not consistent: for qmu analysis, eps_rel should be least than 10^-5, 10^-15 being a better value']);
|
---|
213 | end
|
---|
214 | end
|
---|
215 |
|
---|
216 | %DIAGNOSTIC
|
---|
217 | if md.analysis_type==DiagnosticAnalysisEnum,
|
---|
218 |
|
---|
219 | %CHECK THAT WE ARE NOT FULLY CONSTRAINED
|
---|
220 | if strcmpi(md.type,'2d'),
|
---|
221 | if isempty(find(~md.spcvelocity(:,1:2))),
|
---|
222 | error(['model not consistent: model ' md.name ' is totally constrained, no need to solve!']);
|
---|
223 | end
|
---|
224 | end
|
---|
225 |
|
---|
226 | %HUTTER ON ICESHELF WARNING
|
---|
227 | if any(md.elements_type(:,1)==HutterFormulationEnum & md.elementoniceshelf),
|
---|
228 | disp(sprintf('\n !!! Warning: Hutter''s model is not consistent on ice shelves !!!\n'));
|
---|
229 | end
|
---|
230 |
|
---|
231 | %SINGULAR
|
---|
232 | if ~any(sum(md.spcvelocity(:,1:2),2)==2),
|
---|
233 | error(['model not consistent: model ' md.name ' is not well posed (singular). You need at least one grid with fixed velocity!'])
|
---|
234 | end
|
---|
235 |
|
---|
236 | %DIRICHLET IF THICKNESS <= 0
|
---|
237 | if any(md.thickness<=0),
|
---|
238 | pos=find(md.thickness<=0);
|
---|
239 | if any(find(md.spcthickness(pos,1)==0)),
|
---|
240 | error(['model not consistent: model ' md.name ' has some grids with 0 thickness']);
|
---|
241 | end
|
---|
242 | end
|
---|
243 |
|
---|
244 | %INITIAL VELOCITY
|
---|
245 | if length(md.vx)==md.numberofgrids & length(md.vy)==md.numberofgrids,
|
---|
246 | fields={'vx','vy'};
|
---|
247 | checknan(md,fields);
|
---|
248 | end
|
---|
249 | end
|
---|
250 |
|
---|
251 | %PROGNOSTIC
|
---|
252 | if md.analysis_type==PrognosticAnalysisEnum,
|
---|
253 |
|
---|
254 | %INITIAL VELOCITIES
|
---|
255 | fields={'vx','vy'};
|
---|
256 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
257 | checknan(md,fields);
|
---|
258 |
|
---|
259 | %CHECK THAT WE ARE NOT FULLY CONSTRAINED
|
---|
260 | if strcmpi(md.type,'2d'),
|
---|
261 | if isempty(find(~md.spcthickness(:,1))),
|
---|
262 | error(['model not consistent: model ' md.name ' is totally constrained for prognostic, no need to solve!']);
|
---|
263 | end
|
---|
264 | end
|
---|
265 |
|
---|
266 | end
|
---|
267 |
|
---|
268 | %STEADYSTATE
|
---|
269 | if md.analysis_type==SteadystateAnalysisEnum,
|
---|
270 |
|
---|
271 | %NDT
|
---|
272 | if md.dt~=0,
|
---|
273 | error(['model not consistent: for a steadystate computation, dt must be zero.']);
|
---|
274 | end
|
---|
275 |
|
---|
276 | %PRESSURE
|
---|
277 | if isnans(md.pressure),
|
---|
278 | error(['model not consistent: for a steadystate computation, the model must have an initial pressure, even lithostatic will do.']);
|
---|
279 | end
|
---|
280 |
|
---|
281 | %eps:
|
---|
282 | if isnan(md.eps_rel),
|
---|
283 | error(['model not consistent: for a steadystate computation, eps_rel (relative convergence criterion) must be defined!']);
|
---|
284 | end
|
---|
285 |
|
---|
286 | %dim:
|
---|
287 | if strcmpi(md.type,'2d'),
|
---|
288 | error(['model not consistent: for a steadystate computation, model needs to be 3d']);
|
---|
289 | end
|
---|
290 | end
|
---|
291 |
|
---|
292 | %THERMAL STEADY AND THERMAL TRANSIENT
|
---|
293 | if md.analysis_type==ThermalAnalysisEnum,
|
---|
294 |
|
---|
295 | %EXTRUSION
|
---|
296 | if strcmp(md.type,'2d'),
|
---|
297 | error(['model not consistent: for a ' md.analysis_type ' computation, the model must be 3d, extrude it first!'])
|
---|
298 | end
|
---|
299 |
|
---|
300 | %CHECK THAT WE ARE NOT FULLY CONSTRAINED
|
---|
301 | if strcmpi(md.type,'2d'),
|
---|
302 | if isempty(find(~md.spctemperature(:,1))),
|
---|
303 | error(['model not consistent: model ' md.name ' is totally constrained for temperature, no need to solve!']);
|
---|
304 | end
|
---|
305 | end
|
---|
306 |
|
---|
307 | %VELOCITIES AND PRESSURE
|
---|
308 | fields={'vx','vy','vz','pressure'};
|
---|
309 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
310 | checknan(md,fields);
|
---|
311 |
|
---|
312 | end
|
---|
313 |
|
---|
314 | %THERMAL TRANSIENT
|
---|
315 | if md.analysis_type==ThermalAnalysisEnum & md.dt~=0,
|
---|
316 |
|
---|
317 | %DT and NDT
|
---|
318 | fields={'dt','ndt'};
|
---|
319 | checkgreaterstrict(md,fields,0);
|
---|
320 |
|
---|
321 | %INITIAL TEMPERATURE, MELTING AND ACCUMULATION
|
---|
322 | fields={'temperature','accumulation','melting'};
|
---|
323 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
324 | checknan(md,fields);
|
---|
325 |
|
---|
326 | %INITIAL TEMPERATURE
|
---|
327 | fields={'temperature','spctemperature(:,2)','observed_temperature'};
|
---|
328 | checkgreater(md,fields,0)
|
---|
329 |
|
---|
330 | end
|
---|
331 |
|
---|
332 | %BALANCEDTHICKNESS
|
---|
333 | if md.analysis_type==BalancedthicknessAnalysisEnum
|
---|
334 |
|
---|
335 | %VELOCITIES MELTING AND ACCUMULATION
|
---|
336 | fields={'vx','vy','accumulation','melting'};
|
---|
337 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
338 | checknan(md,fields);
|
---|
339 |
|
---|
340 | %SPC
|
---|
341 | if any(md.spcthickness(find(md.gridonboundary))~=1),
|
---|
342 | error(['model not consistent: model ' md.name ' should have all the nodes on boundary constrained in field spcthickness']);
|
---|
343 | end
|
---|
344 | end
|
---|
345 |
|
---|
346 | %BALANCEDVELOCITIES
|
---|
347 | if md.analysis_type==BalancedvelocitiesAnalysisEnum
|
---|
348 |
|
---|
349 | %VELOCITIES MELTING AND ACCUMULATION
|
---|
350 | fields={'vx','vy','accumulation','melting'};
|
---|
351 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
352 | checknan(md,fields);
|
---|
353 |
|
---|
354 | %SPC
|
---|
355 | if any(md.spcvelocity(find(md.gridonboundary),[1:2])~=1),
|
---|
356 | error(['model not consistent: model ' md.name ' should have all the nodes on boundary constrained in field spcvelocity']);
|
---|
357 | end
|
---|
358 | end
|
---|
359 |
|
---|
360 | %CONTROL
|
---|
361 | if md.control_analysis,
|
---|
362 |
|
---|
363 | %CONTROL TYPE
|
---|
364 | if ~ischar(md.control_type),
|
---|
365 | error('model not consistent: control_type should be a string');
|
---|
366 | end
|
---|
367 |
|
---|
368 | %LENGTH CONTROL FIELDS
|
---|
369 | fields={'maxiter','optscal','fit','cm_jump'};
|
---|
370 | checksize(md,fields,[md.nsteps 1]);
|
---|
371 |
|
---|
372 | %FIT
|
---|
373 | if sum((double(md.fit==1) + double(md.fit==0) + double(md.fit==2))==1)~=md.nsteps
|
---|
374 | error('model not consistent: wrong fits: fit should be a vector of size nsteps holding 0, 1 and 2 only')
|
---|
375 | end
|
---|
376 |
|
---|
377 | %OBSERVED VELOCITIES
|
---|
378 | fields={'vx_obs','vy_obs'};
|
---|
379 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
380 | checknan(md,fields);
|
---|
381 |
|
---|
382 | %DIRICHLET IF THICKNESS <= 0
|
---|
383 | if any(md.thickness<=0),
|
---|
384 | pos=find(md.thickness<=0);
|
---|
385 | if any(find(md.spcthickness(pos,1)==0)),
|
---|
386 | error(['model not consistent: model ' md.name ' has some grids with 0 thickness']);
|
---|
387 | end
|
---|
388 | end
|
---|
389 |
|
---|
390 | %parameters
|
---|
391 | fields={'cm_noisedmp'};
|
---|
392 | checknan(md,fields);
|
---|
393 | end
|
---|
394 |
|
---|
395 | %QMU
|
---|
396 | if strcmpi(md.analysis_type,'qmu'),
|
---|
397 | if ~strcmpi(md.cluster,'none'),
|
---|
398 | if md.waitonlock==0,
|
---|
399 | error(['model is not correctly configured: waitonlock should be activated when running qmu in parallel mode!']);
|
---|
400 | end
|
---|
401 | end
|
---|
402 | end
|
---|
403 |
|
---|
404 | end %end function
|
---|
405 |
|
---|
406 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CHECK FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
407 |
|
---|
408 | function checklength(md,fields,fieldlength)
|
---|
409 | %CHECKSIZE - check length of a field
|
---|
410 | for i=1:length(fields),
|
---|
411 | if length(eval(['md.' fields{i}]))~=fieldlength,
|
---|
412 | error(['model not consistent: field ' fields{i} ' length should be ' num2str(fieldlength)]);
|
---|
413 | end
|
---|
414 | end
|
---|
415 | end
|
---|
416 |
|
---|
417 | function checksize(md,fields,fieldsize)
|
---|
418 | %CHECKSIZE - check size of a field
|
---|
419 | for i=1:length(fields),
|
---|
420 | if isnan(fieldsize(1)),
|
---|
421 | if (size(eval(['md.' fields{i}]),2)~=fieldsize(2)),
|
---|
422 | error(['model not consistent: field ' fields{i} ' should have ' num2str(fieldsize(2)) ' columns']);
|
---|
423 | end
|
---|
424 | elseif isnan(fieldsize(2)),
|
---|
425 | if (size(eval(['md.' fields{i}]),1)~=fieldsize(1)),
|
---|
426 | error(['model not consistent: field ' fields{i} ' should have ' num2str(fieldsize(1)) ' rows']);
|
---|
427 | end
|
---|
428 | else
|
---|
429 | if ((size(eval(['md.' fields{i}]),1)~=fieldsize(1)) | (size(eval(['md.' fields{i}]),2)~=fieldsize(2)))
|
---|
430 | error(['model not consistent: field ' fields{i} ' size should be ' num2str(fieldsize(1)) ' x ' num2str(fieldsize(2))]);
|
---|
431 | end
|
---|
432 | end
|
---|
433 | end
|
---|
434 | end
|
---|
435 |
|
---|
436 | function checknan(md,fields)
|
---|
437 | %CHECKNAN - check nan values of a field
|
---|
438 | for i=1:length(fields),
|
---|
439 | if any(isnan(eval(['md.' fields{i}]))),
|
---|
440 | error(['model not consistent: NaN values in field ' fields{i}]);
|
---|
441 | end
|
---|
442 | end
|
---|
443 | end
|
---|
444 |
|
---|
445 | function checkreal(md,fields)
|
---|
446 | %CHECKREAL - check real values of a field
|
---|
447 | for i=1:length(fields),
|
---|
448 | if any(eval(['~isreal(md.' fields{i} ')'])),
|
---|
449 | error(['model not consistent: complex values in field ' fields{i}]);
|
---|
450 | end
|
---|
451 | end
|
---|
452 | end
|
---|
453 |
|
---|
454 | function checkgreaterstrict(md,fields,lowerbound)
|
---|
455 | %CHECKGREATERSTRICT - check values of a field
|
---|
456 | for i=1:length(fields),
|
---|
457 | if any(eval(['md.' fields{i} '<=' num2str(lowerbound) ])),
|
---|
458 | error(['model not consistent: field ' fields{i} ' should have values stricly above ' num2str(lowerbound)]);
|
---|
459 | end
|
---|
460 | end
|
---|
461 | end
|
---|
462 |
|
---|
463 | function checkgreater(md,fields,lowerbound)
|
---|
464 | %CHECKGREATER - check values of a field
|
---|
465 | for i=1:length(fields),
|
---|
466 | if any(eval(['md.' fields{i} '<' num2str(lowerbound) ])),
|
---|
467 | error(['model not consistent: field ' fields{i} ' should have values above ' num2str(lowerbound)]);
|
---|
468 | end
|
---|
469 | end
|
---|
470 | end
|
---|
471 |
|
---|
472 | function checklessstrict(md,fields,upperbound)
|
---|
473 | %CHECKLESSSTRICT - check values of a field
|
---|
474 | for i=1:length(fields),
|
---|
475 | if any(eval(['md.' fields{i} '>=' num2str(upperbound) ])),
|
---|
476 | error(['model not consistent: field ' fields{i} ' should have values stricly below ' num2str(upperbound)]);
|
---|
477 | end
|
---|
478 | end
|
---|
479 | end
|
---|
480 |
|
---|
481 | function checkless(md,fields,upperbound)
|
---|
482 | %CHECKLESS - check values of a field
|
---|
483 | for i=1:length(fields),
|
---|
484 | if any(eval(['md.' fields{i} '>' num2str(upperbound) ])),
|
---|
485 | error(['model not consistent: field ' fields{i} ' should have values below ' num2str(upperbound)]);
|
---|
486 | end
|
---|
487 | end
|
---|
488 | end
|
---|
489 |
|
---|
490 | function checkvalues(md,fields,values)
|
---|
491 | %CHECKVALUE - check that a field has a certain value
|
---|
492 | for i=1:length(fields),
|
---|
493 | if eval(['~ismember( md.' fields{i} ',values)']),
|
---|
494 | error(['model not consistent: field ' fields{i} ' should have values in ' num2str(values)]);
|
---|
495 | end
|
---|
496 | end
|
---|
497 | end
|
---|