R/step_transport_ogata_banks.R

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#
# Ogata and Banks 1961 Porous Media Flow with Retardation, Diffusion, and Decay
#
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
StepTransportOgataBanks <- R6Class(
  classname = "step_transport_ogata_banks",
  inherit = Step,
  public = list(

    # step specific variables
    diffusion = NULL,
    retardation = NULL,
    decay = NULL,
    velocity = NULL,
    concentration_initial = NULL,
    distance = NULL,
    time = NULL,
    initialize = function(time,
                          distance,
                          concentration_initial = 1.0,
                          velocity = 0.1,
                          diffusion = 0.1,
                          retardation = 1.0,
                          decay = 0.0,
                          role = "predictor",
                          ...) {
      # get function parameters to pass to parent
      time <- deparse(substitute(time))
      distance <- deparse(substitute(distance))
      env_list <- get_function_arguments()
      env_list$step_name <- "step_transport_ogata_banks"
      env_list$type <- "add"
      super$initialize(
        terms = c(as.symbol(time), as.symbol(distance)),
        env_list,
        ...
      )

      # step specific values
      self$time <- time
      self$distance <- distance
      self$concentration_initial <- concentration_initial
      self$velocity <- velocity
      self$diffusion <- diffusion
      self$retardation <- retardation
      self$decay <- decay

      self$columns <- c(time, distance)

      invisible(self)
    },
    bake = function(new_data) {
      ob <- list(ogata_banks_decay_vec(
        self$concentration_initial,
        self$velocity,
        self$diffusion,
        self$retardation,
        self$decay,
        new_data[[2L]],
        new_data[[1L]]
      ))
      self$new_columns <- self$prefix
      self$result <- setNames(ob, self$new_columns)
      self$result

    }
  )
)
jkennel/hydrorecipes documentation built on Dec. 24, 2024, 5:38 p.m.