Good afternoon Mike,
I am very new to NicheMapR and am having a bit of trouble with getting my model to represent natural torpor. I want to mimic the results of a study which shows relatively constant day time temperatures followed by a nightly drop into torpor (doi:10.1098/rsbl.2019.0211). I'm not sure how can I adjust different aspects of torpor to more closely match measured results. I've pasted my code below and am currently using the following parameters:
########### Parameters ############
TC <- 41.9 # Core body temperature (°C)
TC_MAX <- 46 # Maximum core body temperature (°C)
TC_MIN <- 30.4 # Minimum core body temperature (°C)
TC_INC <- 0.22 # Increment of core body temperature elevation (°C)
PCTWET <- 1 # Base skin wetness (%)
PCTWET_MAX <- 5 # Maximum skin wetness (%)
PCTWET_INC <- 0.25 # Increments of skin wetness increase (%)
Q10s <- rep(1, length(TAs)) # The effect of body temperature on metabolic rate,
Q10s[TAs >= TC_MAX] <- 2 # The effect starts above TC_MAX
QBASAL <- 10^(-1.461 + 0.669 * log10(AMASS * 1000)) # Basal heat generation (W)
DELTAR <- 5 # Difference between air temperature and breath (°C)
EXTREF <- 25 # O2 extraction efficiency (%)
PANT_INC <- 0.1 # Increment by which panting is increased
PANT_MAX <- 15 # Maximum panting rate
PANT_MULT <- 1 # Multiplier on basal metabolism at maximum panting level
TORPOR <- 1 # Allows body temperature to drop to TC_MIN
TREGMODE <- 2
endoshade <- 0
#############################################
Here is my endoR loop. I am running it through different feather conditions however that is working well, it is the torpor that needs adjusting:
##############################################
results_list <- list() # store results for each condition level
ptm <- proc.time()
for (i in seq_along(condition_grid)) {
# Scale feather density and length
LHAIRD <- condition_grid[i] * LHAIRD_base
LHAIRV <- condition_grid[i] * LHAIRV_base
RHOD <- condition_grid[i] * RHOD_base
RHOV <- condition_grid[i] * RHOV_base
# Run endoR across all microclimate time steps
endo.out <- lapply(seq_along(TAs), function(x) {
# Behavioural ptiloerection based on air temperature
ptilo <- ptilo_func(TAs[x])
# Adjust feather depth (ptiloerection)
ZFURD <- ZFURD_base + (LHAIRD - ZFURD_base) * ptilo
ZFURV <- ZFURV_base + (LHAIRV - ZFURV_base) * ptilo
# Run endoR with modified insulation
endoR(
# Climate variables
TA = TAs[x], TAREF = TAREFs[x], TSKY = TSKYs[x], TGRD = TGRDs[x],
VEL = VELs[x], RH = RHs[x], QSOLR = QSOLRs[x], Z = Zs[x], ELEV = ELEV,
ABSSB = ABSSB,
# Constants
TC = TC, TC_MAX = TC_MAX, AMASS = AMASS, SHAPE = SHAPE,
SHAPE_B = SHAPE_B, SHAPE_B_MAX = SHAPE_B_MAX,
PCTWET = PCTWET, PCTWET_INC = PCTWET_INC,
Q10 = Q10s[x], QBASAL = QBASAL, DELTAR = DELTAR,
DHAIRD = DHAIRD, DHAIRV = DHAIRV,
REFLD = REFLD, TC_INC = TC_INC, PANT_INC = PANT_INC,
PANT_MAX = PANT_MAX, EXTREF = EXTREF, UNCURL = UNCURL,
SAMODE = SAMODE, PANT_MULT = PANT_MULT, TORPOR = TORPOR,
SHADE = endoshade, TREGMODE = TREGMODE,
# Varied Feather Traits
LHAIRD = LHAIRD,
LHAIRV = LHAIRV,
RHOD = RHOD,
RHOV = RHOV,
ZFURD = ZFURD,
ZFURV = ZFURV
)
})
# Convert list of endoR outputs into a single data frame
endo_df <- do.call(rbind, lapply(endo.out, data.frame))
# Climate
daynight <- ifelse(Zs >= 90, "night", "day")
# Extract heat balance (metabolic rate)
enbal <- endo_df[, grep("enbal", colnames(endo_df))]
colnames(enbal) <- gsub("enbal.", "", colnames(enbal))
# Thermoregulation output
treg <- endo_df[, grep("treg", colnames(endo_df))]
colnames(treg) <- gsub("treg\\.", "", colnames(treg))
# Mass aspects
masbal <- endo_df[, grep("masbal", colnames(endo_df))]
colnames(masbal) <- gsub("masbal\\.", "", colnames(masbal))
# Save results for this condition level
results_list[[i]] <- data.frame(
condition = condition_grid[i],
time_step = seq_along(TAs),
QGEN = enbal$QGEN, # Metabolic energy generated
TCs = treg$TC, # Core temperature
H2O = masbal$H2OResp_g + masbal$H2OCut_g, # Water evaporated (g/hour)
TFA_D = treg$TFA_D, # Dorsal fur surface temperature
TFA_V = treg$TFA_V, # Ventral fur surface temperature
TskinD = treg$TSKIN_D, # Dorsal skin temperature
TskinV = treg$TSKIN_V, # Ventral skin temperature
Pant = treg$PANT, # Panting multiplier
daynight = daynight # Day or night
)
}
proc.time() - ptm
results_all <- do.call(rbind, results_list)
ggplot(results_all, aes(x = time_step, y = TCs, colour = factor(condition))) +
geom_line(size = 1) +
labs(
x = "Time step",
y = "Core Temperature",
colour = "Feather condition"
)
#############################################
I hope this is enough to explain my problem, and thank you for your time.
All the best,
Caity