powered by
solve heat equation via forward-time central-space method
wave(u, alpha, xdelta, tdelta, n)
the initial values of u
the thermal diffusivity coefficient
the change in x at each step in u
x
u
the time step
the number of steps to take
a matrix of u values at each time step
The heat solves the heat equation using the forward-time central-space method in one-dimension.
heat
# NOT RUN { speed <- 2 x0 <- 0 xdelta <- .05 x <- seq(x0, 1, xdelta) m <- length(x) u <- sin(x * pi * 2) u[11:21] <- 0 tdelta <- .02 n <- 40 z <- wave(u, speed, xdelta, tdelta, n) # }
Run the code above in your browser using DataLab