[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'};
|
---|
[3099] | 78 | checksize(md,fields,[NaN 4]);
|
---|
[1796] | 79 | elseif strcmpi(md.type,'3d'),
|
---|
[2326] | 80 | fields={'pressureload'};
|
---|
[3099] | 81 | checksize(md,fields,[NaN 6]);
|
---|
[3356] | 82 | else
|
---|
[3357] | 83 | error('type should be either ''2d'' or ''3d''');
|
---|
[1796] | 84 | end
|
---|
[358] | 85 |
|
---|
[3356] | 86 | %ELEMENTS
|
---|
| 87 | fields={'elements'};
|
---|
| 88 | if strcmpi(md.type,'2d'),
|
---|
| 89 | checksize(md,fields,[md.numberofelements 3]);
|
---|
| 90 | else
|
---|
| 91 | checksize(md,fields,[md.numberofelements 6]);
|
---|
| 92 | end
|
---|
| 93 |
|
---|
[27] | 94 | %NO NAN
|
---|
[1755] | 95 | fields={'numberofelements','numberofgrids','x','y','z','drag','drag_type','p','q',...
|
---|
[27] | 96 | 'rho_ice','rho_water','B','elementoniceshelf','surface','thickness','bed','g','lowmem','sparsity','nsteps','maxiter',...
|
---|
[3203] | 97 | 'tolx','np','eps_res','max_nonlinear_iterations','exclusive','n','gridonbed','gridonsurface','elementonbed','elementonsurface','deltaH','DeltaH','timeacc','timedec'};
|
---|
[2366] | 98 | checknan(md,fields);
|
---|
[1] | 99 |
|
---|
[1666] | 100 | %FIELDS >= 0
|
---|
[1755] | 101 | fields={'numberofelements','numberofgrids','elements','drag','drag_type','p','q',...
|
---|
[3203] | 102 | 'rho_ice','rho_water','B','elementoniceshelf','thickness','g','eps_res','max_nonlinear_iterations','eps_rel','eps_abs','nsteps','maxiter','tolx','exclusive',...
|
---|
[27] | 103 | 'sparsity','lowmem','n','gridonbed','gridonsurface','elementonbed','elementonsurface','deltaH','DeltaH','timeacc','timedec'};
|
---|
[2366] | 104 | checkgreater(md,fields,0);
|
---|
[1] | 105 |
|
---|
[2326] | 106 | %FIELDS > 0
|
---|
| 107 | fields={'numberofelements','numberofgrids','elements','drag_type','p',...
|
---|
[3203] | 108 | 'rho_ice','rho_water','B','thickness','g','max_nonlinear_iterations','eps_res','eps_rel','eps_abs','maxiter','tolx',...
|
---|
[27] | 109 | 'sparsity','deltaH','DeltaH','timeacc','timedec'};
|
---|
[2366] | 110 | checkgreaterstrict(md,fields,0);
|
---|
[1] | 111 |
|
---|
[27] | 112 | %SIZE NUMBEROFELEMENTS
|
---|
[2991] | 113 | fields={'p','q','elementoniceshelf','n','elementonbed'};
|
---|
| 114 | checksize(md,fields,[md.numberofelements 1]);
|
---|
| 115 |
|
---|
[27] | 116 | %SIZE NUMBEROFGRIDS
|
---|
[2991] | 117 | fields={'x','y','z','B','drag','melting','accumulation','surface','thickness','bed','gridonbed','gridonsurface'};
|
---|
| 118 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
[27] | 119 |
|
---|
[2405] | 120 | %SIZE 6
|
---|
| 121 | fields={'spcvelocity'};
|
---|
| 122 | checksize(md,fields,[md.numberofgrids 6]);
|
---|
| 123 |
|
---|
[27] | 124 | %THICKNESS = SURFACE - BED
|
---|
[681] | 125 | if any((md.thickness-md.surface+md.bed)>tolerance),
|
---|
[2326] | 126 | error(['model not consistent: model ' md.name ' violates the equality thickness=surface-bed!']);
|
---|
[27] | 127 | end
|
---|
| 128 |
|
---|
| 129 | %RIFTS
|
---|
| 130 | if md.numrifts,
|
---|
| 131 | if ~strcmpi(md.type,'2d'),
|
---|
[2326] | 132 | error(['model not consistent: models with rifts are only supported in 2d for now!']);
|
---|
[1] | 133 | end
|
---|
[2660] | 134 | if ~isstruct(md.rifts),
|
---|
| 135 | error(['model not consistent: md.rifts should be a structure!']);
|
---|
| 136 | end
|
---|
| 137 | if ~isempty(find(md.segmentmarkers>=2)),
|
---|
| 138 | %We have segments with rift markers, but no rift structure!
|
---|
| 139 | error(['model not consistent: model ' md.name ' should be processed for rifts (run meshprocessrifts)!']);
|
---|
| 140 | end
|
---|
| 141 | %Check that rifts are filled with proper material
|
---|
| 142 | checkvalues(md,{'rifts.fill'},[WaterEnum() AirEnum() IceEnum() MelangeEnum()]);
|
---|
| 143 | else
|
---|
[2748] | 144 | if ~isnans(md.rifts),
|
---|
[2660] | 145 | error(['model not consistent: md.rifts shoud be NaN since md.numrifts is 0!']);
|
---|
[27] | 146 | end
|
---|
| 147 | end
|
---|
[1] | 148 |
|
---|
[27] | 149 | %ARTIFICIAL DIFFUSIVITY
|
---|
[2326] | 150 | if ~ismember(md.artificial_diffusivity,[0 1]),
|
---|
| 151 | error('model not consistent: artificial_diffusivity should be a scalar (1 or 0)');
|
---|
[1] | 152 | end
|
---|
| 153 |
|
---|
[2307] | 154 | %PARAMETEROUTPUT
|
---|
| 155 | if md.numoutput~=length(md.parameteroutput),
|
---|
[2326] | 156 | error('model not consistent: numoutput should be the same size as parameteroutput');
|
---|
[2307] | 157 | end
|
---|
| 158 |
|
---|
[2326] | 159 | %CONNECTIVITY
|
---|
| 160 | if strcmpi(md.type,'2d'),
|
---|
| 161 | if md.connectivity<9,
|
---|
| 162 | error('model not consistent: connectivity should be at least 9 for 2d models');
|
---|
| 163 | end
|
---|
| 164 | end
|
---|
| 165 | if strcmpi(md.type,'3d'),
|
---|
| 166 | if md.connectivity<24,
|
---|
| 167 | error('model not consistent: connectivity should be at least 24 for 3d models');
|
---|
| 168 | end
|
---|
| 169 | end
|
---|
| 170 |
|
---|
| 171 | %LOWMEM = 0 or 1
|
---|
| 172 | if ((md.lowmem ~= 1) & (md.lowmem~=0)),
|
---|
| 173 | error(['model not consistent: model ' md.name ' lowmem field should be 0 or 1']);
|
---|
| 174 | end
|
---|
| 175 |
|
---|
| 176 | %PARALLEL
|
---|
| 177 | if ~strcmpi(md.cluster,'none'),
|
---|
| 178 |
|
---|
| 179 | %NAN VALUES
|
---|
| 180 | fields={'time','np'};
|
---|
[2366] | 181 | checknan(md,fields);
|
---|
[2326] | 182 |
|
---|
| 183 | %FIELD > 0
|
---|
| 184 | fields={'time','np'};
|
---|
[2366] | 185 | checkgreaterstrict(md,fields,0);
|
---|
[2326] | 186 |
|
---|
| 187 | end
|
---|
| 188 |
|
---|
[27] | 189 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SOLUTION CHECKS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
[2326] | 190 |
|
---|
[804] | 191 | %QMU
|
---|
[966] | 192 | if md.qmu_analysis,
|
---|
| 193 | if md.qmu_params.evaluation_concurrency~=1,
|
---|
[2326] | 194 | error(['model not consistent: concurrency should be set to 1 when running dakota in library mode']);
|
---|
[966] | 195 | end
|
---|
[1111] | 196 | if ~isempty(md.part),
|
---|
| 197 | if numel(md.part)~=md.numberofgrids,
|
---|
[2326] | 198 | error(['model not consistent: user supplied partition for qmu analysis should have size md.numberofgrids x 1 ']);
|
---|
[1111] | 199 | end
|
---|
| 200 | if find(md.part)>=md.numberofgrids,
|
---|
[2326] | 201 | error(['model not consistent: user supplied partition should be indexed from 0 (c-convention)']);
|
---|
[1111] | 202 | end
|
---|
[3037] | 203 | if min(md.part)~=0,
|
---|
| 204 | error(['model not consistent: partition vector not indexed from 0 on']);
|
---|
[1111] | 205 | end
|
---|
[3037] | 206 | if max(md.part)>=md.numberofgrids,
|
---|
| 207 | error(['model not consistent: partition vector cannot have maximum index larger than number of grids']);
|
---|
| 208 | end
|
---|
[3055] | 209 | if ~isempty(find(md.part<0)),
|
---|
| 210 | error(['model not consistent: partition vector cannot have values less than 0']);
|
---|
| 211 | end
|
---|
| 212 | if ~isempty(find(md.part>=md.npart)),
|
---|
| 213 | error(['model not consistent: partition vector cannot have values more than md.npart-1']);
|
---|
| 214 | end
|
---|
| 215 |
|
---|
[1111] | 216 | end
|
---|
[3037] | 217 | if md.eps_rel>1.1*10^-5,
|
---|
[2326] | 218 | error(['model not consistent: for qmu analysis, eps_rel should be least than 10^-5, 10^-15 being a better value']);
|
---|
[2052] | 219 | end
|
---|
[804] | 220 | end
|
---|
[27] | 221 |
|
---|
| 222 | %DIAGNOSTIC
|
---|
[1781] | 223 | if md.analysis_type==DiagnosticAnalysisEnum,
|
---|
[27] | 224 |
|
---|
[2208] | 225 | %CHECK THAT WE ARE NOT FULLY CONSTRAINED
|
---|
| 226 | if strcmpi(md.type,'2d'),
|
---|
| 227 | if isempty(find(~md.spcvelocity(:,1:2))),
|
---|
[2326] | 228 | error(['model not consistent: model ' md.name ' is totally constrained, no need to solve!']);
|
---|
[2208] | 229 | end
|
---|
| 230 | end
|
---|
| 231 |
|
---|
[27] | 232 | %HUTTER ON ICESHELF WARNING
|
---|
[1651] | 233 | if any(md.elements_type(:,1)==HutterFormulationEnum & md.elementoniceshelf),
|
---|
[27] | 234 | disp(sprintf('\n !!! Warning: Hutter''s model is not consistent on ice shelves !!!\n'));
|
---|
| 235 | end
|
---|
| 236 |
|
---|
| 237 | %SINGULAR
|
---|
[2282] | 238 | if ~any(sum(md.spcvelocity(:,1:2),2)==2),
|
---|
[2326] | 239 | error(['model not consistent: model ' md.name ' is not well posed (singular). You need at least one grid with fixed velocity!'])
|
---|
[1] | 240 | end
|
---|
| 241 |
|
---|
[27] | 242 | %DIRICHLET IF THICKNESS <= 0
|
---|
[681] | 243 | if any(md.thickness<=0),
|
---|
[27] | 244 | pos=find(md.thickness<=0);
|
---|
[1755] | 245 | if any(find(md.spcthickness(pos,1)==0)),
|
---|
[2326] | 246 | error(['model not consistent: model ' md.name ' has some grids with 0 thickness']);
|
---|
[27] | 247 | end
|
---|
| 248 | end
|
---|
[2357] | 249 |
|
---|
[2367] | 250 | %INITIAL VELOCITY
|
---|
| 251 | if length(md.vx)==md.numberofgrids & length(md.vy)==md.numberofgrids,
|
---|
| 252 | fields={'vx','vy'};
|
---|
| 253 | checknan(md,fields);
|
---|
| 254 | end
|
---|
[1] | 255 | end
|
---|
| 256 |
|
---|
[27] | 257 | %PROGNOSTIC
|
---|
[1781] | 258 | if md.analysis_type==PrognosticAnalysisEnum,
|
---|
[1] | 259 |
|
---|
[2357] | 260 | %INITIAL VELOCITIES
|
---|
| 261 | fields={'vx','vy'};
|
---|
[2366] | 262 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
| 263 | checknan(md,fields);
|
---|
[2357] | 264 |
|
---|
[2519] | 265 | %CHECK THAT WE ARE NOT FULLY CONSTRAINED
|
---|
| 266 | if strcmpi(md.type,'2d'),
|
---|
| 267 | if isempty(find(~md.spcthickness(:,1))),
|
---|
| 268 | error(['model not consistent: model ' md.name ' is totally constrained for prognostic, no need to solve!']);
|
---|
| 269 | end
|
---|
| 270 | end
|
---|
| 271 |
|
---|
[1] | 272 | end
|
---|
| 273 |
|
---|
[1867] | 274 | %STEADYSTATE
|
---|
| 275 | if md.analysis_type==SteadystateAnalysisEnum,
|
---|
[2326] | 276 |
|
---|
[1901] | 277 | %NDT
|
---|
| 278 | if md.dt~=0,
|
---|
[2326] | 279 | error(['model not consistent: for a steadystate computation, dt must be zero.']);
|
---|
[1901] | 280 | end
|
---|
[2326] | 281 |
|
---|
[1787] | 282 | %PRESSURE
|
---|
| 283 | if isnans(md.pressure),
|
---|
[2326] | 284 | error(['model not consistent: for a steadystate computation, the model must have an initial pressure, even lithostatic will do.']);
|
---|
[1787] | 285 | end
|
---|
| 286 |
|
---|
| 287 | %eps:
|
---|
| 288 | if isnan(md.eps_rel),
|
---|
[2326] | 289 | error(['model not consistent: for a steadystate computation, eps_rel (relative convergence criterion) must be defined!']);
|
---|
[1787] | 290 | end
|
---|
| 291 |
|
---|
| 292 | %dim:
|
---|
| 293 | if strcmpi(md.type,'2d'),
|
---|
[2326] | 294 | error(['model not consistent: for a steadystate computation, model needs to be 3d']);
|
---|
[1787] | 295 | end
|
---|
| 296 | end
|
---|
| 297 |
|
---|
[27] | 298 | %THERMAL STEADY AND THERMAL TRANSIENT
|
---|
[1781] | 299 | if md.analysis_type==ThermalAnalysisEnum,
|
---|
[27] | 300 |
|
---|
| 301 | %EXTRUSION
|
---|
| 302 | if strcmp(md.type,'2d'),
|
---|
[2326] | 303 | error(['model not consistent: for a ' md.analysis_type ' computation, the model must be 3d, extrude it first!'])
|
---|
[1] | 304 | end
|
---|
[27] | 305 |
|
---|
[2519] | 306 | %CHECK THAT WE ARE NOT FULLY CONSTRAINED
|
---|
| 307 | if strcmpi(md.type,'2d'),
|
---|
| 308 | if isempty(find(~md.spctemperature(:,1))),
|
---|
| 309 | error(['model not consistent: model ' md.name ' is totally constrained for temperature, no need to solve!']);
|
---|
| 310 | end
|
---|
| 311 | end
|
---|
| 312 |
|
---|
[27] | 313 | %VELOCITIES AND PRESSURE
|
---|
[2357] | 314 | fields={'vx','vy','vz','pressure'};
|
---|
[2366] | 315 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
| 316 | checknan(md,fields);
|
---|
[2357] | 317 |
|
---|
[1] | 318 | end
|
---|
| 319 |
|
---|
[1311] | 320 | %THERMAL TRANSIENT
|
---|
[2520] | 321 | if md.analysis_type==ThermalAnalysisEnum & md.dt~=0,
|
---|
[27] | 322 |
|
---|
| 323 | %DT and NDT
|
---|
| 324 | fields={'dt','ndt'};
|
---|
[2366] | 325 | checkgreaterstrict(md,fields,0);
|
---|
[27] | 326 |
|
---|
[1311] | 327 | %INITIAL TEMPERATURE, MELTING AND ACCUMULATION
|
---|
[2326] | 328 | fields={'temperature','accumulation','melting'};
|
---|
[2366] | 329 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
[2440] | 330 | checknan(md,fields);
|
---|
[1] | 331 |
|
---|
[2714] | 332 | %INITIAL TEMPERATURE
|
---|
[2669] | 333 | fields={'temperature','spctemperature(:,2)','observed_temperature'};
|
---|
| 334 | checkgreater(md,fields,0)
|
---|
| 335 |
|
---|
[1] | 336 | end
|
---|
| 337 |
|
---|
[2714] | 338 | %BALANCEDTHICKNESS
|
---|
| 339 | if md.analysis_type==BalancedthicknessAnalysisEnum
|
---|
| 340 |
|
---|
| 341 | %VELOCITIES MELTING AND ACCUMULATION
|
---|
[3589] | 342 | fields={'vx','vy','accumulation','melting'};
|
---|
| 343 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
| 344 | checknan(md,fields);
|
---|
| 345 |
|
---|
| 346 | %SPC
|
---|
| 347 | if any(md.spcthickness(find(md.gridonboundary))~=1),
|
---|
| 348 | error(['model not consistent: model ' md.name ' should have all the nodes on boundary constrained in field spcthickness']);
|
---|
| 349 | end
|
---|
| 350 | end
|
---|
| 351 |
|
---|
| 352 | %BALANCEDTHICKNESS2
|
---|
| 353 | if md.analysis_type==Balancedthickness2AnalysisEnum
|
---|
| 354 |
|
---|
| 355 | %VELOCITIES MELTING AND ACCUMULATION
|
---|
[3582] | 356 | fields={'vx','vy','accumulation','melting','dhdt'};
|
---|
[2714] | 357 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
| 358 | checknan(md,fields);
|
---|
| 359 |
|
---|
| 360 | end
|
---|
| 361 |
|
---|
[2723] | 362 | %BALANCEDVELOCITIES
|
---|
| 363 | if md.analysis_type==BalancedvelocitiesAnalysisEnum
|
---|
| 364 |
|
---|
| 365 | %VELOCITIES MELTING AND ACCUMULATION
|
---|
| 366 | fields={'vx','vy','accumulation','melting'};
|
---|
| 367 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
| 368 | checknan(md,fields);
|
---|
| 369 |
|
---|
| 370 | %SPC
|
---|
| 371 | if any(md.spcvelocity(find(md.gridonboundary),[1:2])~=1),
|
---|
| 372 | error(['model not consistent: model ' md.name ' should have all the nodes on boundary constrained in field spcvelocity']);
|
---|
| 373 | end
|
---|
| 374 | end
|
---|
| 375 |
|
---|
[27] | 376 | %CONTROL
|
---|
[1907] | 377 | if md.control_analysis,
|
---|
[1] | 378 |
|
---|
[27] | 379 | %CONTROL TYPE
|
---|
[45] | 380 | if ~ischar(md.control_type),
|
---|
[2326] | 381 | error('model not consistent: control_type should be a string');
|
---|
[1] | 382 | end
|
---|
| 383 |
|
---|
[27] | 384 | %LENGTH CONTROL FIELDS
|
---|
[2326] | 385 | fields={'maxiter','optscal','fit','cm_jump'};
|
---|
[2991] | 386 | checksize(md,fields,[md.nsteps 1]);
|
---|
[27] | 387 |
|
---|
| 388 | %FIT
|
---|
[3189] | 389 | checkvalues(md,{'fit'},[0 1 2 3 4]);
|
---|
[1] | 390 |
|
---|
[3203] | 391 | %WEIGHTS
|
---|
| 392 | fields={'weights'};
|
---|
| 393 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
| 394 | checkgreater(md,fields,0);
|
---|
| 395 |
|
---|
[27] | 396 | %OBSERVED VELOCITIES
|
---|
| 397 | fields={'vx_obs','vy_obs'};
|
---|
[2366] | 398 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
| 399 | checknan(md,fields);
|
---|
[1361] | 400 |
|
---|
| 401 | %DIRICHLET IF THICKNESS <= 0
|
---|
| 402 | if any(md.thickness<=0),
|
---|
| 403 | pos=find(md.thickness<=0);
|
---|
[1755] | 404 | if any(find(md.spcthickness(pos,1)==0)),
|
---|
[2326] | 405 | error(['model not consistent: model ' md.name ' has some grids with 0 thickness']);
|
---|
[1361] | 406 | end
|
---|
| 407 | end
|
---|
[2686] | 408 |
|
---|
| 409 | %parameters
|
---|
| 410 | fields={'cm_noisedmp'};
|
---|
| 411 | checknan(md,fields);
|
---|
[1] | 412 | end
|
---|
| 413 |
|
---|
[27] | 414 | %QMU
|
---|
[465] | 415 | if strcmpi(md.analysis_type,'qmu'),
|
---|
[27] | 416 | if ~strcmpi(md.cluster,'none'),
|
---|
| 417 | if md.waitonlock==0,
|
---|
[2326] | 418 | error(['model is not correctly configured: waitonlock should be activated when running qmu in parallel mode!']);
|
---|
[1] | 419 | end
|
---|
| 420 | end
|
---|
| 421 | end
|
---|
| 422 |
|
---|
[2326] | 423 | end %end function
|
---|
[1] | 424 |
|
---|
[2366] | 425 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CHECK FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
[2326] | 426 |
|
---|
[2366] | 427 | function checklength(md,fields,fieldlength)
|
---|
| 428 | %CHECKSIZE - check length of a field
|
---|
[2326] | 429 | for i=1:length(fields),
|
---|
| 430 | if length(eval(['md.' fields{i}]))~=fieldlength,
|
---|
| 431 | error(['model not consistent: field ' fields{i} ' length should be ' num2str(fieldlength)]);
|
---|
[2164] | 432 | end
|
---|
| 433 | end
|
---|
| 434 | end
|
---|
[1] | 435 |
|
---|
[2366] | 436 | function checksize(md,fields,fieldsize)
|
---|
| 437 | %CHECKSIZE - check size of a field
|
---|
[2326] | 438 | for i=1:length(fields),
|
---|
| 439 | if isnan(fieldsize(1)),
|
---|
| 440 | if (size(eval(['md.' fields{i}]),2)~=fieldsize(2)),
|
---|
[3203] | 441 | %LOG warnings:
|
---|
[3104] | 442 | if strcmpi(fields{i},'pressureload'),
|
---|
| 443 | disp(' ');
|
---|
| 444 | disp(' If pressureload does not have the right size (one column missing), this is due to a change in md.pressure.');
|
---|
| 445 | disp(' To update your model, use the following line');
|
---|
| 446 | disp(' md.pressureload=[md.pressureload WaterEnum*md.elementoniceshelf(md.pressureload(:,end))+AirEnum*md.elementonicesheet(md.pressureload(:,end))];');
|
---|
| 447 | disp(' ');
|
---|
| 448 | end
|
---|
[2326] | 449 | error(['model not consistent: field ' fields{i} ' should have ' num2str(fieldsize(2)) ' columns']);
|
---|
| 450 | end
|
---|
| 451 | elseif isnan(fieldsize(2)),
|
---|
| 452 | if (size(eval(['md.' fields{i}]),1)~=fieldsize(1)),
|
---|
| 453 | error(['model not consistent: field ' fields{i} ' should have ' num2str(fieldsize(1)) ' rows']);
|
---|
| 454 | end
|
---|
| 455 | else
|
---|
| 456 | if ((size(eval(['md.' fields{i}]),1)~=fieldsize(1)) | (size(eval(['md.' fields{i}]),2)~=fieldsize(2)))
|
---|
[3219] | 457 | %LOG warnings:
|
---|
| 458 | if strcmpi(fields{i},'weights'),
|
---|
| 459 | disp(' ');
|
---|
| 460 | disp(' ''weights'' is a new field that should be of length numberofgrids.');
|
---|
| 461 | disp(' To update your model, use the following line');
|
---|
| 462 | disp(' md.weights=ones(md.numberofgrids,1)');
|
---|
| 463 | disp(' ');
|
---|
| 464 | end
|
---|
[2326] | 465 | error(['model not consistent: field ' fields{i} ' size should be ' num2str(fieldsize(1)) ' x ' num2str(fieldsize(2))]);
|
---|
| 466 | end
|
---|
[2164] | 467 | end
|
---|
| 468 | end
|
---|
| 469 | end
|
---|
| 470 |
|
---|
[2366] | 471 | function checknan(md,fields)
|
---|
| 472 | %CHECKNAN - check nan values of a field
|
---|
[2326] | 473 | for i=1:length(fields),
|
---|
| 474 | if any(isnan(eval(['md.' fields{i}]))),
|
---|
| 475 | error(['model not consistent: NaN values in field ' fields{i}]);
|
---|
[2164] | 476 | end
|
---|
| 477 | end
|
---|
| 478 | end
|
---|
| 479 |
|
---|
[2366] | 480 | function checkreal(md,fields)
|
---|
| 481 | %CHECKREAL - check real values of a field
|
---|
[2326] | 482 | for i=1:length(fields),
|
---|
| 483 | if any(eval(['~isreal(md.' fields{i} ')'])),
|
---|
| 484 | error(['model not consistent: complex values in field ' fields{i}]);
|
---|
| 485 | end
|
---|
| 486 | end
|
---|
[2164] | 487 | end
|
---|
| 488 |
|
---|
[2366] | 489 | function checkgreaterstrict(md,fields,lowerbound)
|
---|
| 490 | %CHECKGREATERSTRICT - check values of a field
|
---|
[2326] | 491 | for i=1:length(fields),
|
---|
| 492 | if any(eval(['md.' fields{i} '<=' num2str(lowerbound) ])),
|
---|
| 493 | error(['model not consistent: field ' fields{i} ' should have values stricly above ' num2str(lowerbound)]);
|
---|
| 494 | end
|
---|
[2164] | 495 | end
|
---|
| 496 | end
|
---|
| 497 |
|
---|
[2366] | 498 | function checkgreater(md,fields,lowerbound)
|
---|
| 499 | %CHECKGREATER - check values of a field
|
---|
[27] | 500 | for i=1:length(fields),
|
---|
[2326] | 501 | if any(eval(['md.' fields{i} '<' num2str(lowerbound) ])),
|
---|
| 502 | error(['model not consistent: field ' fields{i} ' should have values above ' num2str(lowerbound)]);
|
---|
[27] | 503 | end
|
---|
| 504 | end
|
---|
[2326] | 505 | end
|
---|
[1] | 506 |
|
---|
[2366] | 507 | function checklessstrict(md,fields,upperbound)
|
---|
| 508 | %CHECKLESSSTRICT - check values of a field
|
---|
[27] | 509 | for i=1:length(fields),
|
---|
[2326] | 510 | if any(eval(['md.' fields{i} '>=' num2str(upperbound) ])),
|
---|
| 511 | error(['model not consistent: field ' fields{i} ' should have values stricly below ' num2str(upperbound)]);
|
---|
[27] | 512 | end
|
---|
| 513 | end
|
---|
[2326] | 514 | end
|
---|
[1] | 515 |
|
---|
[2366] | 516 | function checkless(md,fields,upperbound)
|
---|
| 517 | %CHECKLESS - check values of a field
|
---|
[27] | 518 | for i=1:length(fields),
|
---|
[2326] | 519 | if any(eval(['md.' fields{i} '>' num2str(upperbound) ])),
|
---|
| 520 | error(['model not consistent: field ' fields{i} ' should have values below ' num2str(upperbound)]);
|
---|
[27] | 521 | end
|
---|
[1] | 522 | end
|
---|
| 523 | end
|
---|
[2660] | 524 |
|
---|
| 525 | function checkvalues(md,fields,values)
|
---|
| 526 | %CHECKVALUE - check that a field has a certain value
|
---|
| 527 | for i=1:length(fields),
|
---|
| 528 | if eval(['~ismember( md.' fields{i} ',values)']),
|
---|
| 529 | error(['model not consistent: field ' fields{i} ' should have values in ' num2str(values)]);
|
---|
| 530 | end
|
---|
| 531 | end
|
---|
| 532 | end
|
---|