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