#################################################################################### #SEDIMENTATION FUNCTION #################################################################################### #burial - vector of average burial increments per time step #variance of the normal distribution for increments #tmax = maximum time #exp.erosion - multiplication factor that defines erosion in exponential model #that is multiplied by burial #when exp.erosion=0.9, then erosion is 0.9*burial sedimentation=function(burial, variance, tmax, method, exp.erosion) { if (missing(exp.erosion)) exp.erosion <- NULL if (missing(variance)) variance <- NULL average=burial #keep track of all erosional and depositional events store.elevation=numeric() #elevation - final elevation, it is overprinted by erosion events elevation=numeric() #starting elevation elevation[1]=100 #keep track of thickness of each increment (positive or negative) store.r.burial=numeric() store.r.exp.burial=numeric() store.r.exp.erosion=numeric() #keep track of deposit age age=numeric() age[1]=1 for (i in 2:tmax) { if (method=="normal") store.r.burial[i]=rnorm(1,mean=average[i], sd=sqrt(variance[i])) if (method=="exponential") { store.r.exp.burial[i]=rexp(1,rate=1/average[i]) store.r.exp.erosion[i]=rexp(1,rate=1/exp.erosion[i]) store.r.burial[i]=store.r.exp.burial[i]-store.r.exp.erosion[i] } #if positive sedimentation if (store.r.burial[i]>=0) { elevation[i]=store.r.burial[i]+elevation[i-1] store.elevation[i]=elevation[i] age[i]=i } #if erosion if (store.r.burial[i]<0) { new.elevation=store.r.burial[i]+elevation[i-1] store.elevation[i]=new.elevation #find the uppermost elevation level after erosion check.erosion=max(which(elevation