R-Lum / RLumModel
 1 ```#' Calculate the concentrations for a specific record.id ``` 2 ```#' ``` 3 ```#' This function calculates the concentrations ``` 4 ```#' of all available electron/holes traps including valence- and conduction band. ``` 5 ```#' They ``` 6 ```#' ``` 7 ```#' @param data \code{\link{matrix of class \code{deSolve}}} (\bold{required}): the output of a ``` 8 ```#' solver from \code{deSolve}, ``` 9 ```#' ``` 10 ```#' @param times \code{\link{numeric}} (\bold{required}): numeric vector with length nrow(data). ``` 11 ```#' In common this is the time for irradiaton (RF) or illumination (OSL). For TL measurements this ``` 12 ```#' argument should be the temperature scale. ``` 13 ```#' ``` 14 ```#' @return This function returns an \code{\linkS4class{RLum.Analysis}} object ``` 15 ```#' with the concentrations of all available electron/holes traps including ``` 16 ```#' valence- and conduction band. ``` 17 ```#' ``` 18 ```#' @section Function version: 0.1.1 ``` 19 ```#' ``` 20 ```#' @author Johannes Friedrich, University of Bayreuth (Germany) ``` 21 ```#' ``` 22 ```#' @seealso \code{\link{simulate_TL}}, \code{\link{simulate_CW_OSL}}, \code{\link{simulate_LM_OSL}}, ``` 23 ```#' \code{\link{simulate_RF}} ``` 24 ```#' ``` 25 ```#' @examples ``` 26 ```#' ``` 27 ```#' #so far no example available ``` 28 ```#' ``` 29 ```#' @noRd ``` 30 ```.calc_concentrations <- function( ``` 31 ``` data, ``` 32 ``` times, ``` 33 ``` name, ``` 34 ``` RLumModel_ID = NULL ``` 35 ``` ){ ``` 36 37 ``` ##check name of sequence step ``` 38 39 6 ``` if("TL" %in% name){ ``` 40 41 6 ``` xlab <- "Temperature [\u00B0C]" ``` 42 43 6 ``` } else if("OSL" %in% name | "LM-OSL" %in% name){ ``` 44 45 6 ``` xlab <- "Illumination time [s]" ``` 46 47 ``` } else { ``` 48 49 6 ``` xlab <- "Stimulation time [s]" ``` 50 ``` } ``` 51 52 6 ``` ylab <- "Concentration [1/cm^3]" ``` 53 54 ```##calculate concentrations ``` 55 56 6 ``` concentrations <- lapply(2:ncol(data), function(x){ ``` 57 58 6 ``` value <- data[,x] ``` 59 6 ``` if(x < (ncol(data)-1)){ ``` 60 6 ``` recordType <- paste0("conc. level ",x-1," (",name,")")} ``` 61 62 6 ``` if(x == (ncol(data)-1)){ ``` 63 6 ``` recordType <- paste0("conc. n_c (",name,")")} ``` 64 65 6 ``` if(x == ncol(data)){ ``` 66 6 ``` recordType <- paste0("conc. n_v (",name,")")} ``` 67 68 69 6 ``` return(set_RLum(class = "RLum.Data.Curve", ``` 70 6 ``` data = matrix( ``` 71 6 ``` data = c( ``` 72 6 ``` time = times, ``` 73 6 ``` n = value), ``` 74 6 ``` ncol = 2), ``` 75 6 ``` recordType = recordType, ``` 76 6 ``` curveType = "simulated", ``` 77 6 ``` info = list( ``` 78 6 ``` curveDescripter = paste(xlab, ylab, sep = ";"), ``` 79 6 ``` max.change = (1-min(value)/max(value))*100), ``` 80 6 ``` .pid = paste(as.character(RLumModel_ID),x-1,sep = "_")) ``` 81 ``` ) ``` 82 83 ``` }) ``` 84 85 6 ``` return(concentrations) ``` 86 87 ```} ```

Read our documentation on viewing source code .