R-Lum / RLumModel
1
#' Sequence step TL-simulation
2
#'
3
#' This function simulates the TL measurement of quartz in the energy-band-model.
4
#'
5
#' @param temp_begin \code{\link{numeric}} (\bold{required}): initial temperature [deg. C] of the TL-simulation
6
#'
7
#' @param temp_end \code{\link{numeric}} (\bold{required}): end temperature [deg. C] of the TL-simulation
8
#'
9
#' @param heating_rate \code{\link{numeric}} (\bold{required}): heating rate in [deg. C/s] or [K/s]
10
#'
11
#' @param RLumModel_ID \code{\link{numeric}} (optional): A ID-number for the TL-step. This ID
12
#' is pass down to \link{calc_concentrations} so all concentrations had the same ID as the
13
#' sequence step they were calculated from. This ID is identic to the sequence step in "sequence".
14
#'
15
#' @param n \code{\link{numeric}} or \code{\linkS4class{RLum.Results}} (\bold{required}):
16
#' concentration of electron-/holetraps, valence- and conduction band
17
#' from step before. This is necessary to get the boundary condition for the ODEs.
18
#'
19
#' @param parms \code{\linkS4class{RLum.Results}} (\bold{required}): The specific model parameters are used to simulate
20
#' numerical quartz luminescence results.
21
#'
22
#' @return This function returns an \code{\linkS4class{RLum.Results}} object from the TL simulation with
23
#' TL signal and temperature and concentrations for electron/hole levels.
24
#'
25
#' @section Function version: 0.1.1 [2017-09-01]
26
#'
27
#' @author Johannes Friedrich, University of Bayreuth (Germany),
28
#'
29
#' @references
30
#'
31
#' Bailey, R.M., 2001. Towards a general kinetic model for optically and thermally stimulated
32
#' luminescence of quartz. Radiation Measurements 33, 17-45.
33
#'
34
#' @seealso \code{\link{simulate_heating}}
35
#'
36
#' @examples
37
#'
38
#' #so far no example available
39
#'
40
#' @noRd
41
.simulate_TL <- function(
42
  temp_begin,
43
  temp_end,
44
  heating_rate,
45
  RLumModel_ID = NULL,
46
  n,
47
  parms
48
){
49

50
# check input arguments ---------------------------------------------------
51

52
  ##check if heatingrate has the rigth algebraic sign
53 6
  if((temp_begin < temp_end && heating_rate < 0)||(temp_begin > temp_end & heating_rate > 0)){
54 6
    stop("\n [.simulate_TL()] Heatingrate has the wrong algebraic sign!")
55
  }
56

57
  ##check if temperature is > 0 K (-273 degree celsius)
58 6
  if(temp_begin < -273 || temp_end < -273){
59 6
    stop("\n [.simulate_TL()] Argument 'temp' has to be > 0 K!")
60
  }
61

62
  ##check if heating_rate > 0
63 6
  if(heating_rate < 0){
64 6
    stop("\n [.simulate_TL()] Argument 'heating_rate' has to be a positive number!")
65
  }
66

67
  ##check if object is of class RLum.Results
68 6
  if(class(n) != "RLum.Results"){
69 6
    n <- n
70
  } else {
71 6
    n <- n$n
72
  }
73

74
# Set parameters for ODE ---------------------------------------------------
75

76
  ##============================================================================##
77
  # SETTING PARAMETERS FOR HEATING
78
  #
79
  # R: electron-hole-production-rate (in Bailey 2004: 2.5e10, else: 5e7) = 0
80
  # P: Photonflux (in Bailey 2004: wavelength [nm]) = 0
81
  # b: heating rate [deg. C/s]
82
  ##============================================================================##
83

84 6
  R <- 0
85 6
  P <- 0
86 6
  b <- heating_rate
87

88
  ##============================================================================##
89
  # SETTING PARAMETERS FOR ODE
90
  ##============================================================================##
91

92 6
  times <- seq(0, (temp_end-temp_begin)/b, by = 0.1)
93 6
  parameters.step <- .extract_pars(parameters.step = list(
94 6
    R = R,
95 6
    P = P,
96 6
    temp = temp_begin,
97 6
    b = b,
98 6
    times = times,
99 6
    parms = parms))
100

101
  ##============================================================================##
102
  # SOLVING ODE (deSolve requiered)
103
  ##============================================================================##
104 6
  out <- deSolve::lsoda(y = n, times = times, parms = parameters.step, func = .set_ODE_Rcpp, maxsteps = 100000, rtol = 1e-4, atol = 1e-4)
105
  ##============================================================================##
106

107
  ##============================================================================##
108
  # CALCULATe SIGNALS FROM ODE SOLVING
109
  ##============================================================================##
110

111 6
  signal <- .calc_signal(object = out, parameters = parameters.step)
112 6
  TSkala <- times*b+temp_begin
113

114
  ##============================================================================##
115
  # CALCULATING CONCENTRATIONS FROM ODE SOLVING
116
  ##============================================================================##
117

118 6
  name <- c("TL")
119 6
  concentrations <- .calc_concentrations(
120 6
    data = out,
121 6
    times = TSkala,
122 6
    name = name,
123 6
    RLumModel_ID = RLumModel_ID)
124

125
  ##============================================================================##
126
  # TAKING THE LAST LINE OF "OUT" TO COMMIT IT TO THE NEXT STEP
127
  ##============================================================================##
128

129 6
  return(Luminescence::set_RLum(class = "RLum.Results",
130 6
                  data = list(
131 6
                    n = out[length(times),-1],
132 6
                    TL.data = Luminescence::set_RLum(
133 6
                      class = "RLum.Data.Curve",
134 6
                      data = matrix(data = c(TSkala, signal),ncol = 2),
135 6
                      recordType = "TL",
136 6
                      curveType = "simulated",
137 6
                      info = list(
138 6
                        curveDescripter = NA_character_),
139 6
                      .pid = as.character(RLumModel_ID)
140
                      ),
141 6
                    temp = temp_end,
142 6
                    concentrations = concentrations)
143
                  )
144
         )
145
}

Read our documentation on viewing source code .

Loading