isresultconsistent

PURPOSE ^

ISRESULTCONSISTENT: check that results are consistent

SYNOPSIS ^

function bool=isresultconsistent(md,solutiontype),

DESCRIPTION ^

ISRESULTCONSISTENT: check that results are consistent

   This routine is called after a computation and check
   that the values t the penalties are consitent

   Usage:
      bool=IsModelSelfConsistent(model,solutiontype)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function bool=isresultconsistent(md,solutiontype),
0002 %ISRESULTCONSISTENT: check that results are consistent
0003 %
0004 %   This routine is called after a computation and check
0005 %   that the values t the penalties are consitent
0006 %
0007 %   Usage:
0008 %      bool=IsModelSelfConsistent(model,solutiontype)
0009 
0010 %tolerance we use in litmus tests for the consistency of the model
0011 tolerance=10^-2;
0012 
0013 if (nargin~=2  )
0014     IsResultConsistentUsage();
0015     error(' ');
0016 end
0017 %Check velocities i(no penalties for 2d meshes)
0018 if (strcmp(solutiontype,'diagnostic') || strcmp(solutiontype,'diagnostic_horiz') ),
0019 
0020     if strcmpi(md.type,'3d'),
0021         if ~isnan(md.penalties),
0022             for i=1:size(md.penalties,1)
0023                 for n=2:md.numlayers
0024                     relativex=(md.vx(md.penalties(i,1))-md.vx(md.penalties(i,n)))./(md.vx(md.penalties(i,1)));
0025                     if md.vx(md.penalties(i,1))==md.vx(md.penalties(i,n)), relativex=0; end
0026                     relativey=(md.vy(md.penalties(i,1))-md.vy(md.penalties(i,n)))./(md.vy(md.penalties(i,1)));
0027                     if md.vy(md.penalties(i,1))==md.vy(md.penalties(i,n)), relativey=0; end
0028                     if abs(relativex)>tolerance | abs(relativey)>tolerance
0029                         disp(['''diagnostic'' result not consistent: increase penalty_offset (discontinuous horizontal velocity)']);
0030                         bool=0; return;
0031                     end
0032 
0033                 end
0034             end
0035         end
0036     end
0037 end
0038 
0039 if strcmp(solutiontype,'thermalsteady')
0040 
0041     %check melting
0042     if any(abs(md.melting(md.numberofgrids2d+1:end))>tolerance)
0043         disp(['''thermalsteady'' result not consistent: increase penalty_melting (negative melting)']);
0044         bool=0; return; 
0045     end
0046 
0047 end
0048 
0049 if strcmp(solutiontype,'thermaltransient')
0050 
0051     for iter=1:length(md.thermaltransient_results)
0052 
0053     %check melting
0054     if any(abs(md.thermaltransient_results(iter).melting(md.numberofgrids2d+1:end))>tolerance)
0055         disp(['''thermaltransient'' result not consistent: increase penalty_melting (negative melting)']);
0056         bool=0; return;
0057     end
0058 
0059     end
0060 end
0061 
0062 
0063 if (strcmp(solutiontype,'transient') & strcmpi(md.type,'3d')),
0064     for iter=1:length(md.transient_results)
0065 
0066         %check melting
0067         if any(abs(md.transient_results(iter).melting(md.numberofgrids2d+1:end))>tolerance)
0068             disp(['''thermaltransient'' result not consistent: increase penalty_melting (negative melting)']);
0069             bool=0; return;
0070         end
0071 
0072 
0073         %check velocities
0074         if ~isnan(md.penalties),
0075             for i=1:size(md.penalties,1)
0076                 for n=2:md.numlayers
0077                     relativex=(md.transient_results(iter).vx(md.penalties(i,1))-md.transient_results(iter).vx(md.penalties(i,n)))./(md.transient_results(iter).vx(md.penalties(i,1)));
0078                     if md.transient_results(iter).vx(md.penalties(i,1))==md.transient_results(iter).vx(md.penalties(i,n)), relativex=0; end
0079                     relativey=(md.transient_results(iter).vy(md.penalties(i,1))-md.transient_results(iter).vy(md.penalties(i,n)))./(md.transient_results(iter).vy(md.penalties(i,1)));
0080                     if md.transient_results(iter).vy(md.penalties(i,1))==md.transient_results(iter).vy(md.penalties(i,n)), relativey=0; end
0081                     if abs(relativex)>tolerance | abs(relativey)>tolerance
0082                         disp(['''transient'' result not consistent: increase penalty_offset (discontinuous horizontal velocity)']);
0083                         bool=0; return;
0084                     end
0085 
0086                 end
0087             end
0088         end
0089 
0090     end
0091 
0092 end
0093 
0094 
0095 %No problems, just return 1;
0096 bool=1;
0097 return;
0098     
0099 function IsResultConsistentUsage()
0100 disp(' ');
0101 disp('   IsResultConsistent usage: flag=IsResultConsistent(model,solutiontype)');
0102 disp('         where model is an instance of the @model class, and flag a boolean');

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003