0

如果有人可以帮助我如何结合step时间的输入参数。请看下面的代码:

library(ReacTran)

N <- 10   # No of grids
L = 0.10   # thickness, m
l = L/2    # Half of thickness, m

k= 0.412    # thermal conductivity, W/m-K
cp = 3530    # thermal conductivity, J/kg-K
rho = 1100   # density, kg/m3
T_int = 57.2       # Initial temperature , degC
T_air = 19        # air temperature, degC
h_air = 20        # Convective heat transfer coeff of air, W/m2-K

xgrid <- setup.grid.1D(x.up = 0, x.down = l, N = N)
x <- xgrid$x.mid

alpha.coeff <-  (k*3600)/(rho*cp)



Diffusion <- function (t, Y, parms){
  tran <- tran.1D(C=Y, flux.down = 0, C.up = T_air, a.bl.up = h_air,
                   D = alpha.coeff, dx = xgrid)
  list(dY = tran$dC, flux.up = tran$flux.up,
       flux.down = tran$flux.down)
}

# Initial condition
Yini <- rep(T_int, N)
times <- seq(from = 0, to = 2, by = 0.2)
print(system.time(
  out <- ode.1D(y = Yini, times = times, func = Diffusion,
               parms = NULL, dimens = N)))

plot(times, out[,(N+1)], type = "l", lwd = 2, xlab = "time, hr", ylab = "Temperature")

我希望在T_air第一个小时保持不变,它会更改为剩余的另一个值1 hr。这将是step change参数中的一个。我该怎么做?任何帮助,将不胜感激。谢谢,

4

0 回答 0