function verifAE(nGlen, M0yr, Lkm, etamax, sector, tfyr, Nx, Mt); %VERIFAE Compares numerical to exact steady solution of shallow ice % equation with basal sliding % 0 = (M_s + M_b) - Div(q_f + H u_b), % incorporating compensatory accumulation. Numerical method: type I % explicit finite difference. Takes advantage of radial symmetry to % do 1/4 of work. Basal sliding in sector. % %verifAE(n, M0, L, etamax, sector, tf, Nx, Mt); % n = Glen exponent % M0 = accumulation in m/a % L = margin radius (km) % etamax = maximum basal till thickness (mm) % sector = [r1 r2 theta1 theta2] extent of sector; % ri in km, thetai in degrees, 0> verifAE(3,0.3,750,-1,[],25000,15,1800) % 2.6 secs % >> verifAE(3,0.3,750,-1,[],25000,30,7000) % 17 secs % >> verifAE(3,0.3,750,-1,[],25000,60,25000) % 2.8 mins % >> verifAE(3,0.3,750,-1,[],25000,120,100000) % 53 mins % >> verifAE(3,0.3,750,-1,[],25000,240,400000) % (~ 16 hours) %TEST E: (with basal sliding) % >> verifAE(3,0.3,750,200,[200 700 10 40],25000,15,3000) % 6.3 secs % >> verifAE(3,0.3,750,200,[200 700 10 40],25000,30,12000) % 40 secs % >> verifAE(3,0.3,750,200,[200 700 10 40],25000,60,60000) % 10.8 min % >> verifAE(3,0.3,750,200,[200 700 10 40],25000,120,300000) % 142 min %(ELB 4/24/04) clear H global H dx dy fx fy n2 nm Rx Ry global rho g Gam L n M0 Cs global etamonut bsflag r1 r2 theta1 theta2 mustgx mustgy % physical constants, etc SperA=31556926; % seconds per year (i.e. 365.2422 days) A=1e-16/SperA; %=3.17e-24 1/(Pa^3 s); (EISMINT value) flow law parameter rho=910; % kg/m^3; density of ice g=9.81; % m/s^2; gravity n=nGlen; % Glen exponent Gam=2*(rho*g)^n*A/(n+2); % overall constant in deformation discharge q_f tf=tfyr*SperA; M0=M0yr/SperA; L=Lkm*1000; % convert to secs and meters Cs=(2^(n-1)*M0/Gam)^(1/(2*n+2)); % constant in H_s(r) nut=8.0e9; % Pa s; viscosity of till etamonut=(etamax/1000)/nut; % constant in mu H0=getH(0); bsflag=(etamax>0); if bsflag, r1=sector(1)*1000; r2=sector(2)*1000; theta1=sector(3)*pi/180; theta2=sector(4)*pi/180; end errcontours=[-500 -200 -100 -70 -50 -30 -20 -10 -5 -1 ... 1 5 10 20 30 50 70 100 150 500]; % improve display set(0,'defaultaxesfontsize',12,'defaultaxeslinewidth',1.0,... 'defaultlinelinewidth',1.5,'defaultpatchlinewidth',1.2) % display exact; velocity fields first figure(1), Nr=20; Nz=20; rvel=linspace(0,L,Nr); [rrr,zzz]=meshgrid(rvel,linspace(0,H0*1.1,Nz)); HU=getH(rrr); [dHdrU, discard]=getddr(rrr); maskU = (zzz <= HU); U=zeros(size(rrr)); U(maskU) = - 2*A*(rho*g)^n/(n+1) * (-dHdrU(maskU)).^n .* ... ( (HU(maskU)-zzz(maskU)).^(n+1) - HU(maskU).^(n+1) ); if bsflag % add basal sliding component to velocity center=((theta1+theta2)/2); Ub=- getmu(rrr,center*ones(size(rrr))).*HU.*dHdrU; maskB=maskU & (r1 < rrr) & (rrr < r2); U(maskB)=U(maskB)+Ub(maskB); end quiver(rrr/1000,zzz,U,zeros(size(U)),.3,'r') axis([0 L/1000 0 H0*1.1]) text((L/10)/1000,H0*.1,... ['Max |U| = ' num2str(max(max(abs(U)))*SperA) ' m/a.'],'Color','r') % now thickness and accumulation ep=400; r=linspace(0,L,ep); if bsflag, M=M0+getMb(r,center*ones(size(r))); else M=M0*ones(size(r)); end hold on [AX,H1,H2] = plotyy(r/1000,getH(r),r/1000,M*SperA); grid on, xlabel('r in km') if bsflag, title('thickness and accumulation (along centerline of ice stream)'), else, title('thickness and accumulation'); end set(get(AX(1),'Ylabel'),'String','H in m (solid)'), set(H1,'LineStyle','-') set(get(AX(2),'Ylabel'),'String','M in m/a (dotted)'), set(H2,'LineStyle',':') hold off % "overhead view" of region of basal sliding if bsflag figure(4) [xxp,yyp]=meshgrid(linspace(0,1.05*L,100),linspace(0,1.05*L,100)); [thp,rrp]=cart2pol(xxp,yyp); MMp=M0+getMb(rrp,thp); contour(xxp/1000,yyp/1000,MMp*SperA), colorbar %to show contours of till thickness: % contour(xxp/1000,yyp/1000,nut*getmucart(xxp,yyp)) xlabel('x in km'), ylabel('y in km') hold on, view(2) [xl,yl]=pol2cart([theta1 theta1],[r1 r2]); line(xl/1000,yl/1000) [xl,yl]=pol2cart([theta2 theta2],[r1 r2]); line(xl/1000,yl/1000) thl=linspace(theta1,theta2,100); [xl,yl]=pol2cart(thl,r1*ones(1,100)); line(xl/1000,yl/1000) [xl,yl]=pol2cart(thl,r2*ones(1,100)); line(xl/1000,yl/1000) thl=linspace(0,pi/2,200); [xl,yl]=pol2cart(thl,L*ones(1,200)); line(xl/1000,yl/1000,'LineStyle',':') text(1.01*xl(100)/1000,1.01*yl(100)/1000,'margin (dotted)') title('nonzero basal sliding in sector; contours are of accumulation in m/a') hold off end % start numeric comparison if Mt==0, return, end box=1.1*L; dx=box/Nx; dy=dx; dt=tf/Mt; Rx=(dt/(dx)^2); Ry=(dt/(dy)^2); [xx,yy]=ndgrid(linspace(0,box,Nx+1),linspace(0,box,Nx+1)); % grid in space % ndgrid makes coord sys left-handed; better for computation [ththeta,rr]=cart2pol(xx,yy); H=getH(rr); % initial condition is exact profile t=linspace(0,tf,Mt+1); in=2:Nx; fx=4*dx; fy=4*dy; n2=n+2; nm=(n-1)/2; M=M0*ones(size(H)); % base accumulation rate outice=(rr>=L); % outside of ice if true disp(['dx = dy = ' num2str(dx/1000) ' km']) disp(['dt = ' num2str(dt/SperA) ' years']) % volume computation by 2 variable trapezoid, roughly volc=4*ones(Nx+1,Nx+1); volc(1,:)=2; volc(:,1)=2; volc(Nx+1,:)=2; volc(:,Nx+1)=2; volc(1,1)=1; volc(Nx+1,1)=1; volc(1,Nx+1)=1; volc(Nx+1,Nx+1)=1; V0=dx*dy*sum(sum(volc.*H))/4; disp(['initial num vol = ' num2str(V0/1e9) ' cubic km']) % region of basal sliding; compensatory accumulation if bsflag mustgx=getmucart(xx-dx/2,yy); % staggered grid values mustgy=getmucart(xx,yy-dy/2); msk=(rr>r1)&(rrtheta1)&(ththeta H0*2 close(wbhandle), error(['instability (blowup) at step ' int2str(l)]), end if H(1,1)<.1*H0 close(wbhandle), error(['instability (collapse) at step ' int2str(l)]), end waitbar(l/(Mt+1)), end % if lots of steps, estimate compute time if rem(l,500)==0 remsecs=ceil( (Mt+1-l) * (toc/l) ); close(wbhandle) wbhandle=waitbar(0, ['COMPUTING ... ESTIMATED WAIT TIME ' ... int2str(remsecs) ' secs']); waitbar(l/(Mt+1),wbhandle), end end; disp(['actual comp. time = ' num2str(toc) ' secs']) close(wbhandle) % plot numerical final state figure(2), clf surf(xx/1000,yy/1000,H); axis([0 box/1000 0 box/1000 0 H0*1.1]); view(90,0) xlabel('x in km'); ylabel('y in km'); zlabel('h in m'); title(['Numerical final state at t = ' num2str(tf/SperA) ' yrs. Rotatable 3D fig.']) % contour of error at final time figure(3), clf HHexactf=getH(rr); err=H-HHexactf; [Cont,hand] = contour(xx/1000,yy/1000,err,errcontours); clabel(Cont,hand), axis equal, axis square xlabel('x in km'); ylabel('y in km'); disp(['max error = ' num2str(max(max(abs(err)))) ' meters']); disp(['interior error = ' num2str(max(max(abs(err(rr<.8*L))))) ' meters ( r < .80 L)']); disp(['center error = ' num2str(abs(err(1,1))) ' meters']); disp(['work (= N^2 M) = ' int2str(4*Nx*Nx*Mt)]); Vf=dx*dy*sum(sum(volc.*H))/4; disp(['final num volume = ' num2str(Vf/1e9) ' cubic km']) disp(['volume differenc = ' num2str((Vf-V0)/1e9) ' cubic km']) %%%%%%%%%%% exact HELPER FUNCTIONS %%%%%%%%%%% function H=getH(r) global n L Cs ind=(rr1)&(rtheta1)&(thetar1)&(rtheta1)&(theta