R中输入参数随时间的阶跃变化

R中输入参数随时间的阶跃变化,r,numerical-methods,pde,R,Numerical Methods,Pde,如果有人能帮助我如何将步骤与时间相关的输入参数结合起来。请参阅下面的代码: 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 # dens

如果有人能帮助我如何将
步骤
与时间相关的输入参数结合起来。请参阅下面的代码:

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")
库(ReacTran)

N Soetatert、Cash和Mazzia的书《在R中求解微分方程》在第66页有一节介绍了温度超过特定阈值时的加热效应建模。这是第3.4节不连续方程建模的一部分。我认为温度的阶跃变化并不特别现实。你有没有考虑过温度上升率的逐步变化,而不是无限的?谢谢,我会看看的。物理过程可能是系统暴露于具有一定温度的空气中并保持1小时,然后突然暴露于另一种保持不同温度的空气中。这就像一个加热和冷却的过程。