title: "Solvers for Eulerian and Lagrangian descriptions"

output: html_notebook

---

# Objectives

This notebook presents a simple comparison of the Eulerian and Lagrangian approaches for the computation of cosmogenic nuclides concentration evolution in complex denudation and exposure scenarios.

# Set up of the simulation

We load the `TCNtools` package.

```{r}

library("TCNtools")

```

## Definition of parameters

We should define the basic parameters we are going to use for the computation, which are two vectors :

- a vector with the attenuation lengths for different particules (in g/cm$^2$)

- neutrons for spallation reactions $\Lambda_{spal}$

- stopping muons $\Lambda_{stop}$

- fast muons $\Lambda_{fast}$

- a vector (or matrix) with the SLHL production rates (in at/g/a), in this case for the *st* scaling scheme (@stone2000air), and decay constant $\lambda$ (in 1/a) for the nuclide(s) of interest.

```{r ck_2}

# Attenuation lengths

Lambda = c(160,1500,4320) # g/cm2

names(Lambda) <- c("Lspal","Lstop","Lfast") # we just give names to the element of the vector

colnames(prm) <- c("Be10","Al26") # we just give names to the columns of the matrix

rownames(prm) <- c("Pspal","Pstop","Pfast","lambda") # we just give names to the rows of the matrix

# material density

rho = 2.7

print(prm)

```

We also need to define the properties of our site of interest and compute the relevant scaling parameters.

```{r }

altitude = 1000 # elevation in m

latitude = 45 # latitude in degrees

P = atm_pressure(alt=altitude,model="stone2000") # compute atmospheric pressure at site

S = scaling_st(P,latitude) # compute the scaling parameters according to Stone (2000)

```

## Definition of the denudation scenario

We will start from a steady state situation under constant denudation, and then apply a change in the denudation rate for a given period of time.

```{r}

tmax = 2e6 # duration in a

ero = 1/1.e6*100*rho # denudation rate conversion en m/Ma -> g/cm2/a

fact = 5 # change factor

```

Here the duration of the simulation will be `r tmax/1e6` Ma, the initial denudation rate will be `r ero*1e6/100/rho` m/Ma, which will changed by a factor `r fact` at the beggining of the simulation.

# Computation of concentrations

## Eulerian reference frame

We compute the evolution of concentrations at the surface ($z=0$) using an Eulerian point of view.

The calculation is very straightforward thanks to the `solv_conc_eul` function.

Now we do the same calcuation using a Lagrangian point of view, i.e. with a reference frame attached to a rock particule during its journey toward the surface as a response to denudation. It is slightly more complicated than in the Eulerian case. This is done using the `solv_conc_lag` function.

We first initiate a dataframe (`df_l`) and compute the evolution in depth `z` of the particule through time when it is exhumed from its initial depth (here `r ero*fact*tmax/rho/100` m) to the surface at a rate `r ero*fact/rho/100*1e6` m/Ma.

We then define another column with the evolution of scaling parameters through time. It is trivial here in the case of the time-independent **st**

scaling, but it will be highly valuable when dealing with time-dependent scalings, where the Eulerian approach is not applicable.

```{r}

df_l$Ssp = rep(as.numeric(S[1]),nrow(df_l))

df_l$Smu = rep(as.numeric(S[2]),nrow(df_l))

```

Then we calculate the un-scaled production rates at depths the depths of interest. Here again, as we use simple models of exponential decrease for production with depth, the interest of using such Lagrangian approach is not obvious. But such way of computing concentration will allow to deal with non-exponential production profiles, which might necessary in some situation for muons or low-energy neutrons.

The Lagragian evolution starts with a low concentration corresponding to the burial at depth of the particle at the onset of the evolution, while at the same time ($t=0$) we are looking at the surface with the Eulerian point of view, and then obviously observe much higher concentrations.

The two descriptions converge toward the same cocnentration at the end of the evolution (i.e. when the lagrangian particule reaches the surface).

We can also represent the corresponding two nuclides plot for $^{10}$Be and $^{26}$Al.

