Commit b66ccd59 authored by Ahmad Alkadri's avatar Ahmad Alkadri 🎧
Browse files

Updated the function, fixing the bugs

parent 9073fd9b
......@@ -65,11 +65,27 @@ w_after <- function(w_i,h_f,h_c,w_s=0.25,phi_a,phi_d,asoi,adoi,AA,BB,DD) {
wf_d = w_s*(exp(phi_d*(log(h_f))*(exp(h_f*adoi))))
if(h_c==0 | w_i==0 | h_c == w_s){
if(h_c==0 | h_c==1){
stop("ERROR: please choose humidity other than 0 or w_s OR MC initial not 0")
if(h_c==0 & w_i!=0){
stop("ERROR: it's highly unlikely to have w_i above 0 for h_c = 0")
} else {
return(wf_a)
}
if(h_c==1){
return(wf_d)
}
}
##dw_a et dw_d
......@@ -97,23 +113,23 @@ w_after <- function(w_i,h_f,h_c,w_s=0.25,phi_a,phi_d,asoi,adoi,AA,BB,DD) {
##Pour verifier si la valeur w finale est dans le courbe w_a et w_d ou pas
# if (des ==1 & wtemp_c > wf_d){
# wfin = wf_d
# } else {
# if (des == 0 & wtemp_c < wf_a){
# w_fin = wf_a
# } else {
# if (des == 1 & h_c == 1) {
# w_fin = wf_d
# } else {
# if (des == 0 & h_c == 0){
# w_fin = wf_a
# } else {
# w_fin = wtemp_c
# }
# }
# }
# }
if (des ==1 & wtemp_c > wf_d){
wfin = wf_d
} else {
if (des == 0 & wtemp_c < wf_a){
w_fin = wf_a
} else {
if (des == 1 & h_c == 1) {
w_fin = wf_d
} else {
if (des == 0 & h_c == 0){
w_fin = wf_a
} else {
w_fin = wtemp_c
}
}
}
}
##Valeur finale
return(wtemp_c)
......
......@@ -5,12 +5,10 @@
#'
#' @usage w_evo(hr,w_ini,w_s,phi_a,phi_d,asoi,adoi,AA,BB,DD)
#'
#' @param w_ini the initial moisture content of wood measured at RH = hr[1]
#'
#' @param h_c the initial RH of the atmosphere,
#' wherein the w_i value was measured
#' @param hr a vector containing the series of humidity which was imposed of wood with
#' hr[1] as the initial relative humidity
#'
#' @param h_f the actual RH of the atmosphere surrounding the wood
#' @param w_ini the initial moisture content of wood measured at RH = hr[1]
#'
#' @param w_s the fiber saturation point of the wood, defaulted at 0.25 (25\%)
#'
......@@ -28,7 +26,7 @@
#'
#' @param DD the fitting parameter for hysteresis (3)
#'
#' @return the EMC values of wood for each sequence values of `hr` vector
#' @return The EMC values of wood for each sequence values of `hr` vector.
#'
#' @examples
#'
......
......@@ -7,6 +7,9 @@
w_evo(hr,w_ini,w_s,phi_a,phi_d,asoi,adoi,AA,BB,DD)
}
\arguments{
\item{hr}{a vector containing the series of humidity which was imposed of wood with
hr[1] as the initial relative humidity}
\item{w_ini}{the initial moisture content of wood measured at RH = hr[1]}
\item{w_s}{the fiber saturation point of the wood, defaulted at 0.25 (25\%)}
......@@ -24,14 +27,9 @@ w_evo(hr,w_ini,w_s,phi_a,phi_d,asoi,adoi,AA,BB,DD)
\item{BB}{the fitting parameter for hysteresis (2)}
\item{DD}{the fitting parameter for hysteresis (3)}
\item{h_c}{the initial RH of the atmosphere,
wherein the w_i value was measured}
\item{h_f}{the actual RH of the atmosphere surrounding the wood}
}
\value{
the EMC values of wood for each sequence values of `hr` vector
The EMC values of wood for each sequence values of `hr` vector.
}
\description{
A function for predicting the moisture content of wood
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment