R-Lum / RLumModel
1
#' sequence step illumination
2
#'
3
#' This function simulates an illumination step in the energy-band-model of quartz.
4
#'
5
#' @param temp \code{\link{numeric}} (\bold{required}): set temperature [deg. C] of the illumination simulation
6
#'
7
#' @param duration \code{\link{numeric}} (\bold{required}): duration of the illumination simulation
8
#'
9
#' @param n \code{\link{numeric}} or \code{\linkS4class{RLum.Results}} (\bold{required}):
10
#' concentration of electron-/holetraps, valence- and conduction band
11
#' from step before. This is necessary to get the boundary condition for the ODEs.
12
#'
13
#' @param parms \code{\linkS4class{RLum.Results}} (\bold{required}): The specific model parameters are used to simulate
14
#' numerical quartz luminescence results.
15
#'
16
#' @param \dots further arguments and graphical parameters passed to
17
#' \code{\link{plot.default}}. See details for further information
18
#'
19
#' @return This function returns an RLum.Results object from the illumination simulation.
20
#' 
21
#' @section Function version: 0.1.1
22
#'
23
#' @author Johannes Friedrich, University of Bayreuth (Germany),
24
#'
25
#' @references
26
#'
27
#' @seealso \code{\link{plot}}
28
#'
29
#' @examples
30
#'
31
#' #so far no example available
32
#'
33
#' @noRd
34
.simulate_illumination <- function(
35
  temp,
36
  duration,
37
  optical_power = 100,
38
  n,
39
  parms,
40
  ...
41
){
42

43
# check input arguments ---------------------------------------------------
44

45
  ##check if temperature is > 0 K (-273 degree celsius)
46 5
  if(temp < -273){
47 5
    stop("\n [.simulate_illumination()] Argument 'temp' has to be > 0 K!")
48
  }
49
  ##check if duration is a positive number
50 5
  if(duration < 0){
51 5
    stop("\n [.simulate_illumination()] Argument 'duration' has to be a positive number!")
52
  }
53

54
  ##check if optical_power is a positive number
55 5
  if(optical_power < 0){
56 5
    stop("\n [.simulate_illumination()] Argument 'optical_power' has to be a positive number!")
57
  }
58

59
  ##check if n is a RLum object
60 5
  if(class(n) != "RLum.Results"){
61 5
    n <- n
62
  } else {
63 5
    n <- n$n
64
  }
65

66
# Set parameters for ODE ---------------------------------------------------
67

68
  ##============================================================================##
69
  # SETTING PARAMETERS FOR ILLUMINATION
70
  #
71
  # R: electron-hole-production-rate (in Bailey 2004: 2.5e10, else: 5e7) = 0
72
  # P: Photonflux (in Bailey 2002/2004: wavelength [nm]) = 1
73
  # b: heating rate [deg. C/s] = 0
74
  ##============================================================================##
75

76 5
  if(parms$model == "Bailey2004" || parms$model == "Bailey2002"){
77 5
    P <- 0.02/(1.6*10^(-19)*(1240/470))*(optical_power/100)
78
  }
79
  else{
80 5
    P <- 2*(optical_power/100)
81
  }
82

83 5
  R <- 0
84 5
  b <- 0
85

86
  ##============================================================================##
87
  # SETTING PARAMETERS FOR ODE
88
  ##============================================================================##
89

90 5
  times <- seq(0, duration, by = duration/100)
91 5
  parameters.step <- .extract_pars(parameters.step = list(
92 5
    R = R,
93 5
    P = P,
94 5
    temp = temp,
95 5
    b = b,
96 5
    times = times,
97 5
    parms = parms))
98
  ##============================================================================##
99
  # SOLVING ODE (deSolve requiered)
100
  ##============================================================================##
101 5
  out <- deSolve::ode(y = n, times = times, parms = parameters.step, func = .set_ODE_Rcpp, rtol=1e-3, atol=1e-3, maxsteps=1e5, method = "bdf")
102
  ##============================================================================##
103

104
  ##============================================================================##
105
  # TAKING THE LAST LINE OF "OUT" TO COMMIT IT TO THE NEXT STEP
106
  ##============================================================================##
107

108 5
  return(set_RLum(class = "RLum.Results",
109 5
                  data = list(
110 5
                    n = out[length(times),-1],
111 5
                    temp = temp
112
                  )))
113

114
}#end function

Read our documentation on viewing source code .

Loading