Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions R/miniSTICS.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@
#' \item parsurg: PAR fraction
#' \item extin: Light extinction coefficient
#' \item rue: Radiation use efficiency (g MJ-1)
#' \item temin: minimal temperature for plant growth (°C)
#' \item teopt: minimum range of optimal temperature for plant growth (°C)
#' \item teoptbis: maximum range of optimal temperature for plant growth (°C)
#' \item temax: Maximal temperature above which plant growth stops (°C)
#' }
#'
#' Water stress:
Expand Down Expand Up @@ -243,6 +247,7 @@ miniSTICS <- function(soil, weather_station, practices, plant, weather) {
practices = c("sowing_year", "doy_sowing", "doy_stop_sim", "zrac0", "density"),
plant = c(
"tcmin", "tcopt", "tcxstop",
"temin","teopt","teoptbis","temax",
"flag_vern", "jvc", "tfroid", "ampfroid",
"flag_photo", "phobase", "phosat",
"st2germinate", "st2emerge", "stlevamf", "stamflax", "stlevdrp", "stdrpmat",
Expand Down Expand Up @@ -516,6 +521,7 @@ miniSTICS <- function(soil, weather_station, practices, plant, weather) {
ministics$HUR1 <- vector("numeric", sz)
ministics$HUR2 <- vector("numeric", sz)
ministics$SWFAC <- vector("numeric", sz)
ministics$FTEMP <- vector("numeric",sz)

ministics$DELTAMS <- vector("numeric", sz)
ministics$DELTAMS_unstressed <- vector("numeric", sz)
Expand Down Expand Up @@ -766,10 +772,23 @@ miniSTICS <- function(soil, weather_station, practices, plant, weather) {

# TOTAL BIOMASS GROWTH
# --------------------
if (i==1){
ministics$FTEMP[i] <- 1
}else{
if (ministics$Temp[i] < teopt){
ministics$FTEMP[i] <- 1 - ((ministics$UDEVCULT[i-1]-teopt)/(temin-teopt))^2
}else if (teopt <= ministics$UDEVCULT[i-1] & ministics$UDEVCULT[i-1] <= teoptbis){
ministics$FTEMP[i] <- 1
}else{
ministics$FTEMP[i] <- 1-((ministics$UDEVCULT[i-1]-teoptbis)/(temax-teoptbis))^2
}

}
# ministics$FTEMP[i] <- 1

if (ministics$DOY_2EMERG[i] == 1 & ministics$DOY_2Z89[i] == 0) {
ministics$DELTAMS[i] <- 0.95 * parsurg * ministics$Radiation[i] * rue * (1 - exp(-extin * ministics$LAI[i]))
ministics$DELTAMS_unstressed[i] <- 0.95 * parsurg * ministics$Radiation[i] * rue * (1 - exp(-extin * ministics$LAI_unstressed[i]))
ministics$DELTAMS[i] <- 0.95 * parsurg * ministics$Radiation[i] * rue * (1 - exp(-extin * ministics$LAI[i])) * ministics$FTEMP[i]
ministics$DELTAMS_unstressed[i] <- 0.95 * parsurg * ministics$Radiation[i] * rue * (1 - exp(-extin * ministics$LAI_unstressed[i])) * ministics$FTEMP[i]
} else {
ministics$DELTAMS[i] <- 0
ministics$DELTAMS_unstressed[i] <- 0
Expand Down
9 changes: 8 additions & 1 deletion R/plant_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
#' \item parsurg: PAR fraction
#' \item extin: Light extinction coefficient
#' \item rue: Radiation use efficiency (g MJ-1)
#' \item temin: minimal temperature for plant growth (°C)
#' \item teopt: minimum range of optimal temperature for plant growth (°C)
#' \item teoptbis: maximum range of optimal temperature for plant growth (°C)
#' \item temax: Maximal temperature above which plant growth stops (°C)
#' }
#'
#' Water stress:
Expand Down Expand Up @@ -102,6 +106,10 @@ plant_parameters <- function(...) {
params <- list(
tcmin = 0,
tcopt = 35,
temin=0,
teopt=12,
teoptbis=17,
temax=40,
tcxstop = 45,
flag_vern = TRUE,
jvc = 45,
Expand Down Expand Up @@ -148,7 +156,6 @@ plant_parameters <- function(...) {
tminremp = 0,
tmaxremp = 38
)

overrides <- list(...)

if (length(overrides) > 0) {
Expand Down
4 changes: 4 additions & 0 deletions man/miniSTICS.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions man/plant_parameters.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified tests/testthat/fixtures/miniSTICS_example_reference.rds
Binary file not shown.
4 changes: 4 additions & 0 deletions tests/testthat/test-parameter-validation.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ valid_plant <- function() {
extin = 1,
rue = 1,
tetstomate = 1,
temin = 1,
teopt = 1,
teoptbis = 1,
temax = 1,
nbjgrain = 1,
cgrain = 1,
nbgrainmax = 1,
Expand Down
Loading