1
#' sequence step "pause" in model simulation
2
#'
3
#' This function simulates the pause between measurements or after irradiation steps
4
#' in quartz in the energy-band-model.
5
#'
6
#' @param temp \code{\link{numeric}} (\bold{required}): set temperature [deg. C] of the pause simulation
7
#'
8
#' @param duration \code{\link{numeric}} (\bold{required}): duration of the pause in model simulation
9
#' 
10
#' @param detection \code{logical}: should detect luminescene during pause?
11
#'
12
#' @param n \code{\link{numeric}} or \code{\linkS4class{RLum.Results}} (\bold{required}):
13
#' concentration of electron-/holetraps, valence- and conduction band
14
#' from step before. This is necessary to get the boundary condition for the ODEs.
15
#'
16
#' @param parms \code{\linkS4class{RLum.Results}} (\bold{required}): The specific model parameters are used to simulate
17
#' numerical quartz luminescence results.
18
#'
19
#' @param \dots further arguments and graphical parameters passed to
20
#' \code{\link{plot.default}}. See details for further information
21
#'
22
#' @return This function returns an Rlum.Results object from the pause simulation.
23
#'
24
#' @section Function version: 0.1.2 [2016-10-26]
25
#'
26
#' @author Johannes Friedrich, University of Bayreuth (Germany),
27
#'
28
#' @references
29
#'
30
#' Bailey, R.M., 2001. Towards a general kinetic model for optically and thermally stimulated
31
#' luminescence of quartz. Radiation Measurements 33, 17-45.
32
#'
33
#' @seealso \code{\link{plot}}
34
#'
35
#' @examples
36
#'
37
#' #so far no example available
38
#'
39
#' @noRd
40
.simulate_pause <- function(
41
  temp,
42
  duration,
43
  detection = 0,
44
  RLumModel_ID = NULL,
45
  n,
46
  parms
47
  ){
48
  
49
 # check input arguments ---------------------------------------------------
50

51
  ##check if duration is a positive number
52 5
  if(duration < 0){
53 5
    stop("\n [.simulate_pause()] Argument 'duration' has to be an positive number!")
54
  }
55

56
  ##check if temperature is > 0 K (-273 degree celsius)
57 5
  if(temp < -273){
58 5
    stop("\n [.simulate_pause()] Argument 'temp' has to be > 0 K!")
59
  }
60

61
  ##check if object is of class RLum.Data.Curve
62 5
  if(class(n) != "RLum.Results"){
63 5
    n <- n
64
  } else {
65 5
    n <- n$n
66
  }
67

68
# Set parameters for ODE ---------------------------------------------------
69

70

71
  ##============================================================================##
72
  # SETTING PARAMETERS FOR HEATING
73
  #
74
  # R: electron-hole-production-rate = 0
75
  # P: Photonflux (in Bailey 2004: wavelength [nm]) = 0
76
  # b: heating rate [deg. C/s] = 0
77
  ##============================================================================##
78

79 5
  R <- 0
80 5
  P <- 0
81 5
  b <- 0
82

83
  ##============================================================================##
84
  # SETTING PARAMETERS FOR ODE
85
  ##============================================================================##
86

87 5
  times <- seq(0, duration, by = duration/1000)
88 5
  parameters.step <- .extract_pars(parameters.step = list(
89 5
    R = R,
90 5
    P = P,
91 5
    temp = temp,
92 5
    b = b,
93 5
    times = times,
94 5
    parms = parms))
95
  
96
  ##============================================================================##
97
  # SOLVING ODE (deSolve requiered)
98
  ##============================================================================##
99 5
  out <- deSolve::lsoda(y = n, times = times, parms = parameters.step, func = .set_ODE_Rcpp, rtol = 1e-4, atol = 1e-4)
100

101
  ##============================================================================##
102
  # CALCULATING RESULTS FROM ODE SOLVING
103
  ##============================================================================##
104
  
105
  
106 5
  signal <- .calc_signal(object = out, parameters = parameters.step)
107

108
  ##============================================================================##
109
  # CALCULATING CONCENTRATIONS FROM ODE SOLVING
110
  ##============================================================================##
111
  
112 5
  name <- c("detection")
113 5
  concentrations <- .calc_concentrations(
114 5
    data = out,
115 5
    times = times,
116 5
    name = name,
117 5
    RLumModel_ID = RLumModel_ID)
118
  
119
  ##============================================================================##
120
  # TAKING THE LAST LINE OF "OUT" TO COMMIT IT TO THE NEXT STEP
121
  ##============================================================================##
122

123 5
  if(detection == 1){
124
    
125 5
    return(Luminescence::set_RLum(class = "RLum.Results",
126 5
                                  data = list(
127 5
                                    n = out[length(times),-1] ,
128 5
                                    pause.data = Luminescence::set_RLum(
129 5
                                      class = "RLum.Data.Curve",
130 5
                                      data = matrix(data = c(times, signal),ncol = 2),
131 5
                                      recordType = "pause",
132 5
                                      curveType = "simulated",
133 5
                                      info = list(
134 5
                                        curveDescripter = NA_character_),
135 5
                                      .pid = as.character(RLumModel_ID)
136
                                    ),
137 5
                                    temp = temp,
138 5
                                    concentrations = concentrations)
139
    )
140
    )
141
    
142
    
143
    
144
    
145
  } else {
146
  
147 5
  return(Luminescence::set_RLum(class = "RLum.Results",
148 5
                  data = list(
149 5
                    n = out[length(times),-1],
150 5
                    temp = temp
151
                  )))
152
  }
153
}

Read our documentation on viewing source code .

Loading