wave: Wave Equation using

Description Usage Arguments Details Value Examples

View source: R/wave.R

Description

solve heat equation via forward-time central-space method

Usage

1
wave(u, alpha, xdelta, tdelta, n)

Arguments

u

the initial values of u

alpha

the thermal diffusivity coefficient

xdelta

the change in x at each step in u

tdelta

the time step

n

the number of steps to take

Details

The heat solves the heat equation using the forward-time central-space method in one-dimension.

Value

a matrix of u values at each time step

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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)

Example output



cmna documentation built on July 14, 2021, 5:11 p.m.