R/ConstantOutFluxRate_by_PoolName.R

Defines functions ConstantOutFluxRate_by_PoolName

ConstantOutFluxRate_by_PoolName<-function(sourceName,rate_constant){
    if (rate_constant<0){
      stop(
        "Negative rate constant. 
        A rate_constant defines a flux F with F = rate_constant*pool_content. 
        Since fluxes have to be positive and pool contents are positive
        rate constants have to be positive too."
      )
    }
    new(
        'ConstantOutFluxRate_by_PoolName'
        ,sourceName=PoolName(id=sourceName)
        ,rate_constant=rate_constant
    )
}

#' new object with the source pool id converted to a PoolIndex if necessary 
#' @param obj object of class ConstantOutFluxRate_by_PoolName
#' @param poolNames names of pools
setMethod(
  f="by_PoolIndex",
  signature=c(obj='ConstantOutFluxRate_by_PoolName'),
  def=function(obj,poolNames){
      new(
          "ConstantOutFluxRate_by_PoolIndex"
           ,sourceIndex=PoolIndex(id=obj@sourceName,poolNames)
           ,rate_constant=obj@rate_constant
      )
  }
)

Try the SoilR package in your browser

Any scripts or data that you put into this service are public.

SoilR documentation built on Oct. 13, 2023, 5:06 p.m.