We need first to compute the steady-state erosion and constant exposure lines.

This html page is derived from an [R Markdown](http://rmarkdown.rstudio.com) Notebook.

You can copy/paste the various lines of code into your own R script and run it in any R session.

Alternatively you can also download the Notebook (upper-right menu on this page), and open that into RStudio IDE.

You can execute a chunk of code by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Ctrl+Shift+Enter*.

When you execute code within the notebook, the results appear beneath the code.

You can modifiy the code (value of parameters, etc ...) and see how the outputs are affected.

## Objectives

We are going to present the most widely used and simplest scaling scheme known as Lal-Stone and often abbreviated as **st**.

The main equations are presented in the reference article by @stone2000air .

Our goal is to describe the variations of these scaling factors with latitude and elevation, which are the main parameters controlling the production rates of cosmogenic nuclides at the Earth surface.

The first thing we have to do is to load the `TCNtools` library (once it has been installed).

```{r}

library("TCNtools")

```

# Simple calculation

## Site characteristics

We first need to define some parameters concerning the site of interest :

- latitude `lat` in degrees

- altitude `z` in meters (can be a vector or a scalar)

- longitude `lon` in degrees, this is not used for *st* scaling (@stone2000air), just in case we want to compute atmospheric pressure according to ERA40 (@uppala2005era40).

```{r}

lat = 30 # latitude

lon = 30 # longitude

z = seq(0,3000,by=100) # vector from 0 to 3000 m by 100 m increments

```

Now we can compute the atmospheric pressure, with the function `atm_pressure` according to the two models available, and then plot for comparison.

Here `z` is a vector to see the variations over a range of elevations.

To get information about the usage of the function used here (for example what are the different models) type `?atm_pressure` in the R console.

We can now compute the scaling factors according to @stone2000air.

Same as above, to get some information about the function (parameters definition) type `?st_scaling` in the R console.

```{r}

st = scaling_st(P1,lat) # here we use the pressure according to Stone 2000 model

st

```

The result is stored in `st` as a dataframe with as many rows as there are elements in the input pressure vector (`P1`) and two columns named `Nneutrons` and `Nmuons`, for the spallogenic and muogenic contributions, respectively.

We can plot the evolution with elevation, wich illustrates the major influence of altitude of the sampling site in controlling the local production rate.

```{r}

plot(st$Nneutrons,z,type="l",

xlab="Spallogenic st scaling factor (Stone 2000)",ylab="Altitude (m)",

main=paste("Latitude ",lat,"°",sep=""))

```

# Global variations

In order to get a better idea of the variations with both latitude (from 0 to 90°) and elevation (from sea level to 3000 m) we can try the following plot.

xlab="Latitude (°)",ylab="Spallogenic st scaling factor (Stone 2000)")

grid()

text(lat[n],st$Nneutrons[n],"0 km",cex=0.5,adj=0) # put label at the end of curve

for (z in seq(500,3000,by=500)){ # loop on elevations : same as above for a range of elevations

P=atm_pressure(alt=z,model="stone2000")

st = scaling_st(P,lat)

lines(lat,st$Nneutrons)

text(lat[n],st$Nneutrons[n],z/1000,cex=0.5,adj=0)

}

