TimeStepping

PURPOSE ^

TIMESTEPPING - ...

SYNOPSIS ^

function [back,dt,time]=TimeStepping(md,solution,dt,time)

DESCRIPTION ^

TIMESTEPPING - ...

   Usage:

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [back,dt,time]=TimeStepping(md,solution,dt,time)
0002 %TIMESTEPPING - ...
0003 %
0004 %   Usage:
0005 %
0006 
0007 if md.timestepping,
0008     
0009     time0=time-dt; %previous time. we might have to go back in time.
0010 
0011     back=0; %default is to not touch the time step.
0012 
0013     %Is thickness decreasing or increasing too fast?
0014     dh=solution(end).thickness-solution(end-1).thickness;
0015 
0016     maxdeltah=max(abs(dh));
0017     if maxdeltah>md.DeltaH,
0018         disp(sprintf('%s%g','      thickness varying too fast: ',maxdeltah));
0019         disp(sprintf('%s%g%s%g%s','         decreasing time step from ',dt/md.yts,'(yr) to ',dt*md.timedec/md.yts,'(yr)'));
0020         back=1;
0021         dt=dt*md.timedec;
0022         time=time0+dt; %new time is previous time plus reduced time step
0023         return;
0024     end
0025 
0026     %Too slow?
0027     if maxdeltah<md.deltaH,
0028         disp(sprintf('%s%g','      thickness varying too slow: ',maxdeltah));
0029         disp(sprintf('%s%g%s%g%s','         increasing time step from ',dt/md.yts,'(yr) to ',dt*md.timeacc/md.yts,'(yr)'));
0030         back=0;
0031         dt=dt*md.timeacc;
0032         return;
0033     end
0034     
0035     
0036     %Is temperature decreasing or increasing too fast?
0037     dT=solution(end).t_g-solution(end-1).t_g;
0038 
0039     maxdeltaT=max(abs(dT));
0040     if maxdeltaT>md.DeltaT,
0041         disp(sprintf('%s%g','      temperature varying too fast: ',maxdeltaT));
0042         disp(sprintf('%s%g%s%g%s','         decreasing time step from ',dt/md.yts,'(yr) to ',dt*md.timedec/md.yts,'(yr)'));
0043         back=1;
0044         dt=dt*md.timedec;
0045         time=time0+dt;
0046         return;
0047     end
0048 
0049     %Too slow?
0050     if maxdeltaT<md.deltaT,
0051         disp(sprintf('%s%g','      temperature varying too slow: ',maxdeltaT));
0052         disp(sprintf('%s%g%s%g%s','         increasing time step from ',dt/md.yts,'(yr) to ',dt*md.timeacc/md.yts,'(yr)'));
0053         back=0;
0054         dt=dt*md.timeacc;
0055         return;
0056     end
0057 
0058 else
0059     %time stepping not activated.
0060     back=0;
0061     return;
0062 end
0063

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