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