```

This dependance of the scaling factor on latitude is a direct consequence of the dipole nature structure of the Earth magnetic field, with a higher cosmic rays flux at high latitude.

a=uniroot(fun_solv_ss_eros_eul,c(0,1),C0[i],p,S,L,tol=1e-6)# attention à la borne sup de l'interval que le taux d'érosion max soit assez rapide pour les cocentrations faibles

abstract={ERA-40 is a re-analysis of meteorological observations from September 1957 to August 2002 produced by the European Centre for Medium-Range Weather Forecasts (ECMWF) in collaboration with many institutions. The observing system changed considerably over this re-analysis period, with assimilable data provided by a succession of satellite-borne instruments from the 1970s onwards, supplemented by increasing numbers of observations from aircraft, ocean-buoys and other surface platforms, but with a declining number of radiosonde ascents since the late 1980s. The observations used in ERA-40 were accumulated from many sources. The first part of this paper describes the data acquisition and the principal changes in data type and coverage over the period. It also describes the data assimilation system used for ERA-40. This benefited from many of the changes introduced into operational forecasting since the mid-1990s, when the systems used for the 15-year ECMWF re-analysis (ERA-15) and the National Centers for Environmental Prediction/National Center for Atmospheric Research (NCEP/NCAR) re-analysis were implemented. Several of the improvements are discussed. General aspects of the production of the analyses are also summarized. A number of results indicative of the overall performance of the data assimilation system, and implicitly of the observing system, are presented and discussed. The comparison of background (short-range) forecasts and analyses with observations, the consistency of the global mass budget, the magnitude of differences between analysis and background fields and the accuracy of medium-range forecasts run from the ERA-40 analyses are illustrated. Several results demonstrate the marked improvement that was made to the observing system for the southern hemisphere in the 1970s, particularly towards the end of the decade. In contrast, the synoptic quality of the analysis for the northern hemisphere is sufficient to provide forecasts that remain skilful well into the medium range for all years. Two particular problems are also examined: excessive precipitation over tropical oceans and a too strong Brewer-Dobson circulation, both of which are pronounced in later years. Several other aspects of the quality of the re-analyses revealed by monitoring and validation studies are summarized. Expectations that the 'second-generation' ERA-40 re-analysis would provide products that are better than those from the first-generation ERA-15 and NCEP/NCAR re-analyses are found to have been met in most cases. {\textcopyright} Royal Meteorological Society, 2005.},

author={Uppala, S. M. and KÅllberg, P. W. and Simmons, Adrian J. and Andrae, U. and Bechtold, V. Da Costa and Fiorino, M. and Gibson, J. K. and Haseler, J. and Hernandez, A. and Kelly, G. A. and Li, X. and Onogi, K. and Saarinen, S. and Sokka, N. and Allan, R. P. and Andersson, E. and Arpe, K. and Balmaseda, M. A. and Beljaars, A. C. M. and Berg, L. Van De and Bidlot, J. and Bormann, N. and Caires, S. and Chevallier, F. and Dethof, A. and Dragosavac, M. and Fisher, M. and Fuentes, M. and Hagemann, S. and H{\'{o}}lm, E. and Hoskins, B. J. and Isaksen, L. and Janssen, P. A. E. M. and Jenne, R. and Mcnally, A. P. and Mahfouf, J.-F. and Morcrette, J.-J. and Rayner, N. A. and Saunders, R. W. and Simon, P. and Sterl, A. and Trenberth, K. E. and Untch, A. and Vasiljevic, D. and Viterbo, P. and Woollen, J.},

doi={10.1256/qj.04.176},

issn={00359009},

journal={Quarterly Journal of the Royal Meteorological Society},

abstract={The cosmic ray flux increases at higher altitude as air pressure and the shielding effect of the atmosphere decrease. Altitude-dependent scaling factors are required to compensate for this effect in calculating cosmic ray exposure ages. Scaling factors in current use assume a uniform relationship between altitude and atmospheric pressure over the Earth's surface. This masks regional differences in mean annual pressure and spatial variation in cosmogenic isotope production rates. Outside Antarctica, air pressures over land depart from the standard atmosphere by ±4.4 hPa (1$\sigma$) near sea level, corresponding to offsets of ±3–4{\%} in isotope production rates. Greater offsets occur in regions of persistent high and low pressure such as Siberia and Iceland, where conventional scaling factors predict production rates in error by ±10{\%}. The largest deviations occur over Antarctica where ground level pressures are 20–40 hPa lower than the standard atmosphere at all altitudes. Isotope production rates in Antarctica are therefore 25–30{\%} higher than values calculated by scaling Northern Hemisphere production rates with conventional scaling factors. Exposure ages of old Antarctic surfaces, especially those based on cosmogenic radionuclides at levels close to saturation, may be millions of years younger than published estimates